babylon.module.d.ts 6.3 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800828018280282803828048280582806828078280882809828108281182812828138281482815828168281782818828198282082821828228282382824828258282682827828288282982830828318283282833828348283582836828378283882839828408284182842828438284482845828468284782848828498285082851828528285382854828558285682857828588285982860828618286282863828648286582866828678286882869828708287182872828738287482875828768287782878828798288082881828828288382884828858288682887828888288982890828918289282893828948289582896828978289882899829008290182902829038290482905829068290782908829098291082911829128291382914829158291682917829188291982920829218292282923829248292582926829278292882929829308293182932829338293482935829368293782938829398294082941829428294382944829458294682947829488294982950829518295282953829548295582956829578295882959829608296182962829638296482965829668296782968829698297082971829728297382974829758297682977829788297982980829818298282983829848298582986829878298882989829908299182992829938299482995829968299782998829998300083001830028300383004830058300683007830088300983010830118301283013830148301583016830178301883019830208302183022830238302483025830268302783028830298303083031830328303383034830358303683037830388303983040830418304283043830448304583046830478304883049830508305183052830538305483055830568305783058830598306083061830628306383064830658306683067830688306983070830718307283073830748307583076830778307883079830808308183082830838308483085830868308783088830898309083091830928309383094830958309683097830988309983100831018310283103831048310583106831078310883109831108311183112831138311483115831168311783118831198312083121831228312383124831258312683127831288312983130831318313283133831348313583136831378313883139831408314183142831438314483145831468314783148831498315083151831528315383154831558315683157831588315983160831618316283163831648316583166831678316883169831708317183172831738317483175831768317783178831798318083181831828318383184831858318683187831888318983190831918319283193831948319583196831978319883199832008320183202832038320483205832068320783208832098321083211832128321383214832158321683217832188321983220832218322283223832248322583226832278322883229832308323183232832338323483235832368323783238832398324083241832428324383244832458324683247832488324983250832518325283253832548325583256832578325883259832608326183262832638326483265832668326783268832698327083271832728327383274832758327683277832788327983280832818328283283832848328583286832878328883289832908329183292832938329483295832968329783298832998330083301833028330383304833058330683307833088330983310833118331283313833148331583316833178331883319833208332183322833238332483325833268332783328833298333083331833328333383334833358333683337833388333983340833418334283343833448334583346833478334883349833508335183352833538335483355833568335783358833598336083361833628336383364833658336683367833688336983370833718337283373833748337583376833778337883379833808338183382833838338483385833868338783388833898339083391833928339383394833958339683397833988339983400834018340283403834048340583406834078340883409834108341183412834138341483415834168341783418834198342083421834228342383424834258342683427834288342983430834318343283433834348343583436834378343883439834408344183442834438344483445834468344783448834498345083451834528345383454834558345683457834588345983460834618346283463834648346583466834678346883469834708347183472834738347483475834768347783478834798348083481834828348383484834858348683487834888348983490834918349283493834948349583496834978349883499835008350183502835038350483505835068350783508835098351083511835128351383514835158351683517835188351983520835218352283523835248352583526835278352883529835308353183532835338353483535835368353783538835398354083541835428354383544835458354683547835488354983550835518355283553835548355583556835578355883559835608356183562835638356483565835668356783568835698357083571835728357383574835758357683577835788357983580835818358283583835848358583586835878358883589835908359183592835938359483595835968359783598835998360083601836028360383604836058360683607836088360983610836118361283613836148361583616836178361883619836208362183622836238362483625836268362783628836298363083631836328363383634836358363683637836388363983640836418364283643836448364583646836478364883649836508365183652836538365483655836568365783658836598366083661836628366383664836658366683667836688366983670836718367283673836748367583676836778367883679836808368183682836838368483685836868368783688836898369083691836928369383694836958369683697836988369983700837018370283703837048370583706837078370883709837108371183712837138371483715837168371783718837198372083721837228372383724837258372683727837288372983730837318373283733837348373583736837378373883739837408374183742837438374483745837468374783748837498375083751837528375383754837558375683757837588375983760837618376283763837648376583766837678376883769837708377183772837738377483775837768377783778837798378083781837828378383784837858378683787837888378983790837918379283793837948379583796837978379883799838008380183802838038380483805838068380783808838098381083811838128381383814838158381683817838188381983820838218382283823838248382583826838278382883829838308383183832838338383483835838368383783838838398384083841838428384383844838458384683847838488384983850838518385283853838548385583856838578385883859838608386183862838638386483865838668386783868838698387083871838728387383874838758387683877838788387983880838818388283883838848388583886838878388883889838908389183892838938389483895838968389783898838998390083901839028390383904839058390683907839088390983910839118391283913839148391583916839178391883919839208392183922839238392483925839268392783928839298393083931839328393383934839358393683937839388393983940839418394283943839448394583946839478394883949839508395183952839538395483955839568395783958839598396083961839628396383964839658396683967839688396983970839718397283973839748397583976839778397883979839808398183982839838398483985839868398783988839898399083991839928399383994839958399683997839988399984000840018400284003840048400584006840078400884009840108401184012840138401484015840168401784018840198402084021840228402384024840258402684027840288402984030840318403284033840348403584036840378403884039840408404184042840438404484045840468404784048840498405084051840528405384054840558405684057840588405984060840618406284063840648406584066840678406884069840708407184072840738407484075840768407784078840798408084081840828408384084840858408684087840888408984090840918409284093840948409584096840978409884099841008410184102841038410484105841068410784108841098411084111841128411384114841158411684117841188411984120841218412284123841248412584126841278412884129841308413184132841338413484135841368413784138841398414084141841428414384144841458414684147841488414984150841518415284153841548415584156841578415884159841608416184162841638416484165841668416784168841698417084171841728417384174841758417684177841788417984180841818418284183841848418584186841878418884189841908419184192841938419484195841968419784198841998420084201842028420384204842058420684207842088420984210842118421284213842148421584216842178421884219842208422184222842238422484225842268422784228842298423084231842328423384234842358423684237842388423984240842418424284243842448424584246842478424884249842508425184252842538425484255842568425784258842598426084261842628426384264842658426684267842688426984270842718427284273842748427584276842778427884279842808428184282842838428484285842868428784288842898429084291842928429384294842958429684297842988429984300843018430284303843048430584306843078430884309843108431184312843138431484315843168431784318843198432084321843228432384324843258432684327843288432984330843318433284333843348433584336843378433884339843408434184342843438434484345843468434784348843498435084351843528435384354843558435684357843588435984360843618436284363843648436584366843678436884369843708437184372843738437484375843768437784378843798438084381843828438384384843858438684387843888438984390843918439284393843948439584396843978439884399844008440184402844038440484405844068440784408844098441084411844128441384414844158441684417844188441984420844218442284423844248442584426844278442884429844308443184432844338443484435844368443784438844398444084441844428444384444844458444684447844488444984450844518445284453844548445584456844578445884459844608446184462844638446484465844668446784468844698447084471844728447384474844758447684477844788447984480844818448284483844848448584486844878448884489844908449184492844938449484495844968449784498844998450084501845028450384504845058450684507845088450984510845118451284513845148451584516845178451884519845208452184522845238452484525845268452784528845298453084531845328453384534845358453684537845388453984540845418454284543845448454584546845478454884549845508455184552845538455484555845568455784558845598456084561845628456384564845658456684567845688456984570845718457284573845748457584576845778457884579845808458184582845838458484585845868458784588845898459084591845928459384594845958459684597845988459984600846018460284603846048460584606846078460884609846108461184612846138461484615846168461784618846198462084621846228462384624846258462684627846288462984630846318463284633846348463584636846378463884639846408464184642846438464484645846468464784648846498465084651846528465384654846558465684657846588465984660846618466284663846648466584666846678466884669846708467184672846738467484675846768467784678846798468084681846828468384684846858468684687846888468984690846918469284693846948469584696846978469884699847008470184702847038470484705847068470784708847098471084711847128471384714847158471684717847188471984720847218472284723847248472584726847278472884729847308473184732847338473484735847368473784738847398474084741847428474384744847458474684747847488474984750847518475284753847548475584756847578475884759847608476184762847638476484765847668476784768847698477084771847728477384774847758477684777847788477984780847818478284783847848478584786847878478884789847908479184792847938479484795847968479784798847998480084801848028480384804848058480684807848088480984810848118481284813848148481584816848178481884819848208482184822848238482484825848268482784828848298483084831848328483384834848358483684837848388483984840848418484284843848448484584846848478484884849848508485184852848538485484855848568485784858848598486084861848628486384864848658486684867848688486984870848718487284873848748487584876848778487884879848808488184882848838488484885848868488784888848898489084891848928489384894848958489684897848988489984900849018490284903849048490584906849078490884909849108491184912849138491484915849168491784918849198492084921849228492384924849258492684927849288492984930849318493284933849348493584936849378493884939849408494184942849438494484945849468494784948849498495084951849528495384954849558495684957849588495984960849618496284963849648496584966849678496884969849708497184972849738497484975849768497784978849798498084981849828498384984849858498684987849888498984990849918499284993849948499584996849978499884999850008500185002850038500485005850068500785008850098501085011850128501385014850158501685017850188501985020850218502285023850248502585026850278502885029850308503185032850338503485035850368503785038850398504085041850428504385044850458504685047850488504985050850518505285053850548505585056850578505885059850608506185062850638506485065850668506785068850698507085071850728507385074850758507685077850788507985080850818508285083850848508585086850878508885089850908509185092850938509485095850968509785098850998510085101851028510385104851058510685107851088510985110851118511285113851148511585116851178511885119851208512185122851238512485125851268512785128851298513085131851328513385134851358513685137851388513985140851418514285143851448514585146851478514885149851508515185152851538515485155851568515785158851598516085161851628516385164851658516685167851688516985170851718517285173851748517585176851778517885179851808518185182851838518485185851868518785188851898519085191851928519385194851958519685197851988519985200852018520285203852048520585206852078520885209852108521185212852138521485215852168521785218852198522085221852228522385224852258522685227852288522985230852318523285233852348523585236852378523885239852408524185242852438524485245852468524785248852498525085251852528525385254852558525685257852588525985260852618526285263852648526585266852678526885269852708527185272852738527485275852768527785278852798528085281852828528385284852858528685287852888528985290852918529285293852948529585296852978529885299853008530185302853038530485305853068530785308853098531085311853128531385314853158531685317853188531985320853218532285323853248532585326853278532885329853308533185332853338533485335853368533785338853398534085341853428534385344853458534685347853488534985350853518535285353853548535585356853578535885359853608536185362853638536485365853668536785368853698537085371853728537385374853758537685377853788537985380853818538285383853848538585386853878538885389853908539185392853938539485395853968539785398853998540085401854028540385404854058540685407854088540985410854118541285413854148541585416854178541885419854208542185422854238542485425854268542785428854298543085431854328543385434854358543685437854388543985440854418544285443854448544585446854478544885449854508545185452854538545485455854568545785458854598546085461854628546385464854658546685467854688546985470854718547285473854748547585476854778547885479854808548185482854838548485485854868548785488854898549085491854928549385494854958549685497854988549985500855018550285503855048550585506855078550885509855108551185512855138551485515855168551785518855198552085521855228552385524855258552685527855288552985530855318553285533855348553585536855378553885539855408554185542855438554485545855468554785548855498555085551855528555385554855558555685557855588555985560855618556285563855648556585566855678556885569855708557185572855738557485575855768557785578855798558085581855828558385584855858558685587855888558985590855918559285593855948559585596855978559885599856008560185602856038560485605856068560785608856098561085611856128561385614856158561685617856188561985620856218562285623856248562585626856278562885629856308563185632856338563485635856368563785638856398564085641856428564385644856458564685647856488564985650856518565285653856548565585656856578565885659856608566185662856638566485665856668566785668856698567085671856728567385674856758567685677856788567985680856818568285683856848568585686856878568885689856908569185692856938569485695856968569785698856998570085701857028570385704857058570685707857088570985710857118571285713857148571585716857178571885719857208572185722857238572485725857268572785728857298573085731857328573385734857358573685737857388573985740857418574285743857448574585746857478574885749857508575185752857538575485755857568575785758857598576085761857628576385764857658576685767857688576985770857718577285773857748577585776857778577885779857808578185782857838578485785857868578785788857898579085791857928579385794857958579685797857988579985800858018580285803858048580585806858078580885809858108581185812858138581485815858168581785818858198582085821858228582385824858258582685827858288582985830858318583285833858348583585836858378583885839858408584185842858438584485845858468584785848858498585085851858528585385854858558585685857858588585985860858618586285863858648586585866858678586885869858708587185872858738587485875858768587785878858798588085881858828588385884858858588685887858888588985890858918589285893858948589585896858978589885899859008590185902859038590485905859068590785908859098591085911859128591385914859158591685917859188591985920859218592285923859248592585926859278592885929859308593185932859338593485935859368593785938859398594085941859428594385944859458594685947859488594985950859518595285953859548595585956859578595885959859608596185962859638596485965859668596785968859698597085971859728597385974859758597685977859788597985980859818598285983859848598585986859878598885989859908599185992859938599485995859968599785998859998600086001860028600386004860058600686007860088600986010860118601286013860148601586016860178601886019860208602186022860238602486025860268602786028860298603086031860328603386034860358603686037860388603986040860418604286043860448604586046860478604886049860508605186052860538605486055860568605786058860598606086061860628606386064860658606686067860688606986070860718607286073860748607586076860778607886079860808608186082860838608486085860868608786088860898609086091860928609386094860958609686097860988609986100861018610286103861048610586106861078610886109861108611186112861138611486115861168611786118861198612086121861228612386124861258612686127861288612986130861318613286133861348613586136861378613886139861408614186142861438614486145861468614786148861498615086151861528615386154861558615686157861588615986160861618616286163861648616586166861678616886169861708617186172861738617486175861768617786178861798618086181861828618386184861858618686187861888618986190861918619286193861948619586196861978619886199862008620186202862038620486205862068620786208862098621086211862128621386214862158621686217862188621986220862218622286223862248622586226862278622886229862308623186232862338623486235862368623786238862398624086241862428624386244862458624686247862488624986250862518625286253862548625586256862578625886259862608626186262862638626486265862668626786268862698627086271862728627386274862758627686277862788627986280862818628286283862848628586286862878628886289862908629186292862938629486295862968629786298862998630086301863028630386304863058630686307863088630986310863118631286313863148631586316863178631886319863208632186322863238632486325863268632786328863298633086331863328633386334863358633686337863388633986340863418634286343863448634586346863478634886349863508635186352863538635486355863568635786358863598636086361863628636386364863658636686367863688636986370863718637286373863748637586376863778637886379863808638186382863838638486385863868638786388863898639086391863928639386394863958639686397863988639986400864018640286403864048640586406864078640886409864108641186412864138641486415864168641786418864198642086421864228642386424864258642686427864288642986430864318643286433864348643586436864378643886439864408644186442864438644486445864468644786448864498645086451864528645386454864558645686457864588645986460864618646286463864648646586466864678646886469864708647186472864738647486475864768647786478864798648086481864828648386484864858648686487864888648986490864918649286493864948649586496864978649886499865008650186502865038650486505865068650786508865098651086511865128651386514865158651686517865188651986520865218652286523865248652586526865278652886529865308653186532865338653486535865368653786538865398654086541865428654386544865458654686547865488654986550865518655286553865548655586556865578655886559865608656186562865638656486565865668656786568865698657086571865728657386574865758657686577865788657986580865818658286583865848658586586865878658886589865908659186592865938659486595865968659786598865998660086601866028660386604866058660686607866088660986610866118661286613866148661586616866178661886619866208662186622866238662486625866268662786628866298663086631866328663386634866358663686637866388663986640866418664286643866448664586646866478664886649866508665186652866538665486655866568665786658866598666086661866628666386664866658666686667866688666986670866718667286673866748667586676866778667886679866808668186682866838668486685866868668786688866898669086691866928669386694866958669686697866988669986700867018670286703867048670586706867078670886709867108671186712867138671486715867168671786718867198672086721867228672386724867258672686727867288672986730867318673286733867348673586736867378673886739867408674186742867438674486745867468674786748867498675086751867528675386754867558675686757867588675986760867618676286763867648676586766867678676886769867708677186772867738677486775867768677786778867798678086781867828678386784867858678686787867888678986790867918679286793867948679586796867978679886799868008680186802868038680486805868068680786808868098681086811868128681386814868158681686817868188681986820868218682286823868248682586826868278682886829868308683186832868338683486835868368683786838868398684086841868428684386844868458684686847868488684986850868518685286853868548685586856868578685886859868608686186862868638686486865868668686786868868698687086871868728687386874868758687686877868788687986880868818688286883868848688586886868878688886889868908689186892868938689486895868968689786898868998690086901869028690386904869058690686907869088690986910869118691286913869148691586916869178691886919869208692186922869238692486925869268692786928869298693086931869328693386934869358693686937869388693986940869418694286943869448694586946869478694886949869508695186952869538695486955869568695786958869598696086961869628696386964869658696686967869688696986970869718697286973869748697586976869778697886979869808698186982869838698486985869868698786988869898699086991869928699386994869958699686997869988699987000870018700287003870048700587006870078700887009870108701187012870138701487015870168701787018870198702087021870228702387024870258702687027870288702987030870318703287033870348703587036870378703887039870408704187042870438704487045870468704787048870498705087051870528705387054870558705687057870588705987060870618706287063870648706587066870678706887069870708707187072870738707487075870768707787078870798708087081870828708387084870858708687087870888708987090870918709287093870948709587096870978709887099871008710187102871038710487105871068710787108871098711087111871128711387114871158711687117871188711987120871218712287123871248712587126871278712887129871308713187132871338713487135871368713787138871398714087141871428714387144871458714687147871488714987150871518715287153871548715587156871578715887159871608716187162871638716487165871668716787168871698717087171871728717387174871758717687177871788717987180871818718287183871848718587186871878718887189871908719187192871938719487195871968719787198871998720087201872028720387204872058720687207872088720987210872118721287213872148721587216872178721887219872208722187222872238722487225872268722787228872298723087231872328723387234872358723687237872388723987240872418724287243872448724587246872478724887249872508725187252872538725487255872568725787258872598726087261872628726387264872658726687267872688726987270872718727287273872748727587276872778727887279872808728187282872838728487285872868728787288872898729087291872928729387294872958729687297872988729987300873018730287303873048730587306873078730887309873108731187312873138731487315873168731787318873198732087321873228732387324873258732687327873288732987330873318733287333873348733587336873378733887339873408734187342873438734487345873468734787348873498735087351873528735387354873558735687357873588735987360873618736287363873648736587366873678736887369873708737187372873738737487375873768737787378873798738087381873828738387384873858738687387873888738987390873918739287393873948739587396873978739887399874008740187402874038740487405874068740787408874098741087411874128741387414874158741687417874188741987420874218742287423874248742587426874278742887429874308743187432874338743487435874368743787438874398744087441874428744387444874458744687447874488744987450874518745287453874548745587456874578745887459874608746187462874638746487465874668746787468874698747087471874728747387474874758747687477874788747987480874818748287483874848748587486874878748887489874908749187492874938749487495874968749787498874998750087501875028750387504875058750687507875088750987510875118751287513875148751587516875178751887519875208752187522875238752487525875268752787528875298753087531875328753387534875358753687537875388753987540875418754287543875448754587546875478754887549875508755187552875538755487555875568755787558875598756087561875628756387564875658756687567875688756987570875718757287573875748757587576875778757887579875808758187582875838758487585875868758787588875898759087591875928759387594875958759687597875988759987600876018760287603876048760587606876078760887609876108761187612876138761487615876168761787618876198762087621876228762387624876258762687627876288762987630876318763287633876348763587636876378763887639876408764187642876438764487645876468764787648876498765087651876528765387654876558765687657876588765987660876618766287663876648766587666876678766887669876708767187672876738767487675876768767787678876798768087681876828768387684876858768687687876888768987690876918769287693876948769587696876978769887699877008770187702877038770487705877068770787708877098771087711877128771387714877158771687717877188771987720877218772287723877248772587726877278772887729877308773187732877338773487735877368773787738877398774087741877428774387744877458774687747877488774987750877518775287753877548775587756877578775887759877608776187762877638776487765877668776787768877698777087771877728777387774877758777687777877788777987780877818778287783877848778587786877878778887789877908779187792877938779487795877968779787798877998780087801878028780387804878058780687807878088780987810878118781287813878148781587816878178781887819878208782187822878238782487825878268782787828878298783087831878328783387834878358783687837878388783987840878418784287843878448784587846878478784887849878508785187852878538785487855878568785787858878598786087861878628786387864878658786687867878688786987870878718787287873878748787587876878778787887879878808788187882878838788487885878868788787888878898789087891878928789387894878958789687897878988789987900879018790287903879048790587906879078790887909879108791187912879138791487915879168791787918879198792087921879228792387924879258792687927879288792987930879318793287933879348793587936879378793887939879408794187942879438794487945879468794787948879498795087951879528795387954879558795687957879588795987960879618796287963879648796587966879678796887969879708797187972879738797487975879768797787978879798798087981879828798387984879858798687987879888798987990879918799287993879948799587996879978799887999880008800188002880038800488005880068800788008880098801088011880128801388014880158801688017880188801988020880218802288023880248802588026880278802888029880308803188032880338803488035880368803788038880398804088041880428804388044880458804688047880488804988050880518805288053880548805588056880578805888059880608806188062880638806488065880668806788068880698807088071880728807388074880758807688077880788807988080880818808288083880848808588086880878808888089880908809188092880938809488095880968809788098880998810088101881028810388104881058810688107881088810988110881118811288113881148811588116881178811888119881208812188122881238812488125881268812788128881298813088131881328813388134881358813688137881388813988140881418814288143881448814588146881478814888149881508815188152881538815488155881568815788158881598816088161881628816388164881658816688167881688816988170881718817288173881748817588176881778817888179881808818188182881838818488185881868818788188881898819088191881928819388194881958819688197881988819988200882018820288203882048820588206882078820888209882108821188212882138821488215882168821788218882198822088221882228822388224882258822688227882288822988230882318823288233882348823588236882378823888239882408824188242882438824488245882468824788248882498825088251882528825388254882558825688257882588825988260882618826288263882648826588266882678826888269882708827188272882738827488275882768827788278882798828088281882828828388284882858828688287882888828988290882918829288293882948829588296882978829888299883008830188302883038830488305883068830788308883098831088311883128831388314883158831688317883188831988320883218832288323883248832588326883278832888329883308833188332883338833488335883368833788338883398834088341883428834388344883458834688347883488834988350883518835288353883548835588356883578835888359883608836188362883638836488365883668836788368883698837088371883728837388374883758837688377883788837988380883818838288383883848838588386883878838888389883908839188392883938839488395883968839788398883998840088401884028840388404884058840688407884088840988410884118841288413884148841588416884178841888419884208842188422884238842488425884268842788428884298843088431884328843388434884358843688437884388843988440884418844288443884448844588446884478844888449884508845188452884538845488455884568845788458884598846088461884628846388464884658846688467884688846988470884718847288473884748847588476884778847888479884808848188482884838848488485884868848788488884898849088491884928849388494884958849688497884988849988500885018850288503885048850588506885078850888509885108851188512885138851488515885168851788518885198852088521885228852388524885258852688527885288852988530885318853288533885348853588536885378853888539885408854188542885438854488545885468854788548885498855088551885528855388554885558855688557885588855988560885618856288563885648856588566885678856888569885708857188572885738857488575885768857788578885798858088581885828858388584885858858688587885888858988590885918859288593885948859588596885978859888599886008860188602886038860488605886068860788608886098861088611886128861388614886158861688617886188861988620886218862288623886248862588626886278862888629886308863188632886338863488635886368863788638886398864088641886428864388644886458864688647886488864988650886518865288653886548865588656886578865888659886608866188662886638866488665886668866788668886698867088671886728867388674886758867688677886788867988680886818868288683886848868588686886878868888689886908869188692886938869488695886968869788698886998870088701887028870388704887058870688707887088870988710887118871288713887148871588716887178871888719887208872188722887238872488725887268872788728887298873088731887328873388734887358873688737887388873988740887418874288743887448874588746887478874888749887508875188752887538875488755887568875788758887598876088761887628876388764887658876688767887688876988770887718877288773887748877588776887778877888779887808878188782887838878488785887868878788788887898879088791887928879388794887958879688797887988879988800888018880288803888048880588806888078880888809888108881188812888138881488815888168881788818888198882088821888228882388824888258882688827888288882988830888318883288833888348883588836888378883888839888408884188842888438884488845888468884788848888498885088851888528885388854888558885688857888588885988860888618886288863888648886588866888678886888869888708887188872888738887488875888768887788878888798888088881888828888388884888858888688887888888888988890888918889288893888948889588896888978889888899889008890188902889038890488905889068890788908889098891088911889128891388914889158891688917889188891988920889218892288923889248892588926889278892888929889308893188932889338893488935889368893788938889398894088941889428894388944889458894688947889488894988950889518895288953889548895588956889578895888959889608896188962889638896488965889668896788968889698897088971889728897388974889758897688977889788897988980889818898288983889848898588986889878898888989889908899188992889938899488995889968899788998889998900089001890028900389004890058900689007890088900989010890118901289013890148901589016890178901889019890208902189022890238902489025890268902789028890298903089031890328903389034890358903689037890388903989040890418904289043890448904589046890478904889049890508905189052890538905489055890568905789058890598906089061890628906389064890658906689067890688906989070890718907289073890748907589076890778907889079890808908189082890838908489085890868908789088890898909089091890928909389094890958909689097890988909989100891018910289103891048910589106891078910889109891108911189112891138911489115891168911789118891198912089121891228912389124891258912689127891288912989130891318913289133891348913589136891378913889139891408914189142891438914489145891468914789148891498915089151891528915389154891558915689157891588915989160891618916289163891648916589166891678916889169891708917189172891738917489175891768917789178891798918089181891828918389184891858918689187891888918989190891918919289193891948919589196891978919889199892008920189202892038920489205892068920789208892098921089211892128921389214892158921689217892188921989220892218922289223892248922589226892278922889229892308923189232892338923489235892368923789238892398924089241892428924389244892458924689247892488924989250892518925289253892548925589256892578925889259892608926189262892638926489265892668926789268892698927089271892728927389274892758927689277892788927989280892818928289283892848928589286892878928889289892908929189292892938929489295892968929789298892998930089301893028930389304893058930689307893088930989310893118931289313893148931589316893178931889319893208932189322893238932489325893268932789328893298933089331893328933389334893358933689337893388933989340893418934289343893448934589346893478934889349893508935189352893538935489355893568935789358893598936089361893628936389364893658936689367893688936989370893718937289373893748937589376893778937889379893808938189382893838938489385893868938789388893898939089391893928939389394893958939689397893988939989400894018940289403894048940589406894078940889409894108941189412894138941489415894168941789418894198942089421894228942389424894258942689427894288942989430894318943289433894348943589436894378943889439894408944189442894438944489445894468944789448894498945089451894528945389454894558945689457894588945989460894618946289463894648946589466894678946889469894708947189472894738947489475894768947789478894798948089481894828948389484894858948689487894888948989490894918949289493894948949589496894978949889499895008950189502895038950489505895068950789508895098951089511895128951389514895158951689517895188951989520895218952289523895248952589526895278952889529895308953189532895338953489535895368953789538895398954089541895428954389544895458954689547895488954989550895518955289553895548955589556895578955889559895608956189562895638956489565895668956789568895698957089571895728957389574895758957689577895788957989580895818958289583895848958589586895878958889589895908959189592895938959489595895968959789598895998960089601896028960389604896058960689607896088960989610896118961289613896148961589616896178961889619896208962189622896238962489625896268962789628896298963089631896328963389634896358963689637896388963989640896418964289643896448964589646896478964889649896508965189652896538965489655896568965789658896598966089661896628966389664896658966689667896688966989670896718967289673896748967589676896778967889679896808968189682896838968489685896868968789688896898969089691896928969389694896958969689697896988969989700897018970289703897048970589706897078970889709897108971189712897138971489715897168971789718897198972089721897228972389724897258972689727897288972989730897318973289733897348973589736897378973889739897408974189742897438974489745897468974789748897498975089751897528975389754897558975689757897588975989760897618976289763897648976589766897678976889769897708977189772897738977489775897768977789778897798978089781897828978389784897858978689787897888978989790897918979289793897948979589796897978979889799898008980189802898038980489805898068980789808898098981089811898128981389814898158981689817898188981989820898218982289823898248982589826898278982889829898308983189832898338983489835898368983789838898398984089841898428984389844898458984689847898488984989850898518985289853898548985589856898578985889859898608986189862898638986489865898668986789868898698987089871898728987389874898758987689877898788987989880898818988289883898848988589886898878988889889898908989189892898938989489895898968989789898898998990089901899028990389904899058990689907899088990989910899118991289913899148991589916899178991889919899208992189922899238992489925899268992789928899298993089931899328993389934899358993689937899388993989940899418994289943899448994589946899478994889949899508995189952899538995489955899568995789958899598996089961899628996389964899658996689967899688996989970899718997289973899748997589976899778997889979899808998189982899838998489985899868998789988899898999089991899928999389994899958999689997899988999990000900019000290003900049000590006900079000890009900109001190012900139001490015900169001790018900199002090021900229002390024900259002690027900289002990030900319003290033900349003590036900379003890039900409004190042900439004490045900469004790048900499005090051900529005390054900559005690057900589005990060900619006290063900649006590066900679006890069900709007190072900739007490075900769007790078900799008090081900829008390084900859008690087900889008990090900919009290093900949009590096900979009890099901009010190102901039010490105901069010790108901099011090111901129011390114901159011690117901189011990120901219012290123901249012590126901279012890129901309013190132901339013490135901369013790138901399014090141901429014390144901459014690147901489014990150901519015290153901549015590156901579015890159901609016190162901639016490165901669016790168901699017090171901729017390174901759017690177901789017990180901819018290183901849018590186901879018890189901909019190192901939019490195901969019790198901999020090201902029020390204902059020690207902089020990210902119021290213902149021590216902179021890219902209022190222902239022490225902269022790228902299023090231902329023390234902359023690237902389023990240902419024290243902449024590246902479024890249902509025190252902539025490255902569025790258902599026090261902629026390264902659026690267902689026990270902719027290273902749027590276902779027890279902809028190282902839028490285902869028790288902899029090291902929029390294902959029690297902989029990300903019030290303903049030590306903079030890309903109031190312903139031490315903169031790318903199032090321903229032390324903259032690327903289032990330903319033290333903349033590336903379033890339903409034190342903439034490345903469034790348903499035090351903529035390354903559035690357903589035990360903619036290363903649036590366903679036890369903709037190372903739037490375903769037790378903799038090381903829038390384903859038690387903889038990390903919039290393903949039590396903979039890399904009040190402904039040490405904069040790408904099041090411904129041390414904159041690417904189041990420904219042290423904249042590426904279042890429904309043190432904339043490435904369043790438904399044090441904429044390444904459044690447904489044990450904519045290453904549045590456904579045890459904609046190462904639046490465904669046790468904699047090471904729047390474904759047690477904789047990480904819048290483904849048590486904879048890489904909049190492904939049490495904969049790498904999050090501905029050390504905059050690507905089050990510905119051290513905149051590516905179051890519905209052190522905239052490525905269052790528905299053090531905329053390534905359053690537905389053990540905419054290543905449054590546905479054890549905509055190552905539055490555905569055790558905599056090561905629056390564905659056690567905689056990570905719057290573905749057590576905779057890579905809058190582905839058490585905869058790588905899059090591905929059390594905959059690597905989059990600906019060290603906049060590606906079060890609906109061190612906139061490615906169061790618906199062090621906229062390624906259062690627906289062990630906319063290633906349063590636906379063890639906409064190642906439064490645906469064790648906499065090651906529065390654906559065690657906589065990660906619066290663906649066590666906679066890669906709067190672906739067490675906769067790678906799068090681906829068390684906859068690687906889068990690906919069290693906949069590696906979069890699907009070190702907039070490705907069070790708907099071090711907129071390714907159071690717907189071990720907219072290723907249072590726907279072890729907309073190732907339073490735907369073790738907399074090741907429074390744907459074690747907489074990750907519075290753907549075590756907579075890759907609076190762907639076490765907669076790768907699077090771907729077390774907759077690777907789077990780907819078290783907849078590786907879078890789907909079190792907939079490795907969079790798907999080090801908029080390804908059080690807908089080990810908119081290813908149081590816908179081890819908209082190822908239082490825908269082790828908299083090831908329083390834908359083690837908389083990840908419084290843908449084590846908479084890849908509085190852908539085490855908569085790858908599086090861908629086390864908659086690867908689086990870908719087290873908749087590876908779087890879908809088190882908839088490885908869088790888908899089090891908929089390894908959089690897908989089990900909019090290903909049090590906909079090890909909109091190912909139091490915909169091790918909199092090921909229092390924909259092690927909289092990930909319093290933909349093590936909379093890939909409094190942909439094490945909469094790948909499095090951909529095390954909559095690957909589095990960909619096290963909649096590966909679096890969909709097190972909739097490975909769097790978909799098090981909829098390984909859098690987909889098990990909919099290993909949099590996909979099890999910009100191002910039100491005910069100791008910099101091011910129101391014910159101691017910189101991020910219102291023910249102591026910279102891029910309103191032910339103491035910369103791038910399104091041910429104391044910459104691047910489104991050910519105291053910549105591056910579105891059910609106191062910639106491065910669106791068910699107091071910729107391074910759107691077910789107991080910819108291083910849108591086910879108891089910909109191092910939109491095910969109791098910999110091101911029110391104911059110691107911089110991110911119111291113911149111591116911179111891119911209112191122911239112491125911269112791128911299113091131911329113391134911359113691137911389113991140911419114291143911449114591146911479114891149911509115191152911539115491155911569115791158911599116091161911629116391164911659116691167911689116991170911719117291173911749117591176911779117891179911809118191182911839118491185911869118791188911899119091191911929119391194911959119691197911989119991200912019120291203912049120591206912079120891209912109121191212912139121491215912169121791218912199122091221912229122391224912259122691227912289122991230912319123291233912349123591236912379123891239912409124191242912439124491245912469124791248912499125091251912529125391254912559125691257912589125991260912619126291263912649126591266912679126891269912709127191272912739127491275912769127791278912799128091281912829128391284912859128691287912889128991290912919129291293912949129591296912979129891299913009130191302913039130491305913069130791308913099131091311913129131391314913159131691317913189131991320913219132291323913249132591326913279132891329913309133191332913339133491335913369133791338913399134091341913429134391344913459134691347913489134991350913519135291353913549135591356913579135891359913609136191362913639136491365913669136791368913699137091371913729137391374913759137691377913789137991380913819138291383913849138591386913879138891389913909139191392913939139491395913969139791398913999140091401914029140391404914059140691407914089140991410914119141291413914149141591416914179141891419914209142191422914239142491425914269142791428914299143091431914329143391434914359143691437914389143991440914419144291443914449144591446914479144891449914509145191452914539145491455914569145791458914599146091461914629146391464914659146691467914689146991470914719147291473914749147591476914779147891479914809148191482914839148491485914869148791488914899149091491914929149391494914959149691497914989149991500915019150291503915049150591506915079150891509915109151191512915139151491515915169151791518915199152091521915229152391524915259152691527915289152991530915319153291533915349153591536915379153891539915409154191542915439154491545915469154791548915499155091551915529155391554915559155691557915589155991560915619156291563915649156591566915679156891569915709157191572915739157491575915769157791578915799158091581915829158391584915859158691587915889158991590915919159291593915949159591596915979159891599916009160191602916039160491605916069160791608916099161091611916129161391614916159161691617916189161991620916219162291623916249162591626916279162891629916309163191632916339163491635916369163791638916399164091641916429164391644916459164691647916489164991650916519165291653916549165591656916579165891659916609166191662916639166491665916669166791668916699167091671916729167391674916759167691677916789167991680916819168291683916849168591686916879168891689916909169191692916939169491695916969169791698916999170091701917029170391704917059170691707917089170991710917119171291713917149171591716917179171891719917209172191722917239172491725917269172791728917299173091731917329173391734917359173691737917389173991740917419174291743917449174591746917479174891749917509175191752917539175491755917569175791758917599176091761917629176391764917659176691767917689176991770917719177291773917749177591776917779177891779917809178191782917839178491785917869178791788917899179091791917929179391794917959179691797917989179991800918019180291803918049180591806918079180891809918109181191812918139181491815918169181791818918199182091821918229182391824918259182691827918289182991830918319183291833918349183591836918379183891839918409184191842918439184491845918469184791848918499185091851918529185391854918559185691857918589185991860918619186291863918649186591866918679186891869918709187191872918739187491875918769187791878918799188091881918829188391884918859188691887918889188991890918919189291893918949189591896918979189891899919009190191902919039190491905919069190791908919099191091911919129191391914919159191691917919189191991920919219192291923919249192591926919279192891929919309193191932919339193491935919369193791938919399194091941919429194391944919459194691947919489194991950919519195291953919549195591956919579195891959919609196191962919639196491965919669196791968919699197091971919729197391974919759197691977919789197991980919819198291983919849198591986919879198891989919909199191992919939199491995919969199791998919999200092001920029200392004920059200692007920089200992010920119201292013920149201592016920179201892019920209202192022920239202492025920269202792028920299203092031920329203392034920359203692037920389203992040920419204292043920449204592046920479204892049920509205192052920539205492055920569205792058920599206092061920629206392064920659206692067920689206992070920719207292073920749207592076920779207892079920809208192082920839208492085920869208792088920899209092091920929209392094920959209692097920989209992100921019210292103921049210592106921079210892109921109211192112921139211492115921169211792118921199212092121921229212392124921259212692127921289212992130921319213292133921349213592136921379213892139921409214192142921439214492145921469214792148921499215092151921529215392154921559215692157921589215992160921619216292163921649216592166921679216892169921709217192172921739217492175921769217792178921799218092181921829218392184921859218692187921889218992190921919219292193921949219592196921979219892199922009220192202922039220492205922069220792208922099221092211922129221392214922159221692217922189221992220922219222292223922249222592226922279222892229922309223192232922339223492235922369223792238922399224092241922429224392244922459224692247922489224992250922519225292253922549225592256922579225892259922609226192262922639226492265922669226792268922699227092271922729227392274922759227692277922789227992280922819228292283922849228592286922879228892289922909229192292922939229492295922969229792298922999230092301923029230392304923059230692307923089230992310923119231292313923149231592316923179231892319923209232192322923239232492325923269232792328923299233092331923329233392334923359233692337923389233992340923419234292343923449234592346923479234892349923509235192352923539235492355923569235792358923599236092361923629236392364923659236692367923689236992370923719237292373923749237592376923779237892379923809238192382923839238492385923869238792388923899239092391923929239392394923959239692397923989239992400924019240292403924049240592406924079240892409924109241192412924139241492415924169241792418924199242092421924229242392424924259242692427924289242992430924319243292433924349243592436924379243892439924409244192442924439244492445924469244792448924499245092451924529245392454924559245692457924589245992460924619246292463924649246592466924679246892469924709247192472924739247492475924769247792478924799248092481924829248392484924859248692487924889248992490924919249292493924949249592496924979249892499925009250192502925039250492505925069250792508925099251092511925129251392514925159251692517925189251992520925219252292523925249252592526925279252892529925309253192532925339253492535925369253792538925399254092541925429254392544925459254692547925489254992550925519255292553925549255592556925579255892559925609256192562925639256492565925669256792568925699257092571925729257392574925759257692577925789257992580925819258292583925849258592586925879258892589925909259192592925939259492595925969259792598925999260092601926029260392604926059260692607926089260992610926119261292613926149261592616926179261892619926209262192622926239262492625926269262792628926299263092631926329263392634926359263692637926389263992640926419264292643926449264592646926479264892649926509265192652926539265492655926569265792658926599266092661926629266392664926659266692667926689266992670926719267292673926749267592676926779267892679926809268192682926839268492685926869268792688926899269092691926929269392694926959269692697926989269992700927019270292703927049270592706927079270892709927109271192712927139271492715927169271792718927199272092721927229272392724927259272692727927289272992730927319273292733927349273592736927379273892739927409274192742927439274492745927469274792748927499275092751927529275392754927559275692757927589275992760927619276292763927649276592766927679276892769927709277192772927739277492775927769277792778927799278092781927829278392784927859278692787927889278992790927919279292793927949279592796927979279892799928009280192802928039280492805928069280792808928099281092811928129281392814928159281692817928189281992820928219282292823928249282592826928279282892829928309283192832928339283492835928369283792838928399284092841928429284392844928459284692847928489284992850928519285292853928549285592856928579285892859928609286192862928639286492865928669286792868928699287092871928729287392874928759287692877928789287992880928819288292883928849288592886928879288892889928909289192892928939289492895928969289792898928999290092901929029290392904929059290692907929089290992910929119291292913929149291592916929179291892919929209292192922929239292492925929269292792928929299293092931929329293392934929359293692937929389293992940929419294292943929449294592946929479294892949929509295192952929539295492955929569295792958929599296092961929629296392964929659296692967929689296992970929719297292973929749297592976929779297892979929809298192982929839298492985929869298792988929899299092991929929299392994929959299692997929989299993000930019300293003930049300593006930079300893009930109301193012930139301493015930169301793018930199302093021930229302393024930259302693027930289302993030930319303293033930349303593036930379303893039930409304193042930439304493045930469304793048930499305093051930529305393054930559305693057930589305993060930619306293063930649306593066930679306893069930709307193072930739307493075930769307793078930799308093081930829308393084930859308693087930889308993090930919309293093930949309593096930979309893099931009310193102931039310493105931069310793108931099311093111931129311393114931159311693117931189311993120931219312293123931249312593126931279312893129931309313193132931339313493135931369313793138931399314093141931429314393144931459314693147931489314993150931519315293153931549315593156931579315893159931609316193162931639316493165931669316793168931699317093171931729317393174931759317693177931789317993180931819318293183931849318593186931879318893189931909319193192931939319493195931969319793198931999320093201932029320393204932059320693207932089320993210932119321293213932149321593216932179321893219932209322193222932239322493225932269322793228932299323093231932329323393234932359323693237932389323993240932419324293243932449324593246932479324893249932509325193252932539325493255932569325793258932599326093261932629326393264932659326693267932689326993270932719327293273932749327593276932779327893279932809328193282932839328493285932869328793288932899329093291932929329393294932959329693297932989329993300933019330293303933049330593306933079330893309933109331193312933139331493315933169331793318933199332093321933229332393324933259332693327933289332993330933319333293333933349333593336933379333893339933409334193342933439334493345933469334793348933499335093351933529335393354933559335693357933589335993360933619336293363933649336593366933679336893369933709337193372933739337493375933769337793378933799338093381933829338393384933859338693387933889338993390933919339293393933949339593396933979339893399934009340193402934039340493405934069340793408934099341093411934129341393414934159341693417934189341993420934219342293423934249342593426934279342893429934309343193432934339343493435934369343793438934399344093441934429344393444934459344693447934489344993450934519345293453934549345593456934579345893459934609346193462934639346493465934669346793468934699347093471934729347393474934759347693477934789347993480934819348293483934849348593486934879348893489934909349193492934939349493495934969349793498934999350093501935029350393504935059350693507935089350993510935119351293513935149351593516935179351893519935209352193522935239352493525935269352793528935299353093531935329353393534935359353693537935389353993540935419354293543935449354593546935479354893549935509355193552935539355493555935569355793558935599356093561935629356393564935659356693567935689356993570935719357293573935749357593576935779357893579935809358193582935839358493585935869358793588935899359093591935929359393594935959359693597935989359993600936019360293603936049360593606936079360893609936109361193612936139361493615936169361793618936199362093621936229362393624936259362693627936289362993630936319363293633936349363593636936379363893639936409364193642936439364493645936469364793648936499365093651936529365393654936559365693657936589365993660936619366293663936649366593666936679366893669936709367193672936739367493675936769367793678936799368093681936829368393684936859368693687936889368993690936919369293693936949369593696936979369893699937009370193702937039370493705937069370793708937099371093711937129371393714937159371693717937189371993720937219372293723937249372593726937279372893729937309373193732937339373493735937369373793738937399374093741937429374393744937459374693747937489374993750937519375293753937549375593756937579375893759937609376193762937639376493765937669376793768937699377093771937729377393774937759377693777937789377993780937819378293783937849378593786937879378893789937909379193792937939379493795937969379793798937999380093801938029380393804938059380693807938089380993810938119381293813938149381593816938179381893819938209382193822938239382493825938269382793828938299383093831938329383393834938359383693837938389383993840938419384293843938449384593846938479384893849938509385193852938539385493855938569385793858938599386093861938629386393864938659386693867938689386993870938719387293873938749387593876938779387893879938809388193882938839388493885938869388793888938899389093891938929389393894938959389693897938989389993900939019390293903939049390593906939079390893909939109391193912939139391493915939169391793918939199392093921939229392393924939259392693927939289392993930939319393293933939349393593936939379393893939939409394193942939439394493945939469394793948939499395093951939529395393954939559395693957939589395993960939619396293963939649396593966939679396893969939709397193972939739397493975939769397793978939799398093981939829398393984939859398693987939889398993990939919399293993939949399593996939979399893999940009400194002940039400494005940069400794008940099401094011940129401394014940159401694017940189401994020940219402294023940249402594026940279402894029940309403194032940339403494035940369403794038940399404094041940429404394044940459404694047940489404994050940519405294053940549405594056940579405894059940609406194062940639406494065940669406794068940699407094071940729407394074940759407694077940789407994080940819408294083940849408594086940879408894089940909409194092940939409494095940969409794098940999410094101941029410394104941059410694107941089410994110941119411294113941149411594116941179411894119941209412194122941239412494125941269412794128941299413094131941329413394134941359413694137941389413994140941419414294143941449414594146941479414894149941509415194152941539415494155941569415794158941599416094161941629416394164941659416694167941689416994170941719417294173941749417594176941779417894179941809418194182941839418494185941869418794188941899419094191941929419394194941959419694197941989419994200942019420294203942049420594206942079420894209942109421194212942139421494215942169421794218942199422094221942229422394224942259422694227942289422994230942319423294233942349423594236942379423894239942409424194242942439424494245942469424794248942499425094251942529425394254942559425694257942589425994260942619426294263942649426594266942679426894269942709427194272942739427494275942769427794278942799428094281942829428394284942859428694287942889428994290942919429294293942949429594296942979429894299943009430194302943039430494305943069430794308943099431094311943129431394314943159431694317943189431994320943219432294323943249432594326943279432894329943309433194332943339433494335943369433794338943399434094341943429434394344943459434694347943489434994350943519435294353943549435594356943579435894359943609436194362943639436494365943669436794368943699437094371943729437394374943759437694377943789437994380943819438294383943849438594386943879438894389943909439194392943939439494395943969439794398943999440094401944029440394404944059440694407944089440994410944119441294413944149441594416944179441894419944209442194422944239442494425944269442794428944299443094431944329443394434944359443694437944389443994440944419444294443944449444594446944479444894449944509445194452944539445494455944569445794458944599446094461944629446394464944659446694467944689446994470944719447294473944749447594476944779447894479944809448194482944839448494485944869448794488944899449094491944929449394494944959449694497944989449994500945019450294503945049450594506945079450894509945109451194512945139451494515945169451794518945199452094521945229452394524945259452694527945289452994530945319453294533945349453594536945379453894539945409454194542945439454494545945469454794548945499455094551945529455394554945559455694557945589455994560945619456294563945649456594566945679456894569945709457194572945739457494575945769457794578945799458094581945829458394584945859458694587945889458994590945919459294593945949459594596945979459894599946009460194602946039460494605946069460794608946099461094611946129461394614946159461694617946189461994620946219462294623946249462594626946279462894629946309463194632946339463494635946369463794638946399464094641946429464394644946459464694647946489464994650946519465294653946549465594656946579465894659946609466194662946639466494665946669466794668946699467094671946729467394674946759467694677946789467994680946819468294683946849468594686946879468894689946909469194692946939469494695946969469794698946999470094701947029470394704947059470694707947089470994710947119471294713947149471594716947179471894719947209472194722947239472494725947269472794728947299473094731947329473394734947359473694737947389473994740947419474294743947449474594746947479474894749947509475194752947539475494755947569475794758947599476094761947629476394764947659476694767947689476994770947719477294773947749477594776947779477894779947809478194782947839478494785947869478794788947899479094791947929479394794947959479694797947989479994800948019480294803948049480594806948079480894809948109481194812948139481494815948169481794818948199482094821948229482394824948259482694827948289482994830948319483294833948349483594836948379483894839948409484194842948439484494845948469484794848948499485094851948529485394854948559485694857948589485994860948619486294863948649486594866948679486894869948709487194872948739487494875948769487794878948799488094881948829488394884948859488694887948889488994890948919489294893948949489594896948979489894899949009490194902949039490494905949069490794908949099491094911949129491394914949159491694917949189491994920949219492294923949249492594926949279492894929949309493194932949339493494935949369493794938949399494094941949429494394944949459494694947949489494994950949519495294953949549495594956949579495894959949609496194962949639496494965949669496794968949699497094971949729497394974949759497694977949789497994980949819498294983949849498594986949879498894989949909499194992949939499494995949969499794998949999500095001950029500395004950059500695007950089500995010950119501295013950149501595016950179501895019950209502195022950239502495025950269502795028950299503095031950329503395034950359503695037950389503995040950419504295043950449504595046950479504895049950509505195052950539505495055950569505795058950599506095061950629506395064950659506695067950689506995070950719507295073950749507595076950779507895079950809508195082950839508495085950869508795088950899509095091950929509395094950959509695097950989509995100951019510295103951049510595106951079510895109951109511195112951139511495115951169511795118951199512095121951229512395124951259512695127951289512995130951319513295133951349513595136951379513895139951409514195142951439514495145951469514795148951499515095151951529515395154951559515695157951589515995160951619516295163951649516595166951679516895169951709517195172951739517495175951769517795178951799518095181951829518395184951859518695187951889518995190951919519295193951949519595196951979519895199952009520195202952039520495205952069520795208952099521095211952129521395214952159521695217952189521995220952219522295223952249522595226952279522895229952309523195232952339523495235952369523795238952399524095241952429524395244952459524695247952489524995250952519525295253952549525595256952579525895259952609526195262952639526495265952669526795268952699527095271952729527395274952759527695277952789527995280952819528295283952849528595286952879528895289952909529195292952939529495295952969529795298952999530095301953029530395304953059530695307953089530995310953119531295313953149531595316953179531895319953209532195322953239532495325953269532795328953299533095331953329533395334953359533695337953389533995340953419534295343953449534595346953479534895349953509535195352953539535495355953569535795358953599536095361953629536395364953659536695367953689536995370953719537295373953749537595376953779537895379953809538195382953839538495385953869538795388953899539095391953929539395394953959539695397953989539995400954019540295403954049540595406954079540895409954109541195412954139541495415954169541795418954199542095421954229542395424954259542695427954289542995430954319543295433954349543595436954379543895439954409544195442954439544495445954469544795448954499545095451954529545395454954559545695457954589545995460954619546295463954649546595466954679546895469954709547195472954739547495475954769547795478954799548095481954829548395484954859548695487954889548995490954919549295493954949549595496954979549895499955009550195502955039550495505955069550795508955099551095511955129551395514955159551695517955189551995520955219552295523955249552595526955279552895529955309553195532955339553495535955369553795538955399554095541955429554395544955459554695547955489554995550955519555295553955549555595556955579555895559955609556195562955639556495565955669556795568955699557095571955729557395574955759557695577955789557995580955819558295583955849558595586955879558895589955909559195592955939559495595955969559795598955999560095601956029560395604956059560695607956089560995610956119561295613956149561595616956179561895619956209562195622956239562495625956269562795628956299563095631956329563395634956359563695637956389563995640956419564295643956449564595646956479564895649956509565195652956539565495655956569565795658956599566095661956629566395664956659566695667956689566995670956719567295673956749567595676956779567895679956809568195682956839568495685956869568795688956899569095691956929569395694956959569695697956989569995700957019570295703957049570595706957079570895709957109571195712957139571495715957169571795718957199572095721957229572395724957259572695727957289572995730957319573295733957349573595736957379573895739957409574195742957439574495745957469574795748957499575095751957529575395754957559575695757957589575995760957619576295763957649576595766957679576895769957709577195772957739577495775957769577795778957799578095781957829578395784957859578695787957889578995790957919579295793957949579595796957979579895799958009580195802958039580495805958069580795808958099581095811958129581395814958159581695817958189581995820958219582295823958249582595826958279582895829958309583195832958339583495835958369583795838958399584095841958429584395844958459584695847958489584995850958519585295853958549585595856958579585895859958609586195862958639586495865958669586795868958699587095871958729587395874958759587695877958789587995880958819588295883958849588595886958879588895889958909589195892958939589495895958969589795898958999590095901959029590395904959059590695907959089590995910959119591295913959149591595916959179591895919959209592195922959239592495925959269592795928959299593095931959329593395934959359593695937959389593995940959419594295943959449594595946959479594895949959509595195952959539595495955959569595795958959599596095961959629596395964959659596695967959689596995970959719597295973959749597595976959779597895979959809598195982959839598495985959869598795988959899599095991959929599395994959959599695997959989599996000960019600296003960049600596006960079600896009960109601196012960139601496015960169601796018960199602096021960229602396024960259602696027960289602996030960319603296033960349603596036960379603896039960409604196042960439604496045960469604796048960499605096051960529605396054960559605696057960589605996060960619606296063960649606596066960679606896069960709607196072960739607496075960769607796078960799608096081960829608396084960859608696087960889608996090960919609296093960949609596096960979609896099961009610196102961039610496105961069610796108961099611096111961129611396114961159611696117961189611996120961219612296123961249612596126961279612896129961309613196132961339613496135961369613796138961399614096141961429614396144961459614696147961489614996150961519615296153961549615596156961579615896159961609616196162961639616496165961669616796168961699617096171961729617396174961759617696177961789617996180961819618296183961849618596186961879618896189961909619196192961939619496195961969619796198961999620096201962029620396204962059620696207962089620996210962119621296213962149621596216962179621896219962209622196222962239622496225962269622796228962299623096231962329623396234962359623696237962389623996240962419624296243962449624596246962479624896249962509625196252962539625496255962569625796258962599626096261962629626396264962659626696267962689626996270962719627296273962749627596276962779627896279962809628196282962839628496285962869628796288962899629096291962929629396294962959629696297962989629996300963019630296303963049630596306963079630896309963109631196312963139631496315963169631796318963199632096321963229632396324963259632696327963289632996330963319633296333963349633596336963379633896339963409634196342963439634496345963469634796348963499635096351963529635396354963559635696357963589635996360963619636296363963649636596366963679636896369963709637196372963739637496375963769637796378963799638096381963829638396384963859638696387963889638996390963919639296393963949639596396963979639896399964009640196402964039640496405964069640796408964099641096411964129641396414964159641696417964189641996420964219642296423964249642596426964279642896429964309643196432964339643496435964369643796438964399644096441964429644396444964459644696447964489644996450964519645296453964549645596456964579645896459964609646196462964639646496465964669646796468964699647096471964729647396474964759647696477964789647996480964819648296483964849648596486964879648896489964909649196492964939649496495964969649796498964999650096501965029650396504965059650696507965089650996510965119651296513965149651596516965179651896519965209652196522965239652496525965269652796528965299653096531965329653396534965359653696537965389653996540965419654296543965449654596546965479654896549965509655196552965539655496555965569655796558965599656096561965629656396564965659656696567965689656996570965719657296573965749657596576965779657896579965809658196582965839658496585965869658796588965899659096591965929659396594965959659696597965989659996600966019660296603966049660596606966079660896609966109661196612966139661496615966169661796618966199662096621966229662396624966259662696627966289662996630966319663296633966349663596636966379663896639966409664196642966439664496645966469664796648966499665096651966529665396654966559665696657966589665996660966619666296663966649666596666966679666896669966709667196672966739667496675966769667796678966799668096681966829668396684966859668696687966889668996690966919669296693966949669596696966979669896699967009670196702967039670496705967069670796708967099671096711967129671396714967159671696717967189671996720967219672296723967249672596726967279672896729967309673196732967339673496735967369673796738967399674096741967429674396744967459674696747967489674996750967519675296753967549675596756967579675896759967609676196762967639676496765967669676796768967699677096771967729677396774967759677696777967789677996780967819678296783967849678596786967879678896789967909679196792967939679496795967969679796798967999680096801968029680396804968059680696807968089680996810968119681296813968149681596816968179681896819968209682196822968239682496825968269682796828968299683096831968329683396834968359683696837968389683996840968419684296843968449684596846968479684896849968509685196852968539685496855968569685796858968599686096861968629686396864968659686696867968689686996870968719687296873968749687596876968779687896879968809688196882968839688496885968869688796888968899689096891968929689396894968959689696897968989689996900969019690296903969049690596906969079690896909969109691196912969139691496915969169691796918969199692096921969229692396924969259692696927969289692996930969319693296933969349693596936969379693896939969409694196942969439694496945969469694796948969499695096951969529695396954969559695696957969589695996960969619696296963969649696596966969679696896969969709697196972969739697496975969769697796978969799698096981969829698396984969859698696987969889698996990969919699296993969949699596996969979699896999970009700197002970039700497005970069700797008970099701097011970129701397014970159701697017970189701997020970219702297023970249702597026970279702897029970309703197032970339703497035970369703797038970399704097041970429704397044970459704697047970489704997050970519705297053970549705597056970579705897059970609706197062970639706497065970669706797068970699707097071970729707397074970759707697077970789707997080970819708297083970849708597086970879708897089970909709197092970939709497095970969709797098970999710097101971029710397104971059710697107971089710997110971119711297113971149711597116971179711897119971209712197122971239712497125971269712797128971299713097131971329713397134971359713697137971389713997140971419714297143971449714597146971479714897149971509715197152971539715497155971569715797158971599716097161971629716397164971659716697167971689716997170971719717297173971749717597176971779717897179971809718197182971839718497185971869718797188971899719097191971929719397194971959719697197971989719997200972019720297203972049720597206972079720897209972109721197212972139721497215972169721797218972199722097221972229722397224972259722697227972289722997230972319723297233972349723597236972379723897239972409724197242972439724497245972469724797248972499725097251972529725397254972559725697257972589725997260972619726297263972649726597266972679726897269972709727197272972739727497275972769727797278972799728097281972829728397284972859728697287972889728997290972919729297293972949729597296972979729897299973009730197302973039730497305973069730797308973099731097311973129731397314973159731697317973189731997320973219732297323973249732597326973279732897329973309733197332973339733497335973369733797338973399734097341973429734397344973459734697347973489734997350973519735297353973549735597356973579735897359973609736197362973639736497365973669736797368973699737097371973729737397374973759737697377973789737997380973819738297383973849738597386973879738897389973909739197392973939739497395973969739797398973999740097401974029740397404974059740697407974089740997410974119741297413974149741597416974179741897419974209742197422974239742497425974269742797428974299743097431974329743397434974359743697437974389743997440974419744297443974449744597446974479744897449974509745197452974539745497455974569745797458974599746097461974629746397464974659746697467974689746997470974719747297473974749747597476974779747897479974809748197482974839748497485974869748797488974899749097491974929749397494974959749697497974989749997500975019750297503975049750597506975079750897509975109751197512975139751497515975169751797518975199752097521975229752397524975259752697527975289752997530975319753297533975349753597536975379753897539975409754197542975439754497545975469754797548975499755097551975529755397554975559755697557975589755997560975619756297563975649756597566975679756897569975709757197572975739757497575975769757797578975799758097581975829758397584975859758697587975889758997590975919759297593975949759597596975979759897599976009760197602976039760497605976069760797608976099761097611976129761397614976159761697617976189761997620976219762297623976249762597626976279762897629976309763197632976339763497635976369763797638976399764097641976429764397644976459764697647976489764997650976519765297653976549765597656976579765897659976609766197662976639766497665976669766797668976699767097671976729767397674976759767697677976789767997680976819768297683976849768597686976879768897689976909769197692976939769497695976969769797698976999770097701977029770397704977059770697707977089770997710977119771297713977149771597716977179771897719977209772197722977239772497725977269772797728977299773097731977329773397734977359773697737977389773997740977419774297743977449774597746977479774897749977509775197752977539775497755977569775797758977599776097761977629776397764977659776697767977689776997770977719777297773977749777597776977779777897779977809778197782977839778497785977869778797788977899779097791977929779397794977959779697797977989779997800978019780297803978049780597806978079780897809978109781197812978139781497815978169781797818978199782097821978229782397824978259782697827978289782997830978319783297833978349783597836978379783897839978409784197842978439784497845978469784797848978499785097851978529785397854978559785697857978589785997860978619786297863978649786597866978679786897869978709787197872978739787497875978769787797878978799788097881978829788397884978859788697887978889788997890978919789297893978949789597896978979789897899979009790197902979039790497905979069790797908979099791097911979129791397914979159791697917979189791997920979219792297923979249792597926979279792897929979309793197932979339793497935979369793797938979399794097941979429794397944979459794697947979489794997950979519795297953979549795597956979579795897959979609796197962979639796497965979669796797968979699797097971979729797397974979759797697977979789797997980979819798297983979849798597986979879798897989979909799197992979939799497995979969799797998979999800098001980029800398004980059800698007980089800998010980119801298013980149801598016980179801898019980209802198022980239802498025980269802798028980299803098031980329803398034980359803698037980389803998040980419804298043980449804598046980479804898049980509805198052980539805498055980569805798058980599806098061980629806398064980659806698067980689806998070980719807298073980749807598076980779807898079980809808198082980839808498085980869808798088980899809098091980929809398094980959809698097980989809998100981019810298103981049810598106981079810898109981109811198112981139811498115981169811798118981199812098121981229812398124981259812698127981289812998130981319813298133981349813598136981379813898139981409814198142981439814498145981469814798148981499815098151981529815398154981559815698157981589815998160981619816298163981649816598166981679816898169981709817198172981739817498175981769817798178981799818098181981829818398184981859818698187981889818998190981919819298193981949819598196981979819898199982009820198202982039820498205982069820798208982099821098211982129821398214982159821698217982189821998220982219822298223982249822598226982279822898229982309823198232982339823498235982369823798238982399824098241982429824398244982459824698247982489824998250982519825298253982549825598256982579825898259982609826198262982639826498265982669826798268982699827098271982729827398274982759827698277982789827998280982819828298283982849828598286982879828898289982909829198292982939829498295982969829798298982999830098301983029830398304983059830698307983089830998310983119831298313983149831598316983179831898319983209832198322983239832498325983269832798328983299833098331983329833398334983359833698337983389833998340983419834298343983449834598346983479834898349983509835198352983539835498355983569835798358983599836098361983629836398364983659836698367983689836998370983719837298373983749837598376983779837898379983809838198382983839838498385983869838798388983899839098391983929839398394983959839698397983989839998400984019840298403984049840598406984079840898409984109841198412984139841498415984169841798418984199842098421984229842398424984259842698427984289842998430984319843298433984349843598436984379843898439984409844198442984439844498445984469844798448984499845098451984529845398454984559845698457984589845998460984619846298463984649846598466984679846898469984709847198472984739847498475984769847798478984799848098481984829848398484984859848698487984889848998490984919849298493984949849598496984979849898499985009850198502985039850498505985069850798508985099851098511985129851398514985159851698517985189851998520985219852298523985249852598526985279852898529985309853198532985339853498535985369853798538985399854098541985429854398544985459854698547985489854998550985519855298553985549855598556985579855898559985609856198562985639856498565985669856798568985699857098571985729857398574985759857698577985789857998580985819858298583985849858598586985879858898589985909859198592985939859498595985969859798598985999860098601986029860398604986059860698607986089860998610986119861298613986149861598616986179861898619986209862198622986239862498625986269862798628986299863098631986329863398634986359863698637986389863998640986419864298643986449864598646986479864898649986509865198652986539865498655986569865798658986599866098661986629866398664986659866698667986689866998670986719867298673986749867598676986779867898679986809868198682986839868498685986869868798688986899869098691986929869398694986959869698697986989869998700987019870298703987049870598706987079870898709987109871198712987139871498715987169871798718987199872098721987229872398724987259872698727987289872998730987319873298733987349873598736987379873898739987409874198742987439874498745987469874798748987499875098751987529875398754987559875698757987589875998760987619876298763987649876598766987679876898769987709877198772987739877498775987769877798778987799878098781987829878398784987859878698787987889878998790987919879298793987949879598796987979879898799988009880198802988039880498805988069880798808988099881098811988129881398814988159881698817988189881998820988219882298823988249882598826988279882898829988309883198832988339883498835988369883798838988399884098841988429884398844988459884698847988489884998850988519885298853988549885598856988579885898859988609886198862988639886498865988669886798868988699887098871988729887398874988759887698877988789887998880988819888298883988849888598886988879888898889988909889198892988939889498895988969889798898988999890098901989029890398904989059890698907989089890998910989119891298913989149891598916989179891898919989209892198922989239892498925989269892798928989299893098931989329893398934989359893698937989389893998940989419894298943989449894598946989479894898949989509895198952989539895498955989569895798958989599896098961989629896398964989659896698967989689896998970989719897298973989749897598976989779897898979989809898198982989839898498985989869898798988989899899098991989929899398994989959899698997989989899999000990019900299003990049900599006990079900899009990109901199012990139901499015990169901799018990199902099021990229902399024990259902699027990289902999030990319903299033990349903599036990379903899039990409904199042990439904499045990469904799048990499905099051990529905399054990559905699057990589905999060990619906299063990649906599066990679906899069990709907199072990739907499075990769907799078990799908099081990829908399084990859908699087990889908999090990919909299093990949909599096990979909899099991009910199102991039910499105991069910799108991099911099111991129911399114991159911699117991189911999120991219912299123991249912599126991279912899129991309913199132991339913499135991369913799138991399914099141991429914399144991459914699147991489914999150991519915299153991549915599156991579915899159991609916199162991639916499165991669916799168991699917099171991729917399174991759917699177991789917999180991819918299183991849918599186991879918899189991909919199192991939919499195991969919799198991999920099201992029920399204992059920699207992089920999210992119921299213992149921599216992179921899219992209922199222992239922499225992269922799228992299923099231992329923399234992359923699237992389923999240992419924299243992449924599246992479924899249992509925199252992539925499255992569925799258992599926099261992629926399264992659926699267992689926999270992719927299273992749927599276992779927899279992809928199282992839928499285992869928799288992899929099291992929929399294992959929699297992989929999300993019930299303993049930599306993079930899309993109931199312993139931499315993169931799318993199932099321993229932399324993259932699327993289932999330993319933299333993349933599336993379933899339993409934199342993439934499345993469934799348993499935099351993529935399354993559935699357993589935999360993619936299363993649936599366993679936899369993709937199372993739937499375993769937799378993799938099381993829938399384993859938699387993889938999390993919939299393993949939599396993979939899399994009940199402994039940499405994069940799408994099941099411994129941399414994159941699417994189941999420994219942299423994249942599426994279942899429994309943199432994339943499435994369943799438994399944099441994429944399444994459944699447994489944999450994519945299453994549945599456994579945899459994609946199462994639946499465994669946799468994699947099471994729947399474994759947699477994789947999480994819948299483994849948599486994879948899489994909949199492994939949499495994969949799498994999950099501995029950399504995059950699507995089950999510995119951299513995149951599516995179951899519995209952199522995239952499525995269952799528995299953099531995329953399534995359953699537995389953999540995419954299543995449954599546995479954899549995509955199552995539955499555995569955799558995599956099561995629956399564995659956699567995689956999570995719957299573995749957599576995779957899579995809958199582995839958499585995869958799588995899959099591995929959399594995959959699597995989959999600996019960299603996049960599606996079960899609996109961199612996139961499615996169961799618996199962099621996229962399624996259962699627996289962999630996319963299633996349963599636996379963899639996409964199642996439964499645996469964799648996499965099651996529965399654996559965699657996589965999660996619966299663996649966599666996679966899669996709967199672996739967499675996769967799678996799968099681996829968399684996859968699687996889968999690996919969299693996949969599696996979969899699997009970199702997039970499705997069970799708997099971099711997129971399714997159971699717997189971999720997219972299723997249972599726997279972899729997309973199732997339973499735997369973799738997399974099741997429974399744997459974699747997489974999750997519975299753997549975599756997579975899759997609976199762997639976499765997669976799768997699977099771997729977399774997759977699777997789977999780997819978299783997849978599786997879978899789997909979199792997939979499795997969979799798997999980099801998029980399804998059980699807998089980999810998119981299813998149981599816998179981899819998209982199822998239982499825998269982799828998299983099831998329983399834998359983699837998389983999840998419984299843998449984599846998479984899849998509985199852998539985499855998569985799858998599986099861998629986399864998659986699867998689986999870998719987299873998749987599876998779987899879998809988199882998839988499885998869988799888998899989099891998929989399894998959989699897998989989999900999019990299903999049990599906999079990899909999109991199912999139991499915999169991799918999199992099921999229992399924999259992699927999289992999930999319993299933999349993599936999379993899939999409994199942999439994499945999469994799948999499995099951999529995399954999559995699957999589995999960999619996299963999649996599966999679996899969999709997199972999739997499975999769997799978999799998099981999829998399984999859998699987999889998999990999919999299993999949999599996999979999899999100000100001100002100003100004100005100006100007100008100009100010100011100012100013100014100015100016100017100018100019100020100021100022100023100024100025100026100027100028100029100030100031100032100033100034100035100036100037100038100039100040100041100042100043100044100045100046100047100048100049100050100051100052100053100054100055100056100057100058100059100060100061100062100063100064100065100066100067100068100069100070100071100072100073100074100075100076100077100078100079100080100081100082100083100084100085100086100087100088100089100090100091100092100093100094100095100096100097100098100099100100100101100102100103100104100105100106100107100108100109100110100111100112100113100114100115100116100117100118100119100120100121100122100123100124100125100126100127100128100129100130100131100132100133100134100135100136100137100138100139100140100141100142100143100144100145100146100147100148100149100150100151100152100153100154100155100156100157100158100159100160100161100162100163100164100165100166100167100168100169100170100171100172100173100174100175100176100177100178100179100180100181100182100183100184100185100186100187100188100189100190100191100192100193100194100195100196100197100198100199100200100201100202100203100204100205100206100207100208100209100210100211100212100213100214100215100216100217100218100219100220100221100222100223100224100225100226100227100228100229100230100231100232100233100234100235100236100237100238100239100240100241100242100243100244100245100246100247100248100249100250100251100252100253100254100255100256100257100258100259100260100261100262100263100264100265100266100267100268100269100270100271100272100273100274100275100276100277100278100279100280100281100282100283100284100285100286100287100288100289100290100291100292100293100294100295100296100297100298100299100300100301100302100303100304100305100306100307100308100309100310100311100312100313100314100315100316100317100318100319100320100321100322100323100324100325100326100327100328100329100330100331100332100333100334100335100336100337100338100339100340100341100342100343100344100345100346100347100348100349100350100351100352100353100354100355100356100357100358100359100360100361100362100363100364100365100366100367100368100369100370100371100372100373100374100375100376100377100378100379100380100381100382100383100384100385100386100387100388100389100390100391100392100393100394100395100396100397100398100399100400100401100402100403100404100405100406100407100408100409100410100411100412100413100414100415100416100417100418100419100420100421100422100423100424100425100426100427100428100429100430100431100432100433100434100435100436100437100438100439100440100441100442100443100444100445100446100447100448100449100450100451100452100453100454100455100456100457100458100459100460100461100462100463100464100465100466100467100468100469100470100471100472100473100474100475100476100477100478100479100480100481100482100483100484100485100486100487100488100489100490100491100492100493100494100495100496100497100498100499100500100501100502100503100504100505100506100507100508100509100510100511100512100513100514100515100516100517100518100519100520100521100522100523100524100525100526100527100528100529100530100531100532100533100534100535100536100537100538100539100540100541100542100543100544100545100546100547100548100549100550100551100552100553100554100555100556100557100558100559100560100561100562100563100564100565100566100567100568100569100570100571100572100573100574100575100576100577100578100579100580100581100582100583100584100585100586100587100588100589100590100591100592100593100594100595100596100597100598100599100600100601100602100603100604100605100606100607100608100609100610100611100612100613100614100615100616100617100618100619100620100621100622100623100624100625100626100627100628100629100630100631100632100633100634100635100636100637100638100639100640100641100642100643100644100645100646100647100648100649100650100651100652100653100654100655100656100657100658100659100660100661100662100663100664100665100666100667100668100669100670100671100672100673100674100675100676100677100678100679100680100681100682100683100684100685100686100687100688100689100690100691100692100693100694100695100696100697100698100699100700100701100702100703100704100705100706100707100708100709100710100711100712100713100714100715100716100717100718100719100720100721100722100723100724100725100726100727100728100729100730100731100732100733100734100735100736100737100738100739100740100741100742100743100744100745100746100747100748100749100750100751100752100753100754100755100756100757100758100759100760100761100762100763100764100765100766100767100768100769100770100771100772100773100774100775100776100777100778100779100780100781100782100783100784100785100786100787100788100789100790100791100792100793100794100795100796100797100798100799100800100801100802100803100804100805100806100807100808100809100810100811100812100813100814100815100816100817100818100819100820100821100822100823100824100825100826100827100828100829100830100831100832100833100834100835100836100837100838100839100840100841100842100843100844100845100846100847100848100849100850100851100852100853100854100855100856100857100858100859100860100861100862100863100864100865100866100867100868100869100870100871100872100873100874100875100876100877100878100879100880100881100882100883100884100885100886100887100888100889100890100891100892100893100894100895100896100897100898100899100900100901100902100903100904100905100906100907100908100909100910100911100912100913100914100915100916100917100918100919100920100921100922100923100924100925100926100927100928100929100930100931100932100933100934100935100936100937100938100939100940100941100942100943100944100945100946100947100948100949100950100951100952100953100954100955100956100957100958100959100960100961100962100963100964100965100966100967100968100969100970100971100972100973100974100975100976100977100978100979100980100981100982100983100984100985100986100987100988100989100990100991100992100993100994100995100996100997100998100999101000101001101002101003101004101005101006101007101008101009101010101011101012101013101014101015101016101017101018101019101020101021101022101023101024101025101026101027101028101029101030101031101032101033101034101035101036101037101038101039101040101041101042101043101044101045101046101047101048101049101050101051101052101053101054101055101056101057101058101059101060101061101062101063101064101065101066101067101068101069101070101071101072101073101074101075101076101077101078101079101080101081101082101083101084101085101086101087101088101089101090101091101092101093101094101095101096101097101098101099101100101101101102101103101104101105101106101107101108101109101110101111101112101113101114101115101116101117101118101119101120101121101122101123101124101125101126101127101128101129101130101131101132101133101134101135101136101137101138101139101140101141101142101143101144101145101146101147101148101149101150101151101152101153101154101155101156101157101158101159101160101161101162101163101164101165101166101167101168101169101170101171101172101173101174101175101176101177101178101179101180101181101182101183101184101185101186101187101188101189101190101191101192101193101194101195101196101197101198101199101200101201101202101203101204101205101206101207101208101209101210101211101212101213101214101215101216101217101218101219101220101221101222101223101224101225101226101227101228101229101230101231101232101233101234101235101236101237101238101239101240101241101242101243101244101245101246101247101248101249101250101251101252101253101254101255101256101257101258101259101260101261101262101263101264101265101266101267101268101269101270101271101272101273101274101275101276101277101278101279101280101281101282101283101284101285101286101287101288101289101290101291101292101293101294101295101296101297101298101299101300101301101302101303101304101305101306101307101308101309101310101311101312101313101314101315101316101317101318101319101320101321101322101323101324101325101326101327101328101329101330101331101332101333101334101335101336101337101338101339101340101341101342101343101344101345101346101347101348101349101350101351101352101353101354101355101356101357101358101359101360101361101362101363101364101365101366101367101368101369101370101371101372101373101374101375101376101377101378101379101380101381101382101383101384101385101386101387101388101389101390101391101392101393101394101395101396101397101398101399101400101401101402101403101404101405101406101407101408101409101410101411101412101413101414101415101416101417101418101419101420101421101422101423101424101425101426101427101428101429101430101431101432101433101434101435101436101437101438101439101440101441101442101443101444101445101446101447101448101449101450101451101452101453101454101455101456101457101458101459101460101461101462101463101464101465101466101467101468101469101470101471101472101473101474101475101476101477101478101479101480101481101482101483101484101485101486101487101488101489101490101491101492101493101494101495101496101497101498101499101500101501101502101503101504101505101506101507101508101509101510101511101512101513101514101515101516101517101518101519101520101521101522101523101524101525101526101527101528101529101530101531101532101533101534101535101536101537101538101539101540101541101542101543101544101545101546101547101548101549101550101551101552101553101554101555101556101557101558101559101560101561101562101563101564101565101566101567101568101569101570101571101572101573101574101575101576101577101578101579101580101581101582101583101584101585101586101587101588101589101590101591101592101593101594101595101596101597101598101599101600101601101602101603101604101605101606101607101608101609101610101611101612101613101614101615101616101617101618101619101620101621101622101623101624101625101626101627101628101629101630101631101632101633101634101635101636101637101638101639101640101641101642101643101644101645101646101647101648101649101650101651101652101653101654101655101656101657101658101659101660101661101662101663101664101665101666101667101668101669101670101671101672101673101674101675101676101677101678101679101680101681101682101683101684101685101686101687101688101689101690101691101692101693101694101695101696101697101698101699101700101701101702101703101704101705101706101707101708101709101710101711101712101713101714101715101716101717101718101719101720101721101722101723101724101725101726101727101728101729101730101731101732101733101734101735101736101737101738101739101740101741101742101743101744101745101746101747101748101749101750101751101752101753101754101755101756101757101758101759101760101761101762101763101764101765101766101767101768101769101770101771101772101773101774101775101776101777101778101779101780101781101782101783101784101785101786101787101788101789101790101791101792101793101794101795101796101797101798101799101800101801101802101803101804101805101806101807101808101809101810101811101812101813101814101815101816101817101818101819101820101821101822101823101824101825101826101827101828101829101830101831101832101833101834101835101836101837101838101839101840101841101842101843101844101845101846101847101848101849101850101851101852101853101854101855101856101857101858101859101860101861101862101863101864101865101866101867101868101869101870101871101872101873101874101875101876101877101878101879101880101881101882101883101884101885101886101887101888101889101890101891101892101893101894101895101896101897101898101899101900101901101902101903101904101905101906101907101908101909101910101911101912101913101914101915101916101917101918101919101920101921101922101923101924101925101926101927101928101929101930101931101932101933101934101935101936101937101938101939101940101941101942101943101944101945101946101947101948101949101950101951101952101953101954101955101956101957101958101959101960101961101962101963101964101965101966101967101968101969101970101971101972101973101974101975101976101977101978101979101980101981101982101983101984101985101986101987101988101989101990101991101992101993101994101995101996101997101998101999102000102001102002102003102004102005102006102007102008102009102010102011102012102013102014102015102016102017102018102019102020102021102022102023102024102025102026102027102028102029102030102031102032102033102034102035102036102037102038102039102040102041102042102043102044102045102046102047102048102049102050102051102052102053102054102055102056102057102058102059102060102061102062102063102064102065102066102067102068102069102070102071102072102073102074102075102076102077102078102079102080102081102082102083102084102085102086102087102088102089102090102091102092102093102094102095102096102097102098102099102100102101102102102103102104102105102106102107102108102109102110102111102112102113102114102115102116102117102118102119102120102121102122102123102124102125102126102127102128102129102130102131102132102133102134102135102136102137102138102139102140102141102142102143102144102145102146102147102148102149102150102151102152102153102154102155102156102157102158102159102160102161102162102163102164102165102166102167102168102169102170102171102172102173102174102175102176102177102178102179102180102181102182102183102184102185102186102187102188102189102190102191102192102193102194102195102196102197102198102199102200102201102202102203102204102205102206102207102208102209102210102211102212102213102214102215102216102217102218102219102220102221102222102223102224102225102226102227102228102229102230102231102232102233102234102235102236102237102238102239102240102241102242102243102244102245102246102247102248102249102250102251102252102253102254102255102256102257102258102259102260102261102262102263102264102265102266102267102268102269102270102271102272102273102274102275102276102277102278102279102280102281102282102283102284102285102286102287102288102289102290102291102292102293102294102295102296102297102298102299102300102301102302102303102304102305102306102307102308102309102310102311102312102313102314102315102316102317102318102319102320102321102322102323102324102325102326102327102328102329102330102331102332102333102334102335102336102337102338102339102340102341102342102343102344102345102346102347102348102349102350102351102352102353102354102355102356102357102358102359102360102361102362102363102364102365102366102367102368102369102370102371102372102373102374102375102376102377102378102379102380102381102382102383102384102385102386102387102388102389102390102391102392102393102394102395102396102397102398102399102400102401102402102403102404102405102406102407102408102409102410102411102412102413102414102415102416102417102418102419102420102421102422102423102424102425102426102427102428102429102430102431102432102433102434102435102436102437102438102439102440102441102442102443102444102445102446102447102448102449102450102451102452102453102454102455102456102457102458102459102460102461102462102463102464102465102466102467102468102469102470102471102472102473102474102475102476102477102478102479102480102481102482102483102484102485102486102487102488102489102490102491102492102493102494102495102496102497102498102499102500102501102502102503102504102505102506102507102508102509102510102511102512102513102514102515102516102517102518102519102520102521102522102523102524102525102526102527102528102529102530102531102532102533102534102535102536102537102538102539102540102541102542102543102544102545102546102547102548102549102550102551102552102553102554102555102556102557102558102559102560102561102562102563102564102565102566102567102568102569102570102571102572102573102574102575102576102577102578102579102580102581102582102583102584102585102586102587102588102589102590102591102592102593102594102595102596102597102598102599102600102601102602102603102604102605102606102607102608102609102610102611102612102613102614102615102616102617102618102619102620102621102622102623102624102625102626102627102628102629102630102631102632102633102634102635102636102637102638102639102640102641102642102643102644102645102646102647102648102649102650102651102652102653102654102655102656102657102658102659102660102661102662102663102664102665102666102667102668102669102670102671102672102673102674102675102676102677102678102679102680102681102682102683102684102685102686102687102688102689102690102691102692102693102694102695102696102697102698102699102700102701102702102703102704102705102706102707102708102709102710102711102712102713102714102715102716102717102718102719102720102721102722102723102724102725102726102727102728102729102730102731102732102733102734102735102736102737102738102739102740102741102742102743102744102745102746102747102748102749102750102751102752102753102754102755102756102757102758102759102760102761102762102763102764102765102766102767102768102769102770102771102772102773102774102775102776102777102778102779102780102781102782102783102784102785102786102787102788102789102790102791102792102793102794102795102796102797102798102799102800102801102802102803102804102805102806102807102808102809102810102811102812102813102814102815102816102817102818102819102820102821102822102823102824102825102826102827102828102829102830102831102832102833102834102835102836102837102838102839102840102841102842102843102844102845102846102847102848102849102850102851102852102853102854102855102856102857102858102859102860102861102862102863102864102865102866102867102868102869102870102871102872102873102874102875102876102877102878102879102880102881102882102883102884102885102886102887102888102889102890102891102892102893102894102895102896102897102898102899102900102901102902102903102904102905102906102907102908102909102910102911102912102913102914102915102916102917102918102919102920102921102922102923102924102925102926102927102928102929102930102931102932102933102934102935102936102937102938102939102940102941102942102943102944102945102946102947102948102949102950102951102952102953102954102955102956102957102958102959102960102961102962102963102964102965102966102967102968102969102970102971102972102973102974102975102976102977102978102979102980102981102982102983102984102985102986102987102988102989102990102991102992102993102994102995102996102997102998102999103000103001103002103003103004103005103006103007103008103009103010103011103012103013103014103015103016103017103018103019103020103021103022103023103024103025103026103027103028103029103030103031103032103033103034103035103036103037103038103039103040103041103042103043103044103045103046103047103048103049103050103051103052103053103054103055103056103057103058103059103060103061103062103063103064103065103066103067103068103069103070103071103072103073103074103075103076103077103078103079103080103081103082103083103084103085103086103087103088103089103090103091103092103093103094103095103096103097103098103099103100103101103102103103103104103105103106103107103108103109103110103111103112103113103114103115103116103117103118103119103120103121103122103123103124103125103126103127103128103129103130103131103132103133103134103135103136103137103138103139103140103141103142103143103144103145103146103147103148103149103150103151103152103153103154103155103156103157103158103159103160103161103162103163103164103165103166103167103168103169103170103171103172103173103174103175103176103177103178103179103180103181103182103183103184103185103186103187103188103189103190103191103192103193103194103195103196103197103198103199103200103201103202103203103204103205103206103207103208103209103210103211103212103213103214103215103216103217103218103219103220103221103222103223103224103225103226103227103228103229103230103231103232103233103234103235103236103237103238103239103240103241103242103243103244103245103246103247103248103249103250103251103252103253103254103255103256103257103258103259103260103261103262103263103264103265103266103267103268103269103270103271103272103273103274103275103276103277103278103279103280103281103282103283103284103285103286103287103288103289103290103291103292103293103294103295103296103297103298103299103300103301103302103303103304103305103306103307103308103309103310103311103312103313103314103315103316103317103318103319103320103321103322103323103324103325103326103327103328103329103330103331103332103333103334103335103336103337103338103339103340103341103342103343103344103345103346103347103348103349103350103351103352103353103354103355103356103357103358103359103360103361103362103363103364103365103366103367103368103369103370103371103372103373103374103375103376103377103378103379103380103381103382103383103384103385103386103387103388103389103390103391103392103393103394103395103396103397103398103399103400103401103402103403103404103405103406103407103408103409103410103411103412103413103414103415103416103417103418103419103420103421103422103423103424103425103426103427103428103429103430103431103432103433103434103435103436103437103438103439103440103441103442103443103444103445103446103447103448103449103450103451103452103453103454103455103456103457103458103459103460103461103462103463103464103465103466103467103468103469103470103471103472103473103474103475103476103477103478103479103480103481103482103483103484103485103486103487103488103489103490103491103492103493103494103495103496103497103498103499103500103501103502103503103504103505103506103507103508103509103510103511103512103513103514103515103516103517103518103519103520103521103522103523103524103525103526103527103528103529103530103531103532103533103534103535103536103537103538103539103540103541103542103543103544103545103546103547103548103549103550103551103552103553103554103555103556103557103558103559103560103561103562103563103564103565103566103567103568103569103570103571103572103573103574103575103576103577103578103579103580103581103582103583103584103585103586103587103588103589103590103591103592103593103594103595103596103597103598103599103600103601103602103603103604103605103606103607103608103609103610103611103612103613103614103615103616103617103618103619103620103621103622103623103624103625103626103627103628103629103630103631103632103633103634103635103636103637103638103639103640103641103642103643103644103645103646103647103648103649103650103651103652103653103654103655103656103657103658103659103660103661103662103663103664103665103666103667103668103669103670103671103672103673103674103675103676103677103678103679103680103681103682103683103684103685103686103687103688103689103690103691103692103693103694103695103696103697103698103699103700103701103702103703103704103705103706103707103708103709103710103711103712103713103714103715103716103717103718103719103720103721103722103723103724103725103726103727103728103729103730103731103732103733103734103735103736103737103738103739103740103741103742103743103744103745103746103747103748103749103750103751103752103753103754103755103756103757103758103759103760103761103762103763103764103765103766103767103768103769103770103771103772103773103774103775103776103777103778103779103780103781103782103783103784103785103786103787103788103789103790103791103792103793103794103795103796103797103798103799103800103801103802103803103804103805103806103807103808103809103810103811103812103813103814103815103816103817103818103819103820103821103822103823103824103825103826103827103828103829103830103831103832103833103834103835103836103837103838103839103840103841103842103843103844103845103846103847103848103849103850103851103852103853103854103855103856103857103858103859103860103861103862103863103864103865103866103867103868103869103870103871103872103873103874103875103876103877103878103879103880103881103882103883103884103885103886103887103888103889103890103891103892103893103894103895103896103897103898103899103900103901103902103903103904103905103906103907103908103909103910103911103912103913103914103915103916103917103918103919103920103921103922103923103924103925103926103927103928103929103930103931103932103933103934103935103936103937103938103939103940103941103942103943103944103945103946103947103948103949103950103951103952103953103954103955103956103957103958103959103960103961103962103963103964103965103966103967103968103969103970103971103972103973103974103975103976103977103978103979103980103981103982103983103984103985103986103987103988103989103990103991103992103993103994103995103996103997103998103999104000104001104002104003104004104005104006104007104008104009104010104011104012104013104014104015104016104017104018104019104020104021104022104023104024104025104026104027104028104029104030104031104032104033104034104035104036104037104038104039104040104041104042104043104044104045104046104047104048104049104050104051104052104053104054104055104056104057104058104059104060104061104062104063104064104065104066104067104068104069104070104071104072104073104074104075104076104077104078104079104080104081104082104083104084104085104086104087104088104089104090104091104092104093104094104095104096104097104098104099104100104101104102104103104104104105104106104107104108104109104110104111104112104113104114104115104116104117104118104119104120104121104122104123104124104125104126104127104128104129104130104131104132104133104134104135104136104137104138104139104140104141104142104143104144104145104146104147104148104149104150104151104152104153104154104155104156104157104158104159104160104161104162104163104164104165104166104167104168104169104170104171104172104173104174104175104176104177104178104179104180104181104182104183104184104185104186104187104188104189104190104191104192104193104194104195104196104197104198104199104200104201104202104203104204104205104206104207104208104209104210104211104212104213104214104215104216104217104218104219104220104221104222104223104224104225104226104227104228104229104230104231104232104233104234104235104236104237104238104239104240104241104242104243104244104245104246104247104248104249104250104251104252104253104254104255104256104257104258104259104260104261104262104263104264104265104266104267104268104269104270104271104272104273104274104275104276104277104278104279104280104281104282104283104284104285104286104287104288104289104290104291104292104293104294104295104296104297104298104299104300104301104302104303104304104305104306104307104308104309104310104311104312104313104314104315104316104317104318104319104320104321104322104323104324104325104326104327104328104329104330104331104332104333104334104335104336104337104338104339104340104341104342104343104344104345104346104347104348104349104350104351104352104353104354104355104356104357104358104359104360104361104362104363104364104365104366104367104368104369104370104371104372104373104374104375104376104377104378104379104380104381104382104383104384104385104386104387104388104389104390104391104392104393104394104395104396104397104398104399104400104401104402104403104404104405104406104407104408104409104410104411104412104413104414104415104416104417104418104419104420104421104422104423104424104425104426104427104428104429104430104431104432104433104434104435104436104437104438104439104440104441104442104443104444104445104446104447104448104449104450104451104452104453104454104455104456104457104458104459104460104461104462104463104464104465104466104467104468104469104470104471104472104473104474104475104476104477104478104479104480104481104482104483104484104485104486104487104488104489104490104491104492104493104494104495104496104497104498104499104500104501104502104503104504104505104506104507104508104509104510104511104512104513104514104515104516104517104518104519104520104521104522104523104524104525104526104527104528104529104530104531104532104533104534104535104536104537104538104539104540104541104542104543104544104545104546104547104548104549104550104551104552104553104554104555104556104557104558104559104560104561104562104563104564104565104566104567104568104569104570104571104572104573104574104575104576104577104578104579104580104581104582104583104584104585104586104587104588104589104590104591104592104593104594104595104596104597104598104599104600104601104602104603104604104605104606104607104608104609104610104611104612104613104614104615104616104617104618104619104620104621104622104623104624104625104626104627104628104629104630104631104632104633104634104635104636104637104638104639104640104641104642104643104644104645104646104647104648104649104650104651104652104653104654104655104656104657104658104659104660104661104662104663104664104665104666104667104668104669104670104671104672104673104674104675104676104677104678104679104680104681104682104683104684104685104686104687104688104689104690104691104692104693104694104695104696104697104698104699104700104701104702104703104704104705104706104707104708104709104710104711104712104713104714104715104716104717104718104719104720104721104722104723104724104725104726104727104728104729104730104731104732104733104734104735104736104737104738104739104740104741104742104743104744104745104746104747104748104749104750104751104752104753104754104755104756104757104758104759104760104761104762104763104764104765104766104767104768104769104770104771104772104773104774104775104776104777104778104779104780104781104782104783104784104785104786104787104788104789104790104791104792104793104794104795104796104797104798104799104800104801104802104803104804104805104806104807104808104809104810104811104812104813104814104815104816104817104818104819104820104821104822104823104824104825104826104827104828104829104830104831104832104833104834104835104836104837104838104839104840104841104842104843104844104845104846104847104848104849104850104851104852104853104854104855104856104857104858104859104860104861104862104863104864104865104866104867104868104869104870104871104872104873104874104875104876104877104878104879104880104881104882104883104884104885104886104887104888104889104890104891104892104893104894104895104896104897104898104899104900104901104902104903104904104905104906104907104908104909104910104911104912104913104914104915104916104917104918104919104920104921104922104923104924104925104926104927104928104929104930104931104932104933104934104935104936104937104938104939104940104941104942104943104944104945104946104947104948104949104950104951104952104953104954104955104956104957104958104959104960104961104962104963104964104965104966104967104968104969104970104971104972104973104974104975104976104977104978104979104980104981104982104983104984104985104986104987104988104989104990104991104992104993104994104995104996104997104998104999105000105001105002105003105004105005105006105007105008105009105010105011105012105013105014105015105016105017105018105019105020105021105022105023105024105025105026105027105028105029105030105031105032105033105034105035105036105037105038105039105040105041105042105043105044105045105046105047105048105049105050105051105052105053105054105055105056105057105058105059105060105061105062105063105064105065105066105067105068105069105070105071105072105073105074105075105076105077105078105079105080105081105082105083105084105085105086105087105088105089105090105091105092105093105094105095105096105097105098105099105100105101105102105103105104105105105106105107105108105109105110105111105112105113105114105115105116105117105118105119105120105121105122105123105124105125105126105127105128105129105130105131105132105133105134105135105136105137105138105139105140105141105142105143105144105145105146105147105148105149105150105151105152105153105154105155105156105157105158105159105160105161105162105163105164105165105166105167105168105169105170105171105172105173105174105175105176105177105178105179105180105181105182105183105184105185105186105187105188105189105190105191105192105193105194105195105196105197105198105199105200105201105202105203105204105205105206105207105208105209105210105211105212105213105214105215105216105217105218105219105220105221105222105223105224105225105226105227105228105229105230105231105232105233105234105235105236105237105238105239105240105241105242105243105244105245105246105247105248105249105250105251105252105253105254105255105256105257105258105259105260105261105262105263105264105265105266105267105268105269105270105271105272105273105274105275105276105277105278105279105280105281105282105283105284105285105286105287105288105289105290105291105292105293105294105295105296105297105298105299105300105301105302105303105304105305105306105307105308105309105310105311105312105313105314105315105316105317105318105319105320105321105322105323105324105325105326105327105328105329105330105331105332105333105334105335105336105337105338105339105340105341105342105343105344105345105346105347105348105349105350105351105352105353105354105355105356105357105358105359105360105361105362105363105364105365105366105367105368105369105370105371105372105373105374105375105376105377105378105379105380105381105382105383105384105385105386105387105388105389105390105391105392105393105394105395105396105397105398105399105400105401105402105403105404105405105406105407105408105409105410105411105412105413105414105415105416105417105418105419105420105421105422105423105424105425105426105427105428105429105430105431105432105433105434105435105436105437105438105439105440105441105442105443105444105445105446105447105448105449105450105451105452105453105454105455105456105457105458105459105460105461105462105463105464105465105466105467105468105469105470105471105472105473105474105475105476105477105478105479105480105481105482105483105484105485105486105487105488105489105490105491105492105493105494105495105496105497105498105499105500105501105502105503105504105505105506105507105508105509105510105511105512105513105514105515105516105517105518105519105520105521105522105523105524105525105526105527105528105529105530105531105532105533105534105535105536105537105538105539105540105541105542105543105544105545105546105547105548105549105550105551105552105553105554105555105556105557105558105559105560105561105562105563105564105565105566105567105568105569105570105571105572105573105574105575105576105577105578105579105580105581105582105583105584105585105586105587105588105589105590105591105592105593105594105595105596105597105598105599105600105601105602105603105604105605105606105607105608105609105610105611105612105613105614105615105616105617105618105619105620105621105622105623105624105625105626105627105628105629105630105631105632105633105634105635105636105637105638105639105640105641105642105643105644105645105646105647105648105649105650105651105652105653105654105655105656105657105658105659105660105661105662105663105664105665105666105667105668105669105670105671105672105673105674105675105676105677105678105679105680105681105682105683105684105685105686105687105688105689105690105691105692105693105694105695105696105697105698105699105700105701105702105703105704105705105706105707105708105709105710105711105712105713105714105715105716105717105718105719105720105721105722105723105724105725105726105727105728105729105730105731105732105733105734105735105736105737105738105739105740105741105742105743105744105745105746105747105748105749105750105751105752105753105754105755105756105757105758105759105760105761105762105763105764105765105766105767105768105769105770105771105772105773105774105775105776105777105778105779105780105781105782105783105784105785105786105787105788105789105790105791105792105793105794105795105796105797105798105799105800105801105802105803105804105805105806105807105808105809105810105811105812105813105814105815105816105817105818105819105820105821105822105823105824105825105826105827105828105829105830105831105832105833105834105835105836105837105838105839105840105841105842105843105844105845105846105847105848105849105850105851105852105853105854105855105856105857105858105859105860105861105862105863105864105865105866105867105868105869105870105871105872105873105874105875105876105877105878105879105880105881105882105883105884105885105886105887105888105889105890105891105892105893105894105895105896105897105898105899105900105901105902105903105904105905105906105907105908105909105910105911105912105913105914105915105916105917105918105919105920105921105922105923105924105925105926105927105928105929105930105931105932105933105934105935105936105937105938105939105940105941105942105943105944105945105946105947105948105949105950105951105952105953105954105955105956105957105958105959105960105961105962105963105964105965105966105967105968105969105970105971105972105973105974105975105976105977105978105979105980105981105982105983105984105985105986105987105988105989105990105991105992105993105994105995105996105997105998105999106000106001106002106003106004106005106006106007106008106009106010106011106012106013106014106015106016106017106018106019106020106021106022106023106024106025106026106027106028106029106030106031106032106033106034106035106036106037106038106039106040106041106042106043106044106045106046106047106048106049106050106051106052106053106054106055106056106057106058106059106060106061106062106063106064106065106066106067106068106069106070106071106072106073106074106075106076106077106078106079106080106081106082106083106084106085106086106087106088106089106090106091106092106093106094106095106096106097106098106099106100106101106102106103106104106105106106106107106108106109106110106111106112106113106114106115106116106117106118106119106120106121106122106123106124106125106126106127106128106129106130106131106132106133106134106135106136106137106138106139106140106141106142106143106144106145106146106147106148106149106150106151106152106153106154106155106156106157106158106159106160106161106162106163106164106165106166106167106168106169106170106171106172106173106174106175106176106177106178106179106180106181106182106183106184106185106186106187106188106189106190106191106192106193106194106195106196106197106198106199106200106201106202106203106204106205106206106207106208106209106210106211106212106213106214106215106216106217106218106219106220106221106222106223106224106225106226106227106228106229106230106231106232106233106234106235106236106237106238106239106240106241106242106243106244106245106246106247106248106249106250106251106252106253106254106255106256106257106258106259106260106261106262106263106264106265106266106267106268106269106270106271106272106273106274106275106276106277106278106279106280106281106282106283106284106285106286106287106288106289106290106291106292106293106294106295106296106297106298106299106300106301106302106303106304106305106306106307106308106309106310106311106312106313106314106315106316106317106318106319106320106321106322106323106324106325106326106327106328106329106330106331106332106333106334106335106336106337106338106339106340106341106342106343106344106345106346106347106348106349106350106351106352106353106354106355106356106357106358106359106360106361106362106363106364106365106366106367106368106369106370106371106372106373106374106375106376106377106378106379106380106381106382106383106384106385106386106387106388106389106390106391106392106393106394106395106396106397106398106399106400106401106402106403106404106405106406106407106408106409106410106411106412106413106414106415106416106417106418106419106420106421106422106423106424106425106426106427106428106429106430106431106432106433106434106435106436106437106438106439106440106441106442106443106444106445106446106447106448106449106450106451106452106453106454106455106456106457106458106459106460106461106462106463106464106465106466106467106468106469106470106471106472106473106474106475106476106477106478106479106480106481106482106483106484106485106486106487106488106489106490106491106492106493106494106495106496106497106498106499106500106501106502106503106504106505106506106507106508106509106510106511106512106513106514106515106516106517106518106519106520106521106522106523106524106525106526106527106528106529106530106531106532106533106534106535106536106537106538106539106540106541106542106543106544106545106546106547106548106549106550106551106552106553106554106555106556106557106558106559106560106561106562106563106564106565106566106567106568106569106570106571106572106573106574106575106576106577106578106579106580106581106582106583106584106585106586106587106588106589106590106591106592106593106594106595106596106597106598106599106600106601106602106603106604106605106606106607106608106609106610106611106612106613106614106615106616106617106618106619106620106621106622106623106624106625106626106627106628106629106630106631106632106633106634106635106636106637106638106639106640106641106642106643106644106645106646106647106648106649106650106651106652106653106654106655106656106657106658106659106660106661106662106663106664106665106666106667106668106669106670106671106672106673106674106675106676106677106678106679106680106681106682106683106684106685106686106687106688106689106690106691106692106693106694106695106696106697106698106699106700106701106702106703106704106705106706106707106708106709106710106711106712106713106714106715106716106717106718106719106720106721106722106723106724106725106726106727106728106729106730106731106732106733106734106735106736106737106738106739106740106741106742106743106744106745106746106747106748106749106750106751106752106753106754106755106756106757106758106759106760106761106762106763106764106765106766106767106768106769106770106771106772106773106774106775106776106777106778106779106780106781106782106783106784106785106786106787106788106789106790106791106792106793106794106795106796106797106798106799106800106801106802106803106804106805106806106807106808106809106810106811106812106813106814106815106816106817106818106819106820106821106822106823106824106825106826106827106828106829106830106831106832106833106834106835106836106837106838106839106840106841106842106843106844106845106846106847106848106849106850106851106852106853106854106855106856106857106858106859106860106861106862106863106864106865106866106867106868106869106870106871106872106873106874106875106876106877106878106879106880106881106882106883106884106885106886106887106888106889106890106891106892106893106894106895106896106897106898106899106900106901106902106903106904106905106906106907106908106909106910106911106912106913106914106915106916106917106918106919106920106921106922106923106924106925106926106927106928106929106930106931106932106933106934106935106936106937106938106939106940106941106942106943106944106945106946106947106948106949106950106951106952106953106954106955106956106957106958106959106960106961106962106963106964106965106966106967106968106969106970106971106972106973106974106975106976106977106978106979106980106981106982106983106984106985106986106987106988106989106990106991106992106993106994106995106996106997106998106999107000107001107002107003107004107005107006107007107008107009107010107011107012107013107014107015107016107017107018107019107020107021107022107023107024107025107026107027107028107029107030107031107032107033107034107035107036107037107038107039107040107041107042107043107044107045107046107047107048107049107050107051107052107053107054107055107056107057107058107059107060107061107062107063107064107065107066107067107068107069107070107071107072107073107074107075107076107077107078107079107080107081107082107083107084107085107086107087107088107089107090107091107092107093107094107095107096107097107098107099107100107101107102107103107104107105107106107107107108107109107110107111107112107113107114107115107116107117107118107119107120107121107122107123107124107125107126107127107128107129107130107131107132107133107134107135107136107137107138107139107140107141107142107143107144107145107146107147107148107149107150107151107152107153107154107155107156107157107158107159107160107161107162107163107164107165107166107167107168107169107170107171107172107173107174107175107176107177107178107179107180107181107182107183107184107185107186107187107188107189107190107191107192107193107194107195107196107197107198107199107200107201107202107203107204107205107206107207107208107209107210107211107212107213107214107215107216107217107218107219107220107221107222107223107224107225107226107227107228107229107230107231107232107233107234107235107236107237107238107239107240107241107242107243107244107245107246107247107248107249107250107251107252107253107254107255107256107257107258107259107260107261107262107263107264107265107266107267107268107269107270107271107272107273107274107275107276107277107278107279107280107281107282107283107284107285107286107287107288107289107290107291107292107293107294107295107296107297107298107299107300107301107302107303107304107305107306107307107308107309107310107311107312107313107314107315107316107317107318107319107320107321107322107323107324107325107326107327107328107329107330107331107332107333107334107335107336107337107338107339107340107341107342107343107344107345107346107347107348107349107350107351107352107353107354107355107356107357107358107359107360107361107362107363107364107365107366107367107368107369107370107371107372107373107374107375107376107377107378107379107380107381107382107383107384107385107386107387107388107389107390107391107392107393107394107395107396107397107398107399107400107401107402107403107404107405107406107407107408107409107410107411107412107413107414107415107416107417107418107419107420107421107422107423107424107425107426107427107428107429107430107431107432107433107434107435107436107437107438107439107440107441107442107443107444107445107446107447107448107449107450107451107452107453107454107455107456107457107458107459107460107461107462107463107464107465107466107467107468107469107470107471107472107473107474107475107476107477107478107479107480107481107482107483107484107485107486107487107488107489107490107491107492107493107494107495107496107497107498107499107500107501107502107503107504107505107506107507107508107509107510107511107512107513107514107515107516107517107518107519107520107521107522107523107524107525107526107527107528107529107530107531107532107533107534107535107536107537107538107539107540107541107542107543107544107545107546107547107548107549107550107551107552107553107554107555107556107557107558107559107560107561107562107563107564107565107566107567107568107569107570107571107572107573107574107575107576107577107578107579107580107581107582107583107584107585107586107587107588107589107590107591107592107593107594107595107596107597107598107599107600107601107602107603107604107605107606107607107608107609107610107611107612107613107614107615107616107617107618107619107620107621107622107623107624107625107626107627107628107629107630107631107632107633107634107635107636107637107638107639107640107641107642107643107644107645107646107647107648107649107650107651107652107653107654107655107656107657107658107659107660107661107662107663107664107665107666107667107668107669107670107671107672107673107674107675107676107677107678107679107680107681107682107683107684107685107686107687107688107689107690107691107692107693107694107695107696107697107698107699107700107701107702107703107704107705107706107707107708107709107710107711107712107713107714107715107716107717107718107719107720107721107722107723107724107725107726107727107728107729107730107731107732107733107734107735107736107737107738107739107740107741107742107743107744107745107746107747107748107749107750107751107752107753107754107755107756107757107758107759107760107761107762107763107764107765107766107767107768107769107770107771107772107773107774107775107776107777107778107779107780107781107782107783107784107785107786107787107788107789107790107791107792107793107794107795107796107797107798107799107800107801107802107803107804107805107806107807107808107809107810107811107812107813107814107815107816107817107818107819107820107821107822107823107824107825107826107827107828107829107830107831107832107833107834107835107836107837107838107839107840107841107842107843107844107845107846107847107848107849107850107851107852107853107854107855107856107857107858107859107860107861107862107863107864107865107866107867107868107869107870107871107872107873107874107875107876107877107878107879107880107881107882107883107884107885107886107887107888107889107890107891107892107893107894107895107896107897107898107899107900107901107902107903107904107905107906107907107908107909107910107911107912107913107914107915107916107917107918107919107920107921107922107923107924107925107926107927107928107929107930107931107932107933107934107935107936107937107938107939107940107941107942107943107944107945107946107947107948107949107950107951107952107953107954107955107956107957107958107959107960107961107962107963107964107965107966107967107968107969107970107971107972107973107974107975107976107977107978107979107980107981107982107983107984107985107986107987107988107989107990107991107992107993107994107995107996107997107998107999108000108001108002108003108004108005108006108007108008108009108010108011108012108013108014108015108016108017108018108019108020108021108022108023108024108025108026108027108028108029108030108031108032108033108034108035108036108037108038108039108040108041108042108043108044108045108046108047108048108049108050108051108052108053108054108055108056108057108058108059108060108061108062108063108064108065108066108067108068108069108070108071108072108073108074108075108076108077108078108079108080108081108082108083108084108085108086108087108088108089108090108091108092108093108094108095108096108097108098108099108100108101108102108103108104108105108106108107108108108109108110108111108112108113108114108115108116108117108118108119108120108121108122108123108124108125108126108127108128108129108130108131108132108133108134108135108136108137108138108139108140108141108142108143108144108145108146108147108148108149108150108151108152108153108154108155108156108157108158108159108160108161108162108163108164108165108166108167108168108169108170108171108172108173108174108175108176108177108178108179108180108181108182108183108184108185108186108187108188108189108190108191108192108193108194108195108196108197108198108199108200108201108202108203108204108205108206108207108208108209108210108211108212108213108214108215108216108217108218108219108220108221108222108223108224108225108226108227108228108229108230108231108232108233108234108235108236108237108238108239108240108241108242108243108244108245108246108247108248108249108250108251108252108253108254108255108256108257108258108259108260108261108262108263108264108265108266108267108268108269108270108271108272108273108274108275108276108277108278108279108280108281108282108283108284108285108286108287108288108289108290108291108292108293108294108295108296108297108298108299108300108301108302108303108304108305108306108307108308108309108310108311108312108313108314108315108316108317108318108319108320108321108322108323108324108325108326108327108328108329108330108331108332108333108334108335108336108337108338108339108340108341108342108343108344108345108346108347108348108349108350108351108352108353108354108355108356108357108358108359108360108361108362108363108364108365108366108367108368108369108370108371108372108373108374108375108376108377108378108379108380108381108382108383108384108385108386108387108388108389108390108391108392108393108394108395108396108397108398108399108400108401108402108403108404108405108406108407108408108409108410108411108412108413108414108415108416108417108418108419108420108421108422108423108424108425108426108427108428108429108430108431108432108433108434108435108436108437108438108439108440108441108442108443108444108445108446108447108448108449108450108451108452108453108454108455108456108457108458108459108460108461108462108463108464108465108466108467108468108469108470108471108472108473108474108475108476108477108478108479108480108481108482108483108484108485108486108487108488108489108490108491108492108493108494108495108496108497108498108499108500108501108502108503108504108505108506108507108508108509108510108511108512108513108514108515108516108517108518108519108520108521108522108523108524108525108526108527108528108529108530108531108532108533108534108535108536108537108538108539108540108541108542108543108544108545108546108547108548108549108550108551108552108553108554108555108556108557108558108559108560108561108562108563108564108565108566108567108568108569108570108571108572108573108574108575108576108577108578108579108580108581108582108583108584108585108586108587108588108589108590108591108592108593108594108595108596108597108598108599108600108601108602108603108604108605108606108607108608108609108610108611108612108613108614108615108616108617108618108619108620108621108622108623108624108625108626108627108628108629108630108631108632108633108634108635108636108637108638108639108640108641108642108643108644108645108646108647108648108649108650108651108652108653108654108655108656108657108658108659108660108661108662108663108664108665108666108667108668108669108670108671108672108673108674108675108676108677108678108679108680108681108682108683108684108685108686108687108688108689108690108691108692108693108694108695108696108697108698108699108700108701108702108703108704108705108706108707108708108709108710108711108712108713108714108715108716108717108718108719108720108721108722108723108724108725108726108727108728108729108730108731108732108733108734108735108736108737108738108739108740108741108742108743108744108745108746108747108748108749108750108751108752108753108754108755108756108757108758108759108760108761108762108763108764108765108766108767108768108769108770108771108772108773108774108775108776108777108778108779108780108781108782108783108784108785108786108787108788108789108790108791108792108793108794108795108796108797108798108799108800108801108802108803108804108805108806108807108808108809108810108811108812108813108814108815108816108817108818108819108820108821108822108823108824108825108826108827108828108829108830108831108832108833108834108835108836108837108838108839108840108841108842108843108844108845108846108847108848108849108850108851108852108853108854108855108856108857108858108859108860108861108862108863108864108865108866108867108868108869108870108871108872108873108874108875108876108877108878108879108880108881108882108883108884108885108886108887108888108889108890108891108892108893108894108895108896108897108898108899108900108901108902108903108904108905108906108907108908108909108910108911108912108913108914108915108916108917108918108919108920108921108922108923108924108925108926108927108928108929108930108931108932108933108934108935108936108937108938108939108940108941108942108943108944108945108946108947108948108949108950108951108952108953108954108955108956108957108958108959108960108961108962108963108964108965108966108967108968108969108970108971108972108973108974108975108976108977108978108979108980108981108982108983108984108985108986108987108988108989108990108991108992108993108994108995108996108997108998108999109000109001109002109003109004109005109006109007109008109009109010109011109012109013109014109015109016109017109018109019109020109021109022109023109024109025109026109027109028109029109030109031109032109033109034109035109036109037109038109039109040109041109042109043109044109045109046109047109048109049109050109051109052109053109054109055109056109057109058109059109060109061109062109063109064109065109066109067109068109069109070109071109072109073109074109075109076109077109078109079109080109081109082109083109084109085109086109087109088109089109090109091109092109093109094109095109096109097109098109099109100109101109102109103109104109105109106109107109108109109109110109111109112109113109114109115109116109117109118109119109120109121109122109123109124109125109126109127109128109129109130109131109132109133109134109135109136109137109138109139109140109141109142109143109144109145109146109147109148109149109150109151109152109153109154109155109156109157109158109159109160109161109162109163109164109165109166109167109168109169109170109171109172109173109174109175109176109177109178109179109180109181109182109183109184109185109186109187109188109189109190109191109192109193109194109195109196109197109198109199109200109201109202109203109204109205109206109207109208109209109210109211109212109213109214109215109216109217109218109219109220109221109222109223109224109225109226109227109228109229109230109231109232109233109234109235109236109237109238109239109240109241109242109243109244109245109246109247109248109249109250109251109252109253109254109255109256109257109258109259109260109261109262109263109264109265109266109267109268109269109270109271109272109273109274109275109276109277109278109279109280109281109282109283109284109285109286109287109288109289109290109291109292109293109294109295109296109297109298109299109300109301109302109303109304109305109306109307109308109309109310109311109312109313109314109315109316109317109318109319109320109321109322109323109324109325109326109327109328109329109330109331109332109333109334109335109336109337109338109339109340109341109342109343109344109345109346109347109348109349109350109351109352109353109354109355109356109357109358109359109360109361109362109363109364109365109366109367109368109369109370109371109372109373109374109375109376109377109378109379109380109381109382109383109384109385109386109387109388109389109390109391109392109393109394109395109396109397109398109399109400109401109402109403109404109405109406109407109408109409109410109411109412109413109414109415109416109417109418109419109420109421109422109423109424109425109426109427109428109429109430109431109432109433109434109435109436109437109438109439109440109441109442109443109444109445109446109447109448109449109450109451109452109453109454109455109456109457109458109459109460109461109462109463109464109465109466109467109468109469109470109471109472109473109474109475109476109477109478109479109480109481109482109483109484109485109486109487109488109489109490109491109492109493109494109495109496109497109498109499109500109501109502109503109504109505109506109507109508109509109510109511109512109513109514109515109516109517109518109519109520109521109522109523109524109525109526109527109528109529109530109531109532109533109534109535109536109537109538109539109540109541109542109543109544109545109546109547109548109549109550109551109552109553109554109555109556109557109558109559109560109561109562109563109564109565109566109567109568109569109570109571109572109573109574109575109576109577109578109579109580109581109582109583109584109585109586109587109588109589109590109591109592109593109594109595109596109597109598109599109600109601109602109603109604109605109606109607109608109609109610109611109612109613109614109615109616109617109618109619109620109621109622109623109624109625109626109627109628109629109630109631109632109633109634109635109636109637109638109639109640109641109642109643109644109645109646109647109648109649109650109651109652109653109654109655109656109657109658109659109660109661109662109663109664109665109666109667109668109669109670109671109672109673109674109675109676109677109678109679109680109681109682109683109684109685109686109687109688109689109690109691109692109693109694109695109696109697109698109699109700109701109702109703109704109705109706109707109708109709109710109711109712109713109714109715109716109717109718109719109720109721109722109723109724109725109726109727109728109729109730109731109732109733109734109735109736109737109738109739109740109741109742109743109744109745109746109747109748109749109750109751109752109753109754109755109756109757109758109759109760109761109762109763109764109765109766109767109768109769109770109771109772109773109774109775109776109777109778109779109780109781109782109783109784109785109786109787109788109789109790109791109792109793109794109795109796109797109798109799109800109801109802109803109804109805109806109807109808109809109810109811109812109813109814109815109816109817109818109819109820109821109822109823109824109825109826109827109828109829109830109831109832109833109834109835109836109837109838109839109840109841109842109843109844109845109846109847109848109849109850109851109852109853109854109855109856109857109858109859109860109861109862109863109864109865109866109867109868109869109870109871109872109873109874109875109876109877109878109879109880109881109882109883109884109885109886109887109888109889109890109891109892109893109894109895109896109897109898109899109900109901109902109903109904109905109906109907109908109909109910109911109912109913109914109915109916109917109918109919109920109921109922109923109924109925109926109927109928109929109930109931109932109933109934109935109936109937109938109939109940109941109942109943109944109945109946109947109948109949109950109951109952109953109954109955109956109957109958109959109960109961109962109963109964109965109966109967109968109969109970109971109972109973109974109975109976109977109978109979109980109981109982109983109984109985109986109987109988109989109990109991109992109993109994109995109996109997109998109999110000110001110002110003110004110005110006110007110008110009110010110011110012110013110014110015110016110017110018110019110020110021110022110023110024110025110026110027110028110029110030110031110032110033110034110035110036110037110038110039110040110041110042110043110044110045110046110047110048110049110050110051110052110053110054110055110056110057110058110059110060110061110062110063110064110065110066110067110068110069110070110071110072110073110074110075110076110077110078110079110080110081110082110083110084110085110086110087110088110089110090110091110092110093110094110095110096110097110098110099110100110101110102110103110104110105110106110107110108110109110110110111110112110113110114110115110116110117110118110119110120110121110122110123110124110125110126110127110128110129110130110131110132110133110134110135110136110137110138110139110140110141110142110143110144110145110146110147110148110149110150110151110152110153110154110155110156110157110158110159110160110161110162110163110164110165110166110167110168110169110170110171110172110173110174110175110176110177110178110179110180110181110182110183110184110185110186110187110188110189110190110191110192110193110194110195110196110197110198110199110200110201110202110203110204110205110206110207110208110209110210110211110212110213110214110215110216110217110218110219110220110221110222110223110224110225110226110227110228110229110230110231110232110233110234110235110236110237110238110239110240110241110242110243110244110245110246110247110248110249110250110251110252110253110254110255110256110257110258110259110260110261110262110263110264110265110266110267110268110269110270110271110272110273110274110275110276110277110278110279110280110281110282110283110284110285110286110287110288110289110290110291110292110293110294110295110296110297110298110299110300110301110302110303110304110305110306110307110308110309110310110311110312110313110314110315110316110317110318110319110320110321110322110323110324110325110326110327110328110329110330110331110332110333110334110335110336110337110338110339110340110341110342110343110344110345110346110347110348110349110350110351110352110353110354110355110356110357110358110359110360110361110362110363110364110365110366110367110368110369110370110371110372110373110374110375110376110377110378110379110380110381110382110383110384110385110386110387110388110389110390110391110392110393110394110395110396110397110398110399110400110401110402110403110404110405110406110407110408110409110410110411110412110413110414110415110416110417110418110419110420110421110422110423110424110425110426110427110428110429110430110431110432110433110434110435110436110437110438110439110440110441110442110443110444110445110446110447110448110449110450110451110452110453110454110455110456110457110458110459110460110461110462110463110464110465110466110467110468110469110470110471110472110473110474110475110476110477110478110479110480110481110482110483110484110485110486110487110488110489110490110491110492110493110494110495110496110497110498110499110500110501110502110503110504110505110506110507110508110509110510110511110512110513110514110515110516110517110518110519110520110521110522110523110524110525110526110527110528110529110530110531110532110533110534110535110536110537110538110539110540110541110542110543110544110545110546110547110548110549110550110551110552110553110554110555110556110557110558110559110560110561110562110563110564110565110566110567110568110569110570110571110572110573110574110575110576110577110578110579110580110581110582110583110584110585110586110587110588110589110590110591110592110593110594110595110596110597110598110599110600110601110602110603110604110605110606110607110608110609110610110611110612110613110614110615110616110617110618110619110620110621110622110623110624110625110626110627110628110629110630110631110632110633110634110635110636110637110638110639110640110641110642110643110644110645110646110647110648110649110650110651110652110653110654110655110656110657110658110659110660110661110662110663110664110665110666110667110668110669110670110671110672110673110674110675110676110677110678110679110680110681110682110683110684110685110686110687110688110689110690110691110692110693110694110695110696110697110698110699110700110701110702110703110704110705110706110707110708110709110710110711110712110713110714110715110716110717110718110719110720110721110722110723110724110725110726110727110728110729110730110731110732110733110734110735110736110737110738110739110740110741110742110743110744110745110746110747110748110749110750110751110752110753110754110755110756110757110758110759110760110761110762110763110764110765110766110767110768110769110770110771110772110773110774110775110776110777110778110779110780110781110782110783110784110785110786110787110788110789110790110791110792110793110794110795110796110797110798110799110800110801110802110803110804110805110806110807110808110809110810110811110812110813110814110815110816110817110818110819110820110821110822110823110824110825110826110827110828110829110830110831110832110833110834110835110836110837110838110839110840110841110842110843110844110845110846110847110848110849110850110851110852110853110854110855110856110857110858110859110860110861110862110863110864110865110866110867110868110869110870110871110872110873110874110875110876110877110878110879110880110881110882110883110884110885110886110887110888110889110890110891110892110893110894110895110896110897110898110899110900110901110902110903110904110905110906110907110908110909110910110911110912110913110914110915110916110917110918110919110920110921110922110923110924110925110926110927110928110929110930110931110932110933110934110935110936110937110938110939110940110941110942110943110944110945110946110947110948110949110950110951110952110953110954110955110956110957110958110959110960110961110962110963110964110965110966110967110968110969110970110971110972110973110974110975110976110977110978110979110980110981110982110983110984110985110986110987110988110989110990110991110992110993110994110995110996110997110998110999111000111001111002111003111004111005111006111007111008111009111010111011111012111013111014111015111016111017111018111019111020111021111022111023111024111025111026111027111028111029111030111031111032111033111034111035111036111037111038111039111040111041111042111043111044111045111046111047111048111049111050111051111052111053111054111055111056111057111058111059111060111061111062111063111064111065111066111067111068111069111070111071111072111073111074111075111076111077111078111079111080111081111082111083111084111085111086111087111088111089111090111091111092111093111094111095111096111097111098111099111100111101111102111103111104111105111106111107111108111109111110111111111112111113111114111115111116111117111118111119111120111121111122111123111124111125111126111127111128111129111130111131111132111133111134111135111136111137111138111139111140111141111142111143111144111145111146111147111148111149111150111151111152111153111154111155111156111157111158111159111160111161111162111163111164111165111166111167111168111169111170111171111172111173111174111175111176111177111178111179111180111181111182111183111184111185111186111187111188111189111190111191111192111193111194111195111196111197111198111199111200111201111202111203111204111205111206111207111208111209111210111211111212111213111214111215111216111217111218111219111220111221111222111223111224111225111226111227111228111229111230111231111232111233111234111235111236111237111238111239111240111241111242111243111244111245111246111247111248111249111250111251111252111253111254111255111256111257111258111259111260111261111262111263111264111265111266111267111268111269111270111271111272111273111274111275111276111277111278111279111280111281111282111283111284111285111286111287111288111289111290111291111292111293111294111295111296111297111298111299111300111301111302111303111304111305111306111307111308111309111310111311111312111313111314111315111316111317111318111319111320111321111322111323111324111325111326111327111328111329111330111331111332111333111334111335111336111337111338111339111340111341111342111343111344111345111346111347111348111349111350111351111352111353111354111355111356111357111358111359111360111361111362111363111364111365111366111367111368111369111370111371111372111373111374111375111376111377111378111379111380111381111382111383111384111385111386111387111388111389111390111391111392111393111394111395111396111397111398111399111400111401111402111403111404111405111406111407111408111409111410111411111412111413111414111415111416111417111418111419111420111421111422111423111424111425111426111427111428111429111430111431111432111433111434111435111436111437111438111439111440111441111442111443111444111445111446111447111448111449111450111451111452111453111454111455111456111457111458111459111460111461111462111463111464111465111466111467111468111469111470111471111472111473111474111475111476111477111478111479111480111481111482111483111484111485111486111487111488111489111490111491111492111493111494111495111496111497111498111499111500111501111502111503111504111505111506111507111508111509111510111511111512111513111514111515111516111517111518111519111520111521111522111523111524111525111526111527111528111529111530111531111532111533111534111535111536111537111538111539111540111541111542111543111544111545111546111547111548111549111550111551111552111553111554111555111556111557111558111559111560111561111562111563111564111565111566111567111568111569111570111571111572111573111574111575111576111577111578111579111580111581111582111583111584111585111586111587111588111589111590111591111592111593111594111595111596111597111598111599111600111601111602111603111604111605111606111607111608111609111610111611111612111613111614111615111616111617111618111619111620111621111622111623111624111625111626111627111628111629111630111631111632111633111634111635111636111637111638111639111640111641111642111643111644111645111646111647111648111649111650111651111652111653111654111655111656111657111658111659111660111661111662111663111664111665111666111667111668111669111670111671111672111673111674111675111676111677111678111679111680111681111682111683111684111685111686111687111688111689111690111691111692111693111694111695111696111697111698111699111700111701111702111703111704111705111706111707111708111709111710111711111712111713111714111715111716111717111718111719111720111721111722111723111724111725111726111727111728111729111730111731111732111733111734111735111736111737111738111739111740111741111742111743111744111745111746111747111748111749111750111751111752111753111754111755111756111757111758111759111760111761111762111763111764111765111766111767111768111769111770111771111772111773111774111775111776111777111778111779111780111781111782111783111784111785111786111787111788111789111790111791111792111793111794111795111796111797111798111799111800111801111802111803111804111805111806111807111808111809111810111811111812111813111814111815111816111817111818111819111820111821111822111823111824111825111826111827111828111829111830111831111832111833111834111835111836111837111838111839111840111841111842111843111844111845111846111847111848111849111850111851111852111853111854111855111856111857111858111859111860111861111862111863111864111865111866111867111868111869111870111871111872111873111874111875111876111877111878111879111880111881111882111883111884111885111886111887111888111889111890111891111892111893111894111895111896111897111898111899111900111901111902111903111904111905111906111907111908111909111910111911111912111913111914111915111916111917111918111919111920111921111922111923111924111925111926111927111928111929111930111931111932111933111934111935111936111937111938111939111940111941111942111943111944111945111946111947111948111949111950111951111952111953111954111955111956111957111958111959111960111961111962111963111964111965111966111967111968111969111970111971111972111973111974111975111976111977111978111979111980111981111982111983111984111985111986111987111988111989111990111991111992111993111994111995111996111997111998111999112000112001112002112003112004112005112006112007112008112009112010112011112012112013112014112015112016112017112018112019112020112021112022112023112024112025112026112027112028112029112030112031112032112033112034112035112036112037112038112039112040112041112042112043112044112045112046112047112048112049112050112051112052112053112054112055112056112057112058112059112060112061112062112063112064112065112066112067112068112069112070112071112072112073112074112075112076112077112078112079112080112081112082112083112084112085112086112087112088112089112090112091112092112093112094112095112096112097112098112099112100112101112102112103112104112105112106112107112108112109112110112111112112112113112114112115112116112117112118112119112120112121112122112123112124112125112126112127112128112129112130112131112132112133112134112135112136112137112138112139112140112141112142112143112144112145112146112147112148112149112150112151112152112153112154112155112156112157112158112159112160112161112162112163112164112165112166112167112168112169112170112171112172112173112174112175112176112177112178112179112180112181112182112183112184112185112186112187112188112189112190112191112192112193112194112195112196112197112198112199112200112201112202112203112204112205112206112207112208112209112210112211112212112213112214112215112216112217112218112219112220112221112222112223112224112225112226112227112228112229112230112231112232112233112234112235112236112237112238112239112240112241112242112243112244112245112246112247112248112249112250112251112252112253112254112255112256112257112258112259112260112261112262112263112264112265112266112267112268112269112270112271112272112273112274112275112276112277112278112279112280112281112282112283112284112285112286112287112288112289112290112291112292112293112294112295112296112297112298112299112300112301112302112303112304112305112306112307112308112309112310112311112312112313112314112315112316112317112318112319112320112321112322112323112324112325112326112327112328112329112330112331112332112333112334112335112336112337112338112339112340112341112342112343112344112345112346112347112348112349112350112351112352112353112354112355112356112357112358112359112360112361112362112363112364112365112366112367112368112369112370112371112372112373112374112375112376112377112378112379112380112381112382112383112384112385112386112387112388112389112390112391112392112393112394112395112396112397112398112399112400112401112402112403112404112405112406112407112408112409112410112411112412112413112414112415112416112417112418112419112420112421112422112423112424112425112426112427112428112429112430112431112432112433112434112435112436112437112438112439112440112441112442112443112444112445112446112447112448112449112450112451112452112453112454112455112456112457112458112459112460112461112462112463112464112465112466112467112468112469112470112471112472112473112474112475112476112477112478112479112480112481112482112483112484112485112486112487112488112489112490112491112492112493112494112495112496112497112498112499112500112501112502112503112504112505112506112507112508112509112510112511112512112513112514112515112516112517112518112519112520112521112522112523112524112525112526112527112528112529112530112531112532112533112534112535112536112537112538112539112540112541112542112543112544112545112546112547112548112549112550112551112552112553112554112555112556112557112558112559112560112561112562112563112564112565112566112567112568112569112570112571112572112573112574112575112576112577112578112579112580112581112582112583112584112585112586112587112588112589112590112591112592112593112594112595112596112597112598112599112600112601112602112603112604112605112606112607112608112609112610112611112612112613112614112615112616112617112618112619112620112621112622112623112624112625112626112627112628112629112630112631112632112633112634112635112636112637112638112639112640112641112642112643112644112645112646112647112648112649112650112651112652112653112654112655112656112657112658112659112660112661112662112663112664112665112666112667112668112669112670112671112672112673112674112675112676112677112678112679112680112681112682112683112684112685112686112687112688112689112690112691112692112693112694112695112696112697112698112699112700112701112702112703112704112705112706112707112708112709112710112711112712112713112714112715112716112717112718112719112720112721112722112723112724112725112726112727112728112729112730112731112732112733112734112735112736112737112738112739112740112741112742112743112744112745112746112747112748112749112750112751112752112753112754112755112756112757112758112759112760112761112762112763112764112765112766112767112768112769112770112771112772112773112774112775112776112777112778112779112780112781112782112783112784112785112786112787112788112789112790112791112792112793112794112795112796112797112798112799112800112801112802112803112804112805112806112807112808112809112810112811112812112813112814112815112816112817112818112819112820112821112822112823112824112825112826112827112828112829112830112831112832112833112834112835112836112837112838112839112840112841112842112843112844112845112846112847112848112849112850112851112852112853112854112855112856112857112858112859112860112861112862112863112864112865112866112867112868112869112870112871112872112873112874112875112876112877112878112879112880112881112882112883112884112885112886112887112888112889112890112891112892112893112894112895112896112897112898112899112900112901112902112903112904112905112906112907112908112909112910112911112912112913112914112915112916112917112918112919112920112921112922112923112924112925112926112927112928112929112930112931112932112933112934112935112936112937112938112939112940112941112942112943112944112945112946112947112948112949112950112951112952112953112954112955112956112957112958112959112960112961112962112963112964112965112966112967112968112969112970112971112972112973112974112975112976112977112978112979112980112981112982112983112984112985112986112987112988112989112990112991112992112993112994112995112996112997112998112999113000113001113002113003113004113005113006113007113008113009113010113011113012113013113014113015113016113017113018113019113020113021113022113023113024113025113026113027113028113029113030113031113032113033113034113035113036113037113038113039113040113041113042113043113044113045113046113047113048113049113050113051113052113053113054113055113056113057113058113059113060113061113062113063113064113065113066113067113068113069113070113071113072113073113074113075113076113077113078113079113080113081113082113083113084113085113086113087113088113089113090113091113092113093113094113095113096113097113098113099113100113101113102113103113104113105113106113107113108113109113110113111113112113113113114113115113116113117113118113119113120113121113122113123113124113125113126113127113128113129113130113131113132113133113134113135113136113137113138113139113140113141113142113143113144113145113146113147113148113149113150113151113152113153113154113155113156113157113158113159113160113161113162113163113164113165113166113167113168113169113170113171113172113173113174113175113176113177113178113179113180113181113182113183113184113185113186113187113188113189113190113191113192113193113194113195113196113197113198113199113200113201113202113203113204113205113206113207113208113209113210113211113212113213113214113215113216113217113218113219113220113221113222113223113224113225113226113227113228113229113230113231113232113233113234113235113236113237113238113239113240113241113242113243113244113245113246113247113248113249113250113251113252113253113254113255113256113257113258113259113260113261113262113263113264113265113266113267113268113269113270113271113272113273113274113275113276113277113278113279113280113281113282113283113284113285113286113287113288113289113290113291113292113293113294113295113296113297113298113299113300113301113302113303113304113305113306113307113308113309113310113311113312113313113314113315113316113317113318113319113320113321113322113323113324113325113326113327113328113329113330113331113332113333113334113335113336113337113338113339113340113341113342113343113344113345113346113347113348113349113350113351113352113353113354113355113356113357113358113359113360113361113362113363113364113365113366113367113368113369113370113371113372113373113374113375113376113377113378113379113380113381113382113383113384113385113386113387113388113389113390113391113392113393113394113395113396113397113398113399113400113401113402113403113404113405113406113407113408113409113410113411113412113413113414113415113416113417113418113419113420113421113422113423113424113425113426113427113428113429113430113431113432113433113434113435113436113437113438113439113440113441113442113443113444113445113446113447113448113449113450113451113452113453113454113455113456113457113458113459113460113461113462113463113464113465113466113467113468113469113470113471113472113473113474113475113476113477113478113479113480113481113482113483113484113485113486113487113488113489113490113491113492113493113494113495113496113497113498113499113500113501113502113503113504113505113506113507113508113509113510113511113512113513113514113515113516113517113518113519113520113521113522113523113524113525113526113527113528113529113530113531113532113533113534113535113536113537113538113539113540113541113542113543113544113545113546113547113548113549113550113551113552113553113554113555113556113557113558113559113560113561113562113563113564113565113566113567113568113569113570113571113572113573113574113575113576113577113578113579113580113581113582113583113584113585113586113587113588113589113590113591113592113593113594113595113596113597113598113599113600113601113602113603113604113605113606113607113608113609113610113611113612113613113614113615113616113617113618113619113620113621113622113623113624113625113626113627113628113629113630113631113632113633113634113635113636113637113638113639113640113641113642113643113644113645113646113647113648113649113650113651113652113653113654113655113656113657113658113659113660113661113662113663113664113665113666113667113668113669113670113671113672113673113674113675113676113677113678113679113680113681113682113683113684113685113686113687113688113689113690113691113692113693113694113695113696113697113698113699113700113701113702113703113704113705113706113707113708113709113710113711113712113713113714113715113716113717113718113719113720113721113722113723113724113725113726113727113728113729113730113731113732113733113734113735113736113737113738113739113740113741113742113743113744113745113746113747113748113749113750113751113752113753113754113755113756113757113758113759113760113761113762113763113764113765113766113767113768113769113770113771113772113773113774113775113776113777113778113779113780113781113782113783113784113785113786113787113788113789113790113791113792113793113794113795113796113797113798113799113800113801113802113803113804113805113806113807113808113809113810113811113812113813113814113815113816113817113818113819113820113821113822113823113824113825113826113827113828113829113830113831113832113833113834113835113836113837113838113839113840113841113842113843113844113845113846113847113848113849113850113851113852113853113854113855113856113857113858113859113860113861113862113863113864113865113866113867113868113869113870113871113872113873113874113875113876113877113878113879113880113881113882113883113884113885113886113887113888113889113890113891113892113893113894113895113896113897113898113899113900113901113902113903113904113905113906113907113908113909113910113911113912113913113914113915113916113917113918113919113920113921113922113923113924113925113926113927113928113929113930113931113932113933113934113935113936113937113938113939113940113941113942113943113944113945113946113947113948113949113950113951113952113953113954113955113956113957113958113959113960113961113962113963113964113965113966113967113968113969113970113971113972113973113974113975113976113977113978113979113980113981113982113983113984113985113986113987113988113989113990113991113992113993113994113995113996113997113998113999114000114001114002114003114004114005114006114007114008114009114010114011114012114013114014114015114016114017114018114019114020114021114022114023114024114025114026114027114028114029114030114031114032114033114034114035114036114037114038114039114040114041114042114043114044114045114046114047114048114049114050114051114052114053114054114055114056114057114058114059114060114061114062114063114064114065114066114067114068114069114070114071114072114073114074114075114076114077114078114079114080114081114082114083114084114085114086114087114088114089114090114091114092114093114094114095114096114097114098114099114100114101114102114103114104114105114106114107114108114109114110114111114112114113114114114115114116114117114118114119114120114121114122114123114124114125114126114127114128114129114130114131114132114133114134114135114136114137114138114139114140114141114142114143114144114145114146114147114148114149114150114151114152114153114154114155114156114157114158114159114160114161114162114163114164114165114166114167114168114169114170114171114172114173114174114175114176114177114178114179114180114181114182114183114184114185114186114187114188114189114190114191114192114193114194114195114196114197114198114199114200114201114202114203114204114205114206114207114208114209114210114211114212114213114214114215114216114217114218114219114220114221114222114223114224114225114226114227114228114229114230114231114232114233114234114235114236114237114238114239114240114241114242114243114244114245114246114247114248114249114250114251114252114253114254114255114256114257114258114259114260114261114262114263114264114265114266114267114268114269114270114271114272114273114274114275114276114277114278114279114280114281114282114283114284114285114286114287114288114289114290114291114292114293114294114295114296114297114298114299114300114301114302114303114304114305114306114307114308114309114310114311114312114313114314114315114316114317114318114319114320114321114322114323114324114325114326114327114328114329114330114331114332114333114334114335114336114337114338114339114340114341114342114343114344114345114346114347114348114349114350114351114352114353114354114355114356114357114358114359114360114361114362114363114364114365114366114367114368114369114370114371114372114373114374114375114376114377114378114379114380114381114382114383114384114385114386114387114388114389114390114391114392114393114394114395114396114397114398114399114400114401114402114403114404114405114406114407114408114409114410114411114412114413114414114415114416114417114418114419114420114421114422114423114424114425114426114427114428114429114430114431114432114433114434114435114436114437114438114439114440114441114442114443114444114445114446114447114448114449114450114451114452114453114454114455114456114457114458114459114460114461114462114463114464114465114466114467114468114469114470114471114472114473114474114475114476114477114478114479114480114481114482114483114484114485114486114487114488114489114490114491114492114493114494114495114496114497114498114499114500114501114502114503114504114505114506114507114508114509114510114511114512114513114514114515114516114517114518114519114520114521114522114523114524114525114526114527114528114529114530114531114532114533114534114535114536114537114538114539114540114541114542114543114544114545114546114547114548114549114550114551114552114553114554114555114556114557114558114559114560114561114562114563114564114565114566114567114568114569114570114571114572114573114574114575114576114577114578114579114580114581114582114583114584114585114586114587114588114589114590114591114592114593114594114595114596114597114598114599114600114601114602114603114604114605114606114607114608114609114610114611114612114613114614114615114616114617114618114619114620114621114622114623114624114625114626114627114628114629114630114631114632114633114634114635114636114637114638114639114640114641114642114643114644114645114646114647114648114649114650114651114652114653114654114655114656114657114658114659114660114661114662114663114664114665114666114667114668114669114670114671114672114673114674114675114676114677114678114679114680114681114682114683114684114685114686114687114688114689114690114691114692114693114694114695114696114697114698114699114700114701114702114703114704114705114706114707114708114709114710114711114712114713114714114715114716114717114718114719114720114721114722114723114724114725114726114727114728114729114730114731114732114733114734114735114736114737114738114739114740114741114742114743114744114745114746114747114748114749114750114751114752114753114754114755114756114757114758114759114760114761114762114763114764114765114766114767114768114769114770114771114772114773114774114775114776114777114778114779114780114781114782114783114784114785114786114787114788114789114790114791114792114793114794114795114796114797114798114799114800114801114802114803114804114805114806114807114808114809114810114811114812114813114814114815114816114817114818114819114820114821114822114823114824114825114826114827114828114829114830114831114832114833114834114835114836114837114838114839114840114841114842114843114844114845114846114847114848114849114850114851114852114853114854114855114856114857114858114859114860114861114862114863114864114865114866114867114868114869114870114871114872114873114874114875114876114877114878114879114880114881114882114883114884114885114886114887114888114889114890114891114892114893114894114895114896114897114898114899114900114901114902114903114904114905114906114907114908114909114910114911114912114913114914114915114916114917114918114919114920114921114922114923114924114925114926114927114928114929114930114931114932114933114934114935114936114937114938114939114940114941114942114943114944114945114946114947114948114949114950114951114952114953114954114955114956114957114958114959114960114961114962114963114964114965114966114967114968114969114970114971114972114973114974114975114976114977114978114979114980114981114982114983114984114985114986114987114988114989114990114991114992114993114994114995114996114997114998114999115000115001115002115003115004115005115006115007115008115009115010115011115012115013115014115015115016115017115018115019115020115021115022115023115024115025115026115027115028115029115030115031115032115033115034115035115036115037115038115039115040115041115042115043115044115045115046115047115048115049115050115051115052115053115054115055115056115057115058115059115060115061115062115063115064115065115066115067115068115069115070115071115072115073115074115075115076115077115078115079115080115081115082115083115084115085115086115087115088115089115090115091115092115093115094115095115096115097115098115099115100115101115102115103115104115105115106115107115108115109115110115111115112115113115114115115115116115117115118115119115120115121115122115123115124115125115126115127115128115129115130115131115132115133115134115135115136115137115138115139115140115141115142115143115144115145115146115147115148115149115150115151115152115153115154115155115156115157115158115159115160115161115162115163115164115165115166115167115168115169115170115171115172115173115174115175115176115177115178115179115180115181115182115183115184115185115186115187115188115189115190115191115192115193115194115195115196115197115198115199115200115201115202115203115204115205115206115207115208115209115210115211115212115213115214115215115216115217115218115219115220115221115222115223115224115225115226115227115228115229115230115231115232115233115234115235115236115237115238115239115240115241115242115243115244115245115246115247115248115249115250115251115252115253115254115255115256115257115258115259115260115261115262115263115264115265115266115267115268115269115270115271115272115273115274115275115276115277115278115279115280115281115282115283115284115285115286115287115288115289115290115291115292115293115294115295115296115297115298115299115300115301115302115303115304115305115306115307115308115309115310115311115312115313115314115315115316115317115318115319115320115321115322115323115324115325115326115327115328115329115330115331115332115333115334115335115336115337115338115339115340115341115342115343115344115345115346115347115348115349115350115351115352115353115354115355115356115357115358115359115360115361115362115363115364115365115366115367115368115369115370115371115372115373115374115375115376115377115378115379115380115381115382115383115384115385115386115387115388115389115390115391115392115393115394115395115396115397115398115399115400115401115402115403115404115405115406115407115408115409115410115411115412115413115414115415115416115417115418115419115420115421115422115423115424115425115426115427115428115429115430115431115432115433115434115435115436115437115438115439115440115441115442115443115444115445115446115447115448115449115450115451115452115453115454115455115456115457115458115459115460115461115462115463115464115465115466115467115468115469115470115471115472115473115474115475115476115477115478115479115480115481115482115483115484115485115486115487115488115489115490115491115492115493115494115495115496115497115498115499115500115501115502115503115504115505115506115507115508115509115510115511115512115513115514115515115516115517115518115519115520115521115522115523115524115525115526115527115528115529115530115531115532115533115534115535115536115537115538115539115540115541115542115543115544115545115546115547115548115549115550115551115552115553115554115555115556115557115558115559115560115561115562115563115564115565115566115567115568115569115570115571115572115573115574115575115576115577115578115579115580115581115582115583115584115585115586115587115588115589115590115591115592115593115594115595115596115597115598115599115600115601115602115603115604115605115606115607115608115609115610115611115612115613115614115615115616115617115618115619115620115621115622115623115624115625115626115627115628115629115630115631115632115633115634115635115636115637115638115639115640115641115642115643115644115645115646115647115648115649115650115651115652115653115654115655115656115657115658115659115660115661115662115663115664115665115666115667115668115669115670115671115672115673115674115675115676115677115678115679115680115681115682115683115684115685115686115687115688115689115690115691115692115693115694115695115696115697115698115699115700115701115702115703115704115705115706115707115708115709115710115711115712115713115714115715115716115717115718115719115720115721115722115723115724115725115726115727115728115729115730115731115732115733115734115735115736115737115738115739115740115741115742115743115744115745115746115747115748115749115750115751115752115753115754115755115756115757115758115759115760115761115762115763115764115765115766115767115768115769115770115771115772115773115774115775115776115777115778115779115780115781115782115783115784115785115786115787115788115789115790115791115792115793115794115795115796115797115798115799115800115801115802115803115804115805115806115807115808115809115810115811115812115813115814115815115816115817115818115819115820115821115822115823115824115825115826115827115828115829115830115831115832115833115834115835115836115837115838115839115840115841115842115843115844115845115846115847115848115849115850115851115852115853115854115855115856115857115858115859115860115861115862115863115864115865115866115867115868115869115870115871115872115873115874115875115876115877115878115879115880115881115882115883115884115885115886115887115888115889115890115891115892115893115894115895115896115897115898115899115900115901115902115903115904115905115906115907115908115909115910115911115912115913115914115915115916115917115918115919115920115921115922115923115924115925115926115927115928115929115930115931115932115933115934115935115936115937115938115939115940115941115942115943115944115945115946115947115948115949115950115951115952115953115954115955115956115957115958115959115960115961115962115963115964115965115966115967115968115969115970115971115972115973115974115975115976115977115978115979115980115981115982115983115984115985115986115987115988115989115990115991115992115993115994115995115996115997115998115999116000116001116002116003116004116005116006116007116008116009116010116011116012116013116014116015116016116017116018116019116020116021116022116023116024116025116026116027116028116029116030116031116032116033116034116035116036116037116038116039116040116041116042116043116044116045116046116047116048116049116050116051116052116053116054116055116056116057116058116059116060116061116062116063116064116065116066116067116068116069116070116071116072116073116074116075116076116077116078116079116080116081116082116083116084116085116086116087116088116089116090116091116092116093116094116095116096116097116098116099116100116101116102116103116104116105116106116107116108116109116110116111116112116113116114116115116116116117116118116119116120116121116122116123116124116125116126116127116128116129116130116131116132116133116134116135116136116137116138116139116140116141116142116143116144116145116146116147116148116149116150116151116152116153116154116155116156116157116158116159116160116161116162116163116164116165116166116167116168116169116170116171116172116173116174116175116176116177116178116179116180116181116182116183116184116185116186116187116188116189116190116191116192116193116194116195116196116197116198116199116200116201116202116203116204116205116206116207116208116209116210116211116212116213116214116215116216116217116218116219116220116221116222116223116224116225116226116227116228116229116230116231116232116233116234116235116236116237116238116239116240116241116242116243116244116245116246116247116248116249116250116251116252116253116254116255116256116257116258116259116260116261116262116263116264116265116266116267116268116269116270116271116272116273116274116275116276116277116278116279116280116281116282116283116284116285116286116287116288116289116290116291116292116293116294116295116296116297116298116299116300116301116302116303116304116305116306116307116308116309116310116311116312116313116314116315116316116317116318116319116320116321116322116323116324116325116326116327116328116329116330116331116332116333116334116335116336116337116338116339116340116341116342116343116344116345116346116347116348116349116350116351116352116353116354116355116356116357116358116359116360116361116362116363116364116365116366116367116368116369116370116371116372116373116374116375116376116377116378116379116380116381116382116383116384116385116386116387116388116389116390116391116392116393116394116395116396116397116398116399116400116401116402116403116404116405116406116407116408116409116410116411116412116413116414116415116416116417116418116419116420116421116422116423116424116425116426116427116428116429116430116431116432116433116434116435116436116437116438116439116440116441116442116443116444116445116446116447116448116449116450116451116452116453116454116455116456116457116458116459116460116461116462116463116464116465116466116467116468116469116470116471116472116473116474116475116476116477116478116479116480116481116482116483116484116485116486116487116488116489116490116491116492116493116494116495116496116497116498116499116500116501116502116503116504116505116506116507116508116509116510116511116512116513116514116515116516116517116518116519116520116521116522116523116524116525116526116527116528116529116530116531116532116533116534116535116536116537116538116539116540116541116542116543116544116545116546116547116548116549116550116551116552116553116554116555116556116557116558116559116560116561116562116563116564116565116566116567116568116569116570116571116572116573116574116575116576116577116578116579116580116581116582116583116584116585116586116587116588116589116590116591116592116593116594116595116596116597116598116599116600116601116602116603116604116605116606116607116608116609116610116611116612116613116614116615116616116617116618116619116620116621116622116623116624116625116626116627116628116629116630116631116632116633116634116635116636116637116638116639116640116641116642116643116644116645116646116647116648116649116650116651116652116653116654116655116656116657116658116659116660116661116662116663116664116665116666116667116668116669116670116671116672116673116674116675116676116677116678116679116680116681116682116683116684116685116686116687116688116689116690116691116692116693116694116695116696116697116698116699116700116701116702116703116704116705116706116707116708116709116710116711116712116713116714116715116716116717116718116719116720116721116722116723116724116725116726116727116728116729116730116731116732116733116734116735116736116737116738116739116740116741116742116743116744116745116746116747116748116749116750116751116752116753116754116755116756116757116758116759116760116761116762116763116764116765116766116767116768116769116770116771116772116773116774116775116776116777116778116779116780116781116782116783116784116785116786116787116788116789116790116791116792116793116794116795116796116797116798116799116800116801116802116803116804116805116806116807116808116809116810116811116812116813116814116815116816116817116818116819116820116821116822116823116824116825116826116827116828116829116830116831116832116833116834116835116836116837116838116839116840116841116842116843116844116845116846116847116848116849116850116851116852116853116854116855116856116857116858116859116860116861116862116863116864116865116866116867116868116869116870116871116872116873116874116875116876116877116878116879116880116881116882116883116884116885116886116887116888116889116890116891116892116893116894116895116896116897116898116899116900116901116902116903116904116905116906116907116908116909116910116911116912116913116914116915116916116917116918116919116920116921116922116923116924116925116926116927116928116929116930116931116932116933116934116935116936116937116938116939116940116941116942116943116944116945116946116947116948116949116950116951116952116953116954116955116956116957116958116959116960116961116962116963116964116965116966116967116968116969116970116971116972116973116974116975116976116977116978116979116980116981116982116983116984116985116986116987116988116989116990116991116992116993116994116995116996116997116998116999117000117001117002117003117004117005117006117007117008117009117010117011117012117013117014117015117016117017117018117019117020117021117022117023117024117025117026117027117028117029117030117031117032117033117034117035117036117037117038117039117040117041117042117043117044117045117046117047117048117049117050117051117052117053117054117055117056117057117058117059117060117061117062117063117064117065117066117067117068117069117070117071117072117073117074117075117076117077117078117079117080117081117082117083117084117085117086117087117088117089117090117091117092117093117094117095117096117097117098117099117100117101117102117103117104117105117106117107117108117109117110117111117112117113117114117115117116117117117118117119117120117121117122117123117124117125117126117127117128117129117130117131117132117133117134117135117136117137117138117139117140117141117142117143117144117145117146117147117148117149117150117151117152117153117154117155117156117157117158117159117160117161117162117163117164117165117166117167117168117169117170117171117172117173117174117175117176117177117178117179117180117181117182117183117184117185117186117187117188117189117190117191117192117193117194117195117196117197117198117199117200117201117202117203117204117205117206117207117208117209117210117211117212117213117214117215117216117217117218117219117220117221117222117223117224117225117226117227117228117229117230117231117232117233117234117235117236117237117238117239117240117241117242117243117244117245117246117247117248117249117250117251117252117253117254117255117256117257117258117259117260117261117262117263117264117265117266117267117268117269117270117271117272117273117274117275117276117277117278117279117280117281117282117283117284117285117286117287117288117289117290117291117292117293117294117295117296117297117298117299117300117301117302117303117304117305117306117307117308117309117310117311117312117313117314117315117316117317117318117319117320117321117322117323117324117325117326117327117328117329117330117331117332117333117334117335117336117337117338117339117340117341117342117343117344117345117346117347117348117349117350117351117352117353117354117355117356117357117358117359117360117361117362117363117364117365117366117367117368117369117370117371117372117373117374117375117376117377117378117379117380117381117382117383117384117385117386117387117388117389117390117391117392117393117394117395117396117397117398117399117400117401117402117403117404117405117406117407117408117409117410117411117412117413117414117415117416117417117418117419117420117421117422117423117424117425117426117427117428117429117430117431117432117433117434117435117436117437117438117439117440117441117442117443117444117445117446117447117448117449117450117451117452117453117454117455117456117457117458117459117460117461117462117463117464117465117466117467117468117469117470117471117472117473117474117475117476117477117478117479117480117481117482117483117484117485117486117487117488117489117490117491117492117493117494117495117496117497117498117499117500117501117502117503117504117505117506117507117508117509117510117511117512117513117514117515117516117517117518117519117520117521117522117523117524117525117526117527117528117529117530117531117532117533117534117535117536117537117538117539117540117541117542117543117544117545117546117547117548117549117550117551117552117553117554117555117556117557117558117559117560117561117562117563117564117565117566117567117568117569117570117571117572117573117574117575117576117577117578117579117580117581117582117583117584117585117586117587117588117589117590117591117592117593117594117595117596117597117598117599117600117601117602117603117604117605117606117607117608117609117610117611117612117613117614117615117616117617117618117619117620117621117622117623117624117625117626117627117628117629117630117631117632117633117634117635117636117637117638117639117640117641117642117643117644117645117646117647117648117649117650117651117652117653117654117655117656117657117658117659117660117661117662117663117664117665117666117667117668117669117670117671117672117673117674117675117676117677117678117679117680117681117682117683117684117685117686117687117688117689117690117691117692117693117694117695117696117697117698117699117700117701117702117703117704117705117706117707117708117709117710117711117712117713117714117715117716117717117718117719117720117721117722117723117724117725117726117727117728117729117730117731117732117733117734117735117736117737117738117739117740117741117742117743117744117745117746117747117748117749117750117751117752117753117754117755117756117757117758117759117760117761117762117763117764117765117766117767117768117769117770117771117772117773117774117775117776117777117778117779117780117781117782117783117784117785117786117787117788117789117790117791117792117793117794117795117796117797117798117799117800117801117802117803117804117805117806117807117808117809117810117811117812117813117814117815117816117817117818117819117820117821117822117823117824117825117826117827117828117829117830117831117832117833117834117835117836117837117838117839117840117841117842117843117844117845117846117847117848117849117850117851117852117853117854117855117856117857117858117859117860117861117862117863117864117865117866117867117868117869117870117871117872117873117874117875117876117877117878117879117880117881117882117883117884117885117886117887117888117889117890117891117892117893117894117895117896117897117898117899117900117901117902117903117904117905117906117907117908117909117910117911117912117913117914117915117916117917117918117919117920117921117922117923117924117925117926117927117928117929117930117931117932117933117934117935117936117937117938117939117940117941117942117943117944117945117946117947117948117949117950117951117952117953117954117955117956117957117958117959117960117961117962117963117964117965117966117967117968117969117970117971117972117973117974117975117976117977117978117979117980117981117982117983117984117985117986117987117988117989117990117991117992117993117994117995117996117997117998117999118000118001118002118003118004118005118006118007118008118009118010118011118012118013118014118015118016118017118018118019118020118021118022118023118024118025118026118027118028118029118030118031118032118033118034118035118036118037118038118039118040118041118042118043118044118045118046118047118048118049118050118051118052118053118054118055118056118057118058118059118060118061118062118063118064118065118066118067118068118069118070118071118072118073118074118075118076118077118078118079118080118081118082118083118084118085118086118087118088118089118090118091118092118093118094118095118096118097118098118099118100118101118102118103118104118105118106118107118108118109118110118111118112118113118114118115118116118117118118118119118120118121118122118123118124118125118126118127118128118129118130118131118132118133118134118135118136118137118138118139118140118141118142118143118144118145118146118147118148118149118150118151118152118153118154118155118156118157118158118159118160118161118162118163118164118165118166118167118168118169118170118171118172118173118174118175118176118177118178118179118180118181118182118183118184118185118186118187118188118189118190118191118192118193118194118195118196118197118198118199118200118201118202118203118204118205118206118207118208118209118210118211118212118213118214118215118216118217118218118219118220118221118222118223118224118225118226118227118228118229118230118231118232118233118234118235118236118237118238118239118240118241118242118243118244118245118246118247118248118249118250118251118252118253118254118255118256118257118258118259118260118261118262118263118264118265118266118267118268118269118270118271118272118273118274118275118276118277118278118279118280118281118282118283118284118285118286118287118288118289118290118291118292118293118294118295118296118297118298118299118300118301118302118303118304118305118306118307118308118309118310118311118312118313118314118315118316118317118318118319118320118321118322118323118324118325118326118327118328118329118330118331118332118333118334118335118336118337118338118339118340118341118342118343118344118345118346118347118348118349118350118351118352118353118354118355118356118357118358118359118360118361118362118363118364118365118366118367118368118369118370118371118372118373118374118375118376118377118378118379118380118381118382118383118384118385118386118387118388118389118390118391118392118393118394118395118396118397118398118399118400118401118402118403118404118405118406118407118408118409118410118411118412118413118414118415118416118417118418118419118420118421118422118423118424118425118426118427118428118429118430118431118432118433118434118435118436118437118438118439118440118441118442118443118444118445118446118447118448118449118450118451118452118453118454118455118456118457118458118459118460118461118462118463118464118465118466118467118468118469118470118471118472118473118474118475118476118477118478118479118480118481118482118483118484118485118486118487118488118489118490118491118492118493118494118495118496118497118498118499118500118501118502118503118504118505118506118507118508118509118510118511118512118513118514118515118516118517118518118519118520118521118522118523118524118525118526118527118528118529118530118531118532118533118534118535118536118537118538118539118540118541118542118543118544118545118546118547118548118549118550118551118552118553118554118555118556118557118558118559118560118561118562118563118564118565118566118567118568118569118570118571118572118573118574118575118576118577118578118579118580118581118582118583118584118585118586118587118588118589118590118591118592118593118594118595118596118597118598118599118600118601118602118603118604118605118606118607118608118609118610118611118612118613118614118615118616118617118618118619118620118621118622118623118624118625118626118627118628118629118630118631118632118633118634118635118636118637118638118639118640118641118642118643118644118645118646118647118648118649118650118651118652118653118654118655118656118657118658118659118660118661118662118663118664118665118666118667118668118669118670118671118672118673118674118675118676118677118678118679118680118681118682118683118684118685118686118687118688118689118690118691118692118693118694118695118696118697118698118699118700118701118702118703118704118705118706118707118708118709118710118711118712118713118714118715118716118717118718118719118720118721118722118723118724118725118726118727118728118729118730118731118732118733118734118735118736118737118738118739118740118741118742118743118744118745118746118747118748118749118750118751118752118753118754118755118756118757118758118759118760118761118762118763118764118765118766118767118768118769118770118771118772118773118774118775118776118777118778118779118780118781118782118783118784118785118786118787118788118789118790118791118792118793118794118795118796118797118798118799118800118801118802118803118804118805118806118807118808118809118810118811118812118813118814118815118816118817118818118819118820118821118822118823118824118825118826118827118828118829118830118831118832118833118834118835118836118837118838118839118840118841118842118843118844118845118846118847118848118849118850118851118852118853118854118855118856118857118858118859118860118861118862118863118864118865118866118867118868118869118870118871118872118873118874118875118876118877118878118879118880118881118882118883118884118885118886118887118888118889118890118891118892118893118894118895118896118897118898118899118900118901118902118903118904118905118906118907118908118909118910118911118912118913118914118915118916118917118918118919118920118921118922118923118924118925118926118927118928118929118930118931118932118933118934118935118936118937118938118939118940118941118942118943118944118945118946118947118948118949118950118951118952118953118954118955118956118957118958118959118960118961118962118963118964118965118966118967118968118969118970118971118972118973118974118975118976118977118978118979118980118981118982118983118984118985118986118987118988118989118990118991118992118993118994118995118996118997118998118999119000119001119002119003119004119005119006119007119008119009119010119011119012119013119014119015119016119017119018119019119020119021119022119023119024119025119026119027119028119029119030119031119032119033119034119035119036119037119038119039119040119041119042119043119044119045119046119047119048119049119050119051119052119053119054119055119056119057119058119059119060119061119062119063119064119065119066119067119068119069119070119071119072119073119074119075119076119077119078119079119080119081119082119083119084119085119086119087119088119089119090119091119092119093119094119095119096119097119098119099119100119101119102119103119104119105119106119107119108119109119110119111119112119113119114119115119116119117119118119119119120119121119122119123119124119125119126119127119128119129119130119131119132119133119134119135119136119137119138119139119140119141119142119143119144119145119146119147119148119149119150119151119152119153119154119155119156119157119158119159119160119161119162119163119164119165119166119167119168119169119170119171119172119173119174119175119176119177119178119179119180119181119182119183119184119185119186119187119188119189119190119191119192119193119194119195119196119197119198119199119200119201119202119203119204119205119206119207119208119209119210119211119212119213119214119215119216119217119218119219119220119221119222119223119224119225119226119227119228119229119230119231119232119233119234119235119236119237119238119239119240119241119242119243119244119245119246119247119248119249119250119251119252119253119254119255119256119257119258119259119260119261119262119263119264119265119266119267119268119269119270119271119272119273119274119275119276119277119278119279119280119281119282119283119284119285119286119287119288119289119290119291119292119293119294119295119296119297119298119299119300119301119302119303119304119305119306119307119308119309119310119311119312119313119314119315119316119317119318119319119320119321119322119323119324119325119326119327119328119329119330119331119332119333119334119335119336119337119338119339119340119341119342119343119344119345119346119347119348119349119350119351119352119353119354119355119356119357119358119359119360119361119362119363119364119365119366119367119368119369119370119371119372119373119374119375119376119377119378119379119380119381119382119383119384119385119386119387119388119389119390119391119392119393119394119395119396119397119398119399119400119401119402119403119404119405119406119407119408119409119410119411119412119413119414119415119416119417119418119419119420119421119422119423119424119425119426119427119428119429119430119431119432119433119434119435119436119437119438119439119440119441119442119443119444119445119446119447119448119449119450119451119452119453119454119455119456119457119458119459119460119461119462119463119464119465119466119467119468119469119470119471119472119473119474119475119476119477119478119479119480119481119482119483119484119485119486119487119488119489119490119491119492119493119494119495119496119497119498119499119500119501119502119503119504119505119506119507119508119509119510119511119512119513119514119515119516119517119518119519119520119521119522119523119524119525119526119527119528119529119530119531119532119533119534119535119536119537119538119539119540119541119542119543119544119545119546119547119548119549119550119551119552119553119554119555119556119557119558119559119560119561119562119563119564119565119566119567119568119569119570119571119572119573119574119575119576119577119578119579119580119581119582119583119584119585119586119587119588119589119590119591119592119593119594119595119596119597119598119599119600119601119602119603119604119605119606119607119608119609119610119611119612119613119614119615119616119617119618119619119620119621119622119623119624119625119626119627119628119629119630119631119632119633119634119635119636119637119638119639119640119641119642119643119644119645119646119647119648119649119650119651119652119653119654119655119656119657119658119659119660119661119662119663119664119665119666119667119668119669119670119671119672119673119674119675119676119677119678119679119680119681119682119683119684119685119686119687119688119689119690119691119692119693119694119695119696119697119698119699119700119701119702119703119704119705119706119707119708119709119710119711119712119713119714119715119716119717119718119719119720119721119722119723119724119725119726119727119728119729119730119731119732119733119734119735119736119737119738119739119740119741119742119743119744119745119746119747119748119749119750119751119752119753119754119755119756119757119758119759119760119761119762119763119764119765119766119767119768119769119770119771119772119773119774119775119776119777119778119779119780119781119782119783119784119785119786119787119788119789119790119791119792119793119794119795119796119797119798119799119800119801119802119803119804119805119806119807119808119809119810119811119812119813119814119815119816119817119818119819119820119821119822119823119824119825119826119827119828119829119830119831119832119833119834119835119836119837119838119839119840119841119842119843119844119845119846119847119848119849119850119851119852119853119854119855119856119857119858119859119860119861119862119863119864119865119866119867119868119869119870119871119872119873119874119875119876119877119878119879119880119881119882119883119884119885119886119887119888119889119890119891119892119893119894119895119896119897119898119899119900119901119902119903119904119905119906119907119908119909119910119911119912119913119914119915119916119917119918119919119920119921119922119923119924119925119926119927119928119929119930119931119932119933119934119935119936119937119938119939119940119941119942119943119944119945119946119947119948119949119950119951119952119953119954119955119956119957119958119959119960119961119962119963119964119965119966119967119968119969119970119971119972119973119974119975119976119977119978119979119980119981119982119983119984119985119986119987119988119989119990119991119992119993119994119995119996119997119998119999120000120001120002120003120004120005120006120007120008120009120010120011120012120013120014120015120016120017120018120019120020120021120022120023120024120025120026120027120028120029120030120031120032120033120034120035120036120037120038120039120040120041120042120043120044120045120046120047120048120049120050120051120052120053120054120055120056120057120058120059120060120061120062120063120064120065120066120067120068120069120070120071120072120073120074120075120076120077120078120079120080120081120082120083120084120085120086120087120088120089120090120091120092120093120094120095120096120097120098120099120100120101120102120103120104120105120106120107120108120109120110120111120112120113120114120115120116120117120118120119120120120121120122120123120124120125120126120127120128120129120130120131120132120133120134120135120136120137120138120139120140120141120142120143120144120145120146120147120148120149120150120151120152120153120154120155120156120157120158120159120160120161120162120163120164120165120166120167120168120169120170120171120172120173120174120175120176120177120178120179120180120181120182120183120184120185120186120187120188120189120190120191120192120193120194120195120196120197120198120199120200120201120202120203120204120205120206120207120208120209120210120211120212120213120214120215120216120217120218120219120220120221120222120223120224120225120226120227120228120229120230120231120232120233120234120235120236120237120238120239120240120241120242120243120244120245120246120247120248120249120250120251120252120253120254120255120256120257120258120259120260120261120262120263120264120265120266120267120268120269120270120271120272120273120274120275120276120277120278120279120280120281120282120283120284120285120286120287120288120289120290120291120292120293120294120295120296120297120298120299120300120301120302120303120304120305120306120307120308120309120310120311120312120313120314120315120316120317120318120319120320120321120322120323120324120325120326120327120328120329120330120331120332120333120334120335120336120337120338120339120340120341120342120343120344120345120346120347120348120349120350120351120352120353120354120355120356120357120358120359120360120361120362120363120364120365120366120367120368120369120370120371120372120373120374120375120376120377120378120379120380120381120382120383120384120385120386120387120388120389120390120391120392120393120394120395120396120397120398120399120400120401120402120403120404120405120406120407120408120409120410120411120412120413120414120415120416120417120418120419120420120421120422120423120424120425120426120427120428120429120430120431120432120433120434120435120436120437120438120439120440120441120442120443120444120445120446120447120448120449120450120451120452120453120454120455120456120457120458120459120460120461120462120463120464120465120466120467120468120469120470120471120472120473120474120475120476120477120478120479120480120481120482120483120484120485120486120487120488120489120490120491120492120493120494120495120496120497120498120499120500120501120502120503120504120505120506120507120508120509120510120511120512120513120514120515120516120517120518120519120520120521120522120523120524120525120526120527120528120529120530120531120532120533120534120535120536120537120538120539120540120541120542120543120544120545120546120547120548120549120550120551120552120553120554120555120556120557120558120559120560120561120562120563120564120565120566120567120568120569120570120571120572120573120574120575120576120577120578120579120580120581120582120583120584120585120586120587120588120589120590120591120592120593120594120595120596120597120598120599120600120601120602120603120604120605120606120607120608120609120610120611120612120613120614120615120616120617120618120619120620120621120622120623120624120625120626120627120628120629120630120631120632120633120634120635120636120637120638120639120640120641120642120643120644120645120646120647120648120649120650120651120652120653120654120655120656120657120658120659120660120661120662120663120664120665120666120667120668120669120670120671120672120673120674120675120676120677120678120679120680120681120682120683120684120685120686120687120688120689120690120691120692120693120694120695120696120697120698120699120700120701120702120703120704120705120706120707120708120709120710120711120712120713120714120715120716120717120718120719120720120721120722120723120724120725120726120727120728120729120730120731120732120733120734120735120736120737120738120739120740120741120742120743120744120745120746120747120748120749120750120751120752120753120754120755120756120757120758120759120760120761120762120763120764120765120766120767120768120769120770120771120772120773120774120775120776120777120778120779120780120781120782120783120784120785120786120787120788120789120790120791120792120793120794120795120796120797120798120799120800120801120802120803120804120805120806120807120808120809120810120811120812120813120814120815120816120817120818120819120820120821120822120823120824120825120826120827120828120829120830120831120832120833120834120835120836120837120838120839120840120841120842120843120844120845120846120847120848120849120850120851120852120853120854120855120856120857120858120859120860120861120862120863120864120865120866120867120868120869120870120871120872120873120874120875120876120877120878120879120880120881120882120883120884120885120886120887120888120889120890120891120892120893120894120895120896120897120898120899120900120901120902120903120904120905120906120907120908120909120910120911120912120913120914120915120916120917120918120919120920120921120922120923120924120925120926120927120928120929120930120931120932120933120934120935120936120937120938120939120940120941120942120943120944120945120946120947120948120949120950120951120952120953120954120955120956120957120958120959120960120961120962120963120964120965120966120967120968120969120970120971120972120973120974120975120976120977120978120979120980120981120982120983120984120985120986120987120988120989120990120991120992120993120994120995120996120997120998120999121000121001121002121003121004121005121006121007121008121009121010121011121012121013121014121015121016121017121018121019121020121021121022121023121024121025121026121027121028121029121030121031121032121033121034121035121036121037121038121039121040121041121042121043121044121045121046121047121048121049121050121051121052121053121054121055121056121057121058121059121060121061121062121063121064121065121066121067121068121069121070121071121072121073121074121075121076121077121078121079121080121081121082121083121084121085121086121087121088121089121090121091121092121093121094121095121096121097121098121099121100121101121102121103121104121105121106121107121108121109121110121111121112121113121114121115121116121117121118121119121120121121121122121123121124121125121126121127121128121129121130121131121132121133121134121135121136121137121138121139121140121141121142121143121144121145121146121147121148121149121150121151121152121153121154121155121156121157121158121159121160121161121162121163121164121165121166121167121168121169121170121171121172121173121174121175121176121177121178121179121180121181121182121183121184121185121186121187121188121189121190121191121192121193121194121195121196121197121198121199121200121201121202121203121204121205121206121207121208121209121210121211121212121213121214121215121216121217121218121219121220121221121222121223121224121225121226121227121228121229121230121231121232121233121234121235121236121237121238121239121240121241121242121243121244121245121246121247121248121249121250121251121252121253121254121255121256121257121258121259121260121261121262121263121264121265121266121267121268121269121270121271121272121273121274121275121276121277121278121279121280121281121282121283121284121285121286121287121288121289121290121291121292121293121294121295121296121297121298121299121300121301121302121303121304121305121306121307121308121309121310121311121312121313121314121315121316121317121318121319121320121321121322121323121324121325121326121327121328121329121330121331121332121333121334121335121336121337121338121339121340121341121342121343121344121345121346121347121348121349121350121351121352121353121354121355121356121357121358121359121360121361121362121363121364121365121366121367121368121369121370121371121372121373121374121375121376121377121378121379121380121381121382121383121384121385121386121387121388121389121390121391121392121393121394121395121396121397121398121399121400121401121402121403121404121405121406121407121408121409121410121411121412121413121414121415121416121417121418121419121420121421121422121423121424121425121426121427121428121429121430121431121432121433121434121435121436121437121438121439121440121441121442121443121444121445121446121447121448121449121450121451121452121453121454121455121456121457121458121459121460121461121462121463121464121465121466121467121468121469121470121471121472121473121474121475121476121477121478121479121480121481121482121483121484121485121486121487121488121489121490121491121492121493121494121495121496121497121498121499121500121501121502121503121504121505121506121507121508121509121510121511121512121513121514121515121516121517121518121519121520121521121522121523121524121525121526121527121528121529121530121531121532121533121534121535121536121537121538121539121540121541121542121543121544121545121546121547121548121549121550121551121552121553121554121555121556121557121558121559121560121561121562121563121564121565121566121567121568121569121570121571121572121573121574121575121576121577121578121579121580121581121582121583121584121585121586121587121588121589121590121591121592121593121594121595121596121597121598121599121600121601121602121603121604121605121606121607121608121609121610121611121612121613121614121615121616121617121618121619121620121621121622121623121624121625121626121627121628121629121630121631121632121633121634121635121636121637121638121639121640121641121642121643121644121645121646121647121648121649121650121651121652121653121654121655121656121657121658121659121660121661121662121663121664121665121666121667121668121669121670121671121672121673121674121675121676121677121678121679121680121681121682121683121684121685121686121687121688121689121690121691121692121693121694121695121696121697121698121699121700121701121702121703121704121705121706121707121708121709121710121711121712121713121714121715121716121717121718121719121720121721121722121723121724121725121726121727121728121729121730121731121732121733121734121735121736121737121738121739121740121741121742121743121744121745121746121747121748121749121750121751121752121753121754121755121756121757121758121759121760121761121762121763121764121765121766121767121768121769121770121771121772121773121774121775121776121777121778121779121780121781121782121783121784121785121786121787121788121789121790121791121792121793121794121795121796121797121798121799121800121801121802121803121804121805121806121807121808121809121810121811121812121813121814121815121816121817121818121819121820121821121822121823121824121825121826121827121828121829121830121831121832121833121834121835121836121837121838121839121840121841121842121843121844121845121846121847121848121849121850121851121852121853121854121855121856121857121858121859121860121861121862121863121864121865121866121867121868121869121870121871121872121873121874121875121876121877121878121879121880121881121882121883121884121885121886121887121888121889121890121891121892121893121894121895121896121897121898121899121900121901121902121903121904121905121906121907121908121909121910121911121912121913121914121915121916121917121918121919121920121921121922121923121924121925121926121927121928121929121930121931121932121933121934121935121936121937121938121939121940121941121942121943121944121945121946121947121948121949121950121951121952121953121954121955121956121957121958121959121960121961121962121963121964121965121966121967121968121969121970121971121972121973121974121975121976121977121978121979121980121981121982121983121984121985121986121987121988121989121990121991121992121993121994121995121996121997121998121999122000122001122002122003122004122005122006122007122008122009122010122011122012122013122014122015122016122017122018122019122020122021122022122023122024122025122026122027122028122029122030122031122032122033122034122035122036122037122038122039122040122041122042122043122044122045122046122047122048122049122050122051122052122053122054122055122056122057122058122059122060122061122062122063122064122065122066122067122068122069122070122071122072122073122074122075122076122077122078122079122080122081122082122083122084122085122086122087122088122089122090122091122092122093122094122095122096122097122098122099122100122101122102122103122104122105122106122107122108122109122110122111122112122113122114122115122116122117122118122119122120122121122122122123122124122125122126122127122128122129122130122131122132122133122134122135122136122137122138122139122140122141122142122143122144122145122146122147122148122149122150122151122152122153122154122155122156122157122158122159122160122161122162122163122164122165122166122167122168122169122170122171122172122173122174122175122176122177122178122179122180122181122182122183122184122185122186122187122188122189122190122191122192122193122194122195122196122197122198122199122200122201122202122203122204122205122206122207122208122209122210122211122212122213122214122215122216122217122218122219122220122221122222122223122224122225122226122227122228122229122230122231122232122233122234122235122236122237122238122239122240122241122242122243122244122245122246122247122248122249122250122251122252122253122254122255122256122257122258122259122260122261122262122263122264122265122266122267122268122269122270122271122272122273122274122275122276122277122278122279122280122281122282122283122284122285122286122287122288122289122290122291122292122293122294122295122296122297122298122299122300122301122302122303122304122305122306122307122308122309122310122311122312122313122314122315122316122317122318122319122320122321122322122323122324122325122326122327122328122329122330122331122332122333122334122335122336122337122338122339122340122341122342122343122344122345122346122347122348122349122350122351122352122353122354122355122356122357122358122359122360122361122362122363122364122365122366122367122368122369122370122371122372122373122374122375122376122377122378122379122380122381122382122383122384122385122386122387122388122389122390122391122392122393122394122395122396122397122398122399122400122401122402122403122404122405122406122407122408122409122410122411122412122413122414122415122416122417122418122419122420122421122422122423122424122425122426122427122428122429122430122431122432122433122434122435122436122437122438122439122440122441122442122443122444122445122446122447122448122449122450122451122452122453122454122455122456122457122458122459122460122461122462122463122464122465122466122467122468122469122470122471122472122473122474122475122476122477122478122479122480122481122482122483122484122485122486122487122488122489122490122491122492122493122494122495122496122497122498122499122500122501122502122503122504122505122506122507122508122509122510122511122512122513122514122515122516122517122518122519122520122521122522122523122524122525122526122527122528122529122530122531122532122533122534122535122536122537122538122539122540122541122542122543122544122545122546122547122548122549122550122551122552122553122554122555122556122557122558122559122560122561122562122563122564122565122566122567122568122569122570122571122572122573122574122575122576122577122578122579122580122581122582122583122584122585122586122587122588122589122590122591122592122593122594122595122596122597122598122599122600122601122602122603122604122605122606122607122608122609122610122611122612122613122614122615122616122617122618122619122620122621122622122623122624122625122626122627122628122629122630122631122632122633122634122635122636122637122638122639122640122641122642122643122644122645122646122647122648122649122650122651122652122653122654122655122656122657122658122659122660122661122662122663122664122665122666122667122668122669122670122671122672122673122674122675122676122677122678122679122680122681122682122683122684122685122686122687122688122689122690122691122692122693122694122695122696122697122698122699122700122701122702122703122704122705122706122707122708122709122710122711122712122713122714122715122716122717122718122719122720122721122722122723122724122725122726122727122728122729122730122731122732122733122734122735122736122737122738122739122740122741122742122743122744122745122746122747122748122749122750122751122752122753122754122755122756122757122758122759122760122761122762122763122764122765122766122767122768122769122770122771122772122773122774122775122776122777122778122779122780122781122782122783122784122785122786122787122788122789122790122791122792122793122794122795122796122797122798122799122800122801122802122803122804122805122806122807122808122809122810122811122812122813122814122815122816122817122818122819122820122821122822122823122824122825122826122827122828122829122830122831122832122833122834122835122836122837122838122839122840122841122842122843122844122845122846122847122848122849122850122851122852122853122854122855122856122857122858122859122860122861122862122863122864122865122866122867122868122869122870122871122872122873122874122875122876122877122878122879122880122881122882122883122884122885122886122887122888122889122890122891122892122893122894122895122896122897122898122899122900122901122902122903122904122905122906122907122908122909122910122911122912122913122914122915122916122917122918122919122920122921122922122923122924122925122926122927122928122929122930122931122932122933122934122935122936122937122938122939122940122941122942122943122944122945122946122947122948122949122950122951122952122953122954122955122956122957122958122959122960122961122962122963122964122965122966122967122968122969122970122971122972122973122974122975122976122977122978122979122980122981122982122983122984122985122986122987122988122989122990122991122992122993122994122995122996122997122998122999123000123001123002123003123004123005123006123007123008123009123010123011123012123013123014123015123016123017123018123019123020123021123022123023123024123025123026123027123028123029123030123031123032123033123034123035123036123037123038123039123040123041123042123043123044123045123046123047123048123049123050123051123052123053123054123055123056123057123058123059123060123061123062123063123064123065123066123067123068123069123070123071123072123073123074123075123076123077123078123079123080123081123082123083123084123085123086123087123088123089123090123091123092123093123094123095123096123097123098123099123100123101123102123103123104123105123106123107123108123109123110123111123112123113123114123115123116123117123118123119123120123121123122123123123124123125123126123127123128123129123130123131123132123133123134123135123136123137123138123139123140123141123142123143123144123145123146123147123148123149123150123151123152123153123154123155123156123157123158123159123160123161123162123163123164123165123166123167123168123169123170123171123172123173123174123175123176123177123178123179123180123181123182123183123184123185123186123187123188123189123190123191123192123193123194123195123196123197123198123199123200123201123202123203123204123205123206123207123208123209123210123211123212123213123214123215123216123217123218123219123220123221123222123223123224123225123226123227123228123229123230123231123232123233123234123235123236123237123238123239123240123241123242123243123244123245123246123247123248123249123250123251123252123253123254123255123256123257123258123259123260123261123262123263123264123265123266123267123268123269123270123271123272123273123274123275123276123277123278123279123280123281123282123283123284123285123286123287123288123289123290123291123292123293123294123295123296123297123298123299123300123301123302123303123304123305123306123307123308123309123310123311123312123313123314123315123316123317123318123319123320123321123322123323123324123325123326123327123328123329123330123331123332123333123334123335123336123337123338123339123340123341123342123343123344123345123346123347123348123349123350123351123352123353123354123355123356123357123358123359123360123361123362123363123364123365123366123367123368123369123370123371123372123373123374123375123376123377123378123379123380123381123382123383123384123385123386123387123388123389123390123391123392123393123394123395123396123397123398123399123400123401123402123403123404123405123406123407123408123409123410123411123412123413123414123415123416123417123418123419123420123421123422123423123424123425123426123427123428123429123430123431123432123433123434123435123436123437123438123439123440123441123442123443123444123445123446123447123448123449123450123451123452123453123454123455123456123457123458123459123460123461123462123463123464123465123466123467123468123469123470123471123472123473123474123475123476123477123478123479123480123481123482123483123484123485123486123487123488123489123490123491123492123493123494123495123496123497123498123499123500123501123502123503123504123505123506123507123508123509123510123511123512123513123514123515123516123517123518123519123520123521123522123523123524123525123526123527123528123529123530123531123532123533123534123535123536123537123538123539123540123541123542123543123544123545123546123547123548123549123550123551123552123553123554123555123556123557123558123559123560123561123562123563123564123565123566123567123568123569123570123571123572123573123574123575123576123577123578123579123580123581123582123583123584123585123586123587123588123589123590123591123592123593123594123595123596123597123598123599123600123601123602123603123604123605123606123607123608123609123610123611123612123613123614123615123616123617123618123619123620123621123622123623123624123625123626123627123628123629123630123631123632123633123634123635123636123637123638123639123640123641123642123643123644123645123646123647123648123649123650123651123652123653123654123655123656123657123658123659123660123661123662123663123664123665123666123667123668123669123670123671123672123673123674123675123676123677123678123679123680123681123682123683123684123685123686123687123688123689123690123691123692123693123694123695123696123697123698123699123700123701123702123703123704123705123706123707123708123709123710123711123712123713123714123715123716123717123718123719123720123721123722123723123724123725123726123727123728123729123730123731123732123733123734123735123736123737123738123739123740123741123742123743123744123745123746123747123748123749123750123751123752123753123754123755123756123757123758123759123760123761123762123763123764123765123766123767123768123769123770123771123772123773123774123775123776123777123778123779123780123781123782123783123784123785123786123787123788123789123790123791123792123793123794123795123796123797123798123799123800123801123802123803123804123805123806123807123808123809123810123811123812123813123814123815123816123817123818123819123820123821123822123823123824123825123826123827123828123829123830123831123832123833123834123835123836123837123838123839123840123841123842123843123844123845123846123847123848123849123850123851123852123853123854123855123856123857123858123859123860123861123862123863123864123865123866123867123868123869123870123871123872123873123874123875123876123877123878123879123880123881123882123883123884123885123886123887123888123889123890123891123892123893123894123895123896123897123898123899123900123901123902123903123904123905123906123907123908123909123910123911123912123913123914123915123916123917123918123919123920123921123922123923123924123925123926123927123928123929123930123931123932123933123934123935123936123937123938123939123940123941123942123943123944123945123946123947123948123949123950123951123952123953123954123955123956123957123958123959123960123961123962123963123964123965123966123967123968123969123970123971123972123973123974123975123976123977123978123979123980123981123982123983123984123985123986123987123988123989123990123991123992123993123994123995123996123997123998123999124000124001124002124003124004124005124006124007124008124009124010124011124012124013124014124015124016124017124018124019124020124021124022124023124024124025124026124027124028124029124030124031124032124033124034124035124036124037124038124039124040124041124042124043124044124045124046124047124048124049124050124051124052124053124054124055124056124057124058124059124060124061124062124063124064124065124066124067124068124069124070124071124072124073124074124075124076124077124078124079124080124081124082124083124084124085124086124087124088124089124090124091124092124093124094124095124096124097124098124099124100124101124102124103124104124105124106124107124108124109124110124111124112124113124114124115124116124117124118124119124120124121124122124123124124124125124126124127124128124129124130124131124132124133124134124135124136124137124138124139124140124141124142124143124144124145124146124147124148124149124150124151124152124153124154124155124156124157124158124159124160124161124162124163124164124165124166124167124168124169124170124171124172124173124174124175124176124177124178124179124180124181124182124183124184124185124186124187124188124189124190124191124192124193124194124195124196124197124198124199124200124201124202124203124204124205124206124207124208124209124210124211124212124213124214124215124216124217124218124219124220124221124222124223124224124225124226124227124228124229124230124231124232124233124234124235124236124237124238124239124240124241124242124243124244124245124246124247124248124249124250124251124252124253124254124255124256124257124258124259124260124261124262124263124264124265124266124267124268124269124270124271124272124273124274124275124276124277124278124279124280124281124282124283124284124285124286124287124288124289124290124291124292124293124294124295124296124297124298124299124300124301124302124303124304124305124306124307124308124309124310124311124312124313124314124315124316124317124318124319124320124321124322124323124324124325124326124327124328124329124330124331124332124333124334124335124336124337124338124339124340124341124342124343124344124345124346124347124348124349124350124351124352124353124354124355124356124357124358124359124360124361124362124363124364124365124366124367124368124369124370124371124372124373124374124375124376124377124378124379124380124381124382124383124384124385124386124387124388124389124390124391124392124393124394124395124396124397124398124399124400124401124402124403124404124405124406124407124408124409124410124411124412124413124414124415124416124417124418124419124420124421124422124423124424124425124426124427124428124429124430124431124432124433124434124435124436124437124438124439124440124441124442124443124444124445124446124447124448124449124450124451124452124453124454124455124456124457124458124459124460124461124462124463124464124465124466124467124468124469124470124471124472124473124474124475124476124477124478124479124480124481124482124483124484124485124486124487124488124489124490124491124492124493124494124495124496124497124498124499124500124501124502124503124504124505124506124507124508124509124510124511124512124513124514124515124516124517124518124519124520124521124522124523124524124525124526124527124528124529124530124531124532124533124534124535124536124537124538124539124540124541124542124543124544124545124546124547124548124549124550124551124552124553124554124555124556124557124558124559124560124561124562124563124564124565124566124567124568124569124570124571124572124573124574124575124576124577124578124579124580124581124582124583124584124585124586124587124588124589124590124591124592124593124594124595124596124597124598124599124600124601124602124603124604124605124606124607124608124609124610124611124612124613124614124615124616124617124618124619124620124621124622124623124624124625124626124627124628124629124630124631124632124633124634124635124636124637124638124639124640124641124642124643124644124645124646124647124648124649124650124651124652124653124654124655124656124657124658124659124660124661124662124663124664124665124666124667124668124669124670124671124672124673124674124675124676124677124678124679124680124681124682124683124684124685124686124687124688124689124690124691124692124693124694124695124696124697124698124699124700124701124702124703124704124705124706124707124708124709124710124711124712124713124714124715124716124717124718124719124720124721124722124723124724124725124726124727124728124729124730124731124732124733124734124735124736124737124738124739124740124741124742124743124744124745124746124747124748124749124750124751124752124753124754124755124756124757124758124759124760124761124762124763124764124765124766124767124768124769124770124771124772124773124774124775124776124777124778124779124780124781124782124783124784124785124786124787124788124789124790124791124792124793124794124795124796124797124798124799124800124801124802124803124804124805124806124807124808124809124810124811124812124813124814124815124816124817124818124819124820124821124822124823124824124825124826124827124828124829124830124831124832124833124834124835124836124837124838124839124840124841124842124843124844124845124846124847124848124849124850124851124852124853124854124855124856124857124858124859124860124861124862124863124864124865124866124867124868124869124870124871124872124873124874124875124876124877124878124879124880124881124882124883124884124885124886124887124888124889124890124891124892124893124894124895124896124897124898124899124900124901124902124903124904124905124906124907124908124909124910124911124912124913124914124915124916124917124918124919124920124921124922124923124924124925124926124927124928124929124930124931124932124933124934124935124936124937124938124939124940124941124942124943124944124945124946124947124948124949124950124951124952124953124954124955124956124957124958124959124960124961124962124963124964124965124966124967124968124969124970124971124972124973124974124975124976124977124978124979124980124981124982124983124984124985124986124987124988124989124990124991124992124993124994124995124996124997124998124999125000125001125002125003125004125005125006125007125008125009125010125011125012125013125014125015125016125017125018125019125020125021125022125023125024125025125026125027125028125029125030125031125032125033125034125035125036125037125038125039125040125041125042125043125044125045125046125047125048125049125050125051125052125053125054125055125056125057125058125059125060125061125062125063125064125065125066125067125068125069125070125071125072125073125074125075125076125077125078125079125080125081125082125083125084125085125086125087125088125089125090125091125092125093125094125095125096125097125098125099125100125101125102125103125104125105125106125107125108125109125110125111125112125113125114125115125116125117125118125119125120125121125122125123125124125125125126125127125128125129125130125131125132125133125134125135125136125137125138125139125140125141125142125143125144125145125146125147125148125149125150125151125152125153125154125155125156125157125158125159125160125161125162125163125164125165125166125167125168125169125170125171125172125173125174125175125176125177125178125179125180125181125182125183125184125185125186125187125188125189125190125191125192125193125194125195125196125197125198125199125200125201125202125203125204125205125206125207125208125209125210125211125212125213125214125215125216125217125218125219125220125221125222125223125224125225125226125227125228125229125230125231125232125233125234125235125236125237125238125239125240125241125242125243125244125245125246125247125248125249125250125251125252125253125254125255125256125257125258125259125260125261125262125263125264125265125266125267125268125269125270125271125272125273125274125275125276125277125278125279125280125281125282125283125284125285125286125287125288125289125290125291125292125293125294125295125296125297125298125299125300125301125302125303125304125305125306125307125308125309125310125311125312125313125314125315125316125317125318125319125320125321125322125323125324125325125326125327125328125329125330125331125332125333125334125335125336125337125338125339125340125341125342125343125344125345125346125347125348125349125350125351125352125353125354125355125356125357125358125359125360125361125362125363125364125365125366125367125368125369125370125371125372125373125374125375125376125377125378125379125380125381125382125383125384125385125386125387125388125389125390125391125392125393125394125395125396125397125398125399125400125401125402125403125404125405125406125407125408125409125410125411125412125413125414125415125416125417125418125419125420125421125422125423125424125425125426125427125428125429125430125431125432125433125434125435125436125437125438125439125440125441125442125443125444125445125446125447125448125449125450125451125452125453125454125455125456125457125458125459125460125461125462125463125464125465125466125467125468125469125470125471125472125473125474125475125476125477125478125479125480125481125482125483125484125485125486125487125488125489125490125491125492125493125494125495125496125497125498125499125500125501125502125503125504125505125506125507125508125509125510125511125512125513125514125515125516125517125518125519125520125521125522125523125524125525125526125527125528125529125530125531125532125533125534125535125536125537125538125539125540125541125542125543125544125545125546125547125548125549125550125551125552125553125554125555125556125557125558125559125560125561125562125563125564125565125566125567125568125569125570125571125572125573125574125575125576125577125578125579125580125581125582125583125584125585125586125587125588125589125590125591125592125593125594125595125596125597125598125599125600125601125602125603125604125605125606125607125608125609125610125611125612125613125614125615125616125617125618125619125620125621125622125623125624125625125626125627125628125629125630125631125632125633125634125635125636125637125638125639125640125641125642125643125644125645125646125647125648125649125650125651125652125653125654125655125656125657125658125659125660125661125662125663125664125665125666125667125668125669125670125671125672125673125674125675125676125677125678125679125680125681125682125683125684125685125686125687125688125689125690125691125692125693125694125695125696125697125698125699125700125701125702125703125704125705125706125707125708125709125710125711125712125713125714125715125716125717125718125719125720125721125722125723125724125725125726125727125728125729125730125731125732125733125734125735125736125737125738125739125740125741125742125743125744125745125746125747125748125749125750125751125752125753125754125755125756125757125758125759125760125761125762125763125764125765125766125767125768125769125770125771125772125773125774125775125776125777125778125779125780125781125782125783125784125785125786125787125788125789125790125791125792125793125794125795125796125797125798125799125800125801125802125803125804125805125806125807125808125809125810125811125812125813125814125815125816125817125818125819125820125821125822125823125824125825125826125827125828125829125830125831125832125833125834125835125836125837125838125839125840125841125842125843125844125845125846125847125848125849125850125851125852125853125854125855125856125857125858125859125860125861125862125863125864125865125866125867125868125869125870125871125872125873125874125875125876125877125878125879125880125881125882125883125884125885125886125887125888125889125890125891125892125893125894125895125896125897125898125899125900125901125902125903125904125905125906125907125908125909125910125911125912125913125914125915125916125917125918125919125920125921125922125923125924125925125926125927125928125929125930125931125932125933125934125935125936125937125938125939125940125941125942125943125944125945125946125947125948125949125950125951125952125953125954125955125956125957125958125959125960125961125962125963125964125965125966125967125968125969125970125971125972125973125974125975125976125977125978125979125980125981125982125983125984125985125986125987125988125989125990125991125992125993125994125995125996125997125998125999126000126001126002126003126004126005126006126007126008126009126010126011126012126013126014126015126016126017126018126019126020126021126022126023126024126025126026126027126028126029126030126031126032126033126034126035126036126037126038126039126040126041126042126043126044126045126046126047126048126049126050126051126052126053126054126055126056126057126058126059126060126061126062126063126064126065126066126067126068126069126070126071126072126073126074126075126076126077126078126079126080126081126082126083126084126085126086126087126088126089126090126091126092126093126094126095126096126097126098126099126100126101126102126103126104126105126106126107126108126109126110126111126112126113126114126115126116126117126118126119126120126121126122126123126124126125126126126127126128126129126130126131126132126133126134126135126136126137126138126139126140126141126142126143126144126145126146126147126148126149126150126151126152126153126154126155126156126157126158126159126160126161126162126163126164126165126166126167126168126169126170126171126172126173126174126175126176126177126178126179126180126181126182126183126184126185126186126187126188126189126190126191126192126193126194126195126196126197126198126199126200126201126202126203126204126205126206126207126208126209126210126211126212126213126214126215126216126217126218126219126220126221126222126223126224126225126226126227126228126229126230126231126232126233126234126235126236126237126238126239126240126241126242126243126244126245126246126247126248126249126250126251126252126253126254126255126256126257126258126259126260126261126262126263126264126265126266126267126268126269126270126271126272126273126274126275126276126277126278126279126280126281126282126283126284126285126286126287126288126289126290126291126292126293126294126295126296126297126298126299126300126301126302126303126304126305126306126307126308126309126310126311126312126313126314126315126316126317126318126319126320126321126322126323126324126325126326126327126328126329126330126331126332126333126334126335126336126337126338126339126340126341126342126343126344126345126346126347126348126349126350126351126352126353126354126355126356126357126358126359126360126361126362126363126364126365126366126367126368126369126370126371126372126373126374126375126376126377126378126379126380126381126382126383126384126385126386126387126388126389126390126391126392126393126394126395126396126397126398126399126400126401126402126403126404126405126406126407126408126409126410126411126412126413126414126415126416126417126418126419126420126421126422126423126424126425126426126427126428126429126430126431126432126433126434126435126436126437126438126439126440126441126442126443126444126445126446126447126448126449126450126451126452126453126454126455126456126457126458126459126460126461126462126463126464126465126466126467126468126469126470126471126472126473126474126475126476126477126478126479126480126481126482126483126484126485126486126487126488126489126490126491126492126493126494126495126496126497126498126499126500126501126502126503126504126505126506126507126508126509126510126511126512126513126514126515126516126517126518126519126520126521126522126523126524126525126526126527126528126529126530126531126532126533126534126535126536126537126538126539126540126541126542126543126544126545126546126547126548126549126550126551126552126553126554126555126556126557126558126559126560126561126562126563126564126565126566126567126568126569126570126571126572126573126574126575126576126577126578126579126580126581126582126583126584126585126586126587126588126589126590126591126592126593126594126595126596126597126598126599126600126601126602126603126604126605126606126607126608126609126610126611126612126613126614126615126616126617126618126619126620126621126622126623126624126625126626126627126628126629126630126631126632126633126634126635126636126637126638126639126640126641126642126643126644126645126646126647126648126649126650126651126652126653126654126655126656126657126658126659126660126661126662126663126664126665126666126667126668126669126670126671126672126673126674126675126676126677126678126679126680126681126682126683126684126685126686126687126688126689126690126691126692126693126694126695126696126697126698126699126700126701126702126703126704126705126706126707126708126709126710126711126712126713126714126715126716126717126718126719126720126721126722126723126724126725126726126727126728126729126730126731126732126733126734126735126736126737126738126739126740126741126742126743126744126745126746126747126748126749126750126751126752126753126754126755126756126757126758126759126760126761126762126763126764126765126766126767126768126769126770126771126772126773126774126775126776126777126778126779126780126781126782126783126784126785126786126787126788126789126790126791126792126793126794126795126796126797126798126799126800126801126802126803126804126805126806126807126808126809126810126811126812126813126814126815126816126817126818126819126820126821126822126823126824126825126826126827126828126829126830126831126832126833126834126835126836126837126838126839126840126841126842126843126844126845126846126847126848126849126850126851126852126853126854126855126856126857126858126859126860126861126862126863126864126865126866126867126868126869126870126871126872126873126874126875126876126877126878126879126880126881126882126883126884126885126886126887126888126889126890126891126892126893126894126895126896126897126898126899126900126901126902126903126904126905126906126907126908126909126910126911126912126913126914126915126916126917126918126919126920126921126922126923126924126925126926126927126928126929126930126931126932126933126934126935126936126937126938126939126940126941126942126943126944126945126946126947126948126949126950126951126952126953126954126955126956126957126958126959126960126961126962126963126964126965126966126967126968126969126970126971126972126973126974126975126976126977126978126979126980126981126982126983126984126985126986126987126988126989126990126991126992126993126994126995126996126997126998126999127000127001127002127003127004127005127006127007127008127009127010127011127012127013127014127015127016127017127018127019127020127021127022127023127024127025127026127027127028127029127030127031127032127033127034127035127036127037127038127039127040127041127042127043127044127045127046127047127048127049127050127051127052127053127054127055127056127057127058127059127060127061127062127063127064127065127066127067127068127069127070127071127072127073127074127075127076127077127078127079127080127081127082127083127084127085127086127087127088127089127090127091127092127093127094127095127096127097127098127099127100127101127102127103127104127105127106127107127108127109127110127111127112127113127114127115127116127117127118127119127120127121127122127123127124127125127126127127127128127129127130127131127132127133127134127135127136127137127138127139127140127141127142127143127144127145127146127147127148127149127150127151127152127153127154127155127156127157127158127159127160127161127162127163127164127165127166127167127168127169127170127171127172127173127174127175127176127177127178127179127180127181127182127183127184127185127186127187127188127189127190127191127192127193127194127195127196127197127198127199127200127201127202127203127204127205127206127207127208127209127210127211127212127213127214127215127216127217127218127219127220127221127222127223127224127225127226127227127228127229127230127231127232127233127234127235127236127237127238127239127240127241127242127243127244127245127246127247127248127249127250127251127252127253127254127255127256127257127258127259127260127261127262127263127264127265127266127267127268127269127270127271127272127273127274127275127276127277127278127279127280127281127282127283127284127285127286127287127288127289127290127291127292127293127294127295127296127297127298127299127300127301127302127303127304127305127306127307127308127309127310127311127312127313127314127315127316127317127318127319127320127321127322127323127324127325127326127327127328127329127330127331127332127333127334127335127336127337127338127339127340127341127342127343127344127345127346127347127348127349127350127351127352127353127354127355127356127357127358127359127360127361127362127363127364127365127366127367127368127369127370127371127372127373127374127375127376127377127378127379127380127381127382127383127384127385127386127387127388127389127390127391127392127393127394127395127396127397127398127399127400127401127402127403127404127405127406127407127408127409127410127411127412127413127414127415127416127417127418127419127420127421127422127423127424127425127426127427127428127429127430127431127432127433127434127435127436127437127438127439127440127441127442127443127444127445127446127447127448127449127450127451127452127453127454127455127456127457127458127459127460127461127462127463127464127465127466127467127468127469127470127471127472127473127474127475127476127477127478127479127480127481127482127483127484127485127486127487127488127489127490127491127492127493127494127495127496127497127498127499127500127501127502127503127504127505127506127507127508127509127510127511127512127513127514127515127516127517127518127519127520127521127522127523127524127525127526127527127528127529127530127531127532127533127534127535127536127537127538127539127540127541127542127543127544127545127546127547127548127549127550127551127552127553127554127555127556127557127558127559127560127561127562127563127564127565127566127567127568127569127570127571127572127573127574127575127576127577127578127579127580127581127582127583127584127585127586127587127588127589127590127591127592127593127594127595127596127597127598127599127600127601127602127603127604127605127606127607127608127609127610127611127612127613127614127615127616127617127618127619127620127621127622127623127624127625127626127627127628127629127630127631127632127633127634127635127636127637127638127639127640127641127642127643127644127645127646127647127648127649127650127651127652127653127654127655127656127657127658127659127660127661127662127663127664127665127666127667127668127669127670127671127672127673127674127675127676127677127678127679127680127681127682127683127684127685127686127687127688127689127690127691127692127693127694127695127696127697127698127699127700127701127702127703127704127705127706127707127708127709127710127711127712127713127714127715127716127717127718127719127720127721127722127723127724127725127726127727127728127729127730127731127732127733127734127735127736127737127738127739127740127741127742127743127744127745127746127747127748127749127750127751127752127753127754127755127756127757127758127759127760127761127762127763127764127765127766127767127768127769127770127771127772127773127774127775127776127777127778127779127780127781127782127783127784127785127786127787127788127789127790127791127792127793127794127795127796127797127798127799127800127801127802127803127804127805127806127807127808127809127810127811127812127813127814127815127816127817127818127819127820127821127822127823127824127825127826127827127828127829127830127831127832127833127834127835127836127837127838127839127840127841127842127843127844127845127846127847127848127849127850127851127852127853127854127855127856127857127858127859127860127861127862127863127864127865127866127867127868127869127870127871127872127873127874127875127876127877127878127879127880127881127882127883127884127885127886127887127888127889127890127891127892127893127894127895127896127897127898127899127900127901127902127903127904127905127906127907127908127909127910127911127912127913127914127915127916127917127918127919127920127921127922127923127924127925127926127927127928127929127930127931127932127933127934127935127936127937127938127939127940127941127942127943127944127945127946127947127948127949127950127951127952127953127954127955127956127957127958127959127960127961127962127963127964127965127966127967127968127969127970127971127972127973127974127975127976127977127978127979127980127981127982127983127984127985127986127987127988127989127990127991127992127993127994127995127996127997127998127999128000128001128002128003128004128005128006128007128008128009128010128011128012128013128014128015128016128017128018128019128020128021128022128023128024128025128026128027128028128029128030128031128032128033128034128035128036128037128038128039128040128041128042128043128044128045128046128047128048128049128050128051128052128053128054128055128056128057128058128059128060128061128062128063128064128065128066128067128068128069128070128071128072128073128074128075128076128077128078128079128080128081128082128083128084128085128086128087128088128089128090128091128092128093128094128095128096128097128098128099128100128101128102128103128104128105128106128107128108128109128110128111128112128113128114128115128116128117128118128119128120128121128122128123128124128125128126128127128128128129128130128131128132128133128134128135128136128137128138128139128140128141128142128143128144128145128146128147128148128149128150128151128152128153128154128155128156128157128158128159128160128161128162128163128164128165128166128167128168128169128170128171128172128173128174128175128176128177128178128179128180128181128182128183128184128185128186128187128188128189128190128191128192128193128194128195128196128197128198128199128200128201128202128203128204128205128206128207128208128209128210128211128212128213128214128215128216128217128218128219128220128221128222128223128224128225128226128227128228128229128230128231128232128233128234128235128236128237128238128239128240128241128242128243128244128245128246128247128248128249128250128251128252128253128254128255128256128257128258128259128260128261128262128263128264128265128266128267128268128269128270128271128272128273128274128275128276128277128278128279128280128281128282128283128284128285128286128287128288128289128290128291128292128293128294128295128296128297128298128299128300128301128302128303128304128305128306128307128308128309128310128311128312128313128314128315128316128317128318128319128320128321128322128323128324128325128326128327128328128329128330128331128332128333128334128335128336128337128338128339128340128341128342128343128344128345128346128347128348128349128350128351128352128353128354128355128356128357128358128359128360128361128362128363128364128365128366128367128368128369128370128371128372128373128374128375128376128377128378128379128380128381128382128383128384128385128386128387128388128389128390128391128392128393128394128395128396128397128398128399128400128401128402128403128404128405128406128407128408128409128410128411128412128413128414128415128416128417128418128419128420128421128422128423128424128425128426128427128428128429128430128431128432128433128434128435128436128437128438128439128440128441128442128443128444128445128446128447128448128449128450128451128452128453128454128455128456128457128458128459128460128461128462128463128464128465128466128467128468128469128470128471128472128473128474128475128476128477128478128479128480128481128482128483128484128485128486128487128488128489128490128491128492128493128494128495128496128497128498128499128500128501128502128503128504128505128506128507128508128509128510128511128512128513128514128515128516128517128518128519128520128521128522128523128524128525128526128527128528128529128530128531128532128533128534128535128536128537128538128539128540128541128542128543128544128545128546128547128548128549128550128551128552128553128554128555128556128557128558128559128560128561128562128563128564128565128566128567128568128569128570128571128572128573128574128575128576128577128578128579128580128581128582128583128584128585128586128587128588128589128590128591128592128593128594128595128596128597128598128599128600128601128602128603128604128605128606128607128608128609128610128611128612128613128614128615128616128617128618128619128620128621128622128623128624128625128626128627128628128629128630128631128632128633128634128635128636128637128638128639128640128641128642128643128644128645128646128647128648128649128650128651128652128653128654128655128656128657128658128659128660128661128662128663128664128665128666128667128668128669128670128671128672128673128674128675128676128677128678128679128680128681128682128683128684128685128686128687128688128689128690128691128692128693128694128695128696128697128698128699128700128701128702128703128704128705128706128707128708128709128710128711128712128713128714128715128716128717128718128719128720128721128722128723128724128725128726128727128728128729128730128731128732128733128734128735128736128737128738128739128740128741128742128743128744128745128746128747128748128749128750128751128752128753128754128755128756128757128758128759128760128761128762128763128764128765128766128767128768128769128770128771128772128773128774128775128776128777128778128779128780128781128782128783128784128785128786128787128788128789128790128791128792128793128794128795128796128797128798128799128800128801128802128803128804128805128806128807128808128809128810128811128812128813128814128815128816128817128818128819128820128821128822128823128824128825128826128827128828128829128830128831128832128833128834128835128836128837128838128839128840128841128842128843128844128845128846128847128848128849128850128851128852128853128854128855128856128857128858128859128860128861128862128863128864128865128866128867128868128869128870128871128872128873128874128875128876128877128878128879128880128881128882128883128884128885128886128887128888128889128890128891128892128893128894128895128896128897128898128899128900128901128902128903128904128905128906128907128908128909128910128911128912128913128914128915128916128917128918128919128920128921128922128923128924128925128926128927128928128929128930128931128932128933128934128935128936128937128938128939128940128941128942128943128944128945128946128947128948128949128950128951128952128953128954128955128956128957128958128959128960128961128962128963128964128965128966128967128968128969128970128971128972128973128974128975128976128977128978128979128980128981128982128983128984128985128986128987128988128989128990128991128992128993128994128995128996128997128998128999129000129001129002129003129004129005129006129007129008129009129010129011129012129013129014129015129016129017129018129019129020129021129022129023129024129025129026129027129028129029129030129031129032129033129034129035129036129037129038129039129040129041129042129043129044129045129046129047129048129049129050129051129052129053129054129055129056129057129058129059129060129061129062129063129064129065129066129067129068129069129070129071129072129073129074129075129076129077129078129079129080129081129082129083129084129085129086129087129088129089129090129091129092129093129094129095129096129097129098129099129100129101129102129103129104129105129106129107129108129109129110129111129112129113129114129115129116129117129118129119129120129121129122129123129124129125129126129127129128129129129130129131129132129133129134129135129136129137129138129139129140129141129142129143129144129145129146129147129148129149129150129151129152129153129154129155129156129157129158129159129160129161129162129163129164129165129166129167129168129169129170129171129172129173129174129175129176129177129178129179129180129181129182129183129184129185129186129187129188129189129190129191129192129193129194129195129196129197129198129199129200129201129202129203129204129205129206129207129208129209129210129211129212129213129214129215129216129217129218129219129220129221129222129223129224129225129226129227129228129229129230129231129232129233129234129235129236129237129238129239129240129241129242129243129244129245129246129247129248129249129250129251129252129253129254129255129256129257129258129259129260129261129262129263129264129265129266129267129268129269129270129271129272129273129274129275129276129277129278129279129280129281129282129283129284129285129286129287129288129289129290129291129292129293129294129295129296129297129298129299129300129301129302129303129304129305129306129307129308129309129310129311129312129313129314129315129316129317129318129319129320129321129322129323129324129325129326129327129328129329129330129331129332129333129334129335129336129337129338129339129340129341129342129343129344129345129346129347129348129349129350129351129352129353129354129355129356129357129358129359129360129361129362129363129364129365129366129367129368129369129370129371129372129373129374129375129376129377129378129379129380129381129382129383129384129385129386129387129388129389129390129391129392129393129394129395129396129397129398129399129400129401129402129403129404129405129406129407129408129409129410129411129412129413129414129415129416129417129418129419129420129421129422129423129424129425129426129427129428129429129430129431129432129433129434129435129436129437129438129439129440129441129442129443129444129445129446129447129448129449129450129451129452129453129454129455129456129457129458129459129460129461129462129463129464129465129466129467129468129469129470129471129472129473129474129475129476129477129478129479129480129481129482129483129484129485129486129487129488129489129490129491129492129493129494129495129496129497129498129499129500129501129502129503129504129505129506129507129508129509129510129511129512129513129514129515129516129517129518129519129520129521129522129523129524129525129526129527129528129529129530129531129532129533129534129535129536129537129538129539129540129541129542129543129544129545129546129547129548129549129550129551129552129553129554129555129556129557129558129559129560129561129562129563129564129565129566129567129568129569129570129571129572129573129574129575129576129577129578129579129580129581129582129583129584129585129586129587129588129589129590129591129592129593129594129595129596129597129598129599129600129601129602129603129604129605129606129607129608129609129610129611129612129613129614129615129616129617129618129619129620129621129622129623129624129625129626129627129628129629129630129631129632129633129634129635129636129637129638129639129640129641129642129643129644129645129646129647129648129649129650129651129652129653129654129655129656129657129658129659129660129661129662129663129664129665129666129667129668129669129670129671129672129673129674129675129676129677129678129679129680129681129682129683129684129685129686129687129688129689129690129691129692129693129694129695129696129697129698129699129700129701129702129703129704129705129706129707129708129709129710129711129712129713129714129715129716129717129718129719129720129721129722129723129724129725129726129727129728129729129730129731129732129733129734129735129736129737129738129739129740129741129742129743129744129745129746129747129748129749129750129751129752129753129754129755129756129757129758129759129760129761129762129763129764129765129766129767129768129769129770129771129772129773129774129775129776129777129778129779129780129781129782129783129784129785129786129787129788129789129790129791129792129793129794129795129796129797129798129799129800129801129802129803129804129805129806129807129808129809129810129811129812129813129814129815129816129817129818129819129820129821129822129823129824129825129826129827129828129829129830129831129832129833129834129835129836129837129838129839129840129841129842129843129844129845129846129847129848129849129850129851129852129853129854129855129856129857129858129859129860129861129862129863129864129865129866129867129868129869129870129871129872129873129874129875129876129877129878129879129880129881129882129883129884129885129886129887129888129889129890129891129892129893129894129895129896129897129898129899129900129901129902129903129904129905129906129907129908129909129910129911129912129913129914129915129916129917129918129919129920129921129922129923129924129925129926129927129928129929129930129931129932129933129934129935129936129937129938129939129940129941129942129943129944129945129946129947129948129949129950129951129952129953129954129955129956129957129958129959129960129961129962129963129964129965129966129967129968129969129970129971129972129973129974129975129976129977129978129979129980129981129982129983129984129985129986129987129988129989129990129991129992129993129994129995129996129997129998129999130000130001130002130003130004130005130006130007130008130009130010130011130012130013130014130015130016130017130018130019130020130021130022130023130024130025130026130027130028130029130030130031130032130033130034130035130036130037130038130039130040130041130042130043130044130045130046130047130048130049130050130051130052130053130054130055130056130057130058130059130060130061130062130063130064130065130066130067130068130069130070130071130072130073130074130075130076130077130078130079130080130081130082130083130084130085130086130087130088130089130090130091130092130093130094130095130096130097130098130099130100130101130102130103130104130105130106130107130108130109130110130111130112130113130114130115130116130117130118130119130120130121130122130123130124130125130126130127130128130129130130130131130132130133130134130135130136130137130138130139130140130141130142130143130144130145130146130147130148130149130150130151130152130153130154130155130156130157130158130159130160130161130162130163130164130165130166130167130168130169130170130171130172130173130174130175130176130177130178130179130180130181130182130183130184130185130186130187130188130189130190130191130192130193130194130195130196130197130198130199130200130201130202130203130204130205130206130207130208130209130210130211130212130213130214130215130216130217130218130219130220130221130222130223130224130225130226130227130228130229130230130231130232130233130234130235130236130237130238130239130240130241130242130243130244130245130246130247130248130249130250130251130252130253130254130255130256130257130258130259130260130261130262130263130264130265130266130267130268130269130270130271130272130273130274130275130276130277130278130279130280130281130282130283130284130285130286130287130288130289130290130291130292130293130294130295130296130297130298130299130300130301130302130303130304130305130306130307130308130309130310130311130312130313130314130315130316130317130318130319130320130321130322130323130324130325130326130327130328130329130330130331130332130333130334130335130336130337130338130339130340130341130342130343130344130345130346130347130348130349130350130351130352130353130354130355130356130357130358130359130360130361130362130363130364130365130366130367130368130369130370130371130372130373130374130375130376130377130378130379130380130381130382130383130384130385130386130387130388130389130390130391130392130393130394130395130396130397130398130399130400130401130402130403130404130405130406130407130408130409130410130411130412130413130414130415130416130417130418130419130420130421130422130423130424130425130426130427130428130429130430130431130432130433130434130435130436130437130438130439130440130441130442130443130444130445130446130447130448130449130450130451130452130453130454130455130456130457130458130459130460130461130462130463130464130465130466130467130468130469130470130471130472130473130474130475130476130477130478130479130480130481130482130483130484130485130486130487130488130489130490130491130492130493130494130495130496130497130498130499130500130501130502130503130504130505130506130507130508130509130510130511130512130513130514130515130516130517130518130519130520130521130522130523130524130525130526130527130528130529130530130531130532130533130534130535130536130537130538130539130540130541130542130543130544130545130546130547130548130549130550130551130552130553130554130555130556130557130558130559130560130561130562130563130564130565130566130567130568130569130570130571130572130573130574130575130576130577130578130579130580130581130582130583130584130585130586130587130588130589130590130591130592130593130594130595130596130597130598130599130600130601130602130603130604130605130606130607130608130609130610130611130612130613130614130615130616130617130618130619130620130621130622130623130624130625130626130627130628130629130630130631130632130633130634130635130636130637130638130639130640130641130642130643130644130645130646130647130648130649130650130651130652130653130654130655130656130657130658130659130660130661130662130663130664130665130666130667130668130669130670130671130672130673130674130675130676130677130678130679130680130681130682130683130684130685130686130687130688130689130690130691130692130693130694130695130696130697130698130699130700130701130702130703130704130705130706130707130708130709130710130711130712130713130714130715130716130717130718130719130720130721130722130723130724130725130726130727130728130729130730130731130732130733130734130735130736130737130738130739130740130741130742130743130744130745130746130747130748130749130750130751130752130753130754130755130756130757130758130759130760130761130762130763130764130765130766130767130768130769130770130771130772130773130774130775130776130777130778130779130780130781130782130783130784130785130786130787130788130789130790130791130792130793130794130795130796130797130798130799130800130801130802130803130804130805130806130807130808130809130810130811130812130813130814130815130816130817130818130819130820130821130822130823130824130825130826130827130828130829130830130831130832130833130834130835130836130837130838130839130840130841130842130843130844130845130846130847130848130849130850130851130852130853130854130855130856130857130858130859130860130861130862130863130864130865130866130867130868130869130870130871130872130873130874130875130876130877130878130879130880130881130882130883130884130885130886130887130888130889130890130891130892130893130894130895130896130897130898130899130900130901130902130903130904130905130906130907130908130909130910130911130912130913130914130915130916130917130918130919130920130921130922130923130924130925130926130927130928130929130930130931130932130933130934130935130936130937130938130939130940130941130942130943130944130945130946130947130948130949130950130951130952130953130954130955130956130957130958130959130960130961130962130963130964130965130966130967130968130969130970130971130972130973130974130975130976130977130978130979130980130981130982130983130984130985130986130987130988130989130990130991130992130993130994130995130996130997130998130999131000131001131002131003131004131005131006131007131008131009131010131011131012131013131014131015131016131017131018131019131020131021131022131023131024131025131026131027131028131029131030131031131032131033131034131035131036131037131038131039131040131041131042131043131044131045131046131047131048131049131050131051131052131053131054131055131056131057131058131059131060131061131062131063131064131065131066131067131068131069131070131071131072131073131074131075131076131077131078131079131080131081131082131083131084131085131086131087131088131089131090131091131092131093131094131095131096131097131098131099131100131101131102131103131104131105131106131107131108131109131110131111131112131113131114131115131116131117131118131119131120131121131122131123131124131125131126131127131128131129131130131131131132131133131134131135131136131137131138131139131140131141131142131143131144131145131146131147131148131149131150131151131152131153131154131155131156131157131158131159131160131161131162131163131164131165131166131167131168131169131170131171131172131173131174131175131176131177131178131179131180131181131182131183131184131185131186131187131188131189131190131191131192131193131194131195131196131197131198131199131200131201131202131203131204131205131206131207131208131209131210131211131212131213131214131215131216131217131218131219131220131221131222131223131224131225131226131227131228131229131230131231131232131233131234131235131236131237131238131239131240131241131242131243131244131245131246131247131248131249131250131251131252131253131254131255131256131257131258131259131260131261131262131263131264131265131266131267131268131269131270131271131272131273131274131275131276131277131278131279131280131281131282131283131284131285131286131287131288131289131290131291131292131293131294131295131296131297131298131299131300131301131302131303131304131305131306131307131308131309131310131311131312131313131314131315131316131317131318131319131320131321131322131323131324131325131326131327131328131329131330131331131332131333131334131335131336131337131338131339131340131341131342131343131344131345131346131347131348131349131350131351131352131353131354131355131356131357131358131359131360131361131362131363131364131365131366131367131368131369131370131371131372131373131374131375131376131377131378131379131380131381131382131383131384131385131386131387131388131389131390131391131392131393131394131395131396131397131398131399131400131401131402131403131404131405131406131407131408131409131410131411131412131413131414131415131416131417131418131419131420131421131422131423131424131425131426131427131428131429131430131431131432131433131434131435131436131437131438131439131440131441131442131443131444131445131446131447131448131449131450131451131452131453131454131455131456131457131458131459131460131461131462131463131464131465131466131467131468131469131470131471131472131473131474131475131476131477131478131479131480131481131482131483131484131485131486131487131488131489131490131491131492131493131494131495131496131497131498131499131500131501131502131503131504131505131506131507131508131509131510131511131512131513131514131515131516131517131518131519131520131521131522131523131524131525131526131527131528131529131530131531131532131533131534131535131536131537131538131539131540131541131542131543131544131545131546131547131548131549131550131551131552131553131554131555131556131557131558131559131560131561131562131563131564131565131566131567131568131569131570131571131572131573131574131575131576131577131578131579131580131581131582131583131584131585131586131587131588131589131590131591131592131593131594131595131596131597131598131599131600131601131602131603131604131605131606131607131608131609131610131611131612131613131614131615131616131617131618131619131620131621131622131623131624131625131626131627131628131629131630131631131632131633131634131635131636131637131638131639131640131641131642131643131644131645131646131647131648131649131650131651131652131653131654131655131656131657131658131659131660131661131662131663131664131665131666131667131668131669131670131671131672131673131674131675131676131677131678131679131680131681131682131683131684131685131686131687131688131689131690131691131692131693131694131695131696131697131698131699131700131701131702131703131704131705131706131707131708131709131710131711131712131713131714131715131716131717131718131719131720131721131722131723131724131725131726131727131728131729131730131731131732131733131734131735131736131737131738131739131740131741131742131743131744131745131746131747131748131749131750131751131752131753131754131755131756131757131758131759131760131761131762131763131764131765131766131767131768131769131770131771131772131773131774131775131776131777131778131779131780131781131782131783131784131785131786131787131788131789131790131791131792131793131794131795131796131797131798131799131800131801131802131803131804131805131806131807131808131809131810131811131812131813131814131815131816131817131818131819131820131821131822131823131824131825131826131827131828131829131830131831131832131833131834131835131836131837131838131839131840131841131842131843131844131845131846131847131848131849131850131851131852131853131854131855131856131857131858131859131860131861131862131863131864131865131866131867131868131869131870131871131872131873131874131875131876131877131878131879131880131881131882131883131884131885131886131887131888131889131890131891131892131893131894131895131896131897131898131899131900131901131902131903131904131905131906131907131908131909131910131911131912131913131914131915131916131917131918131919131920131921131922131923131924131925131926131927131928131929131930131931131932131933131934131935131936131937131938131939131940131941131942131943131944131945131946131947131948131949131950131951131952131953131954131955131956131957131958131959131960131961131962131963131964131965131966131967131968131969131970131971131972131973131974131975131976131977131978131979131980131981131982131983131984131985131986131987131988131989131990131991131992131993131994131995131996131997131998131999132000132001132002132003132004132005132006132007132008132009132010132011132012132013132014132015132016132017132018132019132020132021132022132023132024132025132026132027132028132029132030132031132032132033132034132035132036132037132038132039132040132041132042132043132044132045132046132047132048132049132050132051132052132053132054132055132056132057132058132059132060132061132062132063132064132065132066132067132068132069132070132071132072132073132074132075132076132077132078132079132080132081132082132083132084132085132086132087132088132089132090132091132092132093132094132095132096132097132098132099132100132101132102132103132104132105132106132107132108132109132110132111132112132113132114132115132116132117132118132119132120132121132122132123132124132125132126132127132128132129132130132131132132132133132134132135132136132137132138132139132140132141132142132143132144132145132146132147132148132149132150132151132152132153132154132155132156132157132158132159132160132161132162132163132164132165132166132167132168132169132170132171132172132173132174132175132176132177132178132179132180132181132182132183132184132185132186132187132188132189132190132191132192132193132194132195132196132197132198132199132200132201132202132203132204132205132206132207132208132209132210132211132212132213132214132215132216132217132218132219132220132221132222132223132224132225132226132227132228132229132230132231132232132233132234132235132236132237132238132239132240132241132242132243132244132245132246132247132248132249132250132251132252132253132254132255132256132257132258132259132260132261132262132263132264132265132266132267132268132269132270132271132272132273132274132275132276132277132278132279132280132281132282132283132284132285132286132287132288132289132290132291132292132293132294132295132296132297132298132299132300132301132302132303132304132305132306132307132308132309132310132311132312132313132314132315132316132317132318132319132320132321132322132323132324132325132326132327132328132329132330132331132332132333132334132335132336132337132338132339132340132341132342132343132344132345132346132347132348132349132350132351132352132353132354132355132356132357132358132359132360132361132362132363132364132365132366132367132368132369132370132371132372132373132374132375132376132377132378132379132380132381132382132383132384132385132386132387132388132389132390132391132392132393132394132395132396132397132398132399132400132401132402132403132404132405132406132407132408132409132410132411132412132413132414132415132416132417132418132419132420132421132422132423132424132425132426132427132428132429132430132431132432132433132434132435132436132437132438132439132440132441132442132443132444132445132446132447132448132449132450132451132452132453132454132455132456132457132458132459132460132461132462132463132464132465132466132467132468132469132470132471132472132473132474132475132476132477132478132479132480132481132482132483132484132485132486132487132488132489132490132491132492132493132494132495132496132497132498132499132500132501132502132503132504132505132506132507132508132509132510132511132512132513132514132515132516132517132518132519132520132521132522132523132524132525132526132527132528132529132530132531132532132533132534132535132536132537132538132539132540132541132542132543132544132545132546132547132548132549132550132551132552132553132554132555132556132557132558132559132560132561132562132563132564132565132566132567132568132569132570132571132572132573132574132575132576132577132578132579132580132581132582132583132584132585132586132587132588132589132590132591132592132593132594132595132596132597132598132599132600132601132602132603132604132605132606132607132608132609132610132611132612132613132614132615132616132617132618132619132620132621132622132623132624132625132626132627132628132629132630132631132632132633132634132635132636132637132638132639132640132641132642132643132644132645132646132647132648132649132650132651132652132653132654132655132656132657132658132659132660132661132662132663132664132665132666132667132668132669132670132671132672132673132674132675132676132677132678132679132680132681132682132683132684132685132686132687132688132689132690132691132692132693132694132695132696132697132698132699132700132701132702132703132704132705132706132707132708132709132710132711132712132713132714132715132716132717132718132719132720132721132722132723132724132725132726132727132728132729132730132731132732132733132734132735132736132737132738132739132740132741132742132743132744132745132746132747132748132749132750132751132752132753132754132755132756132757132758132759132760132761132762132763132764132765132766132767132768132769132770132771132772132773132774132775132776132777132778132779132780132781132782132783132784132785132786132787132788132789132790132791132792132793132794132795132796132797132798132799132800132801132802132803132804132805132806132807132808132809132810132811132812132813132814132815132816132817132818132819132820132821132822132823132824132825132826132827132828132829132830132831132832132833132834132835132836132837132838132839132840132841132842132843132844132845132846132847132848132849132850132851132852132853132854132855132856132857132858132859132860132861132862132863132864132865132866132867132868132869132870132871132872132873132874132875132876132877132878132879132880132881132882132883132884132885132886132887132888132889132890132891132892132893132894132895132896132897132898132899132900132901132902132903132904132905132906132907132908132909132910132911132912132913132914132915132916132917132918132919132920132921132922132923132924132925132926132927132928132929132930132931132932132933132934132935132936132937132938132939132940132941132942132943132944132945132946132947132948132949132950132951132952132953132954132955132956132957132958132959132960132961132962132963132964132965132966132967132968132969132970132971132972132973132974132975132976132977132978132979132980132981132982132983132984132985132986132987132988132989132990132991132992132993132994132995132996132997132998132999133000133001133002133003133004133005133006133007133008133009133010133011133012133013133014133015133016133017133018133019133020133021133022133023133024133025133026133027133028133029133030133031133032133033133034133035133036133037133038133039133040133041133042133043133044133045133046133047133048133049133050133051133052133053133054133055133056133057133058133059133060133061133062133063133064133065133066133067133068133069133070133071133072133073133074133075133076133077133078133079133080133081133082133083133084133085133086133087133088133089133090133091133092133093133094133095133096133097133098133099133100133101133102133103133104133105133106133107133108133109133110133111133112133113133114133115133116133117133118133119133120133121133122133123133124133125133126133127133128133129133130133131133132133133133134133135133136133137133138133139133140133141133142133143133144133145133146133147133148133149133150133151133152133153133154133155133156133157133158133159133160133161133162133163133164133165133166133167133168133169133170133171133172133173133174133175133176133177133178133179133180133181133182133183133184133185133186133187133188133189133190133191133192133193133194133195133196133197133198133199133200133201133202133203133204133205133206133207133208133209133210133211133212133213133214133215133216133217133218133219133220133221133222133223133224133225133226133227133228133229133230133231133232133233133234133235133236133237133238133239133240133241133242133243133244133245133246133247133248133249133250133251133252133253133254133255133256133257133258133259133260133261133262133263133264133265133266133267133268133269133270133271133272133273133274133275133276133277133278133279133280133281133282133283133284133285133286133287133288133289133290133291133292133293133294133295133296133297133298133299133300133301133302133303133304133305133306133307133308133309133310133311133312133313133314133315133316133317133318133319133320133321133322133323133324133325133326133327133328133329133330133331133332133333133334133335133336133337133338133339133340133341133342133343133344133345133346133347133348133349133350133351133352133353133354133355133356133357133358133359133360133361133362133363133364133365133366133367133368133369133370133371133372133373133374133375133376133377133378133379133380133381133382133383133384133385133386133387133388133389133390133391133392133393133394133395133396133397133398133399133400133401133402133403133404133405133406133407133408133409133410133411133412133413133414133415133416133417133418133419133420133421133422133423133424133425133426133427133428133429133430133431133432133433133434133435133436133437133438133439133440133441133442133443133444133445133446133447133448133449133450133451133452133453133454133455133456133457133458133459133460133461133462133463133464133465133466133467133468133469133470133471133472133473133474133475133476133477133478133479133480133481133482133483133484133485133486133487133488133489133490133491133492133493133494133495133496133497133498133499133500133501133502133503133504133505133506133507133508133509133510133511133512133513133514133515133516133517133518133519133520133521133522133523133524133525133526133527133528133529133530133531133532133533133534133535133536133537133538133539133540133541133542133543133544133545133546133547133548133549133550133551133552133553133554133555133556133557133558133559133560133561133562133563133564133565133566133567133568133569133570133571133572133573133574133575133576133577133578133579133580133581133582133583133584133585133586133587133588133589133590133591133592133593133594133595133596133597133598133599133600133601133602133603133604133605133606133607133608133609133610133611133612133613133614133615133616133617133618133619133620133621133622133623133624133625133626133627133628133629133630133631133632133633133634133635133636133637133638133639133640133641133642133643133644133645133646133647133648133649133650133651133652133653133654133655133656133657133658133659133660133661133662133663133664133665133666133667133668133669133670133671133672133673133674133675133676133677133678133679133680133681133682133683133684133685133686133687133688133689133690133691133692133693133694133695133696133697133698133699133700133701133702133703133704133705133706133707133708133709133710133711133712133713133714133715133716133717133718133719133720133721133722133723133724133725133726133727133728133729133730133731133732133733133734133735133736133737133738133739133740133741133742133743133744133745133746133747133748133749133750133751133752133753133754133755133756133757133758133759133760133761133762133763133764133765133766133767133768133769133770133771133772133773133774133775133776133777133778133779133780133781133782133783133784133785133786133787133788133789133790133791133792133793133794133795133796133797133798133799133800133801133802133803133804133805133806133807133808133809133810133811133812133813133814133815133816133817133818133819133820133821133822133823133824133825133826133827133828133829133830133831133832133833133834133835133836133837133838133839133840133841133842133843133844133845133846133847133848133849133850133851133852133853133854133855133856133857133858133859133860133861133862133863133864133865133866133867133868133869133870133871133872133873133874133875133876133877133878133879133880133881133882133883133884133885133886133887133888133889133890133891133892133893133894133895133896133897133898133899133900133901133902133903133904133905133906133907133908133909133910133911133912133913133914133915133916133917133918133919133920133921133922133923133924133925133926133927133928133929133930133931133932133933133934133935133936133937133938133939133940133941133942133943133944133945133946133947133948133949133950133951133952133953133954133955133956133957133958133959133960133961133962133963133964133965133966133967133968133969133970133971133972133973133974133975133976133977133978133979133980133981133982133983133984133985133986133987133988133989133990133991133992133993133994133995133996133997133998133999134000134001134002134003134004134005134006134007134008134009134010134011134012134013134014134015134016134017134018134019134020134021134022134023134024134025134026134027134028134029134030134031134032134033134034134035134036134037134038134039134040134041134042134043134044134045134046134047134048134049134050134051134052134053134054134055134056134057134058134059134060134061134062134063134064134065134066134067134068134069134070134071134072134073134074134075134076134077134078134079134080134081134082134083134084134085134086134087134088134089134090134091134092134093134094134095134096134097134098134099134100134101134102134103134104134105134106134107134108134109134110134111134112134113134114134115134116134117134118134119134120134121134122134123134124134125134126134127134128134129134130134131134132134133134134134135134136134137134138134139134140134141134142134143134144134145134146134147134148134149134150134151134152134153134154134155134156134157134158134159134160134161134162134163134164134165134166134167134168134169134170134171134172134173134174134175134176134177134178134179134180134181134182134183134184134185134186134187134188134189134190134191134192134193134194134195134196134197134198134199134200134201134202134203134204134205134206134207134208134209134210134211134212134213134214134215134216134217134218134219134220134221134222134223134224134225134226134227134228134229134230134231134232134233134234134235134236134237134238134239134240134241134242134243134244134245134246134247134248134249134250134251134252134253134254134255134256134257134258134259134260134261134262134263134264134265134266134267134268134269134270134271134272134273134274134275134276134277134278134279134280134281134282134283134284134285134286134287134288134289134290134291134292134293134294134295134296134297134298134299134300134301134302134303134304134305134306134307134308134309134310134311134312134313134314134315134316134317134318134319134320134321134322134323134324134325134326134327134328134329134330134331134332134333134334134335134336134337134338134339134340134341134342134343134344134345134346134347134348134349134350134351134352134353134354134355134356134357134358134359134360134361134362134363134364134365134366134367134368134369134370134371134372134373134374134375134376134377134378134379134380134381134382134383134384134385134386134387134388134389134390134391134392134393134394134395134396134397134398134399134400134401134402134403134404134405134406134407134408134409134410134411134412134413134414134415134416134417134418134419134420134421134422134423134424134425134426134427134428134429134430134431134432134433134434134435134436134437134438134439134440134441134442134443134444134445134446134447134448134449134450134451134452134453134454134455134456134457134458134459134460134461134462134463134464134465134466134467134468134469134470134471134472134473134474134475134476134477134478134479134480134481134482134483134484134485134486134487134488134489134490134491134492134493134494134495134496134497134498134499134500134501134502134503134504134505134506134507134508134509134510134511134512134513134514134515134516134517134518134519134520134521134522134523134524134525134526134527134528134529134530134531134532134533134534134535134536134537134538134539134540134541134542134543134544134545134546134547134548134549134550134551134552134553134554134555134556134557134558134559134560134561134562134563134564134565134566134567134568134569134570134571134572134573134574134575134576134577134578134579134580134581134582134583134584134585134586134587134588134589134590134591134592134593134594134595134596134597134598134599134600134601134602134603134604134605134606134607134608134609134610134611134612134613134614134615134616134617134618134619134620134621134622134623134624134625134626134627134628134629134630134631134632134633134634134635134636134637134638134639134640134641134642134643134644134645134646134647134648134649134650134651134652134653134654134655134656134657134658134659134660134661134662134663134664134665134666134667134668134669134670134671134672134673134674134675134676134677134678134679134680134681134682134683134684134685134686134687134688134689134690134691134692134693134694134695134696134697134698134699134700134701134702134703134704134705134706134707134708134709134710134711134712134713134714134715134716134717134718134719134720134721134722134723134724134725134726134727134728134729134730134731134732134733134734134735134736134737134738134739134740134741134742134743134744134745134746134747134748134749134750134751134752134753134754134755134756134757134758134759134760134761134762134763134764134765134766134767134768134769134770134771134772134773134774134775134776134777134778134779134780134781134782134783134784134785134786134787134788134789134790134791134792134793134794134795134796134797134798134799134800134801134802134803134804134805134806134807134808134809134810134811134812134813134814134815134816134817134818134819134820134821134822134823134824134825134826134827134828134829134830134831134832134833134834134835134836134837134838134839134840134841134842134843134844134845134846134847134848134849134850134851134852134853134854134855134856134857134858134859134860134861134862134863134864134865134866134867134868134869134870134871134872134873134874134875134876134877134878134879134880134881134882134883134884134885134886134887134888134889134890134891134892134893134894134895134896134897134898134899134900134901134902134903134904134905134906134907134908134909134910134911134912134913134914134915134916134917134918134919134920134921134922134923134924134925134926134927134928134929134930134931134932134933134934134935134936134937134938134939134940134941134942134943134944134945134946134947134948134949134950134951134952134953134954134955134956134957134958134959134960134961134962134963134964134965134966134967134968134969134970134971134972134973134974134975134976134977134978134979134980134981134982134983134984134985134986134987134988134989134990134991134992134993134994134995134996134997134998134999135000135001135002135003135004135005135006135007135008135009135010135011135012135013135014135015135016135017135018135019135020135021135022135023135024135025135026135027135028135029135030135031135032135033135034135035135036135037135038135039135040135041135042135043135044135045135046135047135048135049135050135051135052135053135054135055135056135057135058135059135060135061135062135063135064135065135066135067135068135069135070135071135072135073135074135075135076135077135078135079135080135081135082135083135084135085135086135087135088135089135090135091135092135093135094135095135096135097135098135099135100135101135102135103135104135105135106135107135108135109135110135111135112135113135114135115135116135117135118135119135120135121135122135123135124135125135126135127135128135129135130135131135132135133135134135135135136135137135138135139135140135141135142135143135144135145135146135147135148135149135150135151135152135153135154135155135156135157135158135159135160135161135162135163135164135165135166135167135168135169135170135171135172135173135174135175135176135177135178135179135180135181135182135183135184135185135186135187135188135189135190135191135192135193135194135195135196135197135198135199135200135201135202135203135204135205135206135207135208135209135210135211135212135213135214135215135216135217135218135219135220135221135222135223135224135225135226135227135228135229135230135231135232135233135234135235135236135237135238135239135240135241135242135243135244135245135246135247135248135249135250135251135252135253135254135255135256135257135258135259135260135261135262135263135264135265135266135267135268135269135270135271135272135273135274135275135276135277135278135279135280135281135282135283135284135285135286135287135288135289135290135291135292135293135294135295135296135297135298135299135300135301135302135303135304135305135306135307135308135309135310135311135312135313135314135315135316135317135318135319135320135321135322135323135324135325135326135327135328135329135330135331135332135333135334135335135336135337135338135339135340135341135342135343135344135345135346135347135348135349135350135351135352135353135354135355135356135357135358135359135360135361135362135363135364135365135366135367135368135369135370135371135372135373135374135375135376135377135378135379135380135381135382135383135384135385135386135387135388135389135390135391135392135393135394135395135396135397135398135399135400135401135402135403135404135405135406135407135408135409135410135411135412135413135414135415135416135417135418135419135420135421135422135423135424135425135426135427135428135429135430135431135432135433135434135435135436135437135438135439135440135441135442135443135444135445135446135447135448135449135450135451135452135453135454135455135456135457135458135459135460135461135462135463135464135465135466135467135468135469135470135471135472135473135474135475135476135477135478135479135480135481135482135483135484135485135486135487135488135489135490135491135492135493135494135495135496135497135498135499135500135501135502135503135504135505135506135507135508135509135510135511135512135513135514135515135516135517135518135519135520135521135522135523135524135525135526135527135528135529135530135531135532135533135534135535135536135537135538135539135540135541135542135543135544135545135546135547135548135549135550135551135552135553135554135555135556135557135558135559135560135561135562135563135564135565135566135567135568135569135570135571135572135573135574135575135576135577135578135579135580135581135582135583135584135585135586135587135588135589135590135591135592135593135594135595135596135597135598135599135600135601135602135603135604135605135606135607135608135609135610135611135612135613135614135615135616135617135618135619135620135621135622135623135624135625135626135627135628135629135630135631135632135633135634135635135636135637135638135639135640135641135642135643135644135645135646135647135648135649135650135651135652135653135654135655135656135657135658135659135660135661135662135663135664135665135666135667135668135669135670135671135672135673135674135675135676135677135678135679135680135681135682135683135684135685135686135687135688135689135690135691135692135693135694135695135696135697135698135699135700135701135702135703135704135705135706135707135708135709135710135711135712135713135714135715135716135717135718135719135720135721135722135723135724135725135726135727135728135729135730135731135732135733135734135735135736135737135738135739135740135741135742135743135744135745135746135747135748135749135750135751135752135753135754135755135756135757135758135759135760135761135762135763135764135765135766135767135768135769135770135771135772135773135774135775135776135777135778135779135780135781135782135783135784135785135786135787135788135789135790135791135792135793135794135795135796135797135798135799135800135801135802135803135804135805135806135807135808135809135810135811135812135813135814135815135816135817135818135819135820135821135822135823135824135825135826135827135828135829135830135831135832135833135834135835135836135837135838135839135840135841135842135843135844135845135846135847135848135849135850135851135852135853135854135855135856135857135858135859135860135861135862135863135864135865135866135867135868135869135870135871135872135873135874135875135876135877135878135879135880135881135882135883135884135885135886135887135888135889135890135891135892135893135894135895135896135897135898135899135900135901135902135903135904135905135906135907135908135909135910135911135912135913135914135915135916135917135918135919135920135921135922135923135924135925135926135927135928135929135930135931135932135933135934135935135936135937135938135939135940135941135942135943135944135945135946135947135948135949135950135951135952135953135954135955135956135957135958135959135960135961135962135963135964135965135966135967135968135969135970135971135972135973135974135975135976135977135978135979135980135981135982135983135984135985135986135987135988135989135990135991135992135993135994135995135996135997135998135999136000136001136002136003136004136005136006136007136008136009136010136011136012136013136014136015136016136017136018136019136020136021136022136023136024136025136026136027136028136029136030136031136032136033136034136035136036136037136038136039136040136041136042136043136044136045136046136047136048136049136050136051136052136053136054136055136056136057136058136059136060136061136062136063136064136065136066136067136068136069136070136071136072136073136074136075136076136077136078136079136080136081136082136083136084136085136086136087136088136089136090136091136092136093136094136095136096136097136098136099136100136101136102136103136104136105136106136107136108136109136110136111136112136113136114136115136116136117136118136119136120136121136122136123136124136125136126136127136128136129136130136131136132136133136134136135136136136137136138136139136140136141136142136143136144136145136146136147136148136149136150136151136152136153136154136155136156136157136158136159136160136161136162136163136164136165136166136167136168136169136170136171136172136173136174136175136176136177136178136179136180136181136182136183136184136185136186136187136188136189136190136191136192136193136194136195136196136197136198136199136200136201136202136203136204136205136206136207136208136209136210136211136212136213136214136215136216136217136218136219136220136221136222136223136224136225136226136227136228136229136230136231136232136233136234136235136236136237136238136239136240136241136242136243136244136245136246136247136248136249136250136251136252136253136254136255136256136257136258136259136260136261136262136263136264136265136266136267136268136269136270136271136272136273136274136275136276136277136278136279136280136281136282136283136284136285136286136287136288136289136290136291136292136293136294136295136296136297136298136299136300136301136302136303136304136305136306136307136308136309136310136311136312136313136314136315136316136317136318136319136320136321136322136323136324136325136326136327136328136329136330136331136332136333136334136335136336136337136338136339136340136341136342136343136344136345136346136347136348136349136350136351136352136353136354136355136356136357136358136359136360136361136362136363136364136365136366136367136368136369136370136371136372136373136374136375136376136377136378136379136380136381136382136383136384136385136386136387136388136389136390136391136392136393136394136395136396136397136398136399136400136401136402136403136404136405136406136407136408136409136410136411136412136413136414136415136416136417136418136419136420136421136422136423136424136425136426136427136428136429136430136431136432136433136434136435136436136437136438136439136440136441136442136443136444136445136446136447136448136449136450136451136452136453136454136455136456136457136458136459136460136461136462136463136464136465136466136467136468136469136470136471136472136473136474136475136476136477136478136479136480136481136482136483136484136485136486136487136488136489136490136491136492136493136494136495136496136497136498136499136500136501136502136503136504136505136506136507136508136509136510136511136512136513136514136515136516136517136518136519136520136521136522136523136524136525136526136527136528136529136530136531136532136533136534136535136536136537136538136539136540136541136542136543136544136545136546136547136548136549136550136551136552136553136554136555136556136557136558136559136560136561136562136563136564136565136566136567136568136569136570136571136572136573136574136575136576136577136578136579136580136581136582136583136584136585136586136587136588136589136590136591136592136593136594136595136596136597136598136599136600136601136602136603136604136605136606136607136608136609136610136611136612136613136614136615136616136617136618136619136620136621136622136623136624136625136626136627136628136629136630136631136632136633136634136635136636136637136638136639136640136641136642136643136644136645136646136647136648136649136650136651136652136653136654136655136656136657136658136659136660136661136662136663136664136665136666136667136668136669136670136671136672136673136674136675136676136677136678136679136680136681136682136683136684136685136686136687136688136689136690136691136692136693136694136695136696136697136698136699136700136701136702136703136704136705136706136707136708136709136710136711136712136713136714136715136716136717136718136719136720136721136722136723136724136725136726136727136728136729136730136731136732136733136734136735136736136737136738136739136740136741136742136743136744136745136746136747136748136749136750136751136752136753136754136755136756136757136758136759136760136761136762136763136764136765136766136767136768136769136770136771136772136773136774136775136776136777136778136779136780136781136782136783136784136785136786136787136788136789136790136791136792136793136794136795136796136797136798136799136800136801136802136803136804136805136806136807136808136809136810136811136812136813136814136815136816136817136818136819136820136821136822136823136824136825136826136827136828136829136830136831136832136833136834136835136836136837136838136839136840136841136842136843136844136845136846136847136848136849136850136851136852136853136854136855136856136857136858136859136860136861136862136863136864136865136866136867136868136869136870136871136872136873136874136875136876136877136878136879136880136881136882136883136884136885136886136887136888136889136890136891136892136893136894136895136896136897136898136899136900136901136902136903136904136905136906136907136908136909136910136911136912136913136914136915136916136917136918136919136920136921136922136923136924136925136926136927136928136929136930136931136932136933136934136935136936136937136938136939136940136941136942136943136944136945136946136947136948136949136950136951136952136953136954136955136956136957136958136959136960136961136962136963136964136965136966136967136968136969136970136971136972136973136974136975136976136977136978136979136980136981136982136983136984136985136986136987136988136989136990136991136992136993136994136995136996136997136998136999137000137001137002137003137004137005137006137007137008137009137010137011137012137013137014137015137016137017137018137019137020137021137022137023137024137025137026137027137028137029137030137031137032137033137034137035137036137037137038137039137040137041137042137043137044137045137046137047137048137049137050137051137052137053137054137055137056137057137058137059137060137061137062137063137064137065137066137067137068137069137070137071137072137073137074137075137076137077137078137079137080137081137082137083137084137085137086137087137088137089137090137091137092137093137094137095137096137097137098137099137100137101137102137103137104137105137106137107137108137109137110137111137112137113137114137115137116137117137118137119137120137121137122137123137124137125137126137127137128137129137130137131137132137133137134137135137136137137137138137139137140137141137142137143137144137145137146137147137148137149137150137151137152137153137154137155137156137157137158137159137160137161137162137163137164137165137166137167137168137169137170137171137172137173137174137175137176137177137178137179137180137181137182137183137184137185137186137187137188137189137190137191137192137193137194137195137196137197137198137199137200137201137202137203137204137205137206137207137208137209137210137211137212137213137214137215137216137217137218137219137220137221137222137223137224137225137226137227137228137229137230137231137232137233137234137235137236137237137238137239137240137241137242137243137244137245137246137247137248137249137250137251137252137253137254137255137256137257137258137259137260137261137262137263137264137265137266137267137268137269137270137271137272137273137274137275137276137277137278137279137280137281137282137283137284137285137286137287137288137289137290137291137292137293137294137295137296137297137298137299137300137301137302137303137304137305137306137307137308137309137310137311137312137313137314137315137316137317137318137319137320137321137322137323137324137325137326137327137328137329137330137331137332137333137334137335137336137337137338137339137340137341137342137343137344137345137346137347137348137349137350137351137352137353137354137355137356137357137358137359137360137361137362137363137364137365137366137367137368137369137370137371137372137373137374137375137376137377137378137379137380137381137382137383137384137385137386137387137388137389137390137391137392137393137394137395137396137397137398137399137400137401137402137403137404137405137406137407137408137409137410137411137412137413137414137415137416137417137418137419137420137421137422137423137424137425137426137427137428137429137430137431137432137433137434137435137436137437137438137439137440137441137442137443137444137445137446137447137448137449137450137451137452137453137454137455137456137457137458137459137460137461137462137463137464137465137466137467137468137469137470137471137472137473137474137475137476137477137478137479137480137481137482137483137484137485137486137487137488137489137490137491137492137493137494137495137496137497137498137499137500137501137502137503137504137505137506137507137508137509137510137511137512137513137514137515137516137517137518137519137520137521137522137523137524137525137526137527137528137529137530137531137532137533137534137535137536137537137538137539137540137541137542137543137544137545137546137547137548137549137550137551137552137553137554137555137556137557137558137559137560137561137562137563137564137565137566137567137568137569137570137571137572137573137574137575137576137577137578137579137580137581137582137583137584137585137586137587137588137589137590137591137592137593137594137595137596137597137598137599137600137601137602137603137604137605137606137607137608137609137610137611137612137613137614137615137616137617137618137619137620137621137622137623137624137625137626137627137628137629137630137631137632137633137634137635137636137637137638137639137640137641137642137643137644137645137646137647137648137649137650137651137652137653137654137655137656137657137658137659137660137661137662137663137664137665137666137667137668137669137670137671137672137673137674137675137676137677137678137679137680137681137682137683137684137685137686137687137688137689137690137691137692137693137694137695137696137697137698137699137700137701137702137703137704137705137706137707137708137709137710137711137712137713137714137715137716137717137718137719137720137721137722137723137724137725137726137727137728137729137730137731137732137733137734137735137736137737137738137739137740137741137742137743137744137745137746137747137748137749137750137751137752137753137754137755137756137757137758137759137760137761137762137763137764137765137766137767137768137769137770137771137772137773137774137775137776137777137778137779137780137781137782137783137784137785137786137787137788137789137790137791137792137793137794137795137796137797137798137799137800137801137802137803137804137805137806137807137808137809137810137811137812137813137814137815137816137817137818137819137820137821137822137823137824137825137826137827137828137829137830137831137832137833137834137835137836137837137838137839137840137841137842137843137844137845137846137847137848137849137850137851137852137853137854137855137856137857137858137859137860137861137862137863137864137865137866137867137868137869137870137871137872137873137874137875137876137877137878137879137880137881137882137883137884137885137886137887137888137889137890137891137892137893137894137895137896137897137898137899137900137901137902137903137904137905137906137907137908137909137910137911137912137913137914137915137916137917137918137919137920137921137922137923137924137925137926137927137928137929137930137931137932137933137934137935137936137937137938137939137940137941137942137943137944137945137946137947137948137949137950137951137952137953137954137955137956137957137958137959137960137961137962137963137964137965137966137967137968137969137970137971137972137973137974137975137976137977137978137979137980137981137982137983137984137985137986137987137988137989137990137991137992137993137994137995137996137997137998137999138000138001138002138003138004138005138006138007138008138009138010138011138012138013138014138015138016138017138018138019138020138021138022138023138024138025138026138027138028138029138030138031138032138033138034138035138036138037138038138039138040138041138042138043138044138045138046138047138048138049138050138051138052138053138054138055138056138057138058138059138060138061138062138063138064138065138066138067138068138069138070138071138072138073138074138075138076138077138078138079138080138081138082138083138084138085138086138087138088138089138090138091138092138093138094138095138096138097138098138099138100138101138102138103138104138105138106138107138108138109138110138111138112138113138114138115138116138117138118138119138120138121138122138123138124138125138126138127138128138129138130138131138132138133138134138135138136138137138138138139138140138141138142138143138144138145138146138147138148138149138150138151138152138153138154138155138156138157138158138159138160138161138162138163138164138165138166138167138168138169138170138171138172138173138174138175138176138177138178138179138180138181138182138183138184138185138186138187138188138189138190138191138192138193138194138195138196138197138198138199138200138201138202138203138204138205138206138207138208138209138210138211138212138213138214138215138216138217138218138219138220138221138222138223138224138225138226138227138228138229138230138231138232138233138234138235138236138237138238138239138240138241138242138243138244138245138246138247138248138249138250138251138252138253138254138255138256138257138258138259138260138261138262138263138264138265138266138267138268138269138270138271138272138273138274138275138276138277138278138279138280138281138282138283138284138285138286138287138288138289138290138291138292138293138294138295138296138297138298138299138300138301138302138303138304138305138306138307138308138309138310138311138312138313138314138315138316138317138318138319138320138321138322138323138324138325138326138327138328138329138330138331138332138333138334138335138336138337138338138339138340138341138342138343138344138345138346138347138348138349138350138351138352138353138354138355138356138357138358138359138360138361138362138363138364138365138366138367138368138369138370138371138372138373138374138375138376138377138378138379138380138381138382138383138384138385138386138387138388138389138390138391138392138393138394138395138396138397138398138399138400138401138402138403138404138405138406138407138408138409138410138411138412138413138414138415138416138417138418138419138420138421138422138423138424138425138426138427138428138429138430138431138432138433138434138435138436138437138438138439138440138441138442138443138444138445138446138447138448138449138450138451138452138453138454138455138456138457138458138459138460138461138462138463138464138465138466138467138468138469138470138471138472138473138474138475138476138477138478138479138480138481138482138483138484138485138486138487138488138489138490138491138492138493138494138495138496138497138498138499138500138501138502138503138504138505138506138507138508138509138510138511138512138513138514138515138516138517138518138519138520138521138522138523138524138525138526138527138528138529138530138531138532138533138534138535138536138537138538138539138540138541138542138543138544138545138546138547138548138549138550138551138552138553138554138555138556138557138558138559138560138561138562138563138564138565138566138567138568138569138570138571138572138573138574138575138576138577138578138579138580138581138582138583138584138585138586138587138588138589138590138591138592138593138594138595138596138597138598138599138600138601138602138603138604138605138606138607138608138609138610138611138612138613138614138615138616138617138618138619138620138621138622138623138624138625138626138627138628138629138630138631138632138633138634138635138636138637138638138639138640138641138642138643138644138645138646138647138648138649138650138651138652138653138654138655138656138657138658138659138660138661138662138663138664138665138666138667138668138669138670138671138672138673138674138675138676138677138678138679138680138681138682138683138684138685138686138687138688138689138690138691138692138693138694138695138696138697138698138699138700138701138702138703138704138705138706138707138708138709138710138711138712138713138714138715138716138717138718138719138720138721138722138723138724138725138726138727138728138729138730138731138732138733138734138735138736138737138738138739138740138741138742138743138744138745138746138747138748138749138750138751138752138753138754138755138756138757138758138759138760138761138762138763138764138765138766138767138768138769138770138771138772138773138774138775138776138777138778138779138780138781138782138783138784138785138786138787138788138789138790138791138792138793138794138795138796138797138798138799138800138801138802138803138804138805138806138807138808138809138810138811138812138813138814138815138816138817138818138819138820138821138822138823138824138825138826138827138828138829138830138831138832138833138834138835138836138837138838138839138840138841138842138843138844138845138846138847138848138849138850138851138852138853138854138855138856138857138858138859138860138861138862138863138864138865138866138867138868138869138870138871138872138873138874138875138876138877138878138879138880138881138882138883138884138885138886138887138888138889138890138891138892138893138894138895138896138897138898138899138900138901138902138903138904138905138906138907138908138909138910138911138912138913138914138915138916138917138918138919138920138921138922138923138924138925138926138927138928138929138930138931138932138933138934138935138936138937138938138939138940138941138942138943138944138945138946138947138948138949138950138951138952138953138954138955138956138957138958138959138960138961138962138963138964138965138966138967138968138969138970138971138972138973138974138975138976138977138978138979138980138981138982138983138984138985138986138987138988138989138990138991138992138993138994138995138996138997138998138999139000139001139002139003139004139005139006139007139008139009139010139011139012139013139014139015139016139017139018139019139020139021139022139023139024139025139026139027139028139029139030139031139032139033139034139035139036139037139038139039139040139041139042139043139044139045139046139047139048139049139050139051139052139053139054139055139056139057139058139059139060139061139062139063139064139065139066139067139068139069139070139071139072139073139074139075139076139077139078139079139080139081139082139083139084139085139086139087139088139089139090139091139092139093139094139095139096139097139098139099139100139101139102139103139104139105139106139107139108139109139110139111139112139113139114139115139116139117139118139119139120139121139122139123139124139125139126139127139128139129139130139131139132139133139134139135139136139137139138139139139140139141139142139143139144139145139146139147139148139149139150139151139152139153139154139155139156139157139158139159139160139161139162139163139164139165139166139167139168139169139170139171139172139173139174139175139176139177139178139179139180139181139182139183139184139185139186139187139188139189139190139191139192139193139194139195139196139197139198139199139200139201139202139203139204139205139206139207139208139209139210139211139212139213139214139215139216139217139218139219139220139221139222139223139224139225139226139227139228139229139230139231139232139233139234139235139236139237139238139239139240139241139242139243139244139245139246139247139248139249139250139251139252139253139254139255139256139257139258139259139260139261139262139263139264139265139266139267139268139269139270139271139272139273139274139275139276139277139278139279139280139281139282139283139284139285139286139287139288139289139290139291139292139293139294139295139296139297139298139299139300139301139302139303139304139305139306139307139308139309139310139311139312139313139314139315139316139317139318139319139320139321139322139323139324139325139326139327139328139329139330139331139332139333139334139335139336139337139338139339139340139341139342139343139344139345139346139347139348139349139350139351139352139353139354139355139356139357139358139359139360139361139362139363139364139365139366139367139368139369139370139371139372139373139374139375139376139377139378139379139380139381139382139383139384139385139386139387139388139389139390139391139392139393139394139395139396139397139398139399139400139401139402139403139404139405139406139407139408139409139410139411139412139413139414139415139416139417139418139419139420139421139422139423139424139425139426139427139428139429139430139431139432139433139434139435139436139437139438139439139440139441139442139443139444139445139446139447139448139449139450139451139452139453139454139455139456139457139458139459139460139461139462139463139464139465139466139467139468139469139470139471139472139473139474139475139476139477139478139479139480139481139482139483139484139485139486139487139488139489139490139491139492139493139494139495139496139497139498139499139500139501139502139503139504139505139506139507139508139509139510139511139512139513139514139515139516139517139518139519139520139521139522139523139524139525139526139527139528139529139530139531139532139533139534139535139536139537139538139539139540139541139542139543139544139545139546139547139548139549139550139551139552139553139554139555139556139557139558139559139560139561139562139563139564139565139566139567139568139569139570139571139572139573139574139575139576139577139578139579139580139581139582139583139584139585139586139587139588139589139590139591139592139593139594139595139596139597139598139599139600139601139602139603139604139605139606139607139608139609139610139611139612139613139614139615139616139617139618139619139620139621139622139623139624139625139626139627139628139629139630139631139632139633139634139635139636139637139638139639139640139641139642139643139644139645139646139647139648139649139650139651139652139653139654139655139656139657139658139659139660139661139662139663139664139665139666139667139668139669139670139671139672139673139674139675139676139677139678139679139680139681139682139683139684139685139686139687139688139689139690139691139692139693139694139695139696139697139698139699139700139701139702139703139704139705139706139707139708139709139710139711139712139713139714139715139716139717139718139719139720139721139722139723139724139725139726139727139728139729139730139731139732139733139734139735139736139737139738139739139740139741139742139743139744139745139746139747139748139749139750139751139752139753139754139755139756139757139758139759139760139761139762139763139764139765139766139767139768139769139770139771139772139773139774139775139776139777139778139779139780139781139782139783139784139785139786139787139788139789139790139791139792139793139794139795139796139797139798139799139800139801139802139803139804139805139806139807139808139809139810139811139812139813139814139815139816139817139818139819139820139821139822139823139824139825139826139827139828139829139830139831139832139833139834139835139836139837139838139839139840139841139842139843139844139845139846139847139848139849139850139851139852139853139854139855139856139857139858139859139860139861139862139863139864139865139866139867139868139869139870139871139872139873139874139875139876139877139878139879139880139881139882139883139884139885139886139887139888139889139890139891139892139893139894139895139896139897139898139899139900139901139902139903139904139905139906139907139908139909139910139911139912139913139914139915139916139917139918139919139920139921139922139923139924139925139926139927139928139929139930139931139932139933139934139935139936139937139938139939139940139941139942139943139944139945139946139947139948139949139950139951139952139953139954139955139956139957139958139959139960139961139962139963139964139965139966139967139968139969139970139971139972139973139974139975139976139977139978139979139980139981139982139983139984139985139986139987139988139989139990139991139992139993139994139995139996139997139998139999140000140001140002140003140004140005140006140007140008140009140010140011140012140013140014140015140016140017140018140019140020140021140022140023140024140025140026140027140028140029140030140031140032140033140034140035140036140037140038140039140040140041140042140043140044140045140046140047140048140049140050140051140052140053140054140055140056140057140058140059140060140061140062140063140064140065140066140067140068140069140070140071140072140073140074140075140076140077140078140079140080140081140082140083140084140085140086140087140088140089140090140091140092140093140094140095140096140097140098140099140100140101140102140103140104140105140106140107140108140109140110140111140112140113140114140115140116140117140118140119140120140121140122140123140124140125140126140127140128140129140130140131140132140133140134140135140136140137140138140139140140140141140142140143140144140145140146140147140148140149140150140151140152140153140154140155140156140157140158140159140160140161140162140163140164140165140166140167140168140169140170140171140172140173140174140175140176140177140178140179140180140181140182140183140184140185140186140187140188140189140190140191140192140193140194140195140196140197140198140199140200140201140202140203140204140205140206140207140208140209140210140211140212140213140214140215140216140217140218140219140220140221140222140223140224140225140226140227140228140229140230140231140232140233140234140235140236140237140238140239140240140241140242140243140244140245140246140247140248140249140250140251140252140253140254140255140256140257140258140259140260140261140262140263140264140265140266140267140268140269140270140271140272140273140274140275140276140277140278140279140280140281140282140283140284140285140286140287140288140289140290140291140292140293140294140295140296140297140298140299140300140301140302140303140304140305140306140307140308140309140310140311140312140313140314140315140316140317140318140319140320140321140322140323140324140325140326140327140328140329140330140331140332140333140334140335140336140337140338140339140340140341140342140343140344140345140346140347140348140349140350140351140352140353140354140355140356140357140358140359140360140361140362140363140364140365140366140367140368140369140370140371140372140373140374140375140376140377140378140379140380140381140382140383140384140385140386140387140388140389140390140391140392140393140394140395140396140397140398140399140400140401140402140403140404140405140406140407140408140409140410140411140412140413140414140415140416140417140418140419140420140421140422140423140424140425140426140427140428140429140430140431140432140433140434140435140436140437140438140439140440140441140442140443140444140445140446140447140448140449140450140451140452140453140454140455140456140457140458140459140460140461140462140463140464140465140466140467140468140469140470140471140472140473140474140475140476140477140478140479140480140481140482140483140484140485140486140487140488140489140490140491140492140493140494140495140496140497140498140499140500140501140502140503140504140505140506140507140508140509140510140511140512140513140514140515140516140517140518140519140520140521140522140523140524140525140526140527140528140529140530140531140532140533140534140535140536140537140538140539140540140541140542140543140544140545140546140547140548140549140550140551140552140553140554140555140556140557140558140559140560140561140562140563140564140565140566140567140568140569140570140571140572140573140574140575140576140577140578140579140580140581140582140583140584140585140586140587140588140589140590140591140592140593140594140595140596140597140598140599140600140601140602140603140604140605140606140607140608140609140610140611140612140613140614140615140616140617140618140619140620140621140622140623140624140625140626140627140628140629140630140631140632140633140634140635140636140637140638140639140640140641140642140643140644140645140646140647140648140649140650140651140652140653140654140655140656140657140658140659140660140661140662140663140664140665140666140667140668140669140670140671140672140673140674140675140676140677140678140679140680140681140682140683140684140685140686140687140688140689140690140691140692140693140694140695140696140697140698140699140700140701140702140703140704140705140706140707140708140709140710140711140712140713140714140715140716140717140718140719140720140721140722140723140724140725140726140727140728140729140730140731140732140733140734140735140736140737140738140739140740140741140742140743140744140745140746140747140748140749140750140751140752140753140754140755140756140757140758140759140760140761140762140763140764140765140766140767140768140769140770140771140772140773140774140775140776140777140778140779140780140781140782140783140784140785140786140787140788140789140790140791140792140793140794140795140796140797140798140799140800140801140802140803140804140805140806140807140808140809140810140811140812140813140814140815140816140817140818140819140820140821140822140823140824140825140826140827140828140829140830140831140832140833140834140835140836140837140838140839140840140841140842140843140844140845140846140847140848140849140850140851140852140853140854140855140856140857140858140859140860140861140862140863140864140865140866140867140868140869140870140871140872140873140874140875140876140877140878140879140880140881140882140883140884140885140886140887140888140889140890140891140892140893140894140895140896140897140898140899140900140901140902140903140904140905140906140907140908140909140910140911140912140913140914140915140916140917140918140919140920140921140922140923140924140925140926140927140928140929140930140931140932140933140934140935140936140937140938140939140940140941140942140943140944140945140946140947140948140949140950140951140952140953140954140955140956140957140958140959140960140961140962140963140964140965140966140967140968140969140970140971140972140973140974140975140976140977140978140979140980140981140982140983140984140985140986140987140988140989140990140991140992140993140994140995140996140997140998140999141000141001141002141003141004141005141006141007141008141009141010141011141012141013141014141015141016141017141018141019141020141021141022141023141024141025141026141027141028141029141030141031141032141033141034141035141036141037141038141039141040141041141042141043141044141045141046141047141048141049141050141051141052141053141054141055141056141057141058141059141060141061141062141063141064141065141066141067141068141069141070141071141072141073141074141075141076141077141078141079141080141081141082141083141084141085141086141087141088141089141090141091141092141093141094141095141096141097141098141099141100141101141102141103141104141105141106141107141108141109141110141111141112141113141114141115141116141117141118141119141120141121141122141123141124141125141126141127141128141129141130141131141132141133141134141135141136141137141138141139141140141141141142141143141144141145141146141147141148141149141150141151141152141153141154141155141156141157141158141159141160141161141162141163141164141165141166141167141168141169141170141171141172141173141174141175141176141177141178141179141180141181141182141183141184141185141186141187141188141189141190141191141192141193141194141195141196141197141198141199141200141201141202141203141204141205141206141207141208141209141210141211141212141213141214141215141216141217141218141219141220141221141222141223141224141225141226141227141228141229141230141231141232141233141234141235141236141237141238141239141240141241141242141243141244141245141246141247141248141249141250141251141252141253141254141255141256141257141258141259141260141261141262141263141264141265141266141267141268141269141270141271141272141273141274141275141276141277141278141279141280141281141282141283141284141285141286141287141288141289141290141291141292141293141294141295141296141297141298141299141300141301141302141303141304141305141306141307141308141309141310141311141312141313141314141315141316141317141318141319141320141321141322141323141324141325141326141327141328141329141330141331141332141333141334141335141336141337141338141339141340141341141342141343141344141345141346141347141348141349141350141351141352141353141354141355141356141357141358141359141360141361141362141363141364141365141366141367141368141369141370141371141372141373141374141375141376141377141378141379141380141381141382141383141384141385141386141387141388141389141390141391141392141393141394141395141396141397141398141399141400141401141402141403141404141405141406141407141408141409141410141411141412141413141414141415141416141417141418141419141420141421141422141423141424141425141426141427141428141429141430141431141432141433141434141435141436141437141438141439141440141441141442141443141444141445141446141447141448141449141450141451141452141453141454141455141456141457141458141459141460141461141462141463141464141465141466141467141468141469141470141471141472141473141474141475141476141477141478141479141480141481141482141483141484141485141486141487141488141489141490141491141492141493141494141495141496141497141498141499141500141501141502141503141504141505141506141507141508141509141510141511141512141513141514141515141516141517141518141519141520141521141522141523141524141525141526141527141528141529141530141531141532141533141534141535141536141537141538141539141540141541141542141543141544141545141546141547141548141549141550141551141552141553141554141555141556141557141558141559141560141561141562141563141564141565141566141567141568141569141570141571141572141573141574141575141576141577141578141579141580141581141582141583141584141585141586141587141588141589141590141591141592141593141594141595141596141597141598141599141600141601141602141603141604141605141606141607141608141609141610141611141612141613141614141615141616141617141618141619141620141621141622141623141624141625141626141627141628141629141630141631141632141633141634141635141636141637141638141639141640141641141642141643141644141645141646141647141648141649141650141651141652141653141654141655141656141657141658141659141660141661141662141663141664141665141666141667141668141669141670141671141672141673141674141675141676141677141678141679141680141681141682141683141684141685141686141687141688141689141690141691141692141693141694141695141696141697141698141699141700141701141702141703141704141705141706141707141708141709141710141711141712141713141714141715141716141717141718141719141720141721141722141723141724141725141726141727141728141729141730141731141732141733141734141735141736141737141738141739141740141741141742141743141744141745141746141747141748141749141750141751141752141753141754141755141756141757141758141759141760141761141762141763141764141765141766141767141768141769141770141771141772141773141774141775141776141777141778141779141780141781141782141783141784141785141786141787141788141789141790141791141792141793141794141795141796141797141798141799141800141801141802141803141804141805141806141807141808141809141810141811141812141813141814141815141816141817141818141819141820141821141822141823141824141825141826141827141828141829141830141831141832141833141834141835141836141837141838141839141840141841141842141843141844141845141846141847141848141849141850141851141852141853141854141855141856141857141858141859141860141861141862141863141864141865141866141867141868141869141870141871141872141873141874141875141876141877141878141879141880141881141882141883141884141885141886141887141888141889141890141891141892141893141894141895141896141897141898141899141900141901141902141903141904141905141906141907141908141909141910141911141912141913141914141915141916141917141918141919141920141921141922141923141924141925141926141927141928141929141930141931141932141933141934141935141936141937141938141939141940141941141942141943141944141945141946141947141948141949141950141951141952141953141954141955141956141957141958141959141960141961141962141963141964141965141966141967141968141969141970141971141972141973141974141975141976141977141978141979141980141981141982141983141984141985141986141987141988141989141990141991141992141993141994141995141996141997141998141999142000142001142002142003142004142005142006142007142008142009142010142011142012142013142014142015142016142017142018142019142020142021142022142023142024142025142026142027142028142029142030142031142032142033142034142035142036142037142038142039142040142041142042142043142044142045142046142047142048142049142050142051142052142053142054142055142056142057142058142059142060142061142062142063142064142065142066142067142068142069142070142071142072142073142074142075142076142077142078142079142080142081142082142083142084142085142086142087142088142089142090142091142092142093142094142095142096142097142098142099142100142101142102142103142104142105142106142107142108142109142110142111142112142113142114142115142116142117142118142119142120142121142122142123142124142125142126142127142128142129142130142131142132142133142134142135142136142137142138142139142140142141142142142143142144142145142146142147142148142149142150142151142152142153142154142155142156142157142158142159142160142161142162142163142164142165142166142167142168142169142170142171142172142173142174142175142176142177142178142179142180142181142182142183142184142185142186142187142188142189142190142191142192142193142194142195142196142197142198142199142200142201142202142203142204142205142206142207142208142209142210142211142212142213142214142215142216142217142218142219142220142221142222142223142224142225142226142227142228142229142230142231142232142233142234142235142236142237142238142239142240142241142242142243142244142245142246142247142248142249142250142251142252142253142254142255142256142257142258142259142260142261142262142263142264142265142266142267142268142269142270142271142272142273142274142275142276142277142278142279142280142281142282142283142284142285142286142287142288142289142290142291142292142293142294142295142296142297142298142299142300142301142302142303142304142305142306142307142308142309142310142311142312142313142314142315142316142317142318142319142320142321142322142323142324142325142326142327142328142329142330142331142332142333142334142335142336142337142338142339142340142341142342142343142344142345142346142347142348142349142350142351142352142353142354142355142356142357142358142359142360142361142362142363142364142365142366142367142368142369142370142371142372142373142374142375142376142377142378142379142380142381142382142383142384142385142386142387142388142389142390142391142392142393142394142395142396142397142398142399142400142401142402142403142404142405142406142407142408142409142410142411142412142413142414142415142416142417142418142419142420142421142422142423142424142425142426142427142428142429142430142431142432142433142434142435142436142437142438142439142440142441142442142443142444142445142446142447142448142449142450142451142452142453142454142455142456142457142458142459142460142461142462142463142464142465142466142467142468142469142470142471142472142473142474142475142476142477142478142479142480142481142482142483142484142485142486142487142488142489142490142491142492142493142494142495142496142497142498142499142500142501142502142503142504142505142506142507142508142509142510142511142512142513142514142515142516142517142518142519142520142521142522142523142524142525142526142527142528142529142530142531142532142533142534142535142536142537142538142539142540142541142542142543142544142545142546142547142548142549142550142551142552142553142554142555142556142557142558142559142560142561142562142563142564142565142566142567142568142569142570142571142572142573142574142575142576142577142578142579142580142581142582142583142584142585142586142587142588142589142590142591142592142593142594142595142596142597142598142599142600142601142602142603142604142605142606142607142608142609142610142611142612142613142614142615142616142617142618142619142620142621142622142623142624142625142626142627142628142629142630142631142632142633142634142635142636142637142638142639142640142641142642142643142644142645142646142647142648142649142650142651142652142653142654142655142656142657142658142659142660142661142662142663142664142665142666142667142668142669142670142671142672142673142674142675142676142677142678142679142680142681142682142683142684142685142686142687142688142689142690142691142692142693142694142695142696142697142698142699142700142701142702142703142704142705142706142707142708142709142710142711142712142713142714142715142716142717142718142719142720142721142722142723142724142725142726142727142728142729142730142731142732142733142734142735142736142737142738142739142740142741142742142743142744142745142746142747142748142749142750142751142752142753142754142755142756142757142758142759142760142761142762142763142764142765142766142767142768142769142770142771142772142773142774142775142776142777142778142779142780142781142782142783142784142785142786142787142788142789142790142791142792142793142794142795142796142797142798142799142800142801142802142803142804142805142806142807142808142809142810142811142812142813142814142815142816142817142818142819142820142821142822142823142824142825142826142827142828142829142830142831142832142833142834142835142836142837142838142839142840142841142842142843142844142845142846142847142848142849142850142851142852142853142854142855142856142857142858142859142860142861142862142863142864142865142866142867142868142869142870142871142872142873142874142875142876142877142878142879142880142881142882142883142884142885142886142887142888142889142890142891142892142893142894142895142896142897142898142899142900142901142902142903142904142905142906142907142908142909142910142911142912142913142914142915142916142917142918142919142920142921142922142923142924142925142926142927142928142929142930142931142932142933142934142935142936142937142938142939142940142941142942142943142944142945142946142947142948142949142950142951142952142953142954142955142956142957142958142959142960142961142962142963142964142965142966142967142968142969142970142971142972142973142974142975142976142977142978142979142980142981142982142983142984142985142986142987142988142989142990142991142992142993142994142995142996142997142998142999143000143001143002143003143004143005143006143007143008143009143010143011143012143013143014143015143016143017143018143019143020143021143022143023143024143025143026143027143028143029143030143031143032143033143034143035143036143037143038143039143040143041143042143043143044143045143046143047143048143049143050143051143052143053143054143055143056143057143058143059143060143061143062143063143064143065143066143067143068143069143070143071143072143073143074143075143076143077143078143079143080143081143082143083143084143085143086143087143088143089143090143091143092143093143094143095143096143097143098143099143100143101143102143103143104143105143106143107143108143109143110143111143112143113143114143115143116143117143118143119143120143121143122143123143124143125143126143127143128143129143130143131143132143133143134143135143136143137143138143139143140143141143142143143143144143145143146143147143148143149143150143151143152143153143154143155143156143157143158143159143160143161143162143163143164143165143166143167143168143169143170143171143172143173143174143175143176143177143178143179143180143181143182143183143184143185143186143187143188143189143190143191143192143193143194143195143196143197143198143199143200143201143202143203143204143205143206143207143208143209143210143211143212143213143214143215143216143217143218143219143220143221143222143223143224143225143226143227143228143229143230143231143232143233143234143235143236143237143238143239143240143241143242143243143244143245143246143247143248143249143250143251143252143253143254143255143256143257143258143259143260143261143262143263143264143265143266143267143268143269143270143271143272143273143274143275143276143277143278143279143280143281143282143283143284143285143286143287143288143289143290143291143292143293143294143295143296143297143298143299143300143301143302143303143304143305143306143307143308143309143310143311143312143313143314143315143316143317143318143319143320143321143322143323143324143325143326143327143328143329143330143331143332143333143334143335143336143337143338143339143340143341143342143343143344143345143346143347143348143349143350143351143352143353143354143355143356143357143358143359143360143361143362143363143364143365143366143367143368143369143370143371143372143373143374143375143376143377143378143379143380143381143382143383143384143385143386143387143388143389143390143391143392143393143394143395143396143397143398143399143400143401143402143403143404143405143406143407143408143409143410143411143412143413143414143415143416143417143418143419143420143421143422143423143424143425143426143427143428143429143430143431143432143433143434143435143436143437143438143439143440143441143442143443143444143445143446143447143448143449143450143451143452143453143454143455143456143457143458143459143460143461143462143463143464143465143466143467143468143469143470143471143472143473143474143475143476143477143478143479143480143481143482143483143484143485143486143487143488143489143490143491143492143493143494143495143496143497143498143499143500143501143502143503143504143505143506143507143508143509143510143511143512143513143514143515143516143517143518143519143520143521143522143523143524143525143526143527143528143529143530143531143532143533143534143535143536143537143538143539143540143541143542143543143544143545143546143547143548143549143550143551143552143553143554143555143556143557143558143559143560143561143562143563143564143565143566143567143568143569143570143571143572143573143574143575143576143577143578143579143580143581143582143583143584143585143586143587143588143589143590143591143592143593143594143595143596143597143598143599143600143601143602143603143604143605143606143607143608143609143610143611143612143613143614143615143616143617143618143619143620143621143622143623143624143625143626143627143628143629143630143631143632143633143634143635143636143637143638143639143640143641143642143643143644143645143646143647143648143649143650143651143652143653143654143655143656143657143658143659143660143661143662143663143664143665143666143667143668143669143670143671143672143673143674143675143676143677143678143679143680143681143682143683143684143685143686143687143688143689143690143691143692143693143694143695143696143697143698143699143700143701143702143703143704143705143706143707143708143709143710143711143712143713143714143715143716143717143718143719143720143721143722143723143724143725143726143727143728143729143730143731143732143733143734143735143736143737143738143739143740143741143742143743143744143745143746143747143748143749143750143751143752143753143754143755143756143757143758143759143760143761143762143763143764143765143766143767143768143769143770143771143772143773143774143775143776143777143778143779143780143781143782143783143784143785143786143787143788143789143790143791143792143793143794143795143796143797143798143799143800143801143802143803143804143805143806143807143808143809143810143811143812143813143814143815143816143817143818143819143820143821143822143823143824143825143826143827143828143829143830143831143832143833143834143835143836143837143838143839143840143841143842143843143844143845143846143847143848143849143850143851143852143853143854143855143856143857143858143859143860143861143862143863143864143865143866143867143868143869143870143871143872143873143874143875143876143877143878143879143880143881143882143883143884143885143886143887143888143889143890143891143892143893143894143895143896143897143898143899143900143901143902143903143904143905143906143907143908143909143910143911143912143913143914143915143916143917143918143919143920143921143922143923143924143925143926143927143928143929143930143931143932143933143934143935143936143937143938143939143940143941143942143943143944143945143946143947143948143949143950143951143952143953143954143955143956143957143958143959143960143961143962143963143964143965143966143967143968143969143970143971143972143973143974143975143976143977143978143979143980143981143982143983143984143985143986143987143988143989143990143991143992143993143994143995143996143997143998143999144000144001144002144003144004144005144006144007144008144009144010144011144012144013144014144015144016144017144018144019144020144021144022144023144024144025144026144027144028144029144030144031144032144033144034144035144036144037144038144039144040144041144042144043144044144045144046144047144048144049144050144051144052144053144054144055144056144057144058144059144060144061144062144063144064144065144066144067144068144069144070144071144072144073144074144075144076144077144078144079144080144081144082144083144084144085144086144087144088144089144090144091144092144093144094144095144096144097144098144099144100144101144102144103144104144105144106144107144108144109144110144111144112144113144114144115144116144117144118144119144120144121144122144123144124144125144126144127144128144129144130144131144132144133144134144135144136144137144138144139144140144141144142144143144144144145144146144147144148144149144150144151144152144153144154144155144156144157144158144159144160144161144162144163144164144165144166144167144168144169144170144171144172144173144174144175144176144177144178144179144180144181144182144183144184144185144186144187144188144189144190144191144192144193144194144195144196144197144198144199144200144201144202144203144204144205144206144207144208144209144210144211144212144213144214144215144216144217144218144219144220144221144222144223144224144225144226144227144228144229144230144231144232144233144234144235144236144237144238144239144240144241144242144243144244144245144246144247144248144249144250144251144252144253144254144255144256144257144258144259144260144261144262144263144264144265144266144267144268144269144270144271144272144273144274144275144276144277144278144279144280144281144282144283144284144285144286144287144288144289144290144291144292144293144294144295144296144297144298144299144300144301144302144303144304144305144306144307144308144309144310144311144312144313144314144315144316144317144318144319144320144321144322144323144324144325144326144327144328144329144330144331144332144333144334144335144336144337144338144339144340144341144342144343144344144345144346144347144348144349144350144351144352144353144354144355144356144357144358144359144360144361144362144363144364144365144366144367144368144369144370144371144372144373144374144375144376144377144378144379144380144381144382144383144384144385144386144387144388144389144390144391144392144393144394144395144396144397144398144399144400144401144402144403144404144405144406144407144408144409144410144411144412144413144414144415144416144417144418144419144420144421144422144423144424144425144426144427144428144429144430144431144432144433144434144435144436144437144438144439144440144441144442144443144444144445144446144447144448144449144450144451144452144453144454144455144456144457144458144459144460144461144462144463144464144465144466144467144468144469144470144471144472144473144474144475144476144477144478144479144480144481144482144483144484144485144486144487144488144489144490144491144492144493144494144495144496144497144498144499144500144501144502144503144504144505144506144507144508144509144510144511144512144513144514144515144516144517144518144519144520144521144522144523144524144525144526144527144528144529144530144531144532144533144534144535144536144537144538144539144540144541144542144543144544144545144546144547144548144549144550144551144552144553144554144555144556144557144558144559144560144561144562144563144564144565144566144567144568144569144570144571144572144573144574144575144576144577144578144579144580144581144582144583144584144585144586144587144588144589144590144591144592144593144594144595144596144597144598144599144600144601144602144603144604144605144606144607144608144609144610144611144612144613144614144615144616144617144618144619144620144621144622144623144624144625144626144627144628144629144630144631144632144633144634144635144636144637144638144639144640144641144642144643144644144645144646144647144648144649144650144651144652144653144654144655144656144657144658144659144660144661144662144663144664144665144666144667144668144669144670144671144672144673144674144675144676144677144678144679144680144681144682144683144684144685144686144687144688144689144690144691144692144693144694144695144696144697144698144699144700144701144702144703144704144705144706144707144708144709144710144711144712144713144714144715144716144717144718144719144720144721144722144723144724144725144726144727144728144729144730144731144732144733144734144735144736144737144738144739144740144741144742144743144744144745144746144747144748144749144750144751144752144753144754144755144756144757144758144759144760144761144762144763144764144765144766144767144768144769144770144771144772144773144774144775144776144777144778144779144780144781144782144783144784144785144786144787144788144789144790144791144792144793144794144795144796144797144798144799144800144801144802144803144804144805144806144807144808144809144810144811144812144813144814144815144816144817144818144819144820144821144822144823144824144825144826144827144828144829144830144831144832144833144834144835144836144837144838144839144840144841144842144843144844144845144846144847144848144849144850144851144852144853144854144855144856144857144858144859144860144861144862144863144864144865144866144867144868144869144870144871144872144873144874144875144876144877144878144879144880144881144882144883144884144885144886144887144888144889144890144891144892144893144894144895144896144897144898144899144900144901144902144903144904144905144906144907144908144909144910144911144912144913144914144915144916144917144918144919144920144921144922144923144924144925144926144927144928144929144930144931144932144933144934144935144936144937144938144939144940144941144942144943144944144945144946144947144948144949144950144951144952144953144954144955144956144957144958144959144960144961144962144963144964144965144966144967144968144969144970144971144972144973144974144975144976144977144978144979144980144981144982144983144984144985144986144987144988144989144990144991144992144993144994144995144996144997144998144999145000145001145002145003145004145005145006145007145008145009145010145011145012145013145014145015145016145017145018145019145020145021145022145023145024145025145026145027145028145029145030145031145032145033145034145035145036145037145038145039145040145041145042145043145044145045145046145047145048145049145050145051145052145053145054145055145056145057145058145059145060145061145062145063145064145065145066145067145068145069145070145071145072145073145074145075145076145077145078145079145080145081145082145083145084145085145086145087145088145089145090145091145092145093145094145095145096145097145098145099145100145101145102145103145104145105145106145107145108145109145110145111145112145113145114145115145116145117145118145119145120145121145122145123145124145125145126145127145128145129145130145131145132145133145134145135145136145137145138145139145140145141145142145143145144145145145146145147145148145149145150145151145152145153145154145155145156145157145158145159145160145161145162145163145164145165145166145167145168145169145170145171145172145173145174145175145176145177145178145179145180145181145182145183145184145185145186145187145188145189145190145191145192145193145194145195145196145197145198145199145200145201145202145203145204145205145206145207145208145209145210145211145212145213145214145215145216145217145218145219145220145221145222145223145224145225145226145227145228145229145230145231145232145233145234145235145236145237145238145239145240145241145242145243145244145245145246145247145248145249145250145251145252145253145254145255145256145257145258145259145260145261145262145263145264145265145266145267145268145269145270145271145272145273145274145275145276145277145278145279145280145281145282145283145284145285145286145287145288145289145290145291145292145293145294145295145296145297145298145299145300145301145302145303145304145305145306145307145308145309145310145311145312145313145314145315145316145317145318145319145320145321145322145323145324145325145326145327145328145329145330145331145332145333145334145335145336145337145338145339145340145341145342145343145344145345145346145347145348145349145350145351145352145353145354145355145356145357145358145359145360145361145362145363145364145365145366145367145368145369145370145371145372145373145374145375145376145377145378145379145380145381145382145383145384145385145386145387145388145389145390145391145392145393145394145395145396145397145398145399145400145401145402145403145404145405145406145407145408145409145410145411145412145413145414145415145416145417145418145419145420145421145422145423145424145425145426145427145428145429145430145431145432145433145434145435145436145437145438145439145440145441145442145443145444145445145446145447145448145449145450145451145452145453145454145455145456145457145458145459145460145461145462145463145464145465145466145467145468145469145470145471145472145473145474145475145476145477145478145479145480145481145482145483145484145485145486145487145488145489145490145491145492145493145494145495145496145497145498145499145500145501145502145503145504145505145506145507145508145509145510145511145512145513145514145515145516145517145518145519145520145521145522145523145524145525145526145527145528145529145530145531145532145533145534145535145536145537145538145539145540145541145542145543145544145545145546145547145548145549145550145551145552145553145554145555145556145557145558145559145560145561145562145563145564145565145566145567145568145569145570145571145572145573145574145575145576145577145578145579145580145581145582145583145584145585145586145587145588145589145590145591145592145593145594145595145596145597145598145599145600145601145602145603145604145605145606145607145608145609145610145611145612145613145614145615145616145617145618145619145620145621145622145623145624145625145626145627145628145629145630145631145632145633145634145635145636145637145638145639145640145641145642145643145644145645145646145647145648145649145650145651145652145653145654145655145656145657145658145659145660145661145662145663145664145665145666145667145668145669145670145671145672145673145674145675145676145677145678145679145680145681145682145683145684145685145686145687145688145689145690145691145692145693145694145695145696145697145698145699145700145701145702145703145704145705145706145707145708145709145710145711145712145713145714145715145716145717145718145719145720145721145722145723145724145725145726145727145728145729145730145731145732145733145734145735145736145737145738145739145740145741145742145743145744145745145746145747145748145749145750145751145752145753145754145755145756145757145758145759145760145761145762145763145764145765145766145767145768145769145770145771145772145773145774145775145776145777145778145779145780145781145782145783145784145785145786145787145788145789145790145791145792145793145794145795145796145797145798145799145800145801145802145803145804145805145806145807145808145809145810145811145812145813145814145815145816145817145818145819145820145821145822145823145824145825145826145827145828145829145830145831145832145833145834145835145836145837145838145839145840145841145842145843145844145845145846145847145848145849145850145851145852145853145854145855145856145857145858145859145860145861145862145863145864145865145866145867145868145869145870145871145872145873145874145875145876145877145878145879145880145881145882145883145884145885145886145887145888145889145890145891145892145893145894145895145896145897145898145899145900145901145902145903145904145905145906145907145908145909145910145911145912145913145914145915145916145917145918145919145920145921145922145923145924145925145926145927145928145929145930145931145932145933145934145935145936145937145938145939145940145941145942145943145944145945145946145947145948145949145950145951145952145953145954145955145956145957145958145959145960145961145962145963145964145965145966145967145968145969145970145971145972145973145974145975145976145977145978145979145980145981145982145983145984145985145986145987145988145989145990145991145992145993145994145995145996145997145998145999146000146001146002146003146004146005146006146007146008146009146010146011146012146013146014146015146016146017146018146019146020146021146022146023146024146025146026146027146028146029146030146031146032146033146034146035146036146037146038146039146040146041146042146043146044146045146046146047146048146049146050146051146052146053146054146055146056146057146058146059146060146061146062146063146064146065146066146067146068146069146070146071146072146073146074146075146076146077146078146079146080146081146082146083146084146085146086146087146088146089146090146091146092146093146094146095146096146097146098146099146100146101146102146103146104146105146106146107146108146109146110146111146112146113146114146115146116146117146118146119146120146121146122146123146124146125146126146127146128146129146130146131146132146133146134146135146136146137146138146139146140146141146142146143146144146145146146146147146148146149146150146151146152146153146154146155146156146157146158146159146160146161146162146163146164146165146166146167146168146169146170146171146172146173146174146175146176146177146178146179146180146181146182146183146184146185146186146187146188146189146190146191146192146193146194146195146196146197146198146199146200146201146202146203146204146205146206146207146208146209146210146211146212146213146214146215146216146217146218146219146220146221146222146223146224146225146226146227146228146229146230146231146232146233146234146235146236146237146238146239146240146241146242146243146244146245146246146247146248146249146250146251146252146253146254146255146256146257146258146259146260146261146262146263146264146265146266146267146268146269146270146271146272146273146274146275146276146277146278146279146280146281146282146283146284146285146286146287146288146289146290146291146292146293146294146295146296146297146298146299146300146301146302146303146304146305146306146307146308146309146310146311146312146313146314146315146316146317146318146319146320146321146322146323146324146325146326146327146328146329146330146331146332146333146334146335146336146337146338146339146340146341146342146343146344146345146346146347146348146349146350146351146352146353146354146355146356146357146358146359146360146361146362146363146364146365146366146367146368146369146370146371146372146373146374146375146376146377146378146379146380146381146382146383146384146385146386146387146388146389146390146391146392146393146394146395146396146397146398146399146400146401146402146403146404146405146406146407146408146409146410146411146412146413146414146415146416146417146418146419146420146421146422146423146424146425146426146427146428146429146430146431146432146433146434146435146436146437146438146439146440146441146442146443146444146445146446146447146448146449146450146451146452146453146454146455146456146457146458146459146460146461146462146463146464146465146466146467146468146469146470146471146472146473146474146475146476146477146478146479146480146481146482146483146484146485146486146487146488146489146490146491146492146493146494146495146496146497146498146499146500146501146502146503146504146505146506146507146508146509146510146511146512146513146514146515146516146517146518146519146520146521146522146523146524146525146526146527146528146529146530146531146532146533146534146535146536146537146538146539146540146541146542146543146544146545146546146547146548146549146550146551146552146553146554146555146556146557146558146559146560146561146562146563146564146565146566146567146568146569146570146571146572146573146574146575146576146577146578146579146580146581146582146583146584146585146586146587146588146589146590146591146592146593146594146595146596146597146598146599146600146601146602146603146604146605146606146607146608146609146610146611146612146613146614146615146616146617146618146619146620146621146622146623146624146625146626146627146628146629146630146631146632146633146634146635146636146637146638146639146640146641146642146643146644146645146646146647146648146649146650146651146652146653146654146655146656146657146658146659146660146661146662146663146664146665146666146667146668146669146670146671146672146673146674146675146676146677146678146679146680146681146682146683146684146685146686146687146688146689146690146691146692146693146694146695146696146697146698146699146700146701146702146703146704146705146706146707146708146709146710146711146712146713146714146715146716146717146718146719146720146721146722146723146724146725146726146727146728146729146730146731146732146733146734146735146736146737146738146739146740146741146742146743146744146745146746146747146748146749146750146751146752146753146754146755146756146757146758146759146760146761146762146763146764146765146766146767146768146769146770146771146772146773146774146775146776146777146778146779146780146781146782146783146784146785146786146787146788146789146790146791146792146793146794146795146796146797146798146799146800146801146802146803146804146805146806146807146808146809146810146811146812146813146814146815146816146817146818146819146820146821146822146823146824146825146826146827146828146829146830146831146832146833146834146835146836146837146838146839146840146841146842146843146844146845146846146847146848146849146850146851146852146853146854146855146856146857146858146859146860146861146862146863146864146865146866146867146868146869146870146871146872146873146874146875146876146877146878146879146880146881146882146883146884146885146886146887146888146889146890146891146892146893146894146895146896146897146898146899146900146901146902146903146904146905146906146907146908146909146910146911146912146913146914146915146916146917146918146919146920146921146922146923146924146925146926146927146928146929146930146931146932146933146934146935146936146937146938146939146940146941146942146943146944146945146946146947146948146949146950146951146952146953146954146955146956146957146958146959146960146961146962146963146964146965146966146967146968146969146970146971146972146973146974146975146976146977146978146979146980146981146982146983146984146985146986146987146988146989146990146991146992146993146994146995146996146997146998146999147000147001147002147003147004147005147006147007147008147009147010147011147012147013147014147015147016147017147018147019147020147021147022147023147024147025147026147027147028147029147030147031147032147033147034147035147036147037147038147039147040147041147042147043147044147045147046147047147048147049147050147051147052147053147054147055147056147057147058147059147060147061147062147063147064147065147066147067147068147069147070147071147072147073147074147075147076147077147078147079147080147081147082147083147084147085147086147087147088147089147090147091147092147093147094147095147096147097147098147099147100147101147102147103147104147105147106147107147108147109147110147111147112147113147114147115147116147117147118147119147120147121147122147123147124147125147126147127147128147129147130147131147132147133147134147135147136147137147138147139147140147141147142147143147144147145147146147147147148147149147150147151147152147153147154147155147156147157147158147159147160147161147162147163147164147165147166147167147168147169147170147171147172147173147174147175147176147177147178147179147180147181147182147183147184147185147186147187147188147189147190147191147192147193147194147195147196147197147198147199147200147201147202147203147204147205147206147207147208147209147210147211147212147213147214147215147216147217147218147219147220147221147222147223147224147225147226147227147228147229147230147231147232147233147234147235147236147237147238147239147240147241147242147243147244147245147246147247147248147249147250147251147252147253147254147255147256147257147258147259147260147261147262147263147264147265147266147267147268147269147270147271147272147273147274147275147276147277147278147279147280147281147282147283147284147285147286147287147288147289147290147291147292147293147294147295147296147297147298147299147300147301147302147303147304147305147306147307147308147309147310147311147312147313147314147315147316147317147318147319147320147321147322147323147324147325147326147327147328147329147330147331147332147333147334147335147336147337147338147339147340147341147342147343147344147345147346147347147348147349147350147351147352147353147354147355147356147357147358147359147360147361147362147363147364147365147366147367147368147369147370147371147372147373147374147375147376147377147378147379147380147381147382147383147384147385147386147387147388147389147390147391147392147393147394147395147396147397147398147399147400147401147402147403147404147405147406147407147408147409147410147411147412147413147414147415147416147417147418147419147420147421147422147423147424147425147426147427147428147429147430147431147432147433147434147435147436147437147438147439147440147441147442147443147444147445147446147447147448147449147450147451147452147453147454147455147456147457147458147459147460147461147462147463147464147465147466147467147468147469147470147471147472147473147474147475147476147477147478147479147480147481147482147483147484147485147486147487147488147489147490147491147492147493147494147495147496147497147498147499147500147501147502147503147504147505147506147507147508147509147510147511147512147513147514147515147516147517147518147519147520147521147522147523147524147525147526147527147528147529147530147531147532147533147534147535147536147537147538147539147540147541147542147543147544147545147546147547147548147549147550147551147552147553147554147555147556147557147558147559147560147561147562147563147564147565147566147567147568147569147570147571147572147573147574147575147576147577147578147579147580147581147582147583147584147585147586147587147588147589147590147591147592147593147594147595147596147597147598147599147600147601147602147603
  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 { Vector3 } from "babylonjs/Maths/math.vector";
  28236. import { Mesh } from "babylonjs/Meshes/mesh";
  28237. import { Scene, IDisposable } from "babylonjs/scene";
  28238. import { DepthSortedParticle, SolidParticle } from "babylonjs/Particles/solidParticle";
  28239. import { Material } from "babylonjs/Materials/material";
  28240. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  28241. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  28242. /**
  28243. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  28244. *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.
  28245. * The SPS is also a particle system. It provides some methods to manage the particles.
  28246. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  28247. *
  28248. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  28249. */
  28250. export class SolidParticleSystem implements IDisposable {
  28251. /**
  28252. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  28253. * Example : var p = SPS.particles[i];
  28254. */
  28255. particles: SolidParticle[];
  28256. /**
  28257. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  28258. */
  28259. nbParticles: number;
  28260. /**
  28261. * If the particles must ever face the camera (default false). Useful for planar particles.
  28262. */
  28263. billboard: boolean;
  28264. /**
  28265. * Recompute normals when adding a shape
  28266. */
  28267. recomputeNormals: boolean;
  28268. /**
  28269. * This a counter ofr your own usage. It's not set by any SPS functions.
  28270. */
  28271. counter: number;
  28272. /**
  28273. * The SPS name. This name is also given to the underlying mesh.
  28274. */
  28275. name: string;
  28276. /**
  28277. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  28278. */
  28279. mesh: Mesh;
  28280. /**
  28281. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  28282. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  28283. */
  28284. vars: any;
  28285. /**
  28286. * This array is populated when the SPS is set as 'pickable'.
  28287. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  28288. * Each element of this array is an object `{idx: int, faceId: int}`.
  28289. * `idx` is the picked particle index in the `SPS.particles` array
  28290. * `faceId` is the picked face index counted within this particle.
  28291. * This array is the first element of the pickedBySubMesh array : sps.pickBySubMesh[0].
  28292. * It's not pertinent to use it when using a SPS with the support for MultiMaterial enabled.
  28293. * Use the method SPS.pickedParticle(pickingInfo) instead.
  28294. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  28295. */
  28296. pickedParticles: {
  28297. idx: number;
  28298. faceId: number;
  28299. }[];
  28300. /**
  28301. * This array is populated when the SPS is set as 'pickable'
  28302. * Each key of this array is a submesh index.
  28303. * Each element of this array is a second array defined like this :
  28304. * Each key of this second array is a `faceId` value that you can get from a pickResult object.
  28305. * Each element of this second array is an object `{idx: int, faceId: int}`.
  28306. * `idx` is the picked particle index in the `SPS.particles` array
  28307. * `faceId` is the picked face index counted within this particle.
  28308. * It's better to use the method SPS.pickedParticle(pickingInfo) rather than using directly this array.
  28309. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  28310. */
  28311. pickedBySubMesh: {
  28312. idx: number;
  28313. faceId: number;
  28314. }[][];
  28315. /**
  28316. * This array is populated when `enableDepthSort` is set to true.
  28317. * Each element of this array is an instance of the class DepthSortedParticle.
  28318. */
  28319. depthSortedParticles: DepthSortedParticle[];
  28320. /**
  28321. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  28322. * @hidden
  28323. */
  28324. _bSphereOnly: boolean;
  28325. /**
  28326. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  28327. * @hidden
  28328. */
  28329. _bSphereRadiusFactor: number;
  28330. private _scene;
  28331. private _positions;
  28332. private _indices;
  28333. private _normals;
  28334. private _colors;
  28335. private _uvs;
  28336. private _indices32;
  28337. private _positions32;
  28338. private _normals32;
  28339. private _fixedNormal32;
  28340. private _colors32;
  28341. private _uvs32;
  28342. private _index;
  28343. private _updatable;
  28344. private _pickable;
  28345. private _isVisibilityBoxLocked;
  28346. private _alwaysVisible;
  28347. private _depthSort;
  28348. private _expandable;
  28349. private _shapeCounter;
  28350. private _copy;
  28351. private _color;
  28352. private _computeParticleColor;
  28353. private _computeParticleTexture;
  28354. private _computeParticleRotation;
  28355. private _computeParticleVertex;
  28356. private _computeBoundingBox;
  28357. private _depthSortParticles;
  28358. private _camera;
  28359. private _mustUnrotateFixedNormals;
  28360. private _particlesIntersect;
  28361. private _needs32Bits;
  28362. private _isNotBuilt;
  28363. private _lastParticleId;
  28364. private _idxOfId;
  28365. private _multimaterialEnabled;
  28366. private _useModelMaterial;
  28367. private _indicesByMaterial;
  28368. private _materialIndexes;
  28369. private _depthSortFunction;
  28370. private _materialSortFunction;
  28371. private _materials;
  28372. private _multimaterial;
  28373. private _materialIndexesById;
  28374. private _defaultMaterial;
  28375. private _autoUpdateSubMeshes;
  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 index of the current particle
  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
  28782. * @returns the updated vertex
  28783. */
  28784. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  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 } 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. declare module "babylonjs/Collisions/meshCollisionData" {
  29092. import { Collider } from "babylonjs/Collisions/collider";
  29093. import { Vector3 } from "babylonjs/Maths/math.vector";
  29094. import { Nullable } from "babylonjs/types";
  29095. import { Observer } from "babylonjs/Misc/observable";
  29096. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  29097. /**
  29098. * @hidden
  29099. */
  29100. export class _MeshCollisionData {
  29101. _checkCollisions: boolean;
  29102. _collisionMask: number;
  29103. _collisionGroup: number;
  29104. _surroundingMeshes: Nullable<AbstractMesh[]>;
  29105. _collider: Nullable<Collider>;
  29106. _oldPositionForCollisions: Vector3;
  29107. _diffPositionForCollisions: Vector3;
  29108. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  29109. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  29110. }
  29111. }
  29112. declare module "babylonjs/Meshes/abstractMesh" {
  29113. import { Observable } from "babylonjs/Misc/observable";
  29114. import { Nullable, FloatArray, IndicesArray, DeepImmutable } from "babylonjs/types";
  29115. import { Camera } from "babylonjs/Cameras/camera";
  29116. import { Scene, IDisposable } from "babylonjs/scene";
  29117. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  29118. import { Node } from "babylonjs/node";
  29119. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  29120. import { TransformNode } from "babylonjs/Meshes/transformNode";
  29121. import { SubMesh } from "babylonjs/Meshes/subMesh";
  29122. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  29123. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  29124. import { Material } from "babylonjs/Materials/material";
  29125. import { Light } from "babylonjs/Lights/light";
  29126. import { Skeleton } from "babylonjs/Bones/skeleton";
  29127. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  29128. import { SolidParticle } from "babylonjs/Particles/solidParticle";
  29129. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  29130. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  29131. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  29132. import { Plane } from "babylonjs/Maths/math.plane";
  29133. import { Ray } from "babylonjs/Culling/ray";
  29134. import { Collider } from "babylonjs/Collisions/collider";
  29135. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  29136. import { RenderingGroup } from "babylonjs/Rendering/renderingGroup";
  29137. /** @hidden */
  29138. class _FacetDataStorage {
  29139. facetPositions: Vector3[];
  29140. facetNormals: Vector3[];
  29141. facetPartitioning: number[][];
  29142. facetNb: number;
  29143. partitioningSubdivisions: number;
  29144. partitioningBBoxRatio: number;
  29145. facetDataEnabled: boolean;
  29146. facetParameters: any;
  29147. bbSize: Vector3;
  29148. subDiv: {
  29149. max: number;
  29150. X: number;
  29151. Y: number;
  29152. Z: number;
  29153. };
  29154. facetDepthSort: boolean;
  29155. facetDepthSortEnabled: boolean;
  29156. depthSortedIndices: IndicesArray;
  29157. depthSortedFacets: {
  29158. ind: number;
  29159. sqDistance: number;
  29160. }[];
  29161. facetDepthSortFunction: (f1: {
  29162. ind: number;
  29163. sqDistance: number;
  29164. }, f2: {
  29165. ind: number;
  29166. sqDistance: number;
  29167. }) => number;
  29168. facetDepthSortFrom: Vector3;
  29169. facetDepthSortOrigin: Vector3;
  29170. invertedMatrix: Matrix;
  29171. }
  29172. /**
  29173. * @hidden
  29174. **/
  29175. class _InternalAbstractMeshDataInfo {
  29176. _hasVertexAlpha: boolean;
  29177. _useVertexColors: boolean;
  29178. _numBoneInfluencers: number;
  29179. _applyFog: boolean;
  29180. _receiveShadows: boolean;
  29181. _facetData: _FacetDataStorage;
  29182. _visibility: number;
  29183. _skeleton: Nullable<Skeleton>;
  29184. _layerMask: number;
  29185. _computeBonesUsingShaders: boolean;
  29186. _isActive: boolean;
  29187. _onlyForInstances: boolean;
  29188. _isActiveIntermediate: boolean;
  29189. _onlyForInstancesIntermediate: boolean;
  29190. _actAsRegularMesh: boolean;
  29191. }
  29192. /**
  29193. * Class used to store all common mesh properties
  29194. */
  29195. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  29196. /** No occlusion */
  29197. static OCCLUSION_TYPE_NONE: number;
  29198. /** Occlusion set to optimisitic */
  29199. static OCCLUSION_TYPE_OPTIMISTIC: number;
  29200. /** Occlusion set to strict */
  29201. static OCCLUSION_TYPE_STRICT: number;
  29202. /** Use an accurante occlusion algorithm */
  29203. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  29204. /** Use a conservative occlusion algorithm */
  29205. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  29206. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  29207. * Test order :
  29208. * Is the bounding sphere outside the frustum ?
  29209. * If not, are the bounding box vertices outside the frustum ?
  29210. * It not, then the cullable object is in the frustum.
  29211. */
  29212. static readonly CULLINGSTRATEGY_STANDARD: number;
  29213. /** Culling strategy : Bounding Sphere Only.
  29214. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  29215. * It's also less accurate than the standard because some not visible objects can still be selected.
  29216. * Test : is the bounding sphere outside the frustum ?
  29217. * If not, then the cullable object is in the frustum.
  29218. */
  29219. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  29220. /** Culling strategy : Optimistic Inclusion.
  29221. * This in an inclusion test first, then the standard exclusion test.
  29222. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  29223. * 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.
  29224. * Anyway, it's as accurate as the standard strategy.
  29225. * Test :
  29226. * Is the cullable object bounding sphere center in the frustum ?
  29227. * If not, apply the default culling strategy.
  29228. */
  29229. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  29230. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  29231. * This in an inclusion test first, then the bounding sphere only exclusion test.
  29232. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  29233. * 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.
  29234. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  29235. * Test :
  29236. * Is the cullable object bounding sphere center in the frustum ?
  29237. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  29238. */
  29239. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  29240. /**
  29241. * No billboard
  29242. */
  29243. static get BILLBOARDMODE_NONE(): number;
  29244. /** Billboard on X axis */
  29245. static get BILLBOARDMODE_X(): number;
  29246. /** Billboard on Y axis */
  29247. static get BILLBOARDMODE_Y(): number;
  29248. /** Billboard on Z axis */
  29249. static get BILLBOARDMODE_Z(): number;
  29250. /** Billboard on all axes */
  29251. static get BILLBOARDMODE_ALL(): number;
  29252. /** Billboard on using position instead of orientation */
  29253. static get BILLBOARDMODE_USE_POSITION(): number;
  29254. /** @hidden */
  29255. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  29256. /**
  29257. * The culling strategy to use to check whether the mesh must be rendered or not.
  29258. * This value can be changed at any time and will be used on the next render mesh selection.
  29259. * The possible values are :
  29260. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  29261. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  29262. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  29263. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  29264. * Please read each static variable documentation to get details about the culling process.
  29265. * */
  29266. cullingStrategy: number;
  29267. /**
  29268. * Gets the number of facets in the mesh
  29269. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  29270. */
  29271. get facetNb(): number;
  29272. /**
  29273. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  29274. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  29275. */
  29276. get partitioningSubdivisions(): number;
  29277. set partitioningSubdivisions(nb: number);
  29278. /**
  29279. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  29280. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  29281. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  29282. */
  29283. get partitioningBBoxRatio(): number;
  29284. set partitioningBBoxRatio(ratio: number);
  29285. /**
  29286. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  29287. * Works only for updatable meshes.
  29288. * Doesn't work with multi-materials
  29289. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  29290. */
  29291. get mustDepthSortFacets(): boolean;
  29292. set mustDepthSortFacets(sort: boolean);
  29293. /**
  29294. * The location (Vector3) where the facet depth sort must be computed from.
  29295. * By default, the active camera position.
  29296. * Used only when facet depth sort is enabled
  29297. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  29298. */
  29299. get facetDepthSortFrom(): Vector3;
  29300. set facetDepthSortFrom(location: Vector3);
  29301. /**
  29302. * gets a boolean indicating if facetData is enabled
  29303. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  29304. */
  29305. get isFacetDataEnabled(): boolean;
  29306. /** @hidden */
  29307. _updateNonUniformScalingState(value: boolean): boolean;
  29308. /**
  29309. * An event triggered when this mesh collides with another one
  29310. */
  29311. onCollideObservable: Observable<AbstractMesh>;
  29312. /** Set a function to call when this mesh collides with another one */
  29313. set onCollide(callback: () => void);
  29314. /**
  29315. * An event triggered when the collision's position changes
  29316. */
  29317. onCollisionPositionChangeObservable: Observable<Vector3>;
  29318. /** Set a function to call when the collision's position changes */
  29319. set onCollisionPositionChange(callback: () => void);
  29320. /**
  29321. * An event triggered when material is changed
  29322. */
  29323. onMaterialChangedObservable: Observable<AbstractMesh>;
  29324. /**
  29325. * Gets or sets the orientation for POV movement & rotation
  29326. */
  29327. definedFacingForward: boolean;
  29328. /** @hidden */
  29329. _occlusionQuery: Nullable<WebGLQuery>;
  29330. /** @hidden */
  29331. _renderingGroup: Nullable<RenderingGroup>;
  29332. /**
  29333. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  29334. */
  29335. get visibility(): number;
  29336. /**
  29337. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  29338. */
  29339. set visibility(value: number);
  29340. /** Gets or sets the alpha index used to sort transparent meshes
  29341. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  29342. */
  29343. alphaIndex: number;
  29344. /**
  29345. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  29346. */
  29347. isVisible: boolean;
  29348. /**
  29349. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  29350. */
  29351. isPickable: boolean;
  29352. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  29353. showSubMeshesBoundingBox: boolean;
  29354. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  29355. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  29356. */
  29357. isBlocker: boolean;
  29358. /**
  29359. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  29360. */
  29361. enablePointerMoveEvents: boolean;
  29362. /**
  29363. * Specifies the rendering group id for this mesh (0 by default)
  29364. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  29365. */
  29366. renderingGroupId: number;
  29367. private _material;
  29368. /** Gets or sets current material */
  29369. get material(): Nullable<Material>;
  29370. set material(value: Nullable<Material>);
  29371. /**
  29372. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  29373. * @see http://doc.babylonjs.com/babylon101/shadows
  29374. */
  29375. get receiveShadows(): boolean;
  29376. set receiveShadows(value: boolean);
  29377. /** Defines color to use when rendering outline */
  29378. outlineColor: Color3;
  29379. /** Define width to use when rendering outline */
  29380. outlineWidth: number;
  29381. /** Defines color to use when rendering overlay */
  29382. overlayColor: Color3;
  29383. /** Defines alpha to use when rendering overlay */
  29384. overlayAlpha: number;
  29385. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  29386. get hasVertexAlpha(): boolean;
  29387. set hasVertexAlpha(value: boolean);
  29388. /** 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) */
  29389. get useVertexColors(): boolean;
  29390. set useVertexColors(value: boolean);
  29391. /**
  29392. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  29393. */
  29394. get computeBonesUsingShaders(): boolean;
  29395. set computeBonesUsingShaders(value: boolean);
  29396. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  29397. get numBoneInfluencers(): number;
  29398. set numBoneInfluencers(value: number);
  29399. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  29400. get applyFog(): boolean;
  29401. set applyFog(value: boolean);
  29402. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  29403. useOctreeForRenderingSelection: boolean;
  29404. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  29405. useOctreeForPicking: boolean;
  29406. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  29407. useOctreeForCollisions: boolean;
  29408. /**
  29409. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  29410. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  29411. */
  29412. get layerMask(): number;
  29413. set layerMask(value: number);
  29414. /**
  29415. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  29416. */
  29417. alwaysSelectAsActiveMesh: boolean;
  29418. /**
  29419. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  29420. */
  29421. doNotSyncBoundingInfo: boolean;
  29422. /**
  29423. * Gets or sets the current action manager
  29424. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  29425. */
  29426. actionManager: Nullable<AbstractActionManager>;
  29427. private _meshCollisionData;
  29428. /**
  29429. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  29430. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  29431. */
  29432. ellipsoid: Vector3;
  29433. /**
  29434. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  29435. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  29436. */
  29437. ellipsoidOffset: Vector3;
  29438. /**
  29439. * Gets or sets a collision mask used to mask collisions (default is -1).
  29440. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  29441. */
  29442. get collisionMask(): number;
  29443. set collisionMask(mask: number);
  29444. /**
  29445. * Gets or sets the current collision group mask (-1 by default).
  29446. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  29447. */
  29448. get collisionGroup(): number;
  29449. set collisionGroup(mask: number);
  29450. /**
  29451. * Gets or sets current surrounding meshes (null by default).
  29452. *
  29453. * By default collision detection is tested against every mesh in the scene.
  29454. * It is possible to set surroundingMeshes to a defined list of meshes and then only these specified
  29455. * meshes will be tested for the collision.
  29456. *
  29457. * Note: if set to an empty array no collision will happen when this mesh is moved.
  29458. */
  29459. get surroundingMeshes(): Nullable<AbstractMesh[]>;
  29460. set surroundingMeshes(meshes: Nullable<AbstractMesh[]>);
  29461. /**
  29462. * Defines edge width used when edgesRenderer is enabled
  29463. * @see https://www.babylonjs-playground.com/#10OJSG#13
  29464. */
  29465. edgesWidth: number;
  29466. /**
  29467. * Defines edge color used when edgesRenderer is enabled
  29468. * @see https://www.babylonjs-playground.com/#10OJSG#13
  29469. */
  29470. edgesColor: Color4;
  29471. /** @hidden */
  29472. _edgesRenderer: Nullable<IEdgesRenderer>;
  29473. /** @hidden */
  29474. _masterMesh: Nullable<AbstractMesh>;
  29475. /** @hidden */
  29476. _boundingInfo: Nullable<BoundingInfo>;
  29477. /** @hidden */
  29478. _renderId: number;
  29479. /**
  29480. * Gets or sets the list of subMeshes
  29481. * @see http://doc.babylonjs.com/how_to/multi_materials
  29482. */
  29483. subMeshes: SubMesh[];
  29484. /** @hidden */
  29485. _intersectionsInProgress: AbstractMesh[];
  29486. /** @hidden */
  29487. _unIndexed: boolean;
  29488. /** @hidden */
  29489. _lightSources: Light[];
  29490. /** Gets the list of lights affecting that mesh */
  29491. get lightSources(): Light[];
  29492. /** @hidden */
  29493. get _positions(): Nullable<Vector3[]>;
  29494. /** @hidden */
  29495. _waitingData: {
  29496. lods: Nullable<any>;
  29497. actions: Nullable<any>;
  29498. freezeWorldMatrix: Nullable<boolean>;
  29499. };
  29500. /** @hidden */
  29501. _bonesTransformMatrices: Nullable<Float32Array>;
  29502. /** @hidden */
  29503. _transformMatrixTexture: Nullable<RawTexture>;
  29504. /**
  29505. * Gets or sets a skeleton to apply skining transformations
  29506. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  29507. */
  29508. set skeleton(value: Nullable<Skeleton>);
  29509. get skeleton(): Nullable<Skeleton>;
  29510. /**
  29511. * An event triggered when the mesh is rebuilt.
  29512. */
  29513. onRebuildObservable: Observable<AbstractMesh>;
  29514. /**
  29515. * Creates a new AbstractMesh
  29516. * @param name defines the name of the mesh
  29517. * @param scene defines the hosting scene
  29518. */
  29519. constructor(name: string, scene?: Nullable<Scene>);
  29520. /**
  29521. * Returns the string "AbstractMesh"
  29522. * @returns "AbstractMesh"
  29523. */
  29524. getClassName(): string;
  29525. /**
  29526. * Gets a string representation of the current mesh
  29527. * @param fullDetails defines a boolean indicating if full details must be included
  29528. * @returns a string representation of the current mesh
  29529. */
  29530. toString(fullDetails?: boolean): string;
  29531. /**
  29532. * @hidden
  29533. */
  29534. protected _getEffectiveParent(): Nullable<Node>;
  29535. /** @hidden */
  29536. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  29537. /** @hidden */
  29538. _rebuild(): void;
  29539. /** @hidden */
  29540. _resyncLightSources(): void;
  29541. /** @hidden */
  29542. _resyncLightSource(light: Light): void;
  29543. /** @hidden */
  29544. _unBindEffect(): void;
  29545. /** @hidden */
  29546. _removeLightSource(light: Light, dispose: boolean): void;
  29547. private _markSubMeshesAsDirty;
  29548. /** @hidden */
  29549. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  29550. /** @hidden */
  29551. _markSubMeshesAsAttributesDirty(): void;
  29552. /** @hidden */
  29553. _markSubMeshesAsMiscDirty(): void;
  29554. /**
  29555. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  29556. */
  29557. get scaling(): Vector3;
  29558. set scaling(newScaling: Vector3);
  29559. /**
  29560. * Returns true if the mesh is blocked. Implemented by child classes
  29561. */
  29562. get isBlocked(): boolean;
  29563. /**
  29564. * Returns the mesh itself by default. Implemented by child classes
  29565. * @param camera defines the camera to use to pick the right LOD level
  29566. * @returns the currentAbstractMesh
  29567. */
  29568. getLOD(camera: Camera): Nullable<AbstractMesh>;
  29569. /**
  29570. * Returns 0 by default. Implemented by child classes
  29571. * @returns an integer
  29572. */
  29573. getTotalVertices(): number;
  29574. /**
  29575. * Returns a positive integer : the total number of indices in this mesh geometry.
  29576. * @returns the numner of indices or zero if the mesh has no geometry.
  29577. */
  29578. getTotalIndices(): number;
  29579. /**
  29580. * Returns null by default. Implemented by child classes
  29581. * @returns null
  29582. */
  29583. getIndices(): Nullable<IndicesArray>;
  29584. /**
  29585. * Returns the array of the requested vertex data kind. Implemented by child classes
  29586. * @param kind defines the vertex data kind to use
  29587. * @returns null
  29588. */
  29589. getVerticesData(kind: string): Nullable<FloatArray>;
  29590. /**
  29591. * Sets the vertex data of the mesh geometry for the requested `kind`.
  29592. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  29593. * Note that a new underlying VertexBuffer object is created each call.
  29594. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  29595. * @param kind defines vertex data kind:
  29596. * * VertexBuffer.PositionKind
  29597. * * VertexBuffer.UVKind
  29598. * * VertexBuffer.UV2Kind
  29599. * * VertexBuffer.UV3Kind
  29600. * * VertexBuffer.UV4Kind
  29601. * * VertexBuffer.UV5Kind
  29602. * * VertexBuffer.UV6Kind
  29603. * * VertexBuffer.ColorKind
  29604. * * VertexBuffer.MatricesIndicesKind
  29605. * * VertexBuffer.MatricesIndicesExtraKind
  29606. * * VertexBuffer.MatricesWeightsKind
  29607. * * VertexBuffer.MatricesWeightsExtraKind
  29608. * @param data defines the data source
  29609. * @param updatable defines if the data must be flagged as updatable (or static)
  29610. * @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
  29611. * @returns the current mesh
  29612. */
  29613. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  29614. /**
  29615. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  29616. * If the mesh has no geometry, it is simply returned as it is.
  29617. * @param kind defines vertex data kind:
  29618. * * VertexBuffer.PositionKind
  29619. * * VertexBuffer.UVKind
  29620. * * VertexBuffer.UV2Kind
  29621. * * VertexBuffer.UV3Kind
  29622. * * VertexBuffer.UV4Kind
  29623. * * VertexBuffer.UV5Kind
  29624. * * VertexBuffer.UV6Kind
  29625. * * VertexBuffer.ColorKind
  29626. * * VertexBuffer.MatricesIndicesKind
  29627. * * VertexBuffer.MatricesIndicesExtraKind
  29628. * * VertexBuffer.MatricesWeightsKind
  29629. * * VertexBuffer.MatricesWeightsExtraKind
  29630. * @param data defines the data source
  29631. * @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
  29632. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  29633. * @returns the current mesh
  29634. */
  29635. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  29636. /**
  29637. * Sets the mesh indices,
  29638. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  29639. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  29640. * @param totalVertices Defines the total number of vertices
  29641. * @returns the current mesh
  29642. */
  29643. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  29644. /**
  29645. * Gets a boolean indicating if specific vertex data is present
  29646. * @param kind defines the vertex data kind to use
  29647. * @returns true is data kind is present
  29648. */
  29649. isVerticesDataPresent(kind: string): boolean;
  29650. /**
  29651. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  29652. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  29653. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  29654. * @returns a BoundingInfo
  29655. */
  29656. getBoundingInfo(): BoundingInfo;
  29657. /**
  29658. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  29659. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  29660. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  29661. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  29662. * @returns the current mesh
  29663. */
  29664. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  29665. /**
  29666. * Overwrite the current bounding info
  29667. * @param boundingInfo defines the new bounding info
  29668. * @returns the current mesh
  29669. */
  29670. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  29671. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  29672. get useBones(): boolean;
  29673. /** @hidden */
  29674. _preActivate(): void;
  29675. /** @hidden */
  29676. _preActivateForIntermediateRendering(renderId: number): void;
  29677. /** @hidden */
  29678. _activate(renderId: number, intermediateRendering: boolean): boolean;
  29679. /** @hidden */
  29680. _postActivate(): void;
  29681. /** @hidden */
  29682. _freeze(): void;
  29683. /** @hidden */
  29684. _unFreeze(): void;
  29685. /**
  29686. * Gets the current world matrix
  29687. * @returns a Matrix
  29688. */
  29689. getWorldMatrix(): Matrix;
  29690. /** @hidden */
  29691. _getWorldMatrixDeterminant(): number;
  29692. /**
  29693. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  29694. */
  29695. get isAnInstance(): boolean;
  29696. /**
  29697. * Gets a boolean indicating if this mesh has instances
  29698. */
  29699. get hasInstances(): boolean;
  29700. /**
  29701. * Perform relative position change from the point of view of behind the front of the mesh.
  29702. * This is performed taking into account the meshes current rotation, so you do not have to care.
  29703. * Supports definition of mesh facing forward or backward
  29704. * @param amountRight defines the distance on the right axis
  29705. * @param amountUp defines the distance on the up axis
  29706. * @param amountForward defines the distance on the forward axis
  29707. * @returns the current mesh
  29708. */
  29709. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  29710. /**
  29711. * Calculate relative position change from the point of view of behind the front of the mesh.
  29712. * This is performed taking into account the meshes current rotation, so you do not have to care.
  29713. * Supports definition of mesh facing forward or backward
  29714. * @param amountRight defines the distance on the right axis
  29715. * @param amountUp defines the distance on the up axis
  29716. * @param amountForward defines the distance on the forward axis
  29717. * @returns the new displacement vector
  29718. */
  29719. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  29720. /**
  29721. * Perform relative rotation change from the point of view of behind the front of the mesh.
  29722. * Supports definition of mesh facing forward or backward
  29723. * @param flipBack defines the flip
  29724. * @param twirlClockwise defines the twirl
  29725. * @param tiltRight defines the tilt
  29726. * @returns the current mesh
  29727. */
  29728. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  29729. /**
  29730. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  29731. * Supports definition of mesh facing forward or backward.
  29732. * @param flipBack defines the flip
  29733. * @param twirlClockwise defines the twirl
  29734. * @param tiltRight defines the tilt
  29735. * @returns the new rotation vector
  29736. */
  29737. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  29738. /**
  29739. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  29740. * This means the mesh underlying bounding box and sphere are recomputed.
  29741. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  29742. * @returns the current mesh
  29743. */
  29744. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  29745. /** @hidden */
  29746. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  29747. /** @hidden */
  29748. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  29749. /** @hidden */
  29750. _updateBoundingInfo(): AbstractMesh;
  29751. /** @hidden */
  29752. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  29753. /** @hidden */
  29754. protected _afterComputeWorldMatrix(): void;
  29755. /** @hidden */
  29756. get _effectiveMesh(): AbstractMesh;
  29757. /**
  29758. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  29759. * A mesh is in the frustum if its bounding box intersects the frustum
  29760. * @param frustumPlanes defines the frustum to test
  29761. * @returns true if the mesh is in the frustum planes
  29762. */
  29763. isInFrustum(frustumPlanes: Plane[]): boolean;
  29764. /**
  29765. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  29766. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  29767. * @param frustumPlanes defines the frustum to test
  29768. * @returns true if the mesh is completely in the frustum planes
  29769. */
  29770. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  29771. /**
  29772. * True if the mesh intersects another mesh or a SolidParticle object
  29773. * @param mesh defines a target mesh or SolidParticle to test
  29774. * @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)
  29775. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  29776. * @returns true if there is an intersection
  29777. */
  29778. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  29779. /**
  29780. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  29781. * @param point defines the point to test
  29782. * @returns true if there is an intersection
  29783. */
  29784. intersectsPoint(point: Vector3): boolean;
  29785. /**
  29786. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  29787. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  29788. */
  29789. get checkCollisions(): boolean;
  29790. set checkCollisions(collisionEnabled: boolean);
  29791. /**
  29792. * Gets Collider object used to compute collisions (not physics)
  29793. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  29794. */
  29795. get collider(): Nullable<Collider>;
  29796. /**
  29797. * Move the mesh using collision engine
  29798. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  29799. * @param displacement defines the requested displacement vector
  29800. * @returns the current mesh
  29801. */
  29802. moveWithCollisions(displacement: Vector3): AbstractMesh;
  29803. private _onCollisionPositionChange;
  29804. /** @hidden */
  29805. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  29806. /** @hidden */
  29807. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  29808. /** @hidden */
  29809. _checkCollision(collider: Collider): AbstractMesh;
  29810. /** @hidden */
  29811. _generatePointsArray(): boolean;
  29812. /**
  29813. * Checks if the passed Ray intersects with the mesh
  29814. * @param ray defines the ray to use
  29815. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  29816. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  29817. * @param onlyBoundingInfo defines a boolean indicating if picking should only happen using bounding info (false by default)
  29818. * @returns the picking info
  29819. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  29820. */
  29821. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate, onlyBoundingInfo?: boolean): PickingInfo;
  29822. /**
  29823. * Clones the current mesh
  29824. * @param name defines the mesh name
  29825. * @param newParent defines the new mesh parent
  29826. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  29827. * @returns the new mesh
  29828. */
  29829. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  29830. /**
  29831. * Disposes all the submeshes of the current meshnp
  29832. * @returns the current mesh
  29833. */
  29834. releaseSubMeshes(): AbstractMesh;
  29835. /**
  29836. * Releases resources associated with this abstract mesh.
  29837. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  29838. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  29839. */
  29840. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  29841. /**
  29842. * Adds the passed mesh as a child to the current mesh
  29843. * @param mesh defines the child mesh
  29844. * @returns the current mesh
  29845. */
  29846. addChild(mesh: AbstractMesh): AbstractMesh;
  29847. /**
  29848. * Removes the passed mesh from the current mesh children list
  29849. * @param mesh defines the child mesh
  29850. * @returns the current mesh
  29851. */
  29852. removeChild(mesh: AbstractMesh): AbstractMesh;
  29853. /** @hidden */
  29854. private _initFacetData;
  29855. /**
  29856. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  29857. * This method can be called within the render loop.
  29858. * 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
  29859. * @returns the current mesh
  29860. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29861. */
  29862. updateFacetData(): AbstractMesh;
  29863. /**
  29864. * Returns the facetLocalNormals array.
  29865. * The normals are expressed in the mesh local spac
  29866. * @returns an array of Vector3
  29867. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29868. */
  29869. getFacetLocalNormals(): Vector3[];
  29870. /**
  29871. * Returns the facetLocalPositions array.
  29872. * The facet positions are expressed in the mesh local space
  29873. * @returns an array of Vector3
  29874. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29875. */
  29876. getFacetLocalPositions(): Vector3[];
  29877. /**
  29878. * Returns the facetLocalPartioning array
  29879. * @returns an array of array of numbers
  29880. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29881. */
  29882. getFacetLocalPartitioning(): number[][];
  29883. /**
  29884. * Returns the i-th facet position in the world system.
  29885. * This method allocates a new Vector3 per call
  29886. * @param i defines the facet index
  29887. * @returns a new Vector3
  29888. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29889. */
  29890. getFacetPosition(i: number): Vector3;
  29891. /**
  29892. * Sets the reference Vector3 with the i-th facet position in the world system
  29893. * @param i defines the facet index
  29894. * @param ref defines the target vector
  29895. * @returns the current mesh
  29896. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29897. */
  29898. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  29899. /**
  29900. * Returns the i-th facet normal in the world system.
  29901. * This method allocates a new Vector3 per call
  29902. * @param i defines the facet index
  29903. * @returns a new Vector3
  29904. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29905. */
  29906. getFacetNormal(i: number): Vector3;
  29907. /**
  29908. * Sets the reference Vector3 with the i-th facet normal in the world system
  29909. * @param i defines the facet index
  29910. * @param ref defines the target vector
  29911. * @returns the current mesh
  29912. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29913. */
  29914. getFacetNormalToRef(i: number, ref: Vector3): this;
  29915. /**
  29916. * 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)
  29917. * @param x defines x coordinate
  29918. * @param y defines y coordinate
  29919. * @param z defines z coordinate
  29920. * @returns the array of facet indexes
  29921. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29922. */
  29923. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  29924. /**
  29925. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  29926. * @param projected sets as the (x,y,z) world projection on the facet
  29927. * @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
  29928. * @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
  29929. * @param x defines x coordinate
  29930. * @param y defines y coordinate
  29931. * @param z defines z coordinate
  29932. * @returns the face index if found (or null instead)
  29933. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29934. */
  29935. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  29936. /**
  29937. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  29938. * @param projected sets as the (x,y,z) local projection on the facet
  29939. * @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
  29940. * @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
  29941. * @param x defines x coordinate
  29942. * @param y defines y coordinate
  29943. * @param z defines z coordinate
  29944. * @returns the face index if found (or null instead)
  29945. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29946. */
  29947. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  29948. /**
  29949. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  29950. * @returns the parameters
  29951. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29952. */
  29953. getFacetDataParameters(): any;
  29954. /**
  29955. * Disables the feature FacetData and frees the related memory
  29956. * @returns the current mesh
  29957. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29958. */
  29959. disableFacetData(): AbstractMesh;
  29960. /**
  29961. * Updates the AbstractMesh indices array
  29962. * @param indices defines the data source
  29963. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  29964. * @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)
  29965. * @returns the current mesh
  29966. */
  29967. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  29968. /**
  29969. * Creates new normals data for the mesh
  29970. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  29971. * @returns the current mesh
  29972. */
  29973. createNormals(updatable: boolean): AbstractMesh;
  29974. /**
  29975. * Align the mesh with a normal
  29976. * @param normal defines the normal to use
  29977. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  29978. * @returns the current mesh
  29979. */
  29980. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  29981. /** @hidden */
  29982. _checkOcclusionQuery(): boolean;
  29983. /**
  29984. * Disables the mesh edge rendering mode
  29985. * @returns the currentAbstractMesh
  29986. */
  29987. disableEdgesRendering(): AbstractMesh;
  29988. /**
  29989. * Enables the edge rendering mode on the mesh.
  29990. * This mode makes the mesh edges visible
  29991. * @param epsilon defines the maximal distance between two angles to detect a face
  29992. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  29993. * @returns the currentAbstractMesh
  29994. * @see https://www.babylonjs-playground.com/#19O9TU#0
  29995. */
  29996. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  29997. }
  29998. }
  29999. declare module "babylonjs/Actions/actionEvent" {
  30000. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  30001. import { Nullable } from "babylonjs/types";
  30002. import { Sprite } from "babylonjs/Sprites/sprite";
  30003. import { Scene } from "babylonjs/scene";
  30004. import { Vector2 } from "babylonjs/Maths/math.vector";
  30005. /**
  30006. * Interface used to define ActionEvent
  30007. */
  30008. export interface IActionEvent {
  30009. /** The mesh or sprite that triggered the action */
  30010. source: any;
  30011. /** The X mouse cursor position at the time of the event */
  30012. pointerX: number;
  30013. /** The Y mouse cursor position at the time of the event */
  30014. pointerY: number;
  30015. /** The mesh that is currently pointed at (can be null) */
  30016. meshUnderPointer: Nullable<AbstractMesh>;
  30017. /** the original (browser) event that triggered the ActionEvent */
  30018. sourceEvent?: any;
  30019. /** additional data for the event */
  30020. additionalData?: any;
  30021. }
  30022. /**
  30023. * ActionEvent is the event being sent when an action is triggered.
  30024. */
  30025. export class ActionEvent implements IActionEvent {
  30026. /** The mesh or sprite that triggered the action */
  30027. source: any;
  30028. /** The X mouse cursor position at the time of the event */
  30029. pointerX: number;
  30030. /** The Y mouse cursor position at the time of the event */
  30031. pointerY: number;
  30032. /** The mesh that is currently pointed at (can be null) */
  30033. meshUnderPointer: Nullable<AbstractMesh>;
  30034. /** the original (browser) event that triggered the ActionEvent */
  30035. sourceEvent?: any;
  30036. /** additional data for the event */
  30037. additionalData?: any;
  30038. /**
  30039. * Creates a new ActionEvent
  30040. * @param source The mesh or sprite that triggered the action
  30041. * @param pointerX The X mouse cursor position at the time of the event
  30042. * @param pointerY The Y mouse cursor position at the time of the event
  30043. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  30044. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  30045. * @param additionalData additional data for the event
  30046. */
  30047. constructor(
  30048. /** The mesh or sprite that triggered the action */
  30049. source: any,
  30050. /** The X mouse cursor position at the time of the event */
  30051. pointerX: number,
  30052. /** The Y mouse cursor position at the time of the event */
  30053. pointerY: number,
  30054. /** The mesh that is currently pointed at (can be null) */
  30055. meshUnderPointer: Nullable<AbstractMesh>,
  30056. /** the original (browser) event that triggered the ActionEvent */
  30057. sourceEvent?: any,
  30058. /** additional data for the event */
  30059. additionalData?: any);
  30060. /**
  30061. * Helper function to auto-create an ActionEvent from a source mesh.
  30062. * @param source The source mesh that triggered the event
  30063. * @param evt The original (browser) event
  30064. * @param additionalData additional data for the event
  30065. * @returns the new ActionEvent
  30066. */
  30067. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  30068. /**
  30069. * Helper function to auto-create an ActionEvent from a source sprite
  30070. * @param source The source sprite that triggered the event
  30071. * @param scene Scene associated with the sprite
  30072. * @param evt The original (browser) event
  30073. * @param additionalData additional data for the event
  30074. * @returns the new ActionEvent
  30075. */
  30076. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  30077. /**
  30078. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  30079. * @param scene the scene where the event occurred
  30080. * @param evt The original (browser) event
  30081. * @returns the new ActionEvent
  30082. */
  30083. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  30084. /**
  30085. * Helper function to auto-create an ActionEvent from a primitive
  30086. * @param prim defines the target primitive
  30087. * @param pointerPos defines the pointer position
  30088. * @param evt The original (browser) event
  30089. * @param additionalData additional data for the event
  30090. * @returns the new ActionEvent
  30091. */
  30092. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  30093. }
  30094. }
  30095. declare module "babylonjs/Actions/abstractActionManager" {
  30096. import { IDisposable } from "babylonjs/scene";
  30097. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  30098. import { IAction } from "babylonjs/Actions/action";
  30099. import { Nullable } from "babylonjs/types";
  30100. /**
  30101. * Abstract class used to decouple action Manager from scene and meshes.
  30102. * Do not instantiate.
  30103. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  30104. */
  30105. export abstract class AbstractActionManager implements IDisposable {
  30106. /** Gets the list of active triggers */
  30107. static Triggers: {
  30108. [key: string]: number;
  30109. };
  30110. /** Gets the cursor to use when hovering items */
  30111. hoverCursor: string;
  30112. /** Gets the list of actions */
  30113. actions: IAction[];
  30114. /**
  30115. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  30116. */
  30117. isRecursive: boolean;
  30118. /**
  30119. * Releases all associated resources
  30120. */
  30121. abstract dispose(): void;
  30122. /**
  30123. * Does this action manager has pointer triggers
  30124. */
  30125. abstract get hasPointerTriggers(): boolean;
  30126. /**
  30127. * Does this action manager has pick triggers
  30128. */
  30129. abstract get hasPickTriggers(): boolean;
  30130. /**
  30131. * Process a specific trigger
  30132. * @param trigger defines the trigger to process
  30133. * @param evt defines the event details to be processed
  30134. */
  30135. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  30136. /**
  30137. * Does this action manager handles actions of any of the given triggers
  30138. * @param triggers defines the triggers to be tested
  30139. * @return a boolean indicating whether one (or more) of the triggers is handled
  30140. */
  30141. abstract hasSpecificTriggers(triggers: number[]): boolean;
  30142. /**
  30143. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  30144. * speed.
  30145. * @param triggerA defines the trigger to be tested
  30146. * @param triggerB defines the trigger to be tested
  30147. * @return a boolean indicating whether one (or more) of the triggers is handled
  30148. */
  30149. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  30150. /**
  30151. * Does this action manager handles actions of a given trigger
  30152. * @param trigger defines the trigger to be tested
  30153. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  30154. * @return whether the trigger is handled
  30155. */
  30156. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  30157. /**
  30158. * Serialize this manager to a JSON object
  30159. * @param name defines the property name to store this manager
  30160. * @returns a JSON representation of this manager
  30161. */
  30162. abstract serialize(name: string): any;
  30163. /**
  30164. * Registers an action to this action manager
  30165. * @param action defines the action to be registered
  30166. * @return the action amended (prepared) after registration
  30167. */
  30168. abstract registerAction(action: IAction): Nullable<IAction>;
  30169. /**
  30170. * Unregisters an action to this action manager
  30171. * @param action defines the action to be unregistered
  30172. * @return a boolean indicating whether the action has been unregistered
  30173. */
  30174. abstract unregisterAction(action: IAction): Boolean;
  30175. /**
  30176. * Does exist one action manager with at least one trigger
  30177. **/
  30178. static get HasTriggers(): boolean;
  30179. /**
  30180. * Does exist one action manager with at least one pick trigger
  30181. **/
  30182. static get HasPickTriggers(): boolean;
  30183. /**
  30184. * Does exist one action manager that handles actions of a given trigger
  30185. * @param trigger defines the trigger to be tested
  30186. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  30187. **/
  30188. static HasSpecificTrigger(trigger: number): boolean;
  30189. }
  30190. }
  30191. declare module "babylonjs/node" {
  30192. import { Scene } from "babylonjs/scene";
  30193. import { Nullable } from "babylonjs/types";
  30194. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  30195. import { Engine } from "babylonjs/Engines/engine";
  30196. import { IBehaviorAware, Behavior } from "babylonjs/Behaviors/behavior";
  30197. import { Observable } from "babylonjs/Misc/observable";
  30198. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  30199. import { IInspectable } from "babylonjs/Misc/iInspectable";
  30200. import { Animatable } from "babylonjs/Animations/animatable";
  30201. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  30202. import { Animation } from "babylonjs/Animations/animation";
  30203. import { AnimationRange } from "babylonjs/Animations/animationRange";
  30204. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  30205. /**
  30206. * Defines how a node can be built from a string name.
  30207. */
  30208. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  30209. /**
  30210. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  30211. */
  30212. export class Node implements IBehaviorAware<Node> {
  30213. /** @hidden */
  30214. static _AnimationRangeFactory: (name: string, from: number, to: number) => import("babylonjs/Animations/animationRange").AnimationRange;
  30215. private static _NodeConstructors;
  30216. /**
  30217. * Add a new node constructor
  30218. * @param type defines the type name of the node to construct
  30219. * @param constructorFunc defines the constructor function
  30220. */
  30221. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  30222. /**
  30223. * Returns a node constructor based on type name
  30224. * @param type defines the type name
  30225. * @param name defines the new node name
  30226. * @param scene defines the hosting scene
  30227. * @param options defines optional options to transmit to constructors
  30228. * @returns the new constructor or null
  30229. */
  30230. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  30231. /**
  30232. * Gets or sets the name of the node
  30233. */
  30234. name: string;
  30235. /**
  30236. * Gets or sets the id of the node
  30237. */
  30238. id: string;
  30239. /**
  30240. * Gets or sets the unique id of the node
  30241. */
  30242. uniqueId: number;
  30243. /**
  30244. * Gets or sets a string used to store user defined state for the node
  30245. */
  30246. state: string;
  30247. /**
  30248. * Gets or sets an object used to store user defined information for the node
  30249. */
  30250. metadata: any;
  30251. /**
  30252. * For internal use only. Please do not use.
  30253. */
  30254. reservedDataStore: any;
  30255. /**
  30256. * List of inspectable custom properties (used by the Inspector)
  30257. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  30258. */
  30259. inspectableCustomProperties: IInspectable[];
  30260. private _doNotSerialize;
  30261. /**
  30262. * Gets or sets a boolean used to define if the node must be serialized
  30263. */
  30264. get doNotSerialize(): boolean;
  30265. set doNotSerialize(value: boolean);
  30266. /** @hidden */
  30267. _isDisposed: boolean;
  30268. /**
  30269. * Gets a list of Animations associated with the node
  30270. */
  30271. animations: import("babylonjs/Animations/animation").Animation[];
  30272. protected _ranges: {
  30273. [name: string]: Nullable<AnimationRange>;
  30274. };
  30275. /**
  30276. * Callback raised when the node is ready to be used
  30277. */
  30278. onReady: Nullable<(node: Node) => void>;
  30279. private _isEnabled;
  30280. private _isParentEnabled;
  30281. private _isReady;
  30282. /** @hidden */
  30283. _currentRenderId: number;
  30284. private _parentUpdateId;
  30285. /** @hidden */
  30286. _childUpdateId: number;
  30287. /** @hidden */
  30288. _waitingParentId: Nullable<string>;
  30289. /** @hidden */
  30290. _scene: Scene;
  30291. /** @hidden */
  30292. _cache: any;
  30293. private _parentNode;
  30294. private _children;
  30295. /** @hidden */
  30296. _worldMatrix: Matrix;
  30297. /** @hidden */
  30298. _worldMatrixDeterminant: number;
  30299. /** @hidden */
  30300. _worldMatrixDeterminantIsDirty: boolean;
  30301. /** @hidden */
  30302. private _sceneRootNodesIndex;
  30303. /**
  30304. * Gets a boolean indicating if the node has been disposed
  30305. * @returns true if the node was disposed
  30306. */
  30307. isDisposed(): boolean;
  30308. /**
  30309. * Gets or sets the parent of the node (without keeping the current position in the scene)
  30310. * @see https://doc.babylonjs.com/how_to/parenting
  30311. */
  30312. set parent(parent: Nullable<Node>);
  30313. get parent(): Nullable<Node>;
  30314. /** @hidden */
  30315. _addToSceneRootNodes(): void;
  30316. /** @hidden */
  30317. _removeFromSceneRootNodes(): void;
  30318. private _animationPropertiesOverride;
  30319. /**
  30320. * Gets or sets the animation properties override
  30321. */
  30322. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  30323. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  30324. /**
  30325. * Gets a string idenfifying the name of the class
  30326. * @returns "Node" string
  30327. */
  30328. getClassName(): string;
  30329. /** @hidden */
  30330. readonly _isNode: boolean;
  30331. /**
  30332. * An event triggered when the mesh is disposed
  30333. */
  30334. onDisposeObservable: Observable<Node>;
  30335. private _onDisposeObserver;
  30336. /**
  30337. * Sets a callback that will be raised when the node will be disposed
  30338. */
  30339. set onDispose(callback: () => void);
  30340. /**
  30341. * Creates a new Node
  30342. * @param name the name and id to be given to this node
  30343. * @param scene the scene this node will be added to
  30344. */
  30345. constructor(name: string, scene?: Nullable<Scene>);
  30346. /**
  30347. * Gets the scene of the node
  30348. * @returns a scene
  30349. */
  30350. getScene(): Scene;
  30351. /**
  30352. * Gets the engine of the node
  30353. * @returns a Engine
  30354. */
  30355. getEngine(): Engine;
  30356. private _behaviors;
  30357. /**
  30358. * Attach a behavior to the node
  30359. * @see http://doc.babylonjs.com/features/behaviour
  30360. * @param behavior defines the behavior to attach
  30361. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  30362. * @returns the current Node
  30363. */
  30364. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  30365. /**
  30366. * Remove an attached behavior
  30367. * @see http://doc.babylonjs.com/features/behaviour
  30368. * @param behavior defines the behavior to attach
  30369. * @returns the current Node
  30370. */
  30371. removeBehavior(behavior: Behavior<Node>): Node;
  30372. /**
  30373. * Gets the list of attached behaviors
  30374. * @see http://doc.babylonjs.com/features/behaviour
  30375. */
  30376. get behaviors(): Behavior<Node>[];
  30377. /**
  30378. * Gets an attached behavior by name
  30379. * @param name defines the name of the behavior to look for
  30380. * @see http://doc.babylonjs.com/features/behaviour
  30381. * @returns null if behavior was not found else the requested behavior
  30382. */
  30383. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  30384. /**
  30385. * Returns the latest update of the World matrix
  30386. * @returns a Matrix
  30387. */
  30388. getWorldMatrix(): Matrix;
  30389. /** @hidden */
  30390. _getWorldMatrixDeterminant(): number;
  30391. /**
  30392. * Returns directly the latest state of the mesh World matrix.
  30393. * A Matrix is returned.
  30394. */
  30395. get worldMatrixFromCache(): Matrix;
  30396. /** @hidden */
  30397. _initCache(): void;
  30398. /** @hidden */
  30399. updateCache(force?: boolean): void;
  30400. /** @hidden */
  30401. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  30402. /** @hidden */
  30403. _updateCache(ignoreParentClass?: boolean): void;
  30404. /** @hidden */
  30405. _isSynchronized(): boolean;
  30406. /** @hidden */
  30407. _markSyncedWithParent(): void;
  30408. /** @hidden */
  30409. isSynchronizedWithParent(): boolean;
  30410. /** @hidden */
  30411. isSynchronized(): boolean;
  30412. /**
  30413. * Is this node ready to be used/rendered
  30414. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  30415. * @return true if the node is ready
  30416. */
  30417. isReady(completeCheck?: boolean): boolean;
  30418. /**
  30419. * Is this node enabled?
  30420. * 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
  30421. * @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
  30422. * @return whether this node (and its parent) is enabled
  30423. */
  30424. isEnabled(checkAncestors?: boolean): boolean;
  30425. /** @hidden */
  30426. protected _syncParentEnabledState(): void;
  30427. /**
  30428. * Set the enabled state of this node
  30429. * @param value defines the new enabled state
  30430. */
  30431. setEnabled(value: boolean): void;
  30432. /**
  30433. * Is this node a descendant of the given node?
  30434. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  30435. * @param ancestor defines the parent node to inspect
  30436. * @returns a boolean indicating if this node is a descendant of the given node
  30437. */
  30438. isDescendantOf(ancestor: Node): boolean;
  30439. /** @hidden */
  30440. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  30441. /**
  30442. * Will return all nodes that have this node as ascendant
  30443. * @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
  30444. * @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
  30445. * @return all children nodes of all types
  30446. */
  30447. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  30448. /**
  30449. * Get all child-meshes of this node
  30450. * @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)
  30451. * @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
  30452. * @returns an array of AbstractMesh
  30453. */
  30454. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  30455. /**
  30456. * Get all direct children of this node
  30457. * @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
  30458. * @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)
  30459. * @returns an array of Node
  30460. */
  30461. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  30462. /** @hidden */
  30463. _setReady(state: boolean): void;
  30464. /**
  30465. * Get an animation by name
  30466. * @param name defines the name of the animation to look for
  30467. * @returns null if not found else the requested animation
  30468. */
  30469. getAnimationByName(name: string): Nullable<Animation>;
  30470. /**
  30471. * Creates an animation range for this node
  30472. * @param name defines the name of the range
  30473. * @param from defines the starting key
  30474. * @param to defines the end key
  30475. */
  30476. createAnimationRange(name: string, from: number, to: number): void;
  30477. /**
  30478. * Delete a specific animation range
  30479. * @param name defines the name of the range to delete
  30480. * @param deleteFrames defines if animation frames from the range must be deleted as well
  30481. */
  30482. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  30483. /**
  30484. * Get an animation range by name
  30485. * @param name defines the name of the animation range to look for
  30486. * @returns null if not found else the requested animation range
  30487. */
  30488. getAnimationRange(name: string): Nullable<AnimationRange>;
  30489. /**
  30490. * Gets the list of all animation ranges defined on this node
  30491. * @returns an array
  30492. */
  30493. getAnimationRanges(): Nullable<AnimationRange>[];
  30494. /**
  30495. * Will start the animation sequence
  30496. * @param name defines the range frames for animation sequence
  30497. * @param loop defines if the animation should loop (false by default)
  30498. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  30499. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  30500. * @returns the object created for this animation. If range does not exist, it will return null
  30501. */
  30502. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  30503. /**
  30504. * Serialize animation ranges into a JSON compatible object
  30505. * @returns serialization object
  30506. */
  30507. serializeAnimationRanges(): any;
  30508. /**
  30509. * Computes the world matrix of the node
  30510. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  30511. * @returns the world matrix
  30512. */
  30513. computeWorldMatrix(force?: boolean): Matrix;
  30514. /**
  30515. * Releases resources associated with this node.
  30516. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  30517. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  30518. */
  30519. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  30520. /**
  30521. * Parse animation range data from a serialization object and store them into a given node
  30522. * @param node defines where to store the animation ranges
  30523. * @param parsedNode defines the serialization object to read data from
  30524. * @param scene defines the hosting scene
  30525. */
  30526. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  30527. /**
  30528. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  30529. * @param includeDescendants Include bounding info from descendants as well (true by default)
  30530. * @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
  30531. * @returns the new bounding vectors
  30532. */
  30533. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  30534. min: Vector3;
  30535. max: Vector3;
  30536. };
  30537. }
  30538. }
  30539. declare module "babylonjs/Animations/animation" {
  30540. import { IEasingFunction, EasingFunction } from "babylonjs/Animations/easing";
  30541. import { Vector3, Quaternion, Vector2, Matrix } from "babylonjs/Maths/math.vector";
  30542. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  30543. import { Nullable } from "babylonjs/types";
  30544. import { Scene } from "babylonjs/scene";
  30545. import { IAnimationKey } from "babylonjs/Animations/animationKey";
  30546. import { AnimationRange } from "babylonjs/Animations/animationRange";
  30547. import { AnimationEvent } from "babylonjs/Animations/animationEvent";
  30548. import { Node } from "babylonjs/node";
  30549. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  30550. import { Size } from "babylonjs/Maths/math.size";
  30551. import { Animatable } from "babylonjs/Animations/animatable";
  30552. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  30553. /**
  30554. * @hidden
  30555. */
  30556. export class _IAnimationState {
  30557. key: number;
  30558. repeatCount: number;
  30559. workValue?: any;
  30560. loopMode?: number;
  30561. offsetValue?: any;
  30562. highLimitValue?: any;
  30563. }
  30564. /**
  30565. * Class used to store any kind of animation
  30566. */
  30567. export class Animation {
  30568. /**Name of the animation */
  30569. name: string;
  30570. /**Property to animate */
  30571. targetProperty: string;
  30572. /**The frames per second of the animation */
  30573. framePerSecond: number;
  30574. /**The data type of the animation */
  30575. dataType: number;
  30576. /**The loop mode of the animation */
  30577. loopMode?: number | undefined;
  30578. /**Specifies if blending should be enabled */
  30579. enableBlending?: boolean | undefined;
  30580. /**
  30581. * Use matrix interpolation instead of using direct key value when animating matrices
  30582. */
  30583. static AllowMatricesInterpolation: boolean;
  30584. /**
  30585. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  30586. */
  30587. static AllowMatrixDecomposeForInterpolation: boolean;
  30588. /**
  30589. * Stores the key frames of the animation
  30590. */
  30591. private _keys;
  30592. /**
  30593. * Stores the easing function of the animation
  30594. */
  30595. private _easingFunction;
  30596. /**
  30597. * @hidden Internal use only
  30598. */
  30599. _runtimeAnimations: import("babylonjs/Animations/runtimeAnimation").RuntimeAnimation[];
  30600. /**
  30601. * The set of event that will be linked to this animation
  30602. */
  30603. private _events;
  30604. /**
  30605. * Stores an array of target property paths
  30606. */
  30607. targetPropertyPath: string[];
  30608. /**
  30609. * Stores the blending speed of the animation
  30610. */
  30611. blendingSpeed: number;
  30612. /**
  30613. * Stores the animation ranges for the animation
  30614. */
  30615. private _ranges;
  30616. /**
  30617. * @hidden Internal use
  30618. */
  30619. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  30620. /**
  30621. * Sets up an animation
  30622. * @param property The property to animate
  30623. * @param animationType The animation type to apply
  30624. * @param framePerSecond The frames per second of the animation
  30625. * @param easingFunction The easing function used in the animation
  30626. * @returns The created animation
  30627. */
  30628. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  30629. /**
  30630. * Create and start an animation on a node
  30631. * @param name defines the name of the global animation that will be run on all nodes
  30632. * @param node defines the root node where the animation will take place
  30633. * @param targetProperty defines property to animate
  30634. * @param framePerSecond defines the number of frame per second yo use
  30635. * @param totalFrame defines the number of frames in total
  30636. * @param from defines the initial value
  30637. * @param to defines the final value
  30638. * @param loopMode defines which loop mode you want to use (off by default)
  30639. * @param easingFunction defines the easing function to use (linear by default)
  30640. * @param onAnimationEnd defines the callback to call when animation end
  30641. * @returns the animatable created for this animation
  30642. */
  30643. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  30644. /**
  30645. * Create and start an animation on a node and its descendants
  30646. * @param name defines the name of the global animation that will be run on all nodes
  30647. * @param node defines the root node where the animation will take place
  30648. * @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
  30649. * @param targetProperty defines property to animate
  30650. * @param framePerSecond defines the number of frame per second to use
  30651. * @param totalFrame defines the number of frames in total
  30652. * @param from defines the initial value
  30653. * @param to defines the final value
  30654. * @param loopMode defines which loop mode you want to use (off by default)
  30655. * @param easingFunction defines the easing function to use (linear by default)
  30656. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  30657. * @returns the list of animatables created for all nodes
  30658. * @example https://www.babylonjs-playground.com/#MH0VLI
  30659. */
  30660. 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[]>;
  30661. /**
  30662. * Creates a new animation, merges it with the existing animations and starts it
  30663. * @param name Name of the animation
  30664. * @param node Node which contains the scene that begins the animations
  30665. * @param targetProperty Specifies which property to animate
  30666. * @param framePerSecond The frames per second of the animation
  30667. * @param totalFrame The total number of frames
  30668. * @param from The frame at the beginning of the animation
  30669. * @param to The frame at the end of the animation
  30670. * @param loopMode Specifies the loop mode of the animation
  30671. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  30672. * @param onAnimationEnd Callback to run once the animation is complete
  30673. * @returns Nullable animation
  30674. */
  30675. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  30676. /**
  30677. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  30678. * @param sourceAnimation defines the Animation containing keyframes to convert
  30679. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  30680. * @param range defines the name of the AnimationRange belonging to the Animation to convert
  30681. * @param cloneOriginal defines whether or not to clone the animation and convert the clone or convert the original animation (default is false)
  30682. * @param clonedName defines the name of the resulting cloned Animation if cloneOriginal is true
  30683. * @returns a new Animation if cloneOriginal is true or the original Animation if cloneOriginal is false
  30684. */
  30685. static MakeAnimationAdditive(sourceAnimation: Animation, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): Animation;
  30686. /**
  30687. * Transition property of an host to the target Value
  30688. * @param property The property to transition
  30689. * @param targetValue The target Value of the property
  30690. * @param host The object where the property to animate belongs
  30691. * @param scene Scene used to run the animation
  30692. * @param frameRate Framerate (in frame/s) to use
  30693. * @param transition The transition type we want to use
  30694. * @param duration The duration of the animation, in milliseconds
  30695. * @param onAnimationEnd Callback trigger at the end of the animation
  30696. * @returns Nullable animation
  30697. */
  30698. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  30699. /**
  30700. * Return the array of runtime animations currently using this animation
  30701. */
  30702. get runtimeAnimations(): RuntimeAnimation[];
  30703. /**
  30704. * Specifies if any of the runtime animations are currently running
  30705. */
  30706. get hasRunningRuntimeAnimations(): boolean;
  30707. /**
  30708. * Initializes the animation
  30709. * @param name Name of the animation
  30710. * @param targetProperty Property to animate
  30711. * @param framePerSecond The frames per second of the animation
  30712. * @param dataType The data type of the animation
  30713. * @param loopMode The loop mode of the animation
  30714. * @param enableBlending Specifies if blending should be enabled
  30715. */
  30716. constructor(
  30717. /**Name of the animation */
  30718. name: string,
  30719. /**Property to animate */
  30720. targetProperty: string,
  30721. /**The frames per second of the animation */
  30722. framePerSecond: number,
  30723. /**The data type of the animation */
  30724. dataType: number,
  30725. /**The loop mode of the animation */
  30726. loopMode?: number | undefined,
  30727. /**Specifies if blending should be enabled */
  30728. enableBlending?: boolean | undefined);
  30729. /**
  30730. * Converts the animation to a string
  30731. * @param fullDetails support for multiple levels of logging within scene loading
  30732. * @returns String form of the animation
  30733. */
  30734. toString(fullDetails?: boolean): string;
  30735. /**
  30736. * Add an event to this animation
  30737. * @param event Event to add
  30738. */
  30739. addEvent(event: AnimationEvent): void;
  30740. /**
  30741. * Remove all events found at the given frame
  30742. * @param frame The frame to remove events from
  30743. */
  30744. removeEvents(frame: number): void;
  30745. /**
  30746. * Retrieves all the events from the animation
  30747. * @returns Events from the animation
  30748. */
  30749. getEvents(): AnimationEvent[];
  30750. /**
  30751. * Creates an animation range
  30752. * @param name Name of the animation range
  30753. * @param from Starting frame of the animation range
  30754. * @param to Ending frame of the animation
  30755. */
  30756. createRange(name: string, from: number, to: number): void;
  30757. /**
  30758. * Deletes an animation range by name
  30759. * @param name Name of the animation range to delete
  30760. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  30761. */
  30762. deleteRange(name: string, deleteFrames?: boolean): void;
  30763. /**
  30764. * Gets the animation range by name, or null if not defined
  30765. * @param name Name of the animation range
  30766. * @returns Nullable animation range
  30767. */
  30768. getRange(name: string): Nullable<AnimationRange>;
  30769. /**
  30770. * Gets the key frames from the animation
  30771. * @returns The key frames of the animation
  30772. */
  30773. getKeys(): Array<IAnimationKey>;
  30774. /**
  30775. * Gets the highest frame rate of the animation
  30776. * @returns Highest frame rate of the animation
  30777. */
  30778. getHighestFrame(): number;
  30779. /**
  30780. * Gets the easing function of the animation
  30781. * @returns Easing function of the animation
  30782. */
  30783. getEasingFunction(): IEasingFunction;
  30784. /**
  30785. * Sets the easing function of the animation
  30786. * @param easingFunction A custom mathematical formula for animation
  30787. */
  30788. setEasingFunction(easingFunction: EasingFunction): void;
  30789. /**
  30790. * Interpolates a scalar linearly
  30791. * @param startValue Start value of the animation curve
  30792. * @param endValue End value of the animation curve
  30793. * @param gradient Scalar amount to interpolate
  30794. * @returns Interpolated scalar value
  30795. */
  30796. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  30797. /**
  30798. * Interpolates a scalar cubically
  30799. * @param startValue Start value of the animation curve
  30800. * @param outTangent End tangent of the animation
  30801. * @param endValue End value of the animation curve
  30802. * @param inTangent Start tangent of the animation curve
  30803. * @param gradient Scalar amount to interpolate
  30804. * @returns Interpolated scalar value
  30805. */
  30806. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  30807. /**
  30808. * Interpolates a quaternion using a spherical linear interpolation
  30809. * @param startValue Start value of the animation curve
  30810. * @param endValue End value of the animation curve
  30811. * @param gradient Scalar amount to interpolate
  30812. * @returns Interpolated quaternion value
  30813. */
  30814. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  30815. /**
  30816. * Interpolates a quaternion cubically
  30817. * @param startValue Start value of the animation curve
  30818. * @param outTangent End tangent of the animation curve
  30819. * @param endValue End value of the animation curve
  30820. * @param inTangent Start tangent of the animation curve
  30821. * @param gradient Scalar amount to interpolate
  30822. * @returns Interpolated quaternion value
  30823. */
  30824. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  30825. /**
  30826. * Interpolates a Vector3 linearl
  30827. * @param startValue Start value of the animation curve
  30828. * @param endValue End value of the animation curve
  30829. * @param gradient Scalar amount to interpolate
  30830. * @returns Interpolated scalar value
  30831. */
  30832. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  30833. /**
  30834. * Interpolates a Vector3 cubically
  30835. * @param startValue Start value of the animation curve
  30836. * @param outTangent End tangent of the animation
  30837. * @param endValue End value of the animation curve
  30838. * @param inTangent Start tangent of the animation curve
  30839. * @param gradient Scalar amount to interpolate
  30840. * @returns InterpolatedVector3 value
  30841. */
  30842. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  30843. /**
  30844. * Interpolates a Vector2 linearly
  30845. * @param startValue Start value of the animation curve
  30846. * @param endValue End value of the animation curve
  30847. * @param gradient Scalar amount to interpolate
  30848. * @returns Interpolated Vector2 value
  30849. */
  30850. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  30851. /**
  30852. * Interpolates a Vector2 cubically
  30853. * @param startValue Start value of the animation curve
  30854. * @param outTangent End tangent of the animation
  30855. * @param endValue End value of the animation curve
  30856. * @param inTangent Start tangent of the animation curve
  30857. * @param gradient Scalar amount to interpolate
  30858. * @returns Interpolated Vector2 value
  30859. */
  30860. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  30861. /**
  30862. * Interpolates a size linearly
  30863. * @param startValue Start value of the animation curve
  30864. * @param endValue End value of the animation curve
  30865. * @param gradient Scalar amount to interpolate
  30866. * @returns Interpolated Size value
  30867. */
  30868. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  30869. /**
  30870. * Interpolates a Color3 linearly
  30871. * @param startValue Start value of the animation curve
  30872. * @param endValue End value of the animation curve
  30873. * @param gradient Scalar amount to interpolate
  30874. * @returns Interpolated Color3 value
  30875. */
  30876. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  30877. /**
  30878. * Interpolates a Color4 linearly
  30879. * @param startValue Start value of the animation curve
  30880. * @param endValue End value of the animation curve
  30881. * @param gradient Scalar amount to interpolate
  30882. * @returns Interpolated Color3 value
  30883. */
  30884. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  30885. /**
  30886. * @hidden Internal use only
  30887. */
  30888. _getKeyValue(value: any): any;
  30889. /**
  30890. * @hidden Internal use only
  30891. */
  30892. _interpolate(currentFrame: number, state: _IAnimationState): any;
  30893. /**
  30894. * Defines the function to use to interpolate matrices
  30895. * @param startValue defines the start matrix
  30896. * @param endValue defines the end matrix
  30897. * @param gradient defines the gradient between both matrices
  30898. * @param result defines an optional target matrix where to store the interpolation
  30899. * @returns the interpolated matrix
  30900. */
  30901. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  30902. /**
  30903. * Makes a copy of the animation
  30904. * @returns Cloned animation
  30905. */
  30906. clone(): Animation;
  30907. /**
  30908. * Sets the key frames of the animation
  30909. * @param values The animation key frames to set
  30910. */
  30911. setKeys(values: Array<IAnimationKey>): void;
  30912. /**
  30913. * Serializes the animation to an object
  30914. * @returns Serialized object
  30915. */
  30916. serialize(): any;
  30917. /**
  30918. * Float animation type
  30919. */
  30920. static readonly ANIMATIONTYPE_FLOAT: number;
  30921. /**
  30922. * Vector3 animation type
  30923. */
  30924. static readonly ANIMATIONTYPE_VECTOR3: number;
  30925. /**
  30926. * Quaternion animation type
  30927. */
  30928. static readonly ANIMATIONTYPE_QUATERNION: number;
  30929. /**
  30930. * Matrix animation type
  30931. */
  30932. static readonly ANIMATIONTYPE_MATRIX: number;
  30933. /**
  30934. * Color3 animation type
  30935. */
  30936. static readonly ANIMATIONTYPE_COLOR3: number;
  30937. /**
  30938. * Color3 animation type
  30939. */
  30940. static readonly ANIMATIONTYPE_COLOR4: number;
  30941. /**
  30942. * Vector2 animation type
  30943. */
  30944. static readonly ANIMATIONTYPE_VECTOR2: number;
  30945. /**
  30946. * Size animation type
  30947. */
  30948. static readonly ANIMATIONTYPE_SIZE: number;
  30949. /**
  30950. * Relative Loop Mode
  30951. */
  30952. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  30953. /**
  30954. * Cycle Loop Mode
  30955. */
  30956. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  30957. /**
  30958. * Constant Loop Mode
  30959. */
  30960. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  30961. /** @hidden */
  30962. static _UniversalLerp(left: any, right: any, amount: number): any;
  30963. /**
  30964. * Parses an animation object and creates an animation
  30965. * @param parsedAnimation Parsed animation object
  30966. * @returns Animation object
  30967. */
  30968. static Parse(parsedAnimation: any): Animation;
  30969. /**
  30970. * Appends the serialized animations from the source animations
  30971. * @param source Source containing the animations
  30972. * @param destination Target to store the animations
  30973. */
  30974. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  30975. }
  30976. }
  30977. declare module "babylonjs/Animations/animatable.interface" {
  30978. import { Nullable } from "babylonjs/types";
  30979. import { Animation } from "babylonjs/Animations/animation";
  30980. /**
  30981. * Interface containing an array of animations
  30982. */
  30983. export interface IAnimatable {
  30984. /**
  30985. * Array of animations
  30986. */
  30987. animations: Nullable<Array<Animation>>;
  30988. }
  30989. }
  30990. declare module "babylonjs/Misc/decorators" {
  30991. import { Nullable } from "babylonjs/types";
  30992. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  30993. import { Scene } from "babylonjs/scene";
  30994. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  30995. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30996. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30997. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30998. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30999. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31000. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31001. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31002. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31003. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31004. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31005. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31006. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31007. /**
  31008. * Decorator used to define property that can be serialized as reference to a camera
  31009. * @param sourceName defines the name of the property to decorate
  31010. */
  31011. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31012. /**
  31013. * Class used to help serialization objects
  31014. */
  31015. export class SerializationHelper {
  31016. /** @hidden */
  31017. static _ImageProcessingConfigurationParser: (sourceProperty: any) => import("babylonjs/Materials/imageProcessingConfiguration").ImageProcessingConfiguration;
  31018. /** @hidden */
  31019. static _FresnelParametersParser: (sourceProperty: any) => import("babylonjs/Materials/fresnelParameters").FresnelParameters;
  31020. /** @hidden */
  31021. static _ColorCurvesParser: (sourceProperty: any) => import("babylonjs/Materials/colorCurves").ColorCurves;
  31022. /** @hidden */
  31023. static _TextureParser: (sourceProperty: any, scene: import("babylonjs/scene").Scene, rootUrl: string) => Nullable<import("babylonjs/Materials/Textures/baseTexture").BaseTexture>;
  31024. /**
  31025. * Appends the serialized animations from the source animations
  31026. * @param source Source containing the animations
  31027. * @param destination Target to store the animations
  31028. */
  31029. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  31030. /**
  31031. * Static function used to serialized a specific entity
  31032. * @param entity defines the entity to serialize
  31033. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  31034. * @returns a JSON compatible object representing the serialization of the entity
  31035. */
  31036. static Serialize<T>(entity: T, serializationObject?: any): any;
  31037. /**
  31038. * Creates a new entity from a serialization data object
  31039. * @param creationFunction defines a function used to instanciated the new entity
  31040. * @param source defines the source serialization data
  31041. * @param scene defines the hosting scene
  31042. * @param rootUrl defines the root url for resources
  31043. * @returns a new entity
  31044. */
  31045. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  31046. /**
  31047. * Clones an object
  31048. * @param creationFunction defines the function used to instanciate the new object
  31049. * @param source defines the source object
  31050. * @returns the cloned object
  31051. */
  31052. static Clone<T>(creationFunction: () => T, source: T): T;
  31053. /**
  31054. * Instanciates a new object based on a source one (some data will be shared between both object)
  31055. * @param creationFunction defines the function used to instanciate the new object
  31056. * @param source defines the source object
  31057. * @returns the new object
  31058. */
  31059. static Instanciate<T>(creationFunction: () => T, source: T): T;
  31060. }
  31061. }
  31062. declare module "babylonjs/Materials/Textures/baseTexture" {
  31063. import { Observable } from "babylonjs/Misc/observable";
  31064. import { Nullable } from "babylonjs/types";
  31065. import { Scene } from "babylonjs/scene";
  31066. import { Matrix } from "babylonjs/Maths/math.vector";
  31067. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  31068. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  31069. import { ISize } from "babylonjs/Maths/math.size";
  31070. import "babylonjs/Misc/fileTools";
  31071. /**
  31072. * Base class of all the textures in babylon.
  31073. * It groups all the common properties the materials, post process, lights... might need
  31074. * in order to make a correct use of the texture.
  31075. */
  31076. export class BaseTexture implements IAnimatable {
  31077. /**
  31078. * Default anisotropic filtering level for the application.
  31079. * It is set to 4 as a good tradeoff between perf and quality.
  31080. */
  31081. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  31082. /**
  31083. * Gets or sets the unique id of the texture
  31084. */
  31085. uniqueId: number;
  31086. /**
  31087. * Define the name of the texture.
  31088. */
  31089. name: string;
  31090. /**
  31091. * Gets or sets an object used to store user defined information.
  31092. */
  31093. metadata: any;
  31094. /**
  31095. * For internal use only. Please do not use.
  31096. */
  31097. reservedDataStore: any;
  31098. private _hasAlpha;
  31099. /**
  31100. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  31101. */
  31102. set hasAlpha(value: boolean);
  31103. get hasAlpha(): boolean;
  31104. /**
  31105. * Defines if the alpha value should be determined via the rgb values.
  31106. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  31107. */
  31108. getAlphaFromRGB: boolean;
  31109. /**
  31110. * Intensity or strength of the texture.
  31111. * It is commonly used by materials to fine tune the intensity of the texture
  31112. */
  31113. level: number;
  31114. /**
  31115. * Define the UV chanel to use starting from 0 and defaulting to 0.
  31116. * This is part of the texture as textures usually maps to one uv set.
  31117. */
  31118. coordinatesIndex: number;
  31119. private _coordinatesMode;
  31120. /**
  31121. * How a texture is mapped.
  31122. *
  31123. * | Value | Type | Description |
  31124. * | ----- | ----------------------------------- | ----------- |
  31125. * | 0 | EXPLICIT_MODE | |
  31126. * | 1 | SPHERICAL_MODE | |
  31127. * | 2 | PLANAR_MODE | |
  31128. * | 3 | CUBIC_MODE | |
  31129. * | 4 | PROJECTION_MODE | |
  31130. * | 5 | SKYBOX_MODE | |
  31131. * | 6 | INVCUBIC_MODE | |
  31132. * | 7 | EQUIRECTANGULAR_MODE | |
  31133. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  31134. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  31135. */
  31136. set coordinatesMode(value: number);
  31137. get coordinatesMode(): number;
  31138. /**
  31139. * | Value | Type | Description |
  31140. * | ----- | ------------------ | ----------- |
  31141. * | 0 | CLAMP_ADDRESSMODE | |
  31142. * | 1 | WRAP_ADDRESSMODE | |
  31143. * | 2 | MIRROR_ADDRESSMODE | |
  31144. */
  31145. wrapU: number;
  31146. /**
  31147. * | Value | Type | Description |
  31148. * | ----- | ------------------ | ----------- |
  31149. * | 0 | CLAMP_ADDRESSMODE | |
  31150. * | 1 | WRAP_ADDRESSMODE | |
  31151. * | 2 | MIRROR_ADDRESSMODE | |
  31152. */
  31153. wrapV: number;
  31154. /**
  31155. * | Value | Type | Description |
  31156. * | ----- | ------------------ | ----------- |
  31157. * | 0 | CLAMP_ADDRESSMODE | |
  31158. * | 1 | WRAP_ADDRESSMODE | |
  31159. * | 2 | MIRROR_ADDRESSMODE | |
  31160. */
  31161. wrapR: number;
  31162. /**
  31163. * With compliant hardware and browser (supporting anisotropic filtering)
  31164. * this defines the level of anisotropic filtering in the texture.
  31165. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  31166. */
  31167. anisotropicFilteringLevel: number;
  31168. /**
  31169. * Define if the texture is a cube texture or if false a 2d texture.
  31170. */
  31171. get isCube(): boolean;
  31172. set isCube(value: boolean);
  31173. /**
  31174. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  31175. */
  31176. get is3D(): boolean;
  31177. set is3D(value: boolean);
  31178. /**
  31179. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  31180. */
  31181. get is2DArray(): boolean;
  31182. set is2DArray(value: boolean);
  31183. /**
  31184. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  31185. * HDR texture are usually stored in linear space.
  31186. * This only impacts the PBR and Background materials
  31187. */
  31188. gammaSpace: boolean;
  31189. /**
  31190. * Gets or sets whether or not the texture contains RGBD data.
  31191. */
  31192. get isRGBD(): boolean;
  31193. set isRGBD(value: boolean);
  31194. /**
  31195. * Is Z inverted in the texture (useful in a cube texture).
  31196. */
  31197. invertZ: boolean;
  31198. /**
  31199. * Are mip maps generated for this texture or not.
  31200. */
  31201. get noMipmap(): boolean;
  31202. /**
  31203. * @hidden
  31204. */
  31205. lodLevelInAlpha: boolean;
  31206. /**
  31207. * With prefiltered texture, defined the offset used during the prefiltering steps.
  31208. */
  31209. get lodGenerationOffset(): number;
  31210. set lodGenerationOffset(value: number);
  31211. /**
  31212. * With prefiltered texture, defined the scale used during the prefiltering steps.
  31213. */
  31214. get lodGenerationScale(): number;
  31215. set lodGenerationScale(value: number);
  31216. /**
  31217. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  31218. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  31219. * average roughness values.
  31220. */
  31221. get linearSpecularLOD(): boolean;
  31222. set linearSpecularLOD(value: boolean);
  31223. /**
  31224. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  31225. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  31226. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  31227. */
  31228. get irradianceTexture(): Nullable<BaseTexture>;
  31229. set irradianceTexture(value: Nullable<BaseTexture>);
  31230. /**
  31231. * Define if the texture is a render target.
  31232. */
  31233. isRenderTarget: boolean;
  31234. /**
  31235. * Define the unique id of the texture in the scene.
  31236. */
  31237. get uid(): string;
  31238. /**
  31239. * Return a string representation of the texture.
  31240. * @returns the texture as a string
  31241. */
  31242. toString(): string;
  31243. /**
  31244. * Get the class name of the texture.
  31245. * @returns "BaseTexture"
  31246. */
  31247. getClassName(): string;
  31248. /**
  31249. * Define the list of animation attached to the texture.
  31250. */
  31251. animations: import("babylonjs/Animations/animation").Animation[];
  31252. /**
  31253. * An event triggered when the texture is disposed.
  31254. */
  31255. onDisposeObservable: Observable<BaseTexture>;
  31256. private _onDisposeObserver;
  31257. /**
  31258. * Callback triggered when the texture has been disposed.
  31259. * Kept for back compatibility, you can use the onDisposeObservable instead.
  31260. */
  31261. set onDispose(callback: () => void);
  31262. /**
  31263. * Define the current state of the loading sequence when in delayed load mode.
  31264. */
  31265. delayLoadState: number;
  31266. private _scene;
  31267. /** @hidden */
  31268. _texture: Nullable<InternalTexture>;
  31269. private _uid;
  31270. /**
  31271. * Define if the texture is preventinga material to render or not.
  31272. * If not and the texture is not ready, the engine will use a default black texture instead.
  31273. */
  31274. get isBlocking(): boolean;
  31275. /**
  31276. * Instantiates a new BaseTexture.
  31277. * Base class of all the textures in babylon.
  31278. * It groups all the common properties the materials, post process, lights... might need
  31279. * in order to make a correct use of the texture.
  31280. * @param scene Define the scene the texture blongs to
  31281. */
  31282. constructor(scene: Nullable<Scene>);
  31283. /**
  31284. * Get the scene the texture belongs to.
  31285. * @returns the scene or null if undefined
  31286. */
  31287. getScene(): Nullable<Scene>;
  31288. /**
  31289. * Get the texture transform matrix used to offset tile the texture for istance.
  31290. * @returns the transformation matrix
  31291. */
  31292. getTextureMatrix(): Matrix;
  31293. /**
  31294. * Get the texture reflection matrix used to rotate/transform the reflection.
  31295. * @returns the reflection matrix
  31296. */
  31297. getReflectionTextureMatrix(): Matrix;
  31298. /**
  31299. * Get the underlying lower level texture from Babylon.
  31300. * @returns the insternal texture
  31301. */
  31302. getInternalTexture(): Nullable<InternalTexture>;
  31303. /**
  31304. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  31305. * @returns true if ready or not blocking
  31306. */
  31307. isReadyOrNotBlocking(): boolean;
  31308. /**
  31309. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  31310. * @returns true if fully ready
  31311. */
  31312. isReady(): boolean;
  31313. private _cachedSize;
  31314. /**
  31315. * Get the size of the texture.
  31316. * @returns the texture size.
  31317. */
  31318. getSize(): ISize;
  31319. /**
  31320. * Get the base size of the texture.
  31321. * It can be different from the size if the texture has been resized for POT for instance
  31322. * @returns the base size
  31323. */
  31324. getBaseSize(): ISize;
  31325. /**
  31326. * Update the sampling mode of the texture.
  31327. * Default is Trilinear mode.
  31328. *
  31329. * | Value | Type | Description |
  31330. * | ----- | ------------------ | ----------- |
  31331. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  31332. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  31333. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  31334. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  31335. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  31336. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  31337. * | 7 | NEAREST_LINEAR | |
  31338. * | 8 | NEAREST_NEAREST | |
  31339. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  31340. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  31341. * | 11 | LINEAR_LINEAR | |
  31342. * | 12 | LINEAR_NEAREST | |
  31343. *
  31344. * > _mag_: magnification filter (close to the viewer)
  31345. * > _min_: minification filter (far from the viewer)
  31346. * > _mip_: filter used between mip map levels
  31347. *@param samplingMode Define the new sampling mode of the texture
  31348. */
  31349. updateSamplingMode(samplingMode: number): void;
  31350. /**
  31351. * Scales the texture if is `canRescale()`
  31352. * @param ratio the resize factor we want to use to rescale
  31353. */
  31354. scale(ratio: number): void;
  31355. /**
  31356. * Get if the texture can rescale.
  31357. */
  31358. get canRescale(): boolean;
  31359. /** @hidden */
  31360. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  31361. /** @hidden */
  31362. _rebuild(): void;
  31363. /**
  31364. * Triggers the load sequence in delayed load mode.
  31365. */
  31366. delayLoad(): void;
  31367. /**
  31368. * Clones the texture.
  31369. * @returns the cloned texture
  31370. */
  31371. clone(): Nullable<BaseTexture>;
  31372. /**
  31373. * Get the texture underlying type (INT, FLOAT...)
  31374. */
  31375. get textureType(): number;
  31376. /**
  31377. * Get the texture underlying format (RGB, RGBA...)
  31378. */
  31379. get textureFormat(): number;
  31380. /**
  31381. * Indicates that textures need to be re-calculated for all materials
  31382. */
  31383. protected _markAllSubMeshesAsTexturesDirty(): void;
  31384. /**
  31385. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  31386. * This will returns an RGBA array buffer containing either in values (0-255) or
  31387. * float values (0-1) depending of the underlying buffer type.
  31388. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  31389. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  31390. * @param buffer defines a user defined buffer to fill with data (can be null)
  31391. * @returns The Array buffer containing the pixels data.
  31392. */
  31393. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  31394. /**
  31395. * Release and destroy the underlying lower level texture aka internalTexture.
  31396. */
  31397. releaseInternalTexture(): void;
  31398. /** @hidden */
  31399. get _lodTextureHigh(): Nullable<BaseTexture>;
  31400. /** @hidden */
  31401. get _lodTextureMid(): Nullable<BaseTexture>;
  31402. /** @hidden */
  31403. get _lodTextureLow(): Nullable<BaseTexture>;
  31404. /**
  31405. * Dispose the texture and release its associated resources.
  31406. */
  31407. dispose(): void;
  31408. /**
  31409. * Serialize the texture into a JSON representation that can be parsed later on.
  31410. * @returns the JSON representation of the texture
  31411. */
  31412. serialize(): any;
  31413. /**
  31414. * Helper function to be called back once a list of texture contains only ready textures.
  31415. * @param textures Define the list of textures to wait for
  31416. * @param callback Define the callback triggered once the entire list will be ready
  31417. */
  31418. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  31419. }
  31420. }
  31421. declare module "babylonjs/Materials/effect" {
  31422. import { Observable } from "babylonjs/Misc/observable";
  31423. import { Nullable } from "babylonjs/types";
  31424. import { IDisposable } from "babylonjs/scene";
  31425. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  31426. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  31427. import { IMatrixLike, IVector2Like, IVector3Like, IVector4Like, IColor3Like, IColor4Like } from "babylonjs/Maths/math.like";
  31428. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  31429. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  31430. import { Engine } from "babylonjs/Engines/engine";
  31431. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  31432. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  31433. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  31434. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  31435. /**
  31436. * Options to be used when creating an effect.
  31437. */
  31438. export interface IEffectCreationOptions {
  31439. /**
  31440. * Atrributes that will be used in the shader.
  31441. */
  31442. attributes: string[];
  31443. /**
  31444. * Uniform varible names that will be set in the shader.
  31445. */
  31446. uniformsNames: string[];
  31447. /**
  31448. * Uniform buffer variable names that will be set in the shader.
  31449. */
  31450. uniformBuffersNames: string[];
  31451. /**
  31452. * Sampler texture variable names that will be set in the shader.
  31453. */
  31454. samplers: string[];
  31455. /**
  31456. * Define statements that will be set in the shader.
  31457. */
  31458. defines: any;
  31459. /**
  31460. * Possible fallbacks for this effect to improve performance when needed.
  31461. */
  31462. fallbacks: Nullable<IEffectFallbacks>;
  31463. /**
  31464. * Callback that will be called when the shader is compiled.
  31465. */
  31466. onCompiled: Nullable<(effect: Effect) => void>;
  31467. /**
  31468. * Callback that will be called if an error occurs during shader compilation.
  31469. */
  31470. onError: Nullable<(effect: Effect, errors: string) => void>;
  31471. /**
  31472. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  31473. */
  31474. indexParameters?: any;
  31475. /**
  31476. * Max number of lights that can be used in the shader.
  31477. */
  31478. maxSimultaneousLights?: number;
  31479. /**
  31480. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  31481. */
  31482. transformFeedbackVaryings?: Nullable<string[]>;
  31483. }
  31484. /**
  31485. * Effect containing vertex and fragment shader that can be executed on an object.
  31486. */
  31487. export class Effect implements IDisposable {
  31488. /**
  31489. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  31490. */
  31491. static ShadersRepository: string;
  31492. /**
  31493. * Enable logging of the shader code when a compilation error occurs
  31494. */
  31495. static LogShaderCodeOnCompilationError: boolean;
  31496. /**
  31497. * Name of the effect.
  31498. */
  31499. name: any;
  31500. /**
  31501. * String container all the define statements that should be set on the shader.
  31502. */
  31503. defines: string;
  31504. /**
  31505. * Callback that will be called when the shader is compiled.
  31506. */
  31507. onCompiled: Nullable<(effect: Effect) => void>;
  31508. /**
  31509. * Callback that will be called if an error occurs during shader compilation.
  31510. */
  31511. onError: Nullable<(effect: Effect, errors: string) => void>;
  31512. /**
  31513. * Callback that will be called when effect is bound.
  31514. */
  31515. onBind: Nullable<(effect: Effect) => void>;
  31516. /**
  31517. * Unique ID of the effect.
  31518. */
  31519. uniqueId: number;
  31520. /**
  31521. * Observable that will be called when the shader is compiled.
  31522. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  31523. */
  31524. onCompileObservable: Observable<Effect>;
  31525. /**
  31526. * Observable that will be called if an error occurs during shader compilation.
  31527. */
  31528. onErrorObservable: Observable<Effect>;
  31529. /** @hidden */
  31530. _onBindObservable: Nullable<Observable<Effect>>;
  31531. /**
  31532. * @hidden
  31533. * Specifies if the effect was previously ready
  31534. */
  31535. _wasPreviouslyReady: boolean;
  31536. /**
  31537. * Observable that will be called when effect is bound.
  31538. */
  31539. get onBindObservable(): Observable<Effect>;
  31540. /** @hidden */
  31541. _bonesComputationForcedToCPU: boolean;
  31542. private static _uniqueIdSeed;
  31543. private _engine;
  31544. private _uniformBuffersNames;
  31545. private _uniformBuffersNamesList;
  31546. private _uniformsNames;
  31547. private _samplerList;
  31548. private _samplers;
  31549. private _isReady;
  31550. private _compilationError;
  31551. private _allFallbacksProcessed;
  31552. private _attributesNames;
  31553. private _attributes;
  31554. private _attributeLocationByName;
  31555. private _uniforms;
  31556. /**
  31557. * Key for the effect.
  31558. * @hidden
  31559. */
  31560. _key: string;
  31561. private _indexParameters;
  31562. private _fallbacks;
  31563. private _vertexSourceCode;
  31564. private _fragmentSourceCode;
  31565. private _vertexSourceCodeOverride;
  31566. private _fragmentSourceCodeOverride;
  31567. private _transformFeedbackVaryings;
  31568. /**
  31569. * Compiled shader to webGL program.
  31570. * @hidden
  31571. */
  31572. _pipelineContext: Nullable<IPipelineContext>;
  31573. private _valueCache;
  31574. private static _baseCache;
  31575. /**
  31576. * Instantiates an effect.
  31577. * An effect can be used to create/manage/execute vertex and fragment shaders.
  31578. * @param baseName Name of the effect.
  31579. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  31580. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  31581. * @param samplers List of sampler variables that will be passed to the shader.
  31582. * @param engine Engine to be used to render the effect
  31583. * @param defines Define statements to be added to the shader.
  31584. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  31585. * @param onCompiled Callback that will be called when the shader is compiled.
  31586. * @param onError Callback that will be called if an error occurs during shader compilation.
  31587. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  31588. */
  31589. 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);
  31590. private _useFinalCode;
  31591. /**
  31592. * Unique key for this effect
  31593. */
  31594. get key(): string;
  31595. /**
  31596. * If the effect has been compiled and prepared.
  31597. * @returns if the effect is compiled and prepared.
  31598. */
  31599. isReady(): boolean;
  31600. private _isReadyInternal;
  31601. /**
  31602. * The engine the effect was initialized with.
  31603. * @returns the engine.
  31604. */
  31605. getEngine(): Engine;
  31606. /**
  31607. * The pipeline context for this effect
  31608. * @returns the associated pipeline context
  31609. */
  31610. getPipelineContext(): Nullable<IPipelineContext>;
  31611. /**
  31612. * The set of names of attribute variables for the shader.
  31613. * @returns An array of attribute names.
  31614. */
  31615. getAttributesNames(): string[];
  31616. /**
  31617. * Returns the attribute at the given index.
  31618. * @param index The index of the attribute.
  31619. * @returns The location of the attribute.
  31620. */
  31621. getAttributeLocation(index: number): number;
  31622. /**
  31623. * Returns the attribute based on the name of the variable.
  31624. * @param name of the attribute to look up.
  31625. * @returns the attribute location.
  31626. */
  31627. getAttributeLocationByName(name: string): number;
  31628. /**
  31629. * The number of attributes.
  31630. * @returns the numnber of attributes.
  31631. */
  31632. getAttributesCount(): number;
  31633. /**
  31634. * Gets the index of a uniform variable.
  31635. * @param uniformName of the uniform to look up.
  31636. * @returns the index.
  31637. */
  31638. getUniformIndex(uniformName: string): number;
  31639. /**
  31640. * Returns the attribute based on the name of the variable.
  31641. * @param uniformName of the uniform to look up.
  31642. * @returns the location of the uniform.
  31643. */
  31644. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  31645. /**
  31646. * Returns an array of sampler variable names
  31647. * @returns The array of sampler variable names.
  31648. */
  31649. getSamplers(): string[];
  31650. /**
  31651. * Returns an array of uniform variable names
  31652. * @returns The array of uniform variable names.
  31653. */
  31654. getUniformNames(): string[];
  31655. /**
  31656. * Returns an array of uniform buffer variable names
  31657. * @returns The array of uniform buffer variable names.
  31658. */
  31659. getUniformBuffersNames(): string[];
  31660. /**
  31661. * Returns the index parameters used to create the effect
  31662. * @returns The index parameters object
  31663. */
  31664. getIndexParameters(): any;
  31665. /**
  31666. * The error from the last compilation.
  31667. * @returns the error string.
  31668. */
  31669. getCompilationError(): string;
  31670. /**
  31671. * Gets a boolean indicating that all fallbacks were used during compilation
  31672. * @returns true if all fallbacks were used
  31673. */
  31674. allFallbacksProcessed(): boolean;
  31675. /**
  31676. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  31677. * @param func The callback to be used.
  31678. */
  31679. executeWhenCompiled(func: (effect: Effect) => void): void;
  31680. private _checkIsReady;
  31681. private _loadShader;
  31682. /**
  31683. * Gets the vertex shader source code of this effect
  31684. */
  31685. get vertexSourceCode(): string;
  31686. /**
  31687. * Gets the fragment shader source code of this effect
  31688. */
  31689. get fragmentSourceCode(): string;
  31690. /**
  31691. * Recompiles the webGL program
  31692. * @param vertexSourceCode The source code for the vertex shader.
  31693. * @param fragmentSourceCode The source code for the fragment shader.
  31694. * @param onCompiled Callback called when completed.
  31695. * @param onError Callback called on error.
  31696. * @hidden
  31697. */
  31698. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  31699. /**
  31700. * Prepares the effect
  31701. * @hidden
  31702. */
  31703. _prepareEffect(): void;
  31704. private _getShaderCodeAndErrorLine;
  31705. private _processCompilationErrors;
  31706. /**
  31707. * Checks if the effect is supported. (Must be called after compilation)
  31708. */
  31709. get isSupported(): boolean;
  31710. /**
  31711. * Binds a texture to the engine to be used as output of the shader.
  31712. * @param channel Name of the output variable.
  31713. * @param texture Texture to bind.
  31714. * @hidden
  31715. */
  31716. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  31717. /**
  31718. * Sets a texture on the engine to be used in the shader.
  31719. * @param channel Name of the sampler variable.
  31720. * @param texture Texture to set.
  31721. */
  31722. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  31723. /**
  31724. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  31725. * @param channel Name of the sampler variable.
  31726. * @param texture Texture to set.
  31727. */
  31728. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  31729. /**
  31730. * Sets an array of textures on the engine to be used in the shader.
  31731. * @param channel Name of the variable.
  31732. * @param textures Textures to set.
  31733. */
  31734. setTextureArray(channel: string, textures: BaseTexture[]): void;
  31735. /**
  31736. * 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)
  31737. * @param channel Name of the sampler variable.
  31738. * @param postProcess Post process to get the input texture from.
  31739. */
  31740. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  31741. /**
  31742. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  31743. * 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)
  31744. * @param channel Name of the sampler variable.
  31745. * @param postProcess Post process to get the output texture from.
  31746. */
  31747. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  31748. /** @hidden */
  31749. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  31750. /** @hidden */
  31751. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  31752. /** @hidden */
  31753. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  31754. /** @hidden */
  31755. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  31756. /**
  31757. * Binds a buffer to a uniform.
  31758. * @param buffer Buffer to bind.
  31759. * @param name Name of the uniform variable to bind to.
  31760. */
  31761. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  31762. /**
  31763. * Binds block to a uniform.
  31764. * @param blockName Name of the block to bind.
  31765. * @param index Index to bind.
  31766. */
  31767. bindUniformBlock(blockName: string, index: number): void;
  31768. /**
  31769. * Sets an interger value on a uniform variable.
  31770. * @param uniformName Name of the variable.
  31771. * @param value Value to be set.
  31772. * @returns this effect.
  31773. */
  31774. setInt(uniformName: string, value: number): Effect;
  31775. /**
  31776. * Sets an int array on a uniform variable.
  31777. * @param uniformName Name of the variable.
  31778. * @param array array to be set.
  31779. * @returns this effect.
  31780. */
  31781. setIntArray(uniformName: string, array: Int32Array): Effect;
  31782. /**
  31783. * 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)
  31784. * @param uniformName Name of the variable.
  31785. * @param array array to be set.
  31786. * @returns this effect.
  31787. */
  31788. setIntArray2(uniformName: string, array: Int32Array): Effect;
  31789. /**
  31790. * 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)
  31791. * @param uniformName Name of the variable.
  31792. * @param array array to be set.
  31793. * @returns this effect.
  31794. */
  31795. setIntArray3(uniformName: string, array: Int32Array): Effect;
  31796. /**
  31797. * 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)
  31798. * @param uniformName Name of the variable.
  31799. * @param array array to be set.
  31800. * @returns this effect.
  31801. */
  31802. setIntArray4(uniformName: string, array: Int32Array): Effect;
  31803. /**
  31804. * Sets an float array on a uniform variable.
  31805. * @param uniformName Name of the variable.
  31806. * @param array array to be set.
  31807. * @returns this effect.
  31808. */
  31809. setFloatArray(uniformName: string, array: Float32Array): Effect;
  31810. /**
  31811. * 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)
  31812. * @param uniformName Name of the variable.
  31813. * @param array array to be set.
  31814. * @returns this effect.
  31815. */
  31816. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  31817. /**
  31818. * 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)
  31819. * @param uniformName Name of the variable.
  31820. * @param array array to be set.
  31821. * @returns this effect.
  31822. */
  31823. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  31824. /**
  31825. * 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)
  31826. * @param uniformName Name of the variable.
  31827. * @param array array to be set.
  31828. * @returns this effect.
  31829. */
  31830. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  31831. /**
  31832. * Sets an array on a uniform variable.
  31833. * @param uniformName Name of the variable.
  31834. * @param array array to be set.
  31835. * @returns this effect.
  31836. */
  31837. setArray(uniformName: string, array: number[]): Effect;
  31838. /**
  31839. * 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)
  31840. * @param uniformName Name of the variable.
  31841. * @param array array to be set.
  31842. * @returns this effect.
  31843. */
  31844. setArray2(uniformName: string, array: number[]): Effect;
  31845. /**
  31846. * 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)
  31847. * @param uniformName Name of the variable.
  31848. * @param array array to be set.
  31849. * @returns this effect.
  31850. */
  31851. setArray3(uniformName: string, array: number[]): Effect;
  31852. /**
  31853. * 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)
  31854. * @param uniformName Name of the variable.
  31855. * @param array array to be set.
  31856. * @returns this effect.
  31857. */
  31858. setArray4(uniformName: string, array: number[]): Effect;
  31859. /**
  31860. * Sets matrices on a uniform variable.
  31861. * @param uniformName Name of the variable.
  31862. * @param matrices matrices to be set.
  31863. * @returns this effect.
  31864. */
  31865. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  31866. /**
  31867. * Sets matrix on a uniform variable.
  31868. * @param uniformName Name of the variable.
  31869. * @param matrix matrix to be set.
  31870. * @returns this effect.
  31871. */
  31872. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  31873. /**
  31874. * 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)
  31875. * @param uniformName Name of the variable.
  31876. * @param matrix matrix to be set.
  31877. * @returns this effect.
  31878. */
  31879. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  31880. /**
  31881. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  31882. * @param uniformName Name of the variable.
  31883. * @param matrix matrix to be set.
  31884. * @returns this effect.
  31885. */
  31886. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  31887. /**
  31888. * Sets a float on a uniform variable.
  31889. * @param uniformName Name of the variable.
  31890. * @param value value to be set.
  31891. * @returns this effect.
  31892. */
  31893. setFloat(uniformName: string, value: number): Effect;
  31894. /**
  31895. * Sets a boolean on a uniform variable.
  31896. * @param uniformName Name of the variable.
  31897. * @param bool value to be set.
  31898. * @returns this effect.
  31899. */
  31900. setBool(uniformName: string, bool: boolean): Effect;
  31901. /**
  31902. * Sets a Vector2 on a uniform variable.
  31903. * @param uniformName Name of the variable.
  31904. * @param vector2 vector2 to be set.
  31905. * @returns this effect.
  31906. */
  31907. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  31908. /**
  31909. * Sets a float2 on a uniform variable.
  31910. * @param uniformName Name of the variable.
  31911. * @param x First float in float2.
  31912. * @param y Second float in float2.
  31913. * @returns this effect.
  31914. */
  31915. setFloat2(uniformName: string, x: number, y: number): Effect;
  31916. /**
  31917. * Sets a Vector3 on a uniform variable.
  31918. * @param uniformName Name of the variable.
  31919. * @param vector3 Value to be set.
  31920. * @returns this effect.
  31921. */
  31922. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  31923. /**
  31924. * Sets a float3 on a uniform variable.
  31925. * @param uniformName Name of the variable.
  31926. * @param x First float in float3.
  31927. * @param y Second float in float3.
  31928. * @param z Third float in float3.
  31929. * @returns this effect.
  31930. */
  31931. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  31932. /**
  31933. * Sets a Vector4 on a uniform variable.
  31934. * @param uniformName Name of the variable.
  31935. * @param vector4 Value to be set.
  31936. * @returns this effect.
  31937. */
  31938. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  31939. /**
  31940. * Sets a float4 on a uniform variable.
  31941. * @param uniformName Name of the variable.
  31942. * @param x First float in float4.
  31943. * @param y Second float in float4.
  31944. * @param z Third float in float4.
  31945. * @param w Fourth float in float4.
  31946. * @returns this effect.
  31947. */
  31948. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  31949. /**
  31950. * Sets a Color3 on a uniform variable.
  31951. * @param uniformName Name of the variable.
  31952. * @param color3 Value to be set.
  31953. * @returns this effect.
  31954. */
  31955. setColor3(uniformName: string, color3: IColor3Like): Effect;
  31956. /**
  31957. * Sets a Color4 on a uniform variable.
  31958. * @param uniformName Name of the variable.
  31959. * @param color3 Value to be set.
  31960. * @param alpha Alpha value to be set.
  31961. * @returns this effect.
  31962. */
  31963. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  31964. /**
  31965. * Sets a Color4 on a uniform variable
  31966. * @param uniformName defines the name of the variable
  31967. * @param color4 defines the value to be set
  31968. * @returns this effect.
  31969. */
  31970. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  31971. /** Release all associated resources */
  31972. dispose(): void;
  31973. /**
  31974. * This function will add a new shader to the shader store
  31975. * @param name the name of the shader
  31976. * @param pixelShader optional pixel shader content
  31977. * @param vertexShader optional vertex shader content
  31978. */
  31979. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  31980. /**
  31981. * Store of each shader (The can be looked up using effect.key)
  31982. */
  31983. static ShadersStore: {
  31984. [key: string]: string;
  31985. };
  31986. /**
  31987. * Store of each included file for a shader (The can be looked up using effect.key)
  31988. */
  31989. static IncludesShadersStore: {
  31990. [key: string]: string;
  31991. };
  31992. /**
  31993. * Resets the cache of effects.
  31994. */
  31995. static ResetCache(): void;
  31996. }
  31997. }
  31998. declare module "babylonjs/Engines/engineCapabilities" {
  31999. /**
  32000. * Interface used to describe the capabilities of the engine relatively to the current browser
  32001. */
  32002. export interface EngineCapabilities {
  32003. /** Maximum textures units per fragment shader */
  32004. maxTexturesImageUnits: number;
  32005. /** Maximum texture units per vertex shader */
  32006. maxVertexTextureImageUnits: number;
  32007. /** Maximum textures units in the entire pipeline */
  32008. maxCombinedTexturesImageUnits: number;
  32009. /** Maximum texture size */
  32010. maxTextureSize: number;
  32011. /** Maximum texture samples */
  32012. maxSamples?: number;
  32013. /** Maximum cube texture size */
  32014. maxCubemapTextureSize: number;
  32015. /** Maximum render texture size */
  32016. maxRenderTextureSize: number;
  32017. /** Maximum number of vertex attributes */
  32018. maxVertexAttribs: number;
  32019. /** Maximum number of varyings */
  32020. maxVaryingVectors: number;
  32021. /** Maximum number of uniforms per vertex shader */
  32022. maxVertexUniformVectors: number;
  32023. /** Maximum number of uniforms per fragment shader */
  32024. maxFragmentUniformVectors: number;
  32025. /** Defines if standard derivates (dx/dy) are supported */
  32026. standardDerivatives: boolean;
  32027. /** Defines if s3tc texture compression is supported */
  32028. s3tc?: WEBGL_compressed_texture_s3tc;
  32029. /** Defines if pvrtc texture compression is supported */
  32030. pvrtc: any;
  32031. /** Defines if etc1 texture compression is supported */
  32032. etc1: any;
  32033. /** Defines if etc2 texture compression is supported */
  32034. etc2: any;
  32035. /** Defines if astc texture compression is supported */
  32036. astc: any;
  32037. /** Defines if float textures are supported */
  32038. textureFloat: boolean;
  32039. /** Defines if vertex array objects are supported */
  32040. vertexArrayObject: boolean;
  32041. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  32042. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  32043. /** Gets the maximum level of anisotropy supported */
  32044. maxAnisotropy: number;
  32045. /** Defines if instancing is supported */
  32046. instancedArrays: boolean;
  32047. /** Defines if 32 bits indices are supported */
  32048. uintIndices: boolean;
  32049. /** Defines if high precision shaders are supported */
  32050. highPrecisionShaderSupported: boolean;
  32051. /** Defines if depth reading in the fragment shader is supported */
  32052. fragmentDepthSupported: boolean;
  32053. /** Defines if float texture linear filtering is supported*/
  32054. textureFloatLinearFiltering: boolean;
  32055. /** Defines if rendering to float textures is supported */
  32056. textureFloatRender: boolean;
  32057. /** Defines if half float textures are supported*/
  32058. textureHalfFloat: boolean;
  32059. /** Defines if half float texture linear filtering is supported*/
  32060. textureHalfFloatLinearFiltering: boolean;
  32061. /** Defines if rendering to half float textures is supported */
  32062. textureHalfFloatRender: boolean;
  32063. /** Defines if textureLOD shader command is supported */
  32064. textureLOD: boolean;
  32065. /** Defines if draw buffers extension is supported */
  32066. drawBuffersExtension: boolean;
  32067. /** Defines if depth textures are supported */
  32068. depthTextureExtension: boolean;
  32069. /** Defines if float color buffer are supported */
  32070. colorBufferFloat: boolean;
  32071. /** Gets disjoint timer query extension (null if not supported) */
  32072. timerQuery?: EXT_disjoint_timer_query;
  32073. /** Defines if timestamp can be used with timer query */
  32074. canUseTimestampForTimerQuery: boolean;
  32075. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  32076. multiview?: any;
  32077. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  32078. oculusMultiview?: any;
  32079. /** Function used to let the system compiles shaders in background */
  32080. parallelShaderCompile?: {
  32081. COMPLETION_STATUS_KHR: number;
  32082. };
  32083. /** Max number of texture samples for MSAA */
  32084. maxMSAASamples: number;
  32085. /** Defines if the blend min max extension is supported */
  32086. blendMinMax: boolean;
  32087. }
  32088. }
  32089. declare module "babylonjs/States/depthCullingState" {
  32090. import { Nullable } from "babylonjs/types";
  32091. /**
  32092. * @hidden
  32093. **/
  32094. export class DepthCullingState {
  32095. private _isDepthTestDirty;
  32096. private _isDepthMaskDirty;
  32097. private _isDepthFuncDirty;
  32098. private _isCullFaceDirty;
  32099. private _isCullDirty;
  32100. private _isZOffsetDirty;
  32101. private _isFrontFaceDirty;
  32102. private _depthTest;
  32103. private _depthMask;
  32104. private _depthFunc;
  32105. private _cull;
  32106. private _cullFace;
  32107. private _zOffset;
  32108. private _frontFace;
  32109. /**
  32110. * Initializes the state.
  32111. */
  32112. constructor();
  32113. get isDirty(): boolean;
  32114. get zOffset(): number;
  32115. set zOffset(value: number);
  32116. get cullFace(): Nullable<number>;
  32117. set cullFace(value: Nullable<number>);
  32118. get cull(): Nullable<boolean>;
  32119. set cull(value: Nullable<boolean>);
  32120. get depthFunc(): Nullable<number>;
  32121. set depthFunc(value: Nullable<number>);
  32122. get depthMask(): boolean;
  32123. set depthMask(value: boolean);
  32124. get depthTest(): boolean;
  32125. set depthTest(value: boolean);
  32126. get frontFace(): Nullable<number>;
  32127. set frontFace(value: Nullable<number>);
  32128. reset(): void;
  32129. apply(gl: WebGLRenderingContext): void;
  32130. }
  32131. }
  32132. declare module "babylonjs/States/stencilState" {
  32133. /**
  32134. * @hidden
  32135. **/
  32136. export class StencilState {
  32137. /** 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 */
  32138. static readonly ALWAYS: number;
  32139. /** Passed to stencilOperation to specify that stencil value must be kept */
  32140. static readonly KEEP: number;
  32141. /** Passed to stencilOperation to specify that stencil value must be replaced */
  32142. static readonly REPLACE: number;
  32143. private _isStencilTestDirty;
  32144. private _isStencilMaskDirty;
  32145. private _isStencilFuncDirty;
  32146. private _isStencilOpDirty;
  32147. private _stencilTest;
  32148. private _stencilMask;
  32149. private _stencilFunc;
  32150. private _stencilFuncRef;
  32151. private _stencilFuncMask;
  32152. private _stencilOpStencilFail;
  32153. private _stencilOpDepthFail;
  32154. private _stencilOpStencilDepthPass;
  32155. get isDirty(): boolean;
  32156. get stencilFunc(): number;
  32157. set stencilFunc(value: number);
  32158. get stencilFuncRef(): number;
  32159. set stencilFuncRef(value: number);
  32160. get stencilFuncMask(): number;
  32161. set stencilFuncMask(value: number);
  32162. get stencilOpStencilFail(): number;
  32163. set stencilOpStencilFail(value: number);
  32164. get stencilOpDepthFail(): number;
  32165. set stencilOpDepthFail(value: number);
  32166. get stencilOpStencilDepthPass(): number;
  32167. set stencilOpStencilDepthPass(value: number);
  32168. get stencilMask(): number;
  32169. set stencilMask(value: number);
  32170. get stencilTest(): boolean;
  32171. set stencilTest(value: boolean);
  32172. constructor();
  32173. reset(): void;
  32174. apply(gl: WebGLRenderingContext): void;
  32175. }
  32176. }
  32177. declare module "babylonjs/States/alphaCullingState" {
  32178. /**
  32179. * @hidden
  32180. **/
  32181. export class AlphaState {
  32182. private _isAlphaBlendDirty;
  32183. private _isBlendFunctionParametersDirty;
  32184. private _isBlendEquationParametersDirty;
  32185. private _isBlendConstantsDirty;
  32186. private _alphaBlend;
  32187. private _blendFunctionParameters;
  32188. private _blendEquationParameters;
  32189. private _blendConstants;
  32190. /**
  32191. * Initializes the state.
  32192. */
  32193. constructor();
  32194. get isDirty(): boolean;
  32195. get alphaBlend(): boolean;
  32196. set alphaBlend(value: boolean);
  32197. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  32198. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  32199. setAlphaEquationParameters(rgb: number, alpha: number): void;
  32200. reset(): void;
  32201. apply(gl: WebGLRenderingContext): void;
  32202. }
  32203. }
  32204. declare module "babylonjs/Engines/WebGL/webGL2ShaderProcessors" {
  32205. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  32206. /** @hidden */
  32207. export class WebGL2ShaderProcessor implements IShaderProcessor {
  32208. attributeProcessor(attribute: string): string;
  32209. varyingProcessor(varying: string, isFragment: boolean): string;
  32210. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  32211. }
  32212. }
  32213. declare module "babylonjs/Engines/instancingAttributeInfo" {
  32214. /**
  32215. * Interface for attribute information associated with buffer instanciation
  32216. */
  32217. export interface InstancingAttributeInfo {
  32218. /**
  32219. * Name of the GLSL attribute
  32220. * if attribute index is not specified, this is used to retrieve the index from the effect
  32221. */
  32222. attributeName: string;
  32223. /**
  32224. * Index/offset of the attribute in the vertex shader
  32225. * if not specified, this will be computes from the name.
  32226. */
  32227. index?: number;
  32228. /**
  32229. * size of the attribute, 1, 2, 3 or 4
  32230. */
  32231. attributeSize: number;
  32232. /**
  32233. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  32234. */
  32235. offset: number;
  32236. /**
  32237. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  32238. * default to 1
  32239. */
  32240. divisor?: number;
  32241. /**
  32242. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  32243. * default is FLOAT
  32244. */
  32245. attributeType?: number;
  32246. /**
  32247. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  32248. */
  32249. normalized?: boolean;
  32250. }
  32251. }
  32252. declare module "babylonjs/Engines/Extensions/engine.videoTexture" {
  32253. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  32254. import { Nullable } from "babylonjs/types";
  32255. module "babylonjs/Engines/thinEngine" {
  32256. interface ThinEngine {
  32257. /**
  32258. * Update a video texture
  32259. * @param texture defines the texture to update
  32260. * @param video defines the video element to use
  32261. * @param invertY defines if data must be stored with Y axis inverted
  32262. */
  32263. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  32264. }
  32265. }
  32266. }
  32267. declare module "babylonjs/Materials/Textures/videoTexture" {
  32268. import { Observable } from "babylonjs/Misc/observable";
  32269. import { Nullable } from "babylonjs/types";
  32270. import { Scene } from "babylonjs/scene";
  32271. import { Texture } from "babylonjs/Materials/Textures/texture";
  32272. import "babylonjs/Engines/Extensions/engine.videoTexture";
  32273. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  32274. /**
  32275. * Settings for finer control over video usage
  32276. */
  32277. export interface VideoTextureSettings {
  32278. /**
  32279. * Applies `autoplay` to video, if specified
  32280. */
  32281. autoPlay?: boolean;
  32282. /**
  32283. * Applies `loop` to video, if specified
  32284. */
  32285. loop?: boolean;
  32286. /**
  32287. * Automatically updates internal texture from video at every frame in the render loop
  32288. */
  32289. autoUpdateTexture: boolean;
  32290. /**
  32291. * Image src displayed during the video loading or until the user interacts with the video.
  32292. */
  32293. poster?: string;
  32294. }
  32295. /**
  32296. * If you want to display a video in your scene, this is the special texture for that.
  32297. * This special texture works similar to other textures, with the exception of a few parameters.
  32298. * @see https://doc.babylonjs.com/how_to/video_texture
  32299. */
  32300. export class VideoTexture extends Texture {
  32301. /**
  32302. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  32303. */
  32304. readonly autoUpdateTexture: boolean;
  32305. /**
  32306. * The video instance used by the texture internally
  32307. */
  32308. readonly video: HTMLVideoElement;
  32309. private _onUserActionRequestedObservable;
  32310. /**
  32311. * Event triggerd when a dom action is required by the user to play the video.
  32312. * This happens due to recent changes in browser policies preventing video to auto start.
  32313. */
  32314. get onUserActionRequestedObservable(): Observable<Texture>;
  32315. private _generateMipMaps;
  32316. private _engine;
  32317. private _stillImageCaptured;
  32318. private _displayingPosterTexture;
  32319. private _settings;
  32320. private _createInternalTextureOnEvent;
  32321. private _frameId;
  32322. private _currentSrc;
  32323. /**
  32324. * Creates a video texture.
  32325. * If you want to display a video in your scene, this is the special texture for that.
  32326. * This special texture works similar to other textures, with the exception of a few parameters.
  32327. * @see https://doc.babylonjs.com/how_to/video_texture
  32328. * @param name optional name, will detect from video source, if not defined
  32329. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  32330. * @param scene is obviously the current scene.
  32331. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  32332. * @param invertY is false by default but can be used to invert video on Y axis
  32333. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  32334. * @param settings allows finer control over video usage
  32335. */
  32336. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  32337. private _getName;
  32338. private _getVideo;
  32339. private _createInternalTexture;
  32340. private reset;
  32341. /**
  32342. * @hidden Internal method to initiate `update`.
  32343. */
  32344. _rebuild(): void;
  32345. /**
  32346. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  32347. */
  32348. update(): void;
  32349. /**
  32350. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  32351. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  32352. */
  32353. updateTexture(isVisible: boolean): void;
  32354. protected _updateInternalTexture: () => void;
  32355. /**
  32356. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  32357. * @param url New url.
  32358. */
  32359. updateURL(url: string): void;
  32360. /**
  32361. * Clones the texture.
  32362. * @returns the cloned texture
  32363. */
  32364. clone(): VideoTexture;
  32365. /**
  32366. * Dispose the texture and release its associated resources.
  32367. */
  32368. dispose(): void;
  32369. /**
  32370. * Creates a video texture straight from a stream.
  32371. * @param scene Define the scene the texture should be created in
  32372. * @param stream Define the stream the texture should be created from
  32373. * @returns The created video texture as a promise
  32374. */
  32375. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  32376. /**
  32377. * Creates a video texture straight from your WebCam video feed.
  32378. * @param scene Define the scene the texture should be created in
  32379. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  32380. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  32381. * @returns The created video texture as a promise
  32382. */
  32383. static CreateFromWebCamAsync(scene: Scene, constraints: {
  32384. minWidth: number;
  32385. maxWidth: number;
  32386. minHeight: number;
  32387. maxHeight: number;
  32388. deviceId: string;
  32389. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  32390. /**
  32391. * Creates a video texture straight from your WebCam video feed.
  32392. * @param scene Define the scene the texture should be created in
  32393. * @param onReady Define a callback to triggered once the texture will be ready
  32394. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  32395. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  32396. */
  32397. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  32398. minWidth: number;
  32399. maxWidth: number;
  32400. minHeight: number;
  32401. maxHeight: number;
  32402. deviceId: string;
  32403. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  32404. }
  32405. }
  32406. declare module "babylonjs/Engines/thinEngine" {
  32407. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  32408. import { Effect, IEffectCreationOptions } from "babylonjs/Materials/effect";
  32409. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  32410. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  32411. import { Nullable, DataArray, IndicesArray } from "babylonjs/types";
  32412. import { EngineCapabilities } from "babylonjs/Engines/engineCapabilities";
  32413. import { Observable } from "babylonjs/Misc/observable";
  32414. import { DepthCullingState } from "babylonjs/States/depthCullingState";
  32415. import { StencilState } from "babylonjs/States/stencilState";
  32416. import { AlphaState } from "babylonjs/States/alphaCullingState";
  32417. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  32418. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  32419. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  32420. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  32421. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  32422. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  32423. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  32424. import { InstancingAttributeInfo } from "babylonjs/Engines/instancingAttributeInfo";
  32425. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  32426. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  32427. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  32428. import { IWebRequest } from "babylonjs/Misc/interfaces/iWebRequest";
  32429. import { WebRequest } from "babylonjs/Misc/webRequest";
  32430. import { LoadFileError } from "babylonjs/Misc/fileTools";
  32431. /**
  32432. * Defines the interface used by objects working like Scene
  32433. * @hidden
  32434. */
  32435. export interface ISceneLike {
  32436. _addPendingData(data: any): void;
  32437. _removePendingData(data: any): void;
  32438. offlineProvider: IOfflineProvider;
  32439. }
  32440. /** Interface defining initialization parameters for Engine class */
  32441. export interface EngineOptions extends WebGLContextAttributes {
  32442. /**
  32443. * Defines if the engine should no exceed a specified device ratio
  32444. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  32445. */
  32446. limitDeviceRatio?: number;
  32447. /**
  32448. * Defines if webvr should be enabled automatically
  32449. * @see http://doc.babylonjs.com/how_to/webvr_camera
  32450. */
  32451. autoEnableWebVR?: boolean;
  32452. /**
  32453. * Defines if webgl2 should be turned off even if supported
  32454. * @see http://doc.babylonjs.com/features/webgl2
  32455. */
  32456. disableWebGL2Support?: boolean;
  32457. /**
  32458. * Defines if webaudio should be initialized as well
  32459. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  32460. */
  32461. audioEngine?: boolean;
  32462. /**
  32463. * Defines if animations should run using a deterministic lock step
  32464. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32465. */
  32466. deterministicLockstep?: boolean;
  32467. /** Defines the maximum steps to use with deterministic lock step mode */
  32468. lockstepMaxSteps?: number;
  32469. /** Defines the seconds between each deterministic lock step */
  32470. timeStep?: number;
  32471. /**
  32472. * Defines that engine should ignore context lost events
  32473. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  32474. */
  32475. doNotHandleContextLost?: boolean;
  32476. /**
  32477. * Defines that engine should ignore modifying touch action attribute and style
  32478. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  32479. */
  32480. doNotHandleTouchAction?: boolean;
  32481. /**
  32482. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  32483. */
  32484. useHighPrecisionFloats?: boolean;
  32485. }
  32486. /**
  32487. * The base engine class (root of all engines)
  32488. */
  32489. export class ThinEngine {
  32490. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  32491. static ExceptionList: ({
  32492. key: string;
  32493. capture: string;
  32494. captureConstraint: number;
  32495. targets: string[];
  32496. } | {
  32497. key: string;
  32498. capture: null;
  32499. captureConstraint: null;
  32500. targets: string[];
  32501. })[];
  32502. /** @hidden */
  32503. static _TextureLoaders: IInternalTextureLoader[];
  32504. /**
  32505. * Returns the current npm package of the sdk
  32506. */
  32507. static get NpmPackage(): string;
  32508. /**
  32509. * Returns the current version of the framework
  32510. */
  32511. static get Version(): string;
  32512. /**
  32513. * Returns a string describing the current engine
  32514. */
  32515. get description(): string;
  32516. /**
  32517. * Gets or sets the epsilon value used by collision engine
  32518. */
  32519. static CollisionsEpsilon: number;
  32520. /**
  32521. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  32522. */
  32523. static get ShadersRepository(): string;
  32524. static set ShadersRepository(value: string);
  32525. /** @hidden */
  32526. _shaderProcessor: IShaderProcessor;
  32527. /**
  32528. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  32529. */
  32530. forcePOTTextures: boolean;
  32531. /**
  32532. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  32533. */
  32534. isFullscreen: boolean;
  32535. /**
  32536. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  32537. */
  32538. cullBackFaces: boolean;
  32539. /**
  32540. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  32541. */
  32542. renderEvenInBackground: boolean;
  32543. /**
  32544. * Gets or sets a boolean indicating that cache can be kept between frames
  32545. */
  32546. preventCacheWipeBetweenFrames: boolean;
  32547. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  32548. validateShaderPrograms: boolean;
  32549. /**
  32550. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  32551. * This can provide greater z depth for distant objects.
  32552. */
  32553. useReverseDepthBuffer: boolean;
  32554. /**
  32555. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  32556. */
  32557. disableUniformBuffers: boolean;
  32558. /** @hidden */
  32559. _uniformBuffers: UniformBuffer[];
  32560. /**
  32561. * Gets a boolean indicating that the engine supports uniform buffers
  32562. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  32563. */
  32564. get supportsUniformBuffers(): boolean;
  32565. /** @hidden */
  32566. _gl: WebGLRenderingContext;
  32567. /** @hidden */
  32568. _webGLVersion: number;
  32569. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  32570. protected _windowIsBackground: boolean;
  32571. protected _creationOptions: EngineOptions;
  32572. protected _highPrecisionShadersAllowed: boolean;
  32573. /** @hidden */
  32574. get _shouldUseHighPrecisionShader(): boolean;
  32575. /**
  32576. * Gets a boolean indicating that only power of 2 textures are supported
  32577. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  32578. */
  32579. get needPOTTextures(): boolean;
  32580. /** @hidden */
  32581. _badOS: boolean;
  32582. /** @hidden */
  32583. _badDesktopOS: boolean;
  32584. private _hardwareScalingLevel;
  32585. /** @hidden */
  32586. _caps: EngineCapabilities;
  32587. private _isStencilEnable;
  32588. private _glVersion;
  32589. private _glRenderer;
  32590. private _glVendor;
  32591. /** @hidden */
  32592. _videoTextureSupported: boolean;
  32593. protected _renderingQueueLaunched: boolean;
  32594. protected _activeRenderLoops: (() => void)[];
  32595. /**
  32596. * Observable signaled when a context lost event is raised
  32597. */
  32598. onContextLostObservable: Observable<ThinEngine>;
  32599. /**
  32600. * Observable signaled when a context restored event is raised
  32601. */
  32602. onContextRestoredObservable: Observable<ThinEngine>;
  32603. private _onContextLost;
  32604. private _onContextRestored;
  32605. protected _contextWasLost: boolean;
  32606. /** @hidden */
  32607. _doNotHandleContextLost: boolean;
  32608. /**
  32609. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  32610. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  32611. */
  32612. get doNotHandleContextLost(): boolean;
  32613. set doNotHandleContextLost(value: boolean);
  32614. /**
  32615. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  32616. */
  32617. disableVertexArrayObjects: boolean;
  32618. /** @hidden */
  32619. protected _colorWrite: boolean;
  32620. /** @hidden */
  32621. protected _colorWriteChanged: boolean;
  32622. /** @hidden */
  32623. protected _depthCullingState: DepthCullingState;
  32624. /** @hidden */
  32625. protected _stencilState: StencilState;
  32626. /** @hidden */
  32627. _alphaState: AlphaState;
  32628. /** @hidden */
  32629. _alphaMode: number;
  32630. /** @hidden */
  32631. _alphaEquation: number;
  32632. /** @hidden */
  32633. _internalTexturesCache: InternalTexture[];
  32634. /** @hidden */
  32635. protected _activeChannel: number;
  32636. private _currentTextureChannel;
  32637. /** @hidden */
  32638. protected _boundTexturesCache: {
  32639. [key: string]: Nullable<InternalTexture>;
  32640. };
  32641. /** @hidden */
  32642. protected _currentEffect: Nullable<Effect>;
  32643. /** @hidden */
  32644. protected _currentProgram: Nullable<WebGLProgram>;
  32645. private _compiledEffects;
  32646. private _vertexAttribArraysEnabled;
  32647. /** @hidden */
  32648. protected _cachedViewport: Nullable<IViewportLike>;
  32649. private _cachedVertexArrayObject;
  32650. /** @hidden */
  32651. protected _cachedVertexBuffers: any;
  32652. /** @hidden */
  32653. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  32654. /** @hidden */
  32655. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  32656. /** @hidden */
  32657. _currentRenderTarget: Nullable<InternalTexture>;
  32658. private _uintIndicesCurrentlySet;
  32659. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  32660. /** @hidden */
  32661. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  32662. private _currentBufferPointers;
  32663. private _currentInstanceLocations;
  32664. private _currentInstanceBuffers;
  32665. private _textureUnits;
  32666. /** @hidden */
  32667. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  32668. /** @hidden */
  32669. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  32670. /** @hidden */
  32671. _boundRenderFunction: any;
  32672. private _vaoRecordInProgress;
  32673. private _mustWipeVertexAttributes;
  32674. private _emptyTexture;
  32675. private _emptyCubeTexture;
  32676. private _emptyTexture3D;
  32677. private _emptyTexture2DArray;
  32678. /** @hidden */
  32679. _frameHandler: number;
  32680. private _nextFreeTextureSlots;
  32681. private _maxSimultaneousTextures;
  32682. private _activeRequests;
  32683. /** @hidden */
  32684. _transformTextureUrl: Nullable<(url: string) => string>;
  32685. protected get _supportsHardwareTextureRescaling(): boolean;
  32686. private _framebufferDimensionsObject;
  32687. /**
  32688. * sets the object from which width and height will be taken from when getting render width and height
  32689. * Will fallback to the gl object
  32690. * @param dimensions the framebuffer width and height that will be used.
  32691. */
  32692. set framebufferDimensionsObject(dimensions: Nullable<{
  32693. framebufferWidth: number;
  32694. framebufferHeight: number;
  32695. }>);
  32696. /**
  32697. * Gets the current viewport
  32698. */
  32699. get currentViewport(): Nullable<IViewportLike>;
  32700. /**
  32701. * Gets the default empty texture
  32702. */
  32703. get emptyTexture(): InternalTexture;
  32704. /**
  32705. * Gets the default empty 3D texture
  32706. */
  32707. get emptyTexture3D(): InternalTexture;
  32708. /**
  32709. * Gets the default empty 2D array texture
  32710. */
  32711. get emptyTexture2DArray(): InternalTexture;
  32712. /**
  32713. * Gets the default empty cube texture
  32714. */
  32715. get emptyCubeTexture(): InternalTexture;
  32716. /**
  32717. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  32718. */
  32719. readonly premultipliedAlpha: boolean;
  32720. /**
  32721. * Observable event triggered before each texture is initialized
  32722. */
  32723. onBeforeTextureInitObservable: Observable<import("babylonjs/Materials/Textures/texture").Texture>;
  32724. /**
  32725. * Creates a new engine
  32726. * @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
  32727. * @param antialias defines enable antialiasing (default: false)
  32728. * @param options defines further options to be sent to the getContext() function
  32729. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  32730. */
  32731. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  32732. private _rebuildInternalTextures;
  32733. private _rebuildEffects;
  32734. /**
  32735. * Gets a boolean indicating if all created effects are ready
  32736. * @returns true if all effects are ready
  32737. */
  32738. areAllEffectsReady(): boolean;
  32739. protected _rebuildBuffers(): void;
  32740. protected _initGLContext(): void;
  32741. /**
  32742. * Gets version of the current webGL context
  32743. */
  32744. get webGLVersion(): number;
  32745. /**
  32746. * Gets a string idenfifying the name of the class
  32747. * @returns "Engine" string
  32748. */
  32749. getClassName(): string;
  32750. /**
  32751. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  32752. */
  32753. get isStencilEnable(): boolean;
  32754. /** @hidden */
  32755. _prepareWorkingCanvas(): void;
  32756. /**
  32757. * Reset the texture cache to empty state
  32758. */
  32759. resetTextureCache(): void;
  32760. /**
  32761. * Gets an object containing information about the current webGL context
  32762. * @returns an object containing the vender, the renderer and the version of the current webGL context
  32763. */
  32764. getGlInfo(): {
  32765. vendor: string;
  32766. renderer: string;
  32767. version: string;
  32768. };
  32769. /**
  32770. * Defines the hardware scaling level.
  32771. * By default the hardware scaling level is computed from the window device ratio.
  32772. * 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.
  32773. * @param level defines the level to use
  32774. */
  32775. setHardwareScalingLevel(level: number): void;
  32776. /**
  32777. * Gets the current hardware scaling level.
  32778. * By default the hardware scaling level is computed from the window device ratio.
  32779. * 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.
  32780. * @returns a number indicating the current hardware scaling level
  32781. */
  32782. getHardwareScalingLevel(): number;
  32783. /**
  32784. * Gets the list of loaded textures
  32785. * @returns an array containing all loaded textures
  32786. */
  32787. getLoadedTexturesCache(): InternalTexture[];
  32788. /**
  32789. * Gets the object containing all engine capabilities
  32790. * @returns the EngineCapabilities object
  32791. */
  32792. getCaps(): EngineCapabilities;
  32793. /**
  32794. * stop executing a render loop function and remove it from the execution array
  32795. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  32796. */
  32797. stopRenderLoop(renderFunction?: () => void): void;
  32798. /** @hidden */
  32799. _renderLoop(): void;
  32800. /**
  32801. * Gets the HTML canvas attached with the current webGL context
  32802. * @returns a HTML canvas
  32803. */
  32804. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  32805. /**
  32806. * Gets host window
  32807. * @returns the host window object
  32808. */
  32809. getHostWindow(): Nullable<Window>;
  32810. /**
  32811. * Gets the current render width
  32812. * @param useScreen defines if screen size must be used (or the current render target if any)
  32813. * @returns a number defining the current render width
  32814. */
  32815. getRenderWidth(useScreen?: boolean): number;
  32816. /**
  32817. * Gets the current render height
  32818. * @param useScreen defines if screen size must be used (or the current render target if any)
  32819. * @returns a number defining the current render height
  32820. */
  32821. getRenderHeight(useScreen?: boolean): number;
  32822. /**
  32823. * Can be used to override the current requestAnimationFrame requester.
  32824. * @hidden
  32825. */
  32826. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  32827. /**
  32828. * Register and execute a render loop. The engine can have more than one render function
  32829. * @param renderFunction defines the function to continuously execute
  32830. */
  32831. runRenderLoop(renderFunction: () => void): void;
  32832. /**
  32833. * Clear the current render buffer or the current render target (if any is set up)
  32834. * @param color defines the color to use
  32835. * @param backBuffer defines if the back buffer must be cleared
  32836. * @param depth defines if the depth buffer must be cleared
  32837. * @param stencil defines if the stencil buffer must be cleared
  32838. */
  32839. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  32840. private _viewportCached;
  32841. /** @hidden */
  32842. _viewport(x: number, y: number, width: number, height: number): void;
  32843. /**
  32844. * Set the WebGL's viewport
  32845. * @param viewport defines the viewport element to be used
  32846. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  32847. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  32848. */
  32849. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  32850. /**
  32851. * Begin a new frame
  32852. */
  32853. beginFrame(): void;
  32854. /**
  32855. * Enf the current frame
  32856. */
  32857. endFrame(): void;
  32858. /**
  32859. * Resize the view according to the canvas' size
  32860. */
  32861. resize(): void;
  32862. /**
  32863. * Force a specific size of the canvas
  32864. * @param width defines the new canvas' width
  32865. * @param height defines the new canvas' height
  32866. */
  32867. setSize(width: number, height: number): void;
  32868. /**
  32869. * Binds the frame buffer to the specified texture.
  32870. * @param texture The texture to render to or null for the default canvas
  32871. * @param faceIndex The face of the texture to render to in case of cube texture
  32872. * @param requiredWidth The width of the target to render to
  32873. * @param requiredHeight The height of the target to render to
  32874. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  32875. * @param lodLevel defines the lod level to bind to the frame buffer
  32876. * @param layer defines the 2d array index to bind to frame buffer to
  32877. */
  32878. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  32879. /** @hidden */
  32880. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  32881. /**
  32882. * Unbind the current render target texture from the webGL context
  32883. * @param texture defines the render target texture to unbind
  32884. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  32885. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  32886. */
  32887. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  32888. /**
  32889. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  32890. */
  32891. flushFramebuffer(): void;
  32892. /**
  32893. * Unbind the current render target and bind the default framebuffer
  32894. */
  32895. restoreDefaultFramebuffer(): void;
  32896. /** @hidden */
  32897. protected _resetVertexBufferBinding(): void;
  32898. /**
  32899. * Creates a vertex buffer
  32900. * @param data the data for the vertex buffer
  32901. * @returns the new WebGL static buffer
  32902. */
  32903. createVertexBuffer(data: DataArray): DataBuffer;
  32904. private _createVertexBuffer;
  32905. /**
  32906. * Creates a dynamic vertex buffer
  32907. * @param data the data for the dynamic vertex buffer
  32908. * @returns the new WebGL dynamic buffer
  32909. */
  32910. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  32911. protected _resetIndexBufferBinding(): void;
  32912. /**
  32913. * Creates a new index buffer
  32914. * @param indices defines the content of the index buffer
  32915. * @param updatable defines if the index buffer must be updatable
  32916. * @returns a new webGL buffer
  32917. */
  32918. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  32919. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  32920. /**
  32921. * Bind a webGL buffer to the webGL context
  32922. * @param buffer defines the buffer to bind
  32923. */
  32924. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  32925. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  32926. private bindBuffer;
  32927. /**
  32928. * update the bound buffer with the given data
  32929. * @param data defines the data to update
  32930. */
  32931. updateArrayBuffer(data: Float32Array): void;
  32932. private _vertexAttribPointer;
  32933. /** @hidden */
  32934. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  32935. private _bindVertexBuffersAttributes;
  32936. /**
  32937. * Records a vertex array object
  32938. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  32939. * @param vertexBuffers defines the list of vertex buffers to store
  32940. * @param indexBuffer defines the index buffer to store
  32941. * @param effect defines the effect to store
  32942. * @returns the new vertex array object
  32943. */
  32944. recordVertexArrayObject(vertexBuffers: {
  32945. [key: string]: VertexBuffer;
  32946. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  32947. /**
  32948. * Bind a specific vertex array object
  32949. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  32950. * @param vertexArrayObject defines the vertex array object to bind
  32951. * @param indexBuffer defines the index buffer to bind
  32952. */
  32953. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  32954. /**
  32955. * Bind webGl buffers directly to the webGL context
  32956. * @param vertexBuffer defines the vertex buffer to bind
  32957. * @param indexBuffer defines the index buffer to bind
  32958. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  32959. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  32960. * @param effect defines the effect associated with the vertex buffer
  32961. */
  32962. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  32963. private _unbindVertexArrayObject;
  32964. /**
  32965. * Bind a list of vertex buffers to the webGL context
  32966. * @param vertexBuffers defines the list of vertex buffers to bind
  32967. * @param indexBuffer defines the index buffer to bind
  32968. * @param effect defines the effect associated with the vertex buffers
  32969. */
  32970. bindBuffers(vertexBuffers: {
  32971. [key: string]: Nullable<VertexBuffer>;
  32972. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  32973. /**
  32974. * Unbind all instance attributes
  32975. */
  32976. unbindInstanceAttributes(): void;
  32977. /**
  32978. * Release and free the memory of a vertex array object
  32979. * @param vao defines the vertex array object to delete
  32980. */
  32981. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  32982. /** @hidden */
  32983. _releaseBuffer(buffer: DataBuffer): boolean;
  32984. protected _deleteBuffer(buffer: DataBuffer): void;
  32985. /**
  32986. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  32987. * @param instancesBuffer defines the webGL buffer to update and bind
  32988. * @param data defines the data to store in the buffer
  32989. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  32990. */
  32991. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  32992. /**
  32993. * Bind the content of a webGL buffer used with instantiation
  32994. * @param instancesBuffer defines the webGL buffer to bind
  32995. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  32996. * @param computeStride defines Whether to compute the strides from the info or use the default 0
  32997. */
  32998. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  32999. /**
  33000. * Disable the instance attribute corresponding to the name in parameter
  33001. * @param name defines the name of the attribute to disable
  33002. */
  33003. disableInstanceAttributeByName(name: string): void;
  33004. /**
  33005. * Disable the instance attribute corresponding to the location in parameter
  33006. * @param attributeLocation defines the attribute location of the attribute to disable
  33007. */
  33008. disableInstanceAttribute(attributeLocation: number): void;
  33009. /**
  33010. * Disable the attribute corresponding to the location in parameter
  33011. * @param attributeLocation defines the attribute location of the attribute to disable
  33012. */
  33013. disableAttributeByIndex(attributeLocation: number): void;
  33014. /**
  33015. * Send a draw order
  33016. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  33017. * @param indexStart defines the starting index
  33018. * @param indexCount defines the number of index to draw
  33019. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  33020. */
  33021. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  33022. /**
  33023. * Draw a list of points
  33024. * @param verticesStart defines the index of first vertex to draw
  33025. * @param verticesCount defines the count of vertices to draw
  33026. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  33027. */
  33028. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  33029. /**
  33030. * Draw a list of unindexed primitives
  33031. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  33032. * @param verticesStart defines the index of first vertex to draw
  33033. * @param verticesCount defines the count of vertices to draw
  33034. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  33035. */
  33036. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  33037. /**
  33038. * Draw a list of indexed primitives
  33039. * @param fillMode defines the primitive to use
  33040. * @param indexStart defines the starting index
  33041. * @param indexCount defines the number of index to draw
  33042. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  33043. */
  33044. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  33045. /**
  33046. * Draw a list of unindexed primitives
  33047. * @param fillMode defines the primitive to use
  33048. * @param verticesStart defines the index of first vertex to draw
  33049. * @param verticesCount defines the count of vertices to draw
  33050. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  33051. */
  33052. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  33053. private _drawMode;
  33054. /** @hidden */
  33055. protected _reportDrawCall(): void;
  33056. /** @hidden */
  33057. _releaseEffect(effect: Effect): void;
  33058. /** @hidden */
  33059. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  33060. /**
  33061. * Create a new effect (used to store vertex/fragment shaders)
  33062. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  33063. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  33064. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  33065. * @param samplers defines an array of string used to represent textures
  33066. * @param defines defines the string containing the defines to use to compile the shaders
  33067. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  33068. * @param onCompiled defines a function to call when the effect creation is successful
  33069. * @param onError defines a function to call when the effect creation has failed
  33070. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  33071. * @returns the new Effect
  33072. */
  33073. 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;
  33074. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  33075. private _compileShader;
  33076. private _compileRawShader;
  33077. /** @hidden */
  33078. _getShaderSource(shader: WebGLShader): Nullable<string>;
  33079. /**
  33080. * Directly creates a webGL program
  33081. * @param pipelineContext defines the pipeline context to attach to
  33082. * @param vertexCode defines the vertex shader code to use
  33083. * @param fragmentCode defines the fragment shader code to use
  33084. * @param context defines the webGL context to use (if not set, the current one will be used)
  33085. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  33086. * @returns the new webGL program
  33087. */
  33088. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  33089. /**
  33090. * Creates a webGL program
  33091. * @param pipelineContext defines the pipeline context to attach to
  33092. * @param vertexCode defines the vertex shader code to use
  33093. * @param fragmentCode defines the fragment shader code to use
  33094. * @param defines defines the string containing the defines to use to compile the shaders
  33095. * @param context defines the webGL context to use (if not set, the current one will be used)
  33096. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  33097. * @returns the new webGL program
  33098. */
  33099. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  33100. /**
  33101. * Creates a new pipeline context
  33102. * @returns the new pipeline
  33103. */
  33104. createPipelineContext(): IPipelineContext;
  33105. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  33106. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  33107. /** @hidden */
  33108. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  33109. /** @hidden */
  33110. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  33111. /** @hidden */
  33112. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  33113. /**
  33114. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  33115. * @param pipelineContext defines the pipeline context to use
  33116. * @param uniformsNames defines the list of uniform names
  33117. * @returns an array of webGL uniform locations
  33118. */
  33119. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  33120. /**
  33121. * Gets the lsit of active attributes for a given webGL program
  33122. * @param pipelineContext defines the pipeline context to use
  33123. * @param attributesNames defines the list of attribute names to get
  33124. * @returns an array of indices indicating the offset of each attribute
  33125. */
  33126. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  33127. /**
  33128. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  33129. * @param effect defines the effect to activate
  33130. */
  33131. enableEffect(effect: Nullable<Effect>): void;
  33132. /**
  33133. * Set the value of an uniform to a number (int)
  33134. * @param uniform defines the webGL uniform location where to store the value
  33135. * @param value defines the int number to store
  33136. */
  33137. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  33138. /**
  33139. * Set the value of an uniform to an array of int32
  33140. * @param uniform defines the webGL uniform location where to store the value
  33141. * @param array defines the array of int32 to store
  33142. */
  33143. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  33144. /**
  33145. * Set the value of an uniform to an array of int32 (stored as vec2)
  33146. * @param uniform defines the webGL uniform location where to store the value
  33147. * @param array defines the array of int32 to store
  33148. */
  33149. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  33150. /**
  33151. * Set the value of an uniform to an array of int32 (stored as vec3)
  33152. * @param uniform defines the webGL uniform location where to store the value
  33153. * @param array defines the array of int32 to store
  33154. */
  33155. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  33156. /**
  33157. * Set the value of an uniform to an array of int32 (stored as vec4)
  33158. * @param uniform defines the webGL uniform location where to store the value
  33159. * @param array defines the array of int32 to store
  33160. */
  33161. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  33162. /**
  33163. * Set the value of an uniform to an array of number
  33164. * @param uniform defines the webGL uniform location where to store the value
  33165. * @param array defines the array of number to store
  33166. */
  33167. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  33168. /**
  33169. * Set the value of an uniform to an array of number (stored as vec2)
  33170. * @param uniform defines the webGL uniform location where to store the value
  33171. * @param array defines the array of number to store
  33172. */
  33173. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  33174. /**
  33175. * Set the value of an uniform to an array of number (stored as vec3)
  33176. * @param uniform defines the webGL uniform location where to store the value
  33177. * @param array defines the array of number to store
  33178. */
  33179. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  33180. /**
  33181. * Set the value of an uniform to an array of number (stored as vec4)
  33182. * @param uniform defines the webGL uniform location where to store the value
  33183. * @param array defines the array of number to store
  33184. */
  33185. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  33186. /**
  33187. * Set the value of an uniform to an array of float32 (stored as matrices)
  33188. * @param uniform defines the webGL uniform location where to store the value
  33189. * @param matrices defines the array of float32 to store
  33190. */
  33191. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  33192. /**
  33193. * Set the value of an uniform to a matrix (3x3)
  33194. * @param uniform defines the webGL uniform location where to store the value
  33195. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  33196. */
  33197. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  33198. /**
  33199. * Set the value of an uniform to a matrix (2x2)
  33200. * @param uniform defines the webGL uniform location where to store the value
  33201. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  33202. */
  33203. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  33204. /**
  33205. * Set the value of an uniform to a number (float)
  33206. * @param uniform defines the webGL uniform location where to store the value
  33207. * @param value defines the float number to store
  33208. */
  33209. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  33210. /**
  33211. * Set the value of an uniform to a vec2
  33212. * @param uniform defines the webGL uniform location where to store the value
  33213. * @param x defines the 1st component of the value
  33214. * @param y defines the 2nd component of the value
  33215. */
  33216. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  33217. /**
  33218. * Set the value of an uniform to a vec3
  33219. * @param uniform defines the webGL uniform location where to store the value
  33220. * @param x defines the 1st component of the value
  33221. * @param y defines the 2nd component of the value
  33222. * @param z defines the 3rd component of the value
  33223. */
  33224. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  33225. /**
  33226. * Set the value of an uniform to a vec4
  33227. * @param uniform defines the webGL uniform location where to store the value
  33228. * @param x defines the 1st component of the value
  33229. * @param y defines the 2nd component of the value
  33230. * @param z defines the 3rd component of the value
  33231. * @param w defines the 4th component of the value
  33232. */
  33233. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  33234. /**
  33235. * Apply all cached states (depth, culling, stencil and alpha)
  33236. */
  33237. applyStates(): void;
  33238. /**
  33239. * Enable or disable color writing
  33240. * @param enable defines the state to set
  33241. */
  33242. setColorWrite(enable: boolean): void;
  33243. /**
  33244. * Gets a boolean indicating if color writing is enabled
  33245. * @returns the current color writing state
  33246. */
  33247. getColorWrite(): boolean;
  33248. /**
  33249. * Gets the depth culling state manager
  33250. */
  33251. get depthCullingState(): DepthCullingState;
  33252. /**
  33253. * Gets the alpha state manager
  33254. */
  33255. get alphaState(): AlphaState;
  33256. /**
  33257. * Gets the stencil state manager
  33258. */
  33259. get stencilState(): StencilState;
  33260. /**
  33261. * Clears the list of texture accessible through engine.
  33262. * This can help preventing texture load conflict due to name collision.
  33263. */
  33264. clearInternalTexturesCache(): void;
  33265. /**
  33266. * Force the entire cache to be cleared
  33267. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  33268. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  33269. */
  33270. wipeCaches(bruteForce?: boolean): void;
  33271. /** @hidden */
  33272. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  33273. min: number;
  33274. mag: number;
  33275. };
  33276. /** @hidden */
  33277. _createTexture(): WebGLTexture;
  33278. /**
  33279. * Usually called from Texture.ts.
  33280. * Passed information to create a WebGLTexture
  33281. * @param url defines a value which contains one of the following:
  33282. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  33283. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  33284. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  33285. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  33286. * @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)
  33287. * @param scene needed for loading to the correct scene
  33288. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  33289. * @param onLoad optional callback to be called upon successful completion
  33290. * @param onError optional callback to be called upon failure
  33291. * @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
  33292. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  33293. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  33294. * @param forcedExtension defines the extension to use to pick the right loader
  33295. * @param mimeType defines an optional mime type
  33296. * @returns a InternalTexture for assignment back into BABYLON.Texture
  33297. */
  33298. 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;
  33299. /**
  33300. * Loads an image as an HTMLImageElement.
  33301. * @param input url string, ArrayBuffer, or Blob to load
  33302. * @param onLoad callback called when the image successfully loads
  33303. * @param onError callback called when the image fails to load
  33304. * @param offlineProvider offline provider for caching
  33305. * @param mimeType optional mime type
  33306. * @returns the HTMLImageElement of the loaded image
  33307. * @hidden
  33308. */
  33309. 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>;
  33310. /**
  33311. * @hidden
  33312. */
  33313. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  33314. private _unpackFlipYCached;
  33315. /**
  33316. * In case you are sharing the context with other applications, it might
  33317. * be interested to not cache the unpack flip y state to ensure a consistent
  33318. * value would be set.
  33319. */
  33320. enableUnpackFlipYCached: boolean;
  33321. /** @hidden */
  33322. _unpackFlipY(value: boolean): void;
  33323. /** @hidden */
  33324. _getUnpackAlignement(): number;
  33325. private _getTextureTarget;
  33326. /**
  33327. * Update the sampling mode of a given texture
  33328. * @param samplingMode defines the required sampling mode
  33329. * @param texture defines the texture to update
  33330. * @param generateMipMaps defines whether to generate mipmaps for the texture
  33331. */
  33332. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  33333. /**
  33334. * Update the sampling mode of a given texture
  33335. * @param texture defines the texture to update
  33336. * @param wrapU defines the texture wrap mode of the u coordinates
  33337. * @param wrapV defines the texture wrap mode of the v coordinates
  33338. * @param wrapR defines the texture wrap mode of the r coordinates
  33339. */
  33340. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  33341. /** @hidden */
  33342. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  33343. width: number;
  33344. height: number;
  33345. layers?: number;
  33346. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  33347. /** @hidden */
  33348. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  33349. /** @hidden */
  33350. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  33351. /**
  33352. * Update a portion of an internal texture
  33353. * @param texture defines the texture to update
  33354. * @param imageData defines the data to store into the texture
  33355. * @param xOffset defines the x coordinates of the update rectangle
  33356. * @param yOffset defines the y coordinates of the update rectangle
  33357. * @param width defines the width of the update rectangle
  33358. * @param height defines the height of the update rectangle
  33359. * @param faceIndex defines the face index if texture is a cube (0 by default)
  33360. * @param lod defines the lod level to update (0 by default)
  33361. */
  33362. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  33363. /** @hidden */
  33364. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  33365. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  33366. private _prepareWebGLTexture;
  33367. /** @hidden */
  33368. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  33369. private _getDepthStencilBuffer;
  33370. /** @hidden */
  33371. _releaseFramebufferObjects(texture: InternalTexture): void;
  33372. /** @hidden */
  33373. _releaseTexture(texture: InternalTexture): void;
  33374. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  33375. protected _setProgram(program: WebGLProgram): void;
  33376. protected _boundUniforms: {
  33377. [key: number]: WebGLUniformLocation;
  33378. };
  33379. /**
  33380. * Binds an effect to the webGL context
  33381. * @param effect defines the effect to bind
  33382. */
  33383. bindSamplers(effect: Effect): void;
  33384. private _activateCurrentTexture;
  33385. /** @hidden */
  33386. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  33387. /** @hidden */
  33388. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  33389. /**
  33390. * Unbind all textures from the webGL context
  33391. */
  33392. unbindAllTextures(): void;
  33393. /**
  33394. * Sets a texture to the according uniform.
  33395. * @param channel The texture channel
  33396. * @param uniform The uniform to set
  33397. * @param texture The texture to apply
  33398. */
  33399. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  33400. private _bindSamplerUniformToChannel;
  33401. private _getTextureWrapMode;
  33402. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  33403. /**
  33404. * Sets an array of texture to the webGL context
  33405. * @param channel defines the channel where the texture array must be set
  33406. * @param uniform defines the associated uniform location
  33407. * @param textures defines the array of textures to bind
  33408. */
  33409. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  33410. /** @hidden */
  33411. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  33412. private _setTextureParameterFloat;
  33413. private _setTextureParameterInteger;
  33414. /**
  33415. * Unbind all vertex attributes from the webGL context
  33416. */
  33417. unbindAllAttributes(): void;
  33418. /**
  33419. * 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
  33420. */
  33421. releaseEffects(): void;
  33422. /**
  33423. * Dispose and release all associated resources
  33424. */
  33425. dispose(): void;
  33426. /**
  33427. * Attach a new callback raised when context lost event is fired
  33428. * @param callback defines the callback to call
  33429. */
  33430. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  33431. /**
  33432. * Attach a new callback raised when context restored event is fired
  33433. * @param callback defines the callback to call
  33434. */
  33435. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  33436. /**
  33437. * Get the current error code of the webGL context
  33438. * @returns the error code
  33439. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  33440. */
  33441. getError(): number;
  33442. private _canRenderToFloatFramebuffer;
  33443. private _canRenderToHalfFloatFramebuffer;
  33444. private _canRenderToFramebuffer;
  33445. /** @hidden */
  33446. _getWebGLTextureType(type: number): number;
  33447. /** @hidden */
  33448. _getInternalFormat(format: number): number;
  33449. /** @hidden */
  33450. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  33451. /** @hidden */
  33452. _getRGBAMultiSampleBufferFormat(type: number): number;
  33453. /** @hidden */
  33454. _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;
  33455. /**
  33456. * Loads a file from a url
  33457. * @param url url to load
  33458. * @param onSuccess callback called when the file successfully loads
  33459. * @param onProgress callback called while file is loading (if the server supports this mode)
  33460. * @param offlineProvider defines the offline provider for caching
  33461. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  33462. * @param onError callback called when the file fails to load
  33463. * @returns a file request object
  33464. * @hidden
  33465. */
  33466. 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;
  33467. /**
  33468. * Reads pixels from the current frame buffer. Please note that this function can be slow
  33469. * @param x defines the x coordinate of the rectangle where pixels must be read
  33470. * @param y defines the y coordinate of the rectangle where pixels must be read
  33471. * @param width defines the width of the rectangle where pixels must be read
  33472. * @param height defines the height of the rectangle where pixels must be read
  33473. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  33474. * @returns a Uint8Array containing RGBA colors
  33475. */
  33476. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  33477. private static _isSupported;
  33478. /**
  33479. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  33480. * @returns true if the engine can be created
  33481. * @ignorenaming
  33482. */
  33483. static isSupported(): boolean;
  33484. /**
  33485. * Find the next highest power of two.
  33486. * @param x Number to start search from.
  33487. * @return Next highest power of two.
  33488. */
  33489. static CeilingPOT(x: number): number;
  33490. /**
  33491. * Find the next lowest power of two.
  33492. * @param x Number to start search from.
  33493. * @return Next lowest power of two.
  33494. */
  33495. static FloorPOT(x: number): number;
  33496. /**
  33497. * Find the nearest power of two.
  33498. * @param x Number to start search from.
  33499. * @return Next nearest power of two.
  33500. */
  33501. static NearestPOT(x: number): number;
  33502. /**
  33503. * Get the closest exponent of two
  33504. * @param value defines the value to approximate
  33505. * @param max defines the maximum value to return
  33506. * @param mode defines how to define the closest value
  33507. * @returns closest exponent of two of the given value
  33508. */
  33509. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  33510. /**
  33511. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  33512. * @param func - the function to be called
  33513. * @param requester - the object that will request the next frame. Falls back to window.
  33514. * @returns frame number
  33515. */
  33516. static QueueNewFrame(func: () => void, requester?: any): number;
  33517. /**
  33518. * Gets host document
  33519. * @returns the host document object
  33520. */
  33521. getHostDocument(): Nullable<Document>;
  33522. }
  33523. }
  33524. declare module "babylonjs/Maths/sphericalPolynomial" {
  33525. import { Vector3 } from "babylonjs/Maths/math.vector";
  33526. import { Color3 } from "babylonjs/Maths/math.color";
  33527. /**
  33528. * Class representing spherical harmonics coefficients to the 3rd degree
  33529. */
  33530. export class SphericalHarmonics {
  33531. /**
  33532. * Defines whether or not the harmonics have been prescaled for rendering.
  33533. */
  33534. preScaled: boolean;
  33535. /**
  33536. * The l0,0 coefficients of the spherical harmonics
  33537. */
  33538. l00: Vector3;
  33539. /**
  33540. * The l1,-1 coefficients of the spherical harmonics
  33541. */
  33542. l1_1: Vector3;
  33543. /**
  33544. * The l1,0 coefficients of the spherical harmonics
  33545. */
  33546. l10: Vector3;
  33547. /**
  33548. * The l1,1 coefficients of the spherical harmonics
  33549. */
  33550. l11: Vector3;
  33551. /**
  33552. * The l2,-2 coefficients of the spherical harmonics
  33553. */
  33554. l2_2: Vector3;
  33555. /**
  33556. * The l2,-1 coefficients of the spherical harmonics
  33557. */
  33558. l2_1: Vector3;
  33559. /**
  33560. * The l2,0 coefficients of the spherical harmonics
  33561. */
  33562. l20: Vector3;
  33563. /**
  33564. * The l2,1 coefficients of the spherical harmonics
  33565. */
  33566. l21: Vector3;
  33567. /**
  33568. * The l2,2 coefficients of the spherical harmonics
  33569. */
  33570. l22: Vector3;
  33571. /**
  33572. * Adds a light to the spherical harmonics
  33573. * @param direction the direction of the light
  33574. * @param color the color of the light
  33575. * @param deltaSolidAngle the delta solid angle of the light
  33576. */
  33577. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  33578. /**
  33579. * Scales the spherical harmonics by the given amount
  33580. * @param scale the amount to scale
  33581. */
  33582. scaleInPlace(scale: number): void;
  33583. /**
  33584. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  33585. *
  33586. * ```
  33587. * E_lm = A_l * L_lm
  33588. * ```
  33589. *
  33590. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  33591. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  33592. * the scaling factors are given in equation 9.
  33593. */
  33594. convertIncidentRadianceToIrradiance(): void;
  33595. /**
  33596. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  33597. *
  33598. * ```
  33599. * L = (1/pi) * E * rho
  33600. * ```
  33601. *
  33602. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  33603. */
  33604. convertIrradianceToLambertianRadiance(): void;
  33605. /**
  33606. * Integrates the reconstruction coefficients directly in to the SH preventing further
  33607. * required operations at run time.
  33608. *
  33609. * This is simply done by scaling back the SH with Ylm constants parameter.
  33610. * The trigonometric part being applied by the shader at run time.
  33611. */
  33612. preScaleForRendering(): void;
  33613. /**
  33614. * Constructs a spherical harmonics from an array.
  33615. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  33616. * @returns the spherical harmonics
  33617. */
  33618. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  33619. /**
  33620. * Gets the spherical harmonics from polynomial
  33621. * @param polynomial the spherical polynomial
  33622. * @returns the spherical harmonics
  33623. */
  33624. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  33625. }
  33626. /**
  33627. * Class representing spherical polynomial coefficients to the 3rd degree
  33628. */
  33629. export class SphericalPolynomial {
  33630. private _harmonics;
  33631. /**
  33632. * The spherical harmonics used to create the polynomials.
  33633. */
  33634. get preScaledHarmonics(): SphericalHarmonics;
  33635. /**
  33636. * The x coefficients of the spherical polynomial
  33637. */
  33638. x: Vector3;
  33639. /**
  33640. * The y coefficients of the spherical polynomial
  33641. */
  33642. y: Vector3;
  33643. /**
  33644. * The z coefficients of the spherical polynomial
  33645. */
  33646. z: Vector3;
  33647. /**
  33648. * The xx coefficients of the spherical polynomial
  33649. */
  33650. xx: Vector3;
  33651. /**
  33652. * The yy coefficients of the spherical polynomial
  33653. */
  33654. yy: Vector3;
  33655. /**
  33656. * The zz coefficients of the spherical polynomial
  33657. */
  33658. zz: Vector3;
  33659. /**
  33660. * The xy coefficients of the spherical polynomial
  33661. */
  33662. xy: Vector3;
  33663. /**
  33664. * The yz coefficients of the spherical polynomial
  33665. */
  33666. yz: Vector3;
  33667. /**
  33668. * The zx coefficients of the spherical polynomial
  33669. */
  33670. zx: Vector3;
  33671. /**
  33672. * Adds an ambient color to the spherical polynomial
  33673. * @param color the color to add
  33674. */
  33675. addAmbient(color: Color3): void;
  33676. /**
  33677. * Scales the spherical polynomial by the given amount
  33678. * @param scale the amount to scale
  33679. */
  33680. scaleInPlace(scale: number): void;
  33681. /**
  33682. * Gets the spherical polynomial from harmonics
  33683. * @param harmonics the spherical harmonics
  33684. * @returns the spherical polynomial
  33685. */
  33686. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  33687. /**
  33688. * Constructs a spherical polynomial from an array.
  33689. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  33690. * @returns the spherical polynomial
  33691. */
  33692. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  33693. }
  33694. }
  33695. declare module "babylonjs/Materials/Textures/internalTexture" {
  33696. import { Observable } from "babylonjs/Misc/observable";
  33697. import { Nullable, int } from "babylonjs/types";
  33698. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  33699. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  33700. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  33701. /**
  33702. * Defines the source of the internal texture
  33703. */
  33704. export enum InternalTextureSource {
  33705. /**
  33706. * The source of the texture data is unknown
  33707. */
  33708. Unknown = 0,
  33709. /**
  33710. * Texture data comes from an URL
  33711. */
  33712. Url = 1,
  33713. /**
  33714. * Texture data is only used for temporary storage
  33715. */
  33716. Temp = 2,
  33717. /**
  33718. * Texture data comes from raw data (ArrayBuffer)
  33719. */
  33720. Raw = 3,
  33721. /**
  33722. * Texture content is dynamic (video or dynamic texture)
  33723. */
  33724. Dynamic = 4,
  33725. /**
  33726. * Texture content is generated by rendering to it
  33727. */
  33728. RenderTarget = 5,
  33729. /**
  33730. * Texture content is part of a multi render target process
  33731. */
  33732. MultiRenderTarget = 6,
  33733. /**
  33734. * Texture data comes from a cube data file
  33735. */
  33736. Cube = 7,
  33737. /**
  33738. * Texture data comes from a raw cube data
  33739. */
  33740. CubeRaw = 8,
  33741. /**
  33742. * Texture data come from a prefiltered cube data file
  33743. */
  33744. CubePrefiltered = 9,
  33745. /**
  33746. * Texture content is raw 3D data
  33747. */
  33748. Raw3D = 10,
  33749. /**
  33750. * Texture content is raw 2D array data
  33751. */
  33752. Raw2DArray = 11,
  33753. /**
  33754. * Texture content is a depth texture
  33755. */
  33756. Depth = 12,
  33757. /**
  33758. * Texture data comes from a raw cube data encoded with RGBD
  33759. */
  33760. CubeRawRGBD = 13
  33761. }
  33762. /**
  33763. * Class used to store data associated with WebGL texture data for the engine
  33764. * This class should not be used directly
  33765. */
  33766. export class InternalTexture {
  33767. /** @hidden */
  33768. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<import("babylonjs/Maths/sphericalPolynomial").SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  33769. /**
  33770. * Defines if the texture is ready
  33771. */
  33772. isReady: boolean;
  33773. /**
  33774. * Defines if the texture is a cube texture
  33775. */
  33776. isCube: boolean;
  33777. /**
  33778. * Defines if the texture contains 3D data
  33779. */
  33780. is3D: boolean;
  33781. /**
  33782. * Defines if the texture contains 2D array data
  33783. */
  33784. is2DArray: boolean;
  33785. /**
  33786. * Defines if the texture contains multiview data
  33787. */
  33788. isMultiview: boolean;
  33789. /**
  33790. * Gets the URL used to load this texture
  33791. */
  33792. url: string;
  33793. /**
  33794. * Gets the sampling mode of the texture
  33795. */
  33796. samplingMode: number;
  33797. /**
  33798. * Gets a boolean indicating if the texture needs mipmaps generation
  33799. */
  33800. generateMipMaps: boolean;
  33801. /**
  33802. * Gets the number of samples used by the texture (WebGL2+ only)
  33803. */
  33804. samples: number;
  33805. /**
  33806. * Gets the type of the texture (int, float...)
  33807. */
  33808. type: number;
  33809. /**
  33810. * Gets the format of the texture (RGB, RGBA...)
  33811. */
  33812. format: number;
  33813. /**
  33814. * Observable called when the texture is loaded
  33815. */
  33816. onLoadedObservable: Observable<InternalTexture>;
  33817. /**
  33818. * Gets the width of the texture
  33819. */
  33820. width: number;
  33821. /**
  33822. * Gets the height of the texture
  33823. */
  33824. height: number;
  33825. /**
  33826. * Gets the depth of the texture
  33827. */
  33828. depth: number;
  33829. /**
  33830. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  33831. */
  33832. baseWidth: number;
  33833. /**
  33834. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  33835. */
  33836. baseHeight: number;
  33837. /**
  33838. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  33839. */
  33840. baseDepth: number;
  33841. /**
  33842. * Gets a boolean indicating if the texture is inverted on Y axis
  33843. */
  33844. invertY: boolean;
  33845. /** @hidden */
  33846. _invertVScale: boolean;
  33847. /** @hidden */
  33848. _associatedChannel: number;
  33849. /** @hidden */
  33850. _source: InternalTextureSource;
  33851. /** @hidden */
  33852. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  33853. /** @hidden */
  33854. _bufferView: Nullable<ArrayBufferView>;
  33855. /** @hidden */
  33856. _bufferViewArray: Nullable<ArrayBufferView[]>;
  33857. /** @hidden */
  33858. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  33859. /** @hidden */
  33860. _size: number;
  33861. /** @hidden */
  33862. _extension: string;
  33863. /** @hidden */
  33864. _files: Nullable<string[]>;
  33865. /** @hidden */
  33866. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  33867. /** @hidden */
  33868. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  33869. /** @hidden */
  33870. _framebuffer: Nullable<WebGLFramebuffer>;
  33871. /** @hidden */
  33872. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  33873. /** @hidden */
  33874. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  33875. /** @hidden */
  33876. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  33877. /** @hidden */
  33878. _attachments: Nullable<number[]>;
  33879. /** @hidden */
  33880. _cachedCoordinatesMode: Nullable<number>;
  33881. /** @hidden */
  33882. _cachedWrapU: Nullable<number>;
  33883. /** @hidden */
  33884. _cachedWrapV: Nullable<number>;
  33885. /** @hidden */
  33886. _cachedWrapR: Nullable<number>;
  33887. /** @hidden */
  33888. _cachedAnisotropicFilteringLevel: Nullable<number>;
  33889. /** @hidden */
  33890. _isDisabled: boolean;
  33891. /** @hidden */
  33892. _compression: Nullable<string>;
  33893. /** @hidden */
  33894. _generateStencilBuffer: boolean;
  33895. /** @hidden */
  33896. _generateDepthBuffer: boolean;
  33897. /** @hidden */
  33898. _comparisonFunction: number;
  33899. /** @hidden */
  33900. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  33901. /** @hidden */
  33902. _lodGenerationScale: number;
  33903. /** @hidden */
  33904. _lodGenerationOffset: number;
  33905. /** @hidden */
  33906. _depthStencilTexture: Nullable<InternalTexture>;
  33907. /** @hidden */
  33908. _colorTextureArray: Nullable<WebGLTexture>;
  33909. /** @hidden */
  33910. _depthStencilTextureArray: Nullable<WebGLTexture>;
  33911. /** @hidden */
  33912. _lodTextureHigh: Nullable<BaseTexture>;
  33913. /** @hidden */
  33914. _lodTextureMid: Nullable<BaseTexture>;
  33915. /** @hidden */
  33916. _lodTextureLow: Nullable<BaseTexture>;
  33917. /** @hidden */
  33918. _isRGBD: boolean;
  33919. /** @hidden */
  33920. _linearSpecularLOD: boolean;
  33921. /** @hidden */
  33922. _irradianceTexture: Nullable<BaseTexture>;
  33923. /** @hidden */
  33924. _webGLTexture: Nullable<WebGLTexture>;
  33925. /** @hidden */
  33926. _references: number;
  33927. private _engine;
  33928. /**
  33929. * Gets the Engine the texture belongs to.
  33930. * @returns The babylon engine
  33931. */
  33932. getEngine(): ThinEngine;
  33933. /**
  33934. * Gets the data source type of the texture
  33935. */
  33936. get source(): InternalTextureSource;
  33937. /**
  33938. * Creates a new InternalTexture
  33939. * @param engine defines the engine to use
  33940. * @param source defines the type of data that will be used
  33941. * @param delayAllocation if the texture allocation should be delayed (default: false)
  33942. */
  33943. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  33944. /**
  33945. * Increments the number of references (ie. the number of Texture that point to it)
  33946. */
  33947. incrementReferences(): void;
  33948. /**
  33949. * Change the size of the texture (not the size of the content)
  33950. * @param width defines the new width
  33951. * @param height defines the new height
  33952. * @param depth defines the new depth (1 by default)
  33953. */
  33954. updateSize(width: int, height: int, depth?: int): void;
  33955. /** @hidden */
  33956. _rebuild(): void;
  33957. /** @hidden */
  33958. _swapAndDie(target: InternalTexture): void;
  33959. /**
  33960. * Dispose the current allocated resources
  33961. */
  33962. dispose(): void;
  33963. }
  33964. }
  33965. declare module "babylonjs/Audio/analyser" {
  33966. import { Scene } from "babylonjs/scene";
  33967. /**
  33968. * Class used to work with sound analyzer using fast fourier transform (FFT)
  33969. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  33970. */
  33971. export class Analyser {
  33972. /**
  33973. * Gets or sets the smoothing
  33974. * @ignorenaming
  33975. */
  33976. SMOOTHING: number;
  33977. /**
  33978. * Gets or sets the FFT table size
  33979. * @ignorenaming
  33980. */
  33981. FFT_SIZE: number;
  33982. /**
  33983. * Gets or sets the bar graph amplitude
  33984. * @ignorenaming
  33985. */
  33986. BARGRAPHAMPLITUDE: number;
  33987. /**
  33988. * Gets or sets the position of the debug canvas
  33989. * @ignorenaming
  33990. */
  33991. DEBUGCANVASPOS: {
  33992. x: number;
  33993. y: number;
  33994. };
  33995. /**
  33996. * Gets or sets the debug canvas size
  33997. * @ignorenaming
  33998. */
  33999. DEBUGCANVASSIZE: {
  34000. width: number;
  34001. height: number;
  34002. };
  34003. private _byteFreqs;
  34004. private _byteTime;
  34005. private _floatFreqs;
  34006. private _webAudioAnalyser;
  34007. private _debugCanvas;
  34008. private _debugCanvasContext;
  34009. private _scene;
  34010. private _registerFunc;
  34011. private _audioEngine;
  34012. /**
  34013. * Creates a new analyser
  34014. * @param scene defines hosting scene
  34015. */
  34016. constructor(scene: Scene);
  34017. /**
  34018. * Get the number of data values you will have to play with for the visualization
  34019. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  34020. * @returns a number
  34021. */
  34022. getFrequencyBinCount(): number;
  34023. /**
  34024. * Gets the current frequency data as a byte array
  34025. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  34026. * @returns a Uint8Array
  34027. */
  34028. getByteFrequencyData(): Uint8Array;
  34029. /**
  34030. * Gets the current waveform as a byte array
  34031. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  34032. * @returns a Uint8Array
  34033. */
  34034. getByteTimeDomainData(): Uint8Array;
  34035. /**
  34036. * Gets the current frequency data as a float array
  34037. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  34038. * @returns a Float32Array
  34039. */
  34040. getFloatFrequencyData(): Float32Array;
  34041. /**
  34042. * Renders the debug canvas
  34043. */
  34044. drawDebugCanvas(): void;
  34045. /**
  34046. * Stops rendering the debug canvas and removes it
  34047. */
  34048. stopDebugCanvas(): void;
  34049. /**
  34050. * Connects two audio nodes
  34051. * @param inputAudioNode defines first node to connect
  34052. * @param outputAudioNode defines second node to connect
  34053. */
  34054. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  34055. /**
  34056. * Releases all associated resources
  34057. */
  34058. dispose(): void;
  34059. }
  34060. }
  34061. declare module "babylonjs/Audio/audioEngine" {
  34062. import { IDisposable } from "babylonjs/scene";
  34063. import { Analyser } from "babylonjs/Audio/analyser";
  34064. import { Nullable } from "babylonjs/types";
  34065. import { Observable } from "babylonjs/Misc/observable";
  34066. /**
  34067. * This represents an audio engine and it is responsible
  34068. * to play, synchronize and analyse sounds throughout the application.
  34069. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34070. */
  34071. export interface IAudioEngine extends IDisposable {
  34072. /**
  34073. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  34074. */
  34075. readonly canUseWebAudio: boolean;
  34076. /**
  34077. * Gets the current AudioContext if available.
  34078. */
  34079. readonly audioContext: Nullable<AudioContext>;
  34080. /**
  34081. * The master gain node defines the global audio volume of your audio engine.
  34082. */
  34083. readonly masterGain: GainNode;
  34084. /**
  34085. * Gets whether or not mp3 are supported by your browser.
  34086. */
  34087. readonly isMP3supported: boolean;
  34088. /**
  34089. * Gets whether or not ogg are supported by your browser.
  34090. */
  34091. readonly isOGGsupported: boolean;
  34092. /**
  34093. * Defines if Babylon should emit a warning if WebAudio is not supported.
  34094. * @ignoreNaming
  34095. */
  34096. WarnedWebAudioUnsupported: boolean;
  34097. /**
  34098. * Defines if the audio engine relies on a custom unlocked button.
  34099. * In this case, the embedded button will not be displayed.
  34100. */
  34101. useCustomUnlockedButton: boolean;
  34102. /**
  34103. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  34104. */
  34105. readonly unlocked: boolean;
  34106. /**
  34107. * Event raised when audio has been unlocked on the browser.
  34108. */
  34109. onAudioUnlockedObservable: Observable<AudioEngine>;
  34110. /**
  34111. * Event raised when audio has been locked on the browser.
  34112. */
  34113. onAudioLockedObservable: Observable<AudioEngine>;
  34114. /**
  34115. * Flags the audio engine in Locked state.
  34116. * This happens due to new browser policies preventing audio to autoplay.
  34117. */
  34118. lock(): void;
  34119. /**
  34120. * Unlocks the audio engine once a user action has been done on the dom.
  34121. * This is helpful to resume play once browser policies have been satisfied.
  34122. */
  34123. unlock(): void;
  34124. /**
  34125. * Gets the global volume sets on the master gain.
  34126. * @returns the global volume if set or -1 otherwise
  34127. */
  34128. getGlobalVolume(): number;
  34129. /**
  34130. * Sets the global volume of your experience (sets on the master gain).
  34131. * @param newVolume Defines the new global volume of the application
  34132. */
  34133. setGlobalVolume(newVolume: number): void;
  34134. /**
  34135. * Connect the audio engine to an audio analyser allowing some amazing
  34136. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  34137. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  34138. * @param analyser The analyser to connect to the engine
  34139. */
  34140. connectToAnalyser(analyser: Analyser): void;
  34141. }
  34142. /**
  34143. * This represents the default audio engine used in babylon.
  34144. * It is responsible to play, synchronize and analyse sounds throughout the application.
  34145. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34146. */
  34147. export class AudioEngine implements IAudioEngine {
  34148. private _audioContext;
  34149. private _audioContextInitialized;
  34150. private _muteButton;
  34151. private _hostElement;
  34152. /**
  34153. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  34154. */
  34155. canUseWebAudio: boolean;
  34156. /**
  34157. * The master gain node defines the global audio volume of your audio engine.
  34158. */
  34159. masterGain: GainNode;
  34160. /**
  34161. * Defines if Babylon should emit a warning if WebAudio is not supported.
  34162. * @ignoreNaming
  34163. */
  34164. WarnedWebAudioUnsupported: boolean;
  34165. /**
  34166. * Gets whether or not mp3 are supported by your browser.
  34167. */
  34168. isMP3supported: boolean;
  34169. /**
  34170. * Gets whether or not ogg are supported by your browser.
  34171. */
  34172. isOGGsupported: boolean;
  34173. /**
  34174. * Gets whether audio has been unlocked on the device.
  34175. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  34176. * a user interaction has happened.
  34177. */
  34178. unlocked: boolean;
  34179. /**
  34180. * Defines if the audio engine relies on a custom unlocked button.
  34181. * In this case, the embedded button will not be displayed.
  34182. */
  34183. useCustomUnlockedButton: boolean;
  34184. /**
  34185. * Event raised when audio has been unlocked on the browser.
  34186. */
  34187. onAudioUnlockedObservable: Observable<AudioEngine>;
  34188. /**
  34189. * Event raised when audio has been locked on the browser.
  34190. */
  34191. onAudioLockedObservable: Observable<AudioEngine>;
  34192. /**
  34193. * Gets the current AudioContext if available.
  34194. */
  34195. get audioContext(): Nullable<AudioContext>;
  34196. private _connectedAnalyser;
  34197. /**
  34198. * Instantiates a new audio engine.
  34199. *
  34200. * There should be only one per page as some browsers restrict the number
  34201. * of audio contexts you can create.
  34202. * @param hostElement defines the host element where to display the mute icon if necessary
  34203. */
  34204. constructor(hostElement?: Nullable<HTMLElement>);
  34205. /**
  34206. * Flags the audio engine in Locked state.
  34207. * This happens due to new browser policies preventing audio to autoplay.
  34208. */
  34209. lock(): void;
  34210. /**
  34211. * Unlocks the audio engine once a user action has been done on the dom.
  34212. * This is helpful to resume play once browser policies have been satisfied.
  34213. */
  34214. unlock(): void;
  34215. private _resumeAudioContext;
  34216. private _initializeAudioContext;
  34217. private _tryToRun;
  34218. private _triggerRunningState;
  34219. private _triggerSuspendedState;
  34220. private _displayMuteButton;
  34221. private _moveButtonToTopLeft;
  34222. private _onResize;
  34223. private _hideMuteButton;
  34224. /**
  34225. * Destroy and release the resources associated with the audio ccontext.
  34226. */
  34227. dispose(): void;
  34228. /**
  34229. * Gets the global volume sets on the master gain.
  34230. * @returns the global volume if set or -1 otherwise
  34231. */
  34232. getGlobalVolume(): number;
  34233. /**
  34234. * Sets the global volume of your experience (sets on the master gain).
  34235. * @param newVolume Defines the new global volume of the application
  34236. */
  34237. setGlobalVolume(newVolume: number): void;
  34238. /**
  34239. * Connect the audio engine to an audio analyser allowing some amazing
  34240. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  34241. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  34242. * @param analyser The analyser to connect to the engine
  34243. */
  34244. connectToAnalyser(analyser: Analyser): void;
  34245. }
  34246. }
  34247. declare module "babylonjs/Loading/loadingScreen" {
  34248. /**
  34249. * Interface used to present a loading screen while loading a scene
  34250. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34251. */
  34252. export interface ILoadingScreen {
  34253. /**
  34254. * Function called to display the loading screen
  34255. */
  34256. displayLoadingUI: () => void;
  34257. /**
  34258. * Function called to hide the loading screen
  34259. */
  34260. hideLoadingUI: () => void;
  34261. /**
  34262. * Gets or sets the color to use for the background
  34263. */
  34264. loadingUIBackgroundColor: string;
  34265. /**
  34266. * Gets or sets the text to display while loading
  34267. */
  34268. loadingUIText: string;
  34269. }
  34270. /**
  34271. * Class used for the default loading screen
  34272. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34273. */
  34274. export class DefaultLoadingScreen implements ILoadingScreen {
  34275. private _renderingCanvas;
  34276. private _loadingText;
  34277. private _loadingDivBackgroundColor;
  34278. private _loadingDiv;
  34279. private _loadingTextDiv;
  34280. /** Gets or sets the logo url to use for the default loading screen */
  34281. static DefaultLogoUrl: string;
  34282. /** Gets or sets the spinner url to use for the default loading screen */
  34283. static DefaultSpinnerUrl: string;
  34284. /**
  34285. * Creates a new default loading screen
  34286. * @param _renderingCanvas defines the canvas used to render the scene
  34287. * @param _loadingText defines the default text to display
  34288. * @param _loadingDivBackgroundColor defines the default background color
  34289. */
  34290. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  34291. /**
  34292. * Function called to display the loading screen
  34293. */
  34294. displayLoadingUI(): void;
  34295. /**
  34296. * Function called to hide the loading screen
  34297. */
  34298. hideLoadingUI(): void;
  34299. /**
  34300. * Gets or sets the text to display while loading
  34301. */
  34302. set loadingUIText(text: string);
  34303. get loadingUIText(): string;
  34304. /**
  34305. * Gets or sets the color to use for the background
  34306. */
  34307. get loadingUIBackgroundColor(): string;
  34308. set loadingUIBackgroundColor(color: string);
  34309. private _resizeLoadingUI;
  34310. }
  34311. }
  34312. declare module "babylonjs/Misc/customAnimationFrameRequester" {
  34313. /**
  34314. * Interface for any object that can request an animation frame
  34315. */
  34316. export interface ICustomAnimationFrameRequester {
  34317. /**
  34318. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  34319. */
  34320. renderFunction?: Function;
  34321. /**
  34322. * Called to request the next frame to render to
  34323. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  34324. */
  34325. requestAnimationFrame: Function;
  34326. /**
  34327. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  34328. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  34329. */
  34330. requestID?: number;
  34331. }
  34332. }
  34333. declare module "babylonjs/Misc/performanceMonitor" {
  34334. /**
  34335. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  34336. */
  34337. export class PerformanceMonitor {
  34338. private _enabled;
  34339. private _rollingFrameTime;
  34340. private _lastFrameTimeMs;
  34341. /**
  34342. * constructor
  34343. * @param frameSampleSize The number of samples required to saturate the sliding window
  34344. */
  34345. constructor(frameSampleSize?: number);
  34346. /**
  34347. * Samples current frame
  34348. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  34349. */
  34350. sampleFrame(timeMs?: number): void;
  34351. /**
  34352. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  34353. */
  34354. get averageFrameTime(): number;
  34355. /**
  34356. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  34357. */
  34358. get averageFrameTimeVariance(): number;
  34359. /**
  34360. * Returns the frame time of the most recent frame
  34361. */
  34362. get instantaneousFrameTime(): number;
  34363. /**
  34364. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  34365. */
  34366. get averageFPS(): number;
  34367. /**
  34368. * Returns the average framerate in frames per second using the most recent frame time
  34369. */
  34370. get instantaneousFPS(): number;
  34371. /**
  34372. * Returns true if enough samples have been taken to completely fill the sliding window
  34373. */
  34374. get isSaturated(): boolean;
  34375. /**
  34376. * Enables contributions to the sliding window sample set
  34377. */
  34378. enable(): void;
  34379. /**
  34380. * Disables contributions to the sliding window sample set
  34381. * Samples will not be interpolated over the disabled period
  34382. */
  34383. disable(): void;
  34384. /**
  34385. * Returns true if sampling is enabled
  34386. */
  34387. get isEnabled(): boolean;
  34388. /**
  34389. * Resets performance monitor
  34390. */
  34391. reset(): void;
  34392. }
  34393. /**
  34394. * RollingAverage
  34395. *
  34396. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  34397. */
  34398. export class RollingAverage {
  34399. /**
  34400. * Current average
  34401. */
  34402. average: number;
  34403. /**
  34404. * Current variance
  34405. */
  34406. variance: number;
  34407. protected _samples: Array<number>;
  34408. protected _sampleCount: number;
  34409. protected _pos: number;
  34410. protected _m2: number;
  34411. /**
  34412. * constructor
  34413. * @param length The number of samples required to saturate the sliding window
  34414. */
  34415. constructor(length: number);
  34416. /**
  34417. * Adds a sample to the sample set
  34418. * @param v The sample value
  34419. */
  34420. add(v: number): void;
  34421. /**
  34422. * Returns previously added values or null if outside of history or outside the sliding window domain
  34423. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  34424. * @return Value previously recorded with add() or null if outside of range
  34425. */
  34426. history(i: number): number;
  34427. /**
  34428. * Returns true if enough samples have been taken to completely fill the sliding window
  34429. * @return true if sample-set saturated
  34430. */
  34431. isSaturated(): boolean;
  34432. /**
  34433. * Resets the rolling average (equivalent to 0 samples taken so far)
  34434. */
  34435. reset(): void;
  34436. /**
  34437. * Wraps a value around the sample range boundaries
  34438. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  34439. * @return Wrapped position in sample range
  34440. */
  34441. protected _wrapPosition(i: number): number;
  34442. }
  34443. }
  34444. declare module "babylonjs/Misc/perfCounter" {
  34445. /**
  34446. * This class is used to track a performance counter which is number based.
  34447. * The user has access to many properties which give statistics of different nature.
  34448. *
  34449. * The implementer can track two kinds of Performance Counter: time and count.
  34450. * 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.
  34451. * 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.
  34452. */
  34453. export class PerfCounter {
  34454. /**
  34455. * Gets or sets a global boolean to turn on and off all the counters
  34456. */
  34457. static Enabled: boolean;
  34458. /**
  34459. * Returns the smallest value ever
  34460. */
  34461. get min(): number;
  34462. /**
  34463. * Returns the biggest value ever
  34464. */
  34465. get max(): number;
  34466. /**
  34467. * Returns the average value since the performance counter is running
  34468. */
  34469. get average(): number;
  34470. /**
  34471. * Returns the average value of the last second the counter was monitored
  34472. */
  34473. get lastSecAverage(): number;
  34474. /**
  34475. * Returns the current value
  34476. */
  34477. get current(): number;
  34478. /**
  34479. * Gets the accumulated total
  34480. */
  34481. get total(): number;
  34482. /**
  34483. * Gets the total value count
  34484. */
  34485. get count(): number;
  34486. /**
  34487. * Creates a new counter
  34488. */
  34489. constructor();
  34490. /**
  34491. * Call this method to start monitoring a new frame.
  34492. * 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.
  34493. */
  34494. fetchNewFrame(): void;
  34495. /**
  34496. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  34497. * @param newCount the count value to add to the monitored count
  34498. * @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.
  34499. */
  34500. addCount(newCount: number, fetchResult: boolean): void;
  34501. /**
  34502. * Start monitoring this performance counter
  34503. */
  34504. beginMonitoring(): void;
  34505. /**
  34506. * Compute the time lapsed since the previous beginMonitoring() call.
  34507. * @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
  34508. */
  34509. endMonitoring(newFrame?: boolean): void;
  34510. private _fetchResult;
  34511. private _startMonitoringTime;
  34512. private _min;
  34513. private _max;
  34514. private _average;
  34515. private _current;
  34516. private _totalValueCount;
  34517. private _totalAccumulated;
  34518. private _lastSecAverage;
  34519. private _lastSecAccumulated;
  34520. private _lastSecTime;
  34521. private _lastSecValueCount;
  34522. }
  34523. }
  34524. declare module "babylonjs/Engines/Extensions/engine.alpha" {
  34525. module "babylonjs/Engines/thinEngine" {
  34526. interface ThinEngine {
  34527. /**
  34528. * Sets alpha constants used by some alpha blending modes
  34529. * @param r defines the red component
  34530. * @param g defines the green component
  34531. * @param b defines the blue component
  34532. * @param a defines the alpha component
  34533. */
  34534. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  34535. /**
  34536. * Sets the current alpha mode
  34537. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  34538. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  34539. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  34540. */
  34541. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  34542. /**
  34543. * Gets the current alpha mode
  34544. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  34545. * @returns the current alpha mode
  34546. */
  34547. getAlphaMode(): number;
  34548. /**
  34549. * Sets the current alpha equation
  34550. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  34551. */
  34552. setAlphaEquation(equation: number): void;
  34553. /**
  34554. * Gets the current alpha equation.
  34555. * @returns the current alpha equation
  34556. */
  34557. getAlphaEquation(): number;
  34558. }
  34559. }
  34560. }
  34561. declare module "babylonjs/Engines/engine" {
  34562. import { Observable } from "babylonjs/Misc/observable";
  34563. import { Nullable, IndicesArray, DataArray } from "babylonjs/types";
  34564. import { Scene } from "babylonjs/scene";
  34565. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  34566. import { IAudioEngine } from "babylonjs/Audio/audioEngine";
  34567. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  34568. import { ILoadingScreen } from "babylonjs/Loading/loadingScreen";
  34569. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  34570. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  34571. import { ICustomAnimationFrameRequester } from "babylonjs/Misc/customAnimationFrameRequester";
  34572. import { ThinEngine, EngineOptions } from "babylonjs/Engines/thinEngine";
  34573. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  34574. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  34575. import { PerformanceMonitor } from "babylonjs/Misc/performanceMonitor";
  34576. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  34577. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  34578. import "babylonjs/Engines/Extensions/engine.alpha";
  34579. import { Material } from "babylonjs/Materials/material";
  34580. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  34581. /**
  34582. * Defines the interface used by display changed events
  34583. */
  34584. export interface IDisplayChangedEventArgs {
  34585. /** Gets the vrDisplay object (if any) */
  34586. vrDisplay: Nullable<any>;
  34587. /** Gets a boolean indicating if webVR is supported */
  34588. vrSupported: boolean;
  34589. }
  34590. /**
  34591. * Defines the interface used by objects containing a viewport (like a camera)
  34592. */
  34593. interface IViewportOwnerLike {
  34594. /**
  34595. * Gets or sets the viewport
  34596. */
  34597. viewport: IViewportLike;
  34598. }
  34599. /**
  34600. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  34601. */
  34602. export class Engine extends ThinEngine {
  34603. /** Defines that alpha blending is disabled */
  34604. static readonly ALPHA_DISABLE: number;
  34605. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  34606. static readonly ALPHA_ADD: number;
  34607. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  34608. static readonly ALPHA_COMBINE: number;
  34609. /** Defines that alpha blending to DEST - SRC * DEST */
  34610. static readonly ALPHA_SUBTRACT: number;
  34611. /** Defines that alpha blending to SRC * DEST */
  34612. static readonly ALPHA_MULTIPLY: number;
  34613. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  34614. static readonly ALPHA_MAXIMIZED: number;
  34615. /** Defines that alpha blending to SRC + DEST */
  34616. static readonly ALPHA_ONEONE: number;
  34617. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  34618. static readonly ALPHA_PREMULTIPLIED: number;
  34619. /**
  34620. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  34621. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  34622. */
  34623. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  34624. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  34625. static readonly ALPHA_INTERPOLATE: number;
  34626. /**
  34627. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  34628. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  34629. */
  34630. static readonly ALPHA_SCREENMODE: number;
  34631. /** Defines that the ressource is not delayed*/
  34632. static readonly DELAYLOADSTATE_NONE: number;
  34633. /** Defines that the ressource was successfully delay loaded */
  34634. static readonly DELAYLOADSTATE_LOADED: number;
  34635. /** Defines that the ressource is currently delay loading */
  34636. static readonly DELAYLOADSTATE_LOADING: number;
  34637. /** Defines that the ressource is delayed and has not started loading */
  34638. static readonly DELAYLOADSTATE_NOTLOADED: number;
  34639. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  34640. static readonly NEVER: number;
  34641. /** 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 */
  34642. static readonly ALWAYS: number;
  34643. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  34644. static readonly LESS: number;
  34645. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  34646. static readonly EQUAL: number;
  34647. /** 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 */
  34648. static readonly LEQUAL: number;
  34649. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  34650. static readonly GREATER: number;
  34651. /** 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 */
  34652. static readonly GEQUAL: number;
  34653. /** 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 */
  34654. static readonly NOTEQUAL: number;
  34655. /** Passed to stencilOperation to specify that stencil value must be kept */
  34656. static readonly KEEP: number;
  34657. /** Passed to stencilOperation to specify that stencil value must be replaced */
  34658. static readonly REPLACE: number;
  34659. /** Passed to stencilOperation to specify that stencil value must be incremented */
  34660. static readonly INCR: number;
  34661. /** Passed to stencilOperation to specify that stencil value must be decremented */
  34662. static readonly DECR: number;
  34663. /** Passed to stencilOperation to specify that stencil value must be inverted */
  34664. static readonly INVERT: number;
  34665. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  34666. static readonly INCR_WRAP: number;
  34667. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  34668. static readonly DECR_WRAP: number;
  34669. /** Texture is not repeating outside of 0..1 UVs */
  34670. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  34671. /** Texture is repeating outside of 0..1 UVs */
  34672. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  34673. /** Texture is repeating and mirrored */
  34674. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  34675. /** ALPHA */
  34676. static readonly TEXTUREFORMAT_ALPHA: number;
  34677. /** LUMINANCE */
  34678. static readonly TEXTUREFORMAT_LUMINANCE: number;
  34679. /** LUMINANCE_ALPHA */
  34680. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  34681. /** RGB */
  34682. static readonly TEXTUREFORMAT_RGB: number;
  34683. /** RGBA */
  34684. static readonly TEXTUREFORMAT_RGBA: number;
  34685. /** RED */
  34686. static readonly TEXTUREFORMAT_RED: number;
  34687. /** RED (2nd reference) */
  34688. static readonly TEXTUREFORMAT_R: number;
  34689. /** RG */
  34690. static readonly TEXTUREFORMAT_RG: number;
  34691. /** RED_INTEGER */
  34692. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  34693. /** RED_INTEGER (2nd reference) */
  34694. static readonly TEXTUREFORMAT_R_INTEGER: number;
  34695. /** RG_INTEGER */
  34696. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  34697. /** RGB_INTEGER */
  34698. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  34699. /** RGBA_INTEGER */
  34700. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  34701. /** UNSIGNED_BYTE */
  34702. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  34703. /** UNSIGNED_BYTE (2nd reference) */
  34704. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  34705. /** FLOAT */
  34706. static readonly TEXTURETYPE_FLOAT: number;
  34707. /** HALF_FLOAT */
  34708. static readonly TEXTURETYPE_HALF_FLOAT: number;
  34709. /** BYTE */
  34710. static readonly TEXTURETYPE_BYTE: number;
  34711. /** SHORT */
  34712. static readonly TEXTURETYPE_SHORT: number;
  34713. /** UNSIGNED_SHORT */
  34714. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  34715. /** INT */
  34716. static readonly TEXTURETYPE_INT: number;
  34717. /** UNSIGNED_INT */
  34718. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  34719. /** UNSIGNED_SHORT_4_4_4_4 */
  34720. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  34721. /** UNSIGNED_SHORT_5_5_5_1 */
  34722. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  34723. /** UNSIGNED_SHORT_5_6_5 */
  34724. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  34725. /** UNSIGNED_INT_2_10_10_10_REV */
  34726. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  34727. /** UNSIGNED_INT_24_8 */
  34728. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  34729. /** UNSIGNED_INT_10F_11F_11F_REV */
  34730. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  34731. /** UNSIGNED_INT_5_9_9_9_REV */
  34732. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  34733. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  34734. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  34735. /** nearest is mag = nearest and min = nearest and mip = linear */
  34736. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  34737. /** Bilinear is mag = linear and min = linear and mip = nearest */
  34738. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  34739. /** Trilinear is mag = linear and min = linear and mip = linear */
  34740. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  34741. /** nearest is mag = nearest and min = nearest and mip = linear */
  34742. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  34743. /** Bilinear is mag = linear and min = linear and mip = nearest */
  34744. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  34745. /** Trilinear is mag = linear and min = linear and mip = linear */
  34746. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  34747. /** mag = nearest and min = nearest and mip = nearest */
  34748. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  34749. /** mag = nearest and min = linear and mip = nearest */
  34750. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  34751. /** mag = nearest and min = linear and mip = linear */
  34752. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  34753. /** mag = nearest and min = linear and mip = none */
  34754. static readonly TEXTURE_NEAREST_LINEAR: number;
  34755. /** mag = nearest and min = nearest and mip = none */
  34756. static readonly TEXTURE_NEAREST_NEAREST: number;
  34757. /** mag = linear and min = nearest and mip = nearest */
  34758. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  34759. /** mag = linear and min = nearest and mip = linear */
  34760. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  34761. /** mag = linear and min = linear and mip = none */
  34762. static readonly TEXTURE_LINEAR_LINEAR: number;
  34763. /** mag = linear and min = nearest and mip = none */
  34764. static readonly TEXTURE_LINEAR_NEAREST: number;
  34765. /** Explicit coordinates mode */
  34766. static readonly TEXTURE_EXPLICIT_MODE: number;
  34767. /** Spherical coordinates mode */
  34768. static readonly TEXTURE_SPHERICAL_MODE: number;
  34769. /** Planar coordinates mode */
  34770. static readonly TEXTURE_PLANAR_MODE: number;
  34771. /** Cubic coordinates mode */
  34772. static readonly TEXTURE_CUBIC_MODE: number;
  34773. /** Projection coordinates mode */
  34774. static readonly TEXTURE_PROJECTION_MODE: number;
  34775. /** Skybox coordinates mode */
  34776. static readonly TEXTURE_SKYBOX_MODE: number;
  34777. /** Inverse Cubic coordinates mode */
  34778. static readonly TEXTURE_INVCUBIC_MODE: number;
  34779. /** Equirectangular coordinates mode */
  34780. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  34781. /** Equirectangular Fixed coordinates mode */
  34782. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  34783. /** Equirectangular Fixed Mirrored coordinates mode */
  34784. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  34785. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  34786. static readonly SCALEMODE_FLOOR: number;
  34787. /** Defines that texture rescaling will look for the nearest power of 2 size */
  34788. static readonly SCALEMODE_NEAREST: number;
  34789. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  34790. static readonly SCALEMODE_CEILING: number;
  34791. /**
  34792. * Returns the current npm package of the sdk
  34793. */
  34794. static get NpmPackage(): string;
  34795. /**
  34796. * Returns the current version of the framework
  34797. */
  34798. static get Version(): string;
  34799. /** Gets the list of created engines */
  34800. static get Instances(): Engine[];
  34801. /**
  34802. * Gets the latest created engine
  34803. */
  34804. static get LastCreatedEngine(): Nullable<Engine>;
  34805. /**
  34806. * Gets the latest created scene
  34807. */
  34808. static get LastCreatedScene(): Nullable<Scene>;
  34809. /**
  34810. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  34811. * @param flag defines which part of the materials must be marked as dirty
  34812. * @param predicate defines a predicate used to filter which materials should be affected
  34813. */
  34814. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  34815. /**
  34816. * Method called to create the default loading screen.
  34817. * This can be overriden in your own app.
  34818. * @param canvas The rendering canvas element
  34819. * @returns The loading screen
  34820. */
  34821. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  34822. /**
  34823. * Method called to create the default rescale post process on each engine.
  34824. */
  34825. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  34826. /**
  34827. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  34828. **/
  34829. enableOfflineSupport: boolean;
  34830. /**
  34831. * 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)
  34832. **/
  34833. disableManifestCheck: boolean;
  34834. /**
  34835. * Gets the list of created scenes
  34836. */
  34837. scenes: Scene[];
  34838. /**
  34839. * Event raised when a new scene is created
  34840. */
  34841. onNewSceneAddedObservable: Observable<Scene>;
  34842. /**
  34843. * Gets the list of created postprocesses
  34844. */
  34845. postProcesses: import("babylonjs/PostProcesses/postProcess").PostProcess[];
  34846. /**
  34847. * Gets a boolean indicating if the pointer is currently locked
  34848. */
  34849. isPointerLock: boolean;
  34850. /**
  34851. * Observable event triggered each time the rendering canvas is resized
  34852. */
  34853. onResizeObservable: Observable<Engine>;
  34854. /**
  34855. * Observable event triggered each time the canvas loses focus
  34856. */
  34857. onCanvasBlurObservable: Observable<Engine>;
  34858. /**
  34859. * Observable event triggered each time the canvas gains focus
  34860. */
  34861. onCanvasFocusObservable: Observable<Engine>;
  34862. /**
  34863. * Observable event triggered each time the canvas receives pointerout event
  34864. */
  34865. onCanvasPointerOutObservable: Observable<PointerEvent>;
  34866. /**
  34867. * Observable raised when the engine begins a new frame
  34868. */
  34869. onBeginFrameObservable: Observable<Engine>;
  34870. /**
  34871. * If set, will be used to request the next animation frame for the render loop
  34872. */
  34873. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  34874. /**
  34875. * Observable raised when the engine ends the current frame
  34876. */
  34877. onEndFrameObservable: Observable<Engine>;
  34878. /**
  34879. * Observable raised when the engine is about to compile a shader
  34880. */
  34881. onBeforeShaderCompilationObservable: Observable<Engine>;
  34882. /**
  34883. * Observable raised when the engine has jsut compiled a shader
  34884. */
  34885. onAfterShaderCompilationObservable: Observable<Engine>;
  34886. /**
  34887. * Gets the audio engine
  34888. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34889. * @ignorenaming
  34890. */
  34891. static audioEngine: IAudioEngine;
  34892. /**
  34893. * Default AudioEngine factory responsible of creating the Audio Engine.
  34894. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  34895. */
  34896. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  34897. /**
  34898. * Default offline support factory responsible of creating a tool used to store data locally.
  34899. * By default, this will create a Database object if the workload has been embedded.
  34900. */
  34901. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  34902. private _loadingScreen;
  34903. private _pointerLockRequested;
  34904. private _dummyFramebuffer;
  34905. private _rescalePostProcess;
  34906. private _deterministicLockstep;
  34907. private _lockstepMaxSteps;
  34908. private _timeStep;
  34909. protected get _supportsHardwareTextureRescaling(): boolean;
  34910. private _fps;
  34911. private _deltaTime;
  34912. /** @hidden */
  34913. _drawCalls: PerfCounter;
  34914. /** 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 */
  34915. canvasTabIndex: number;
  34916. /**
  34917. * Turn this value on if you want to pause FPS computation when in background
  34918. */
  34919. disablePerformanceMonitorInBackground: boolean;
  34920. private _performanceMonitor;
  34921. /**
  34922. * Gets the performance monitor attached to this engine
  34923. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  34924. */
  34925. get performanceMonitor(): PerformanceMonitor;
  34926. private _onFocus;
  34927. private _onBlur;
  34928. private _onCanvasPointerOut;
  34929. private _onCanvasBlur;
  34930. private _onCanvasFocus;
  34931. private _onFullscreenChange;
  34932. private _onPointerLockChange;
  34933. /**
  34934. * Gets the HTML element used to attach event listeners
  34935. * @returns a HTML element
  34936. */
  34937. getInputElement(): Nullable<HTMLElement>;
  34938. /**
  34939. * Creates a new engine
  34940. * @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
  34941. * @param antialias defines enable antialiasing (default: false)
  34942. * @param options defines further options to be sent to the getContext() function
  34943. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  34944. */
  34945. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  34946. /**
  34947. * Gets current aspect ratio
  34948. * @param viewportOwner defines the camera to use to get the aspect ratio
  34949. * @param useScreen defines if screen size must be used (or the current render target if any)
  34950. * @returns a number defining the aspect ratio
  34951. */
  34952. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  34953. /**
  34954. * Gets current screen aspect ratio
  34955. * @returns a number defining the aspect ratio
  34956. */
  34957. getScreenAspectRatio(): number;
  34958. /**
  34959. * Gets the client rect of the HTML canvas attached with the current webGL context
  34960. * @returns a client rectanglee
  34961. */
  34962. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  34963. /**
  34964. * Gets the client rect of the HTML element used for events
  34965. * @returns a client rectanglee
  34966. */
  34967. getInputElementClientRect(): Nullable<ClientRect>;
  34968. /**
  34969. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  34970. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34971. * @returns true if engine is in deterministic lock step mode
  34972. */
  34973. isDeterministicLockStep(): boolean;
  34974. /**
  34975. * Gets the max steps when engine is running in deterministic lock step
  34976. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34977. * @returns the max steps
  34978. */
  34979. getLockstepMaxSteps(): number;
  34980. /**
  34981. * Returns the time in ms between steps when using deterministic lock step.
  34982. * @returns time step in (ms)
  34983. */
  34984. getTimeStep(): number;
  34985. /**
  34986. * Force the mipmap generation for the given render target texture
  34987. * @param texture defines the render target texture to use
  34988. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  34989. */
  34990. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  34991. /** States */
  34992. /**
  34993. * Set various states to the webGL context
  34994. * @param culling defines backface culling state
  34995. * @param zOffset defines the value to apply to zOffset (0 by default)
  34996. * @param force defines if states must be applied even if cache is up to date
  34997. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  34998. */
  34999. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  35000. /**
  35001. * Set the z offset to apply to current rendering
  35002. * @param value defines the offset to apply
  35003. */
  35004. setZOffset(value: number): void;
  35005. /**
  35006. * Gets the current value of the zOffset
  35007. * @returns the current zOffset state
  35008. */
  35009. getZOffset(): number;
  35010. /**
  35011. * Enable or disable depth buffering
  35012. * @param enable defines the state to set
  35013. */
  35014. setDepthBuffer(enable: boolean): void;
  35015. /**
  35016. * Gets a boolean indicating if depth writing is enabled
  35017. * @returns the current depth writing state
  35018. */
  35019. getDepthWrite(): boolean;
  35020. /**
  35021. * Enable or disable depth writing
  35022. * @param enable defines the state to set
  35023. */
  35024. setDepthWrite(enable: boolean): void;
  35025. /**
  35026. * Gets a boolean indicating if stencil buffer is enabled
  35027. * @returns the current stencil buffer state
  35028. */
  35029. getStencilBuffer(): boolean;
  35030. /**
  35031. * Enable or disable the stencil buffer
  35032. * @param enable defines if the stencil buffer must be enabled or disabled
  35033. */
  35034. setStencilBuffer(enable: boolean): void;
  35035. /**
  35036. * Gets the current stencil mask
  35037. * @returns a number defining the new stencil mask to use
  35038. */
  35039. getStencilMask(): number;
  35040. /**
  35041. * Sets the current stencil mask
  35042. * @param mask defines the new stencil mask to use
  35043. */
  35044. setStencilMask(mask: number): void;
  35045. /**
  35046. * Gets the current stencil function
  35047. * @returns a number defining the stencil function to use
  35048. */
  35049. getStencilFunction(): number;
  35050. /**
  35051. * Gets the current stencil reference value
  35052. * @returns a number defining the stencil reference value to use
  35053. */
  35054. getStencilFunctionReference(): number;
  35055. /**
  35056. * Gets the current stencil mask
  35057. * @returns a number defining the stencil mask to use
  35058. */
  35059. getStencilFunctionMask(): number;
  35060. /**
  35061. * Sets the current stencil function
  35062. * @param stencilFunc defines the new stencil function to use
  35063. */
  35064. setStencilFunction(stencilFunc: number): void;
  35065. /**
  35066. * Sets the current stencil reference
  35067. * @param reference defines the new stencil reference to use
  35068. */
  35069. setStencilFunctionReference(reference: number): void;
  35070. /**
  35071. * Sets the current stencil mask
  35072. * @param mask defines the new stencil mask to use
  35073. */
  35074. setStencilFunctionMask(mask: number): void;
  35075. /**
  35076. * Gets the current stencil operation when stencil fails
  35077. * @returns a number defining stencil operation to use when stencil fails
  35078. */
  35079. getStencilOperationFail(): number;
  35080. /**
  35081. * Gets the current stencil operation when depth fails
  35082. * @returns a number defining stencil operation to use when depth fails
  35083. */
  35084. getStencilOperationDepthFail(): number;
  35085. /**
  35086. * Gets the current stencil operation when stencil passes
  35087. * @returns a number defining stencil operation to use when stencil passes
  35088. */
  35089. getStencilOperationPass(): number;
  35090. /**
  35091. * Sets the stencil operation to use when stencil fails
  35092. * @param operation defines the stencil operation to use when stencil fails
  35093. */
  35094. setStencilOperationFail(operation: number): void;
  35095. /**
  35096. * Sets the stencil operation to use when depth fails
  35097. * @param operation defines the stencil operation to use when depth fails
  35098. */
  35099. setStencilOperationDepthFail(operation: number): void;
  35100. /**
  35101. * Sets the stencil operation to use when stencil passes
  35102. * @param operation defines the stencil operation to use when stencil passes
  35103. */
  35104. setStencilOperationPass(operation: number): void;
  35105. /**
  35106. * Sets a boolean indicating if the dithering state is enabled or disabled
  35107. * @param value defines the dithering state
  35108. */
  35109. setDitheringState(value: boolean): void;
  35110. /**
  35111. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  35112. * @param value defines the rasterizer state
  35113. */
  35114. setRasterizerState(value: boolean): void;
  35115. /**
  35116. * Gets the current depth function
  35117. * @returns a number defining the depth function
  35118. */
  35119. getDepthFunction(): Nullable<number>;
  35120. /**
  35121. * Sets the current depth function
  35122. * @param depthFunc defines the function to use
  35123. */
  35124. setDepthFunction(depthFunc: number): void;
  35125. /**
  35126. * Sets the current depth function to GREATER
  35127. */
  35128. setDepthFunctionToGreater(): void;
  35129. /**
  35130. * Sets the current depth function to GEQUAL
  35131. */
  35132. setDepthFunctionToGreaterOrEqual(): void;
  35133. /**
  35134. * Sets the current depth function to LESS
  35135. */
  35136. setDepthFunctionToLess(): void;
  35137. /**
  35138. * Sets the current depth function to LEQUAL
  35139. */
  35140. setDepthFunctionToLessOrEqual(): void;
  35141. private _cachedStencilBuffer;
  35142. private _cachedStencilFunction;
  35143. private _cachedStencilMask;
  35144. private _cachedStencilOperationPass;
  35145. private _cachedStencilOperationFail;
  35146. private _cachedStencilOperationDepthFail;
  35147. private _cachedStencilReference;
  35148. /**
  35149. * Caches the the state of the stencil buffer
  35150. */
  35151. cacheStencilState(): void;
  35152. /**
  35153. * Restores the state of the stencil buffer
  35154. */
  35155. restoreStencilState(): void;
  35156. /**
  35157. * Directly set the WebGL Viewport
  35158. * @param x defines the x coordinate of the viewport (in screen space)
  35159. * @param y defines the y coordinate of the viewport (in screen space)
  35160. * @param width defines the width of the viewport (in screen space)
  35161. * @param height defines the height of the viewport (in screen space)
  35162. * @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
  35163. */
  35164. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  35165. /**
  35166. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  35167. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  35168. * @param y defines the y-coordinate of the corner of the clear rectangle
  35169. * @param width defines the width of the clear rectangle
  35170. * @param height defines the height of the clear rectangle
  35171. * @param clearColor defines the clear color
  35172. */
  35173. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  35174. /**
  35175. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  35176. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  35177. * @param y defines the y-coordinate of the corner of the clear rectangle
  35178. * @param width defines the width of the clear rectangle
  35179. * @param height defines the height of the clear rectangle
  35180. */
  35181. enableScissor(x: number, y: number, width: number, height: number): void;
  35182. /**
  35183. * Disable previously set scissor test rectangle
  35184. */
  35185. disableScissor(): void;
  35186. protected _reportDrawCall(): void;
  35187. /**
  35188. * Initializes a webVR display and starts listening to display change events
  35189. * The onVRDisplayChangedObservable will be notified upon these changes
  35190. * @returns The onVRDisplayChangedObservable
  35191. */
  35192. initWebVR(): Observable<IDisplayChangedEventArgs>;
  35193. /** @hidden */
  35194. _prepareVRComponent(): void;
  35195. /** @hidden */
  35196. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  35197. /** @hidden */
  35198. _submitVRFrame(): void;
  35199. /**
  35200. * Call this function to leave webVR mode
  35201. * Will do nothing if webVR is not supported or if there is no webVR device
  35202. * @see http://doc.babylonjs.com/how_to/webvr_camera
  35203. */
  35204. disableVR(): void;
  35205. /**
  35206. * Gets a boolean indicating that the system is in VR mode and is presenting
  35207. * @returns true if VR mode is engaged
  35208. */
  35209. isVRPresenting(): boolean;
  35210. /** @hidden */
  35211. _requestVRFrame(): void;
  35212. /** @hidden */
  35213. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  35214. /**
  35215. * Gets the source code of the vertex shader associated with a specific webGL program
  35216. * @param program defines the program to use
  35217. * @returns a string containing the source code of the vertex shader associated with the program
  35218. */
  35219. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  35220. /**
  35221. * Gets the source code of the fragment shader associated with a specific webGL program
  35222. * @param program defines the program to use
  35223. * @returns a string containing the source code of the fragment shader associated with the program
  35224. */
  35225. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  35226. /**
  35227. * Sets a depth stencil texture from a render target to the according uniform.
  35228. * @param channel The texture channel
  35229. * @param uniform The uniform to set
  35230. * @param texture The render target texture containing the depth stencil texture to apply
  35231. */
  35232. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  35233. /**
  35234. * Sets a texture to the webGL context from a postprocess
  35235. * @param channel defines the channel to use
  35236. * @param postProcess defines the source postprocess
  35237. */
  35238. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  35239. /**
  35240. * Binds the output of the passed in post process to the texture channel specified
  35241. * @param channel The channel the texture should be bound to
  35242. * @param postProcess The post process which's output should be bound
  35243. */
  35244. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  35245. protected _rebuildBuffers(): void;
  35246. /** @hidden */
  35247. _renderFrame(): void;
  35248. _renderLoop(): void;
  35249. /** @hidden */
  35250. _renderViews(): boolean;
  35251. /**
  35252. * Toggle full screen mode
  35253. * @param requestPointerLock defines if a pointer lock should be requested from the user
  35254. */
  35255. switchFullscreen(requestPointerLock: boolean): void;
  35256. /**
  35257. * Enters full screen mode
  35258. * @param requestPointerLock defines if a pointer lock should be requested from the user
  35259. */
  35260. enterFullscreen(requestPointerLock: boolean): void;
  35261. /**
  35262. * Exits full screen mode
  35263. */
  35264. exitFullscreen(): void;
  35265. /**
  35266. * Enters Pointerlock mode
  35267. */
  35268. enterPointerlock(): void;
  35269. /**
  35270. * Exits Pointerlock mode
  35271. */
  35272. exitPointerlock(): void;
  35273. /**
  35274. * Begin a new frame
  35275. */
  35276. beginFrame(): void;
  35277. /**
  35278. * Enf the current frame
  35279. */
  35280. endFrame(): void;
  35281. resize(): void;
  35282. /**
  35283. * Force a specific size of the canvas
  35284. * @param width defines the new canvas' width
  35285. * @param height defines the new canvas' height
  35286. */
  35287. setSize(width: number, height: number): void;
  35288. /**
  35289. * Updates a dynamic vertex buffer.
  35290. * @param vertexBuffer the vertex buffer to update
  35291. * @param data the data used to update the vertex buffer
  35292. * @param byteOffset the byte offset of the data
  35293. * @param byteLength the byte length of the data
  35294. */
  35295. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  35296. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  35297. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  35298. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  35299. _releaseTexture(texture: InternalTexture): void;
  35300. /**
  35301. * @hidden
  35302. * Rescales a texture
  35303. * @param source input texutre
  35304. * @param destination destination texture
  35305. * @param scene scene to use to render the resize
  35306. * @param internalFormat format to use when resizing
  35307. * @param onComplete callback to be called when resize has completed
  35308. */
  35309. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  35310. /**
  35311. * Gets the current framerate
  35312. * @returns a number representing the framerate
  35313. */
  35314. getFps(): number;
  35315. /**
  35316. * Gets the time spent between current and previous frame
  35317. * @returns a number representing the delta time in ms
  35318. */
  35319. getDeltaTime(): number;
  35320. private _measureFps;
  35321. /** @hidden */
  35322. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  35323. /**
  35324. * Update a dynamic index buffer
  35325. * @param indexBuffer defines the target index buffer
  35326. * @param indices defines the data to update
  35327. * @param offset defines the offset in the target index buffer where update should start
  35328. */
  35329. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  35330. /**
  35331. * Updates the sample count of a render target texture
  35332. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  35333. * @param texture defines the texture to update
  35334. * @param samples defines the sample count to set
  35335. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  35336. */
  35337. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  35338. /**
  35339. * Updates a depth texture Comparison Mode and Function.
  35340. * If the comparison Function is equal to 0, the mode will be set to none.
  35341. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  35342. * @param texture The texture to set the comparison function for
  35343. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  35344. */
  35345. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  35346. /**
  35347. * Creates a webGL buffer to use with instanciation
  35348. * @param capacity defines the size of the buffer
  35349. * @returns the webGL buffer
  35350. */
  35351. createInstancesBuffer(capacity: number): DataBuffer;
  35352. /**
  35353. * Delete a webGL buffer used with instanciation
  35354. * @param buffer defines the webGL buffer to delete
  35355. */
  35356. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  35357. private _clientWaitAsync;
  35358. /** @hidden */
  35359. _readPixelsAsync(x: number, y: number, w: number, h: number, format: number, type: number, outputBuffer: ArrayBufferView): Promise<ArrayBufferView> | null;
  35360. /** @hidden */
  35361. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  35362. dispose(): void;
  35363. private _disableTouchAction;
  35364. /**
  35365. * Display the loading screen
  35366. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  35367. */
  35368. displayLoadingUI(): void;
  35369. /**
  35370. * Hide the loading screen
  35371. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  35372. */
  35373. hideLoadingUI(): void;
  35374. /**
  35375. * Gets the current loading screen object
  35376. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  35377. */
  35378. get loadingScreen(): ILoadingScreen;
  35379. /**
  35380. * Sets the current loading screen object
  35381. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  35382. */
  35383. set loadingScreen(loadingScreen: ILoadingScreen);
  35384. /**
  35385. * Sets the current loading screen text
  35386. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  35387. */
  35388. set loadingUIText(text: string);
  35389. /**
  35390. * Sets the current loading screen background color
  35391. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  35392. */
  35393. set loadingUIBackgroundColor(color: string);
  35394. /** Pointerlock and fullscreen */
  35395. /**
  35396. * Ask the browser to promote the current element to pointerlock mode
  35397. * @param element defines the DOM element to promote
  35398. */
  35399. static _RequestPointerlock(element: HTMLElement): void;
  35400. /**
  35401. * Asks the browser to exit pointerlock mode
  35402. */
  35403. static _ExitPointerlock(): void;
  35404. /**
  35405. * Ask the browser to promote the current element to fullscreen rendering mode
  35406. * @param element defines the DOM element to promote
  35407. */
  35408. static _RequestFullscreen(element: HTMLElement): void;
  35409. /**
  35410. * Asks the browser to exit fullscreen mode
  35411. */
  35412. static _ExitFullscreen(): void;
  35413. }
  35414. }
  35415. declare module "babylonjs/Engines/engineStore" {
  35416. import { Nullable } from "babylonjs/types";
  35417. import { Engine } from "babylonjs/Engines/engine";
  35418. import { Scene } from "babylonjs/scene";
  35419. /**
  35420. * The engine store class is responsible to hold all the instances of Engine and Scene created
  35421. * during the life time of the application.
  35422. */
  35423. export class EngineStore {
  35424. /** Gets the list of created engines */
  35425. static Instances: import("babylonjs/Engines/engine").Engine[];
  35426. /** @hidden */
  35427. static _LastCreatedScene: Nullable<Scene>;
  35428. /**
  35429. * Gets the latest created engine
  35430. */
  35431. static get LastCreatedEngine(): Nullable<Engine>;
  35432. /**
  35433. * Gets the latest created scene
  35434. */
  35435. static get LastCreatedScene(): Nullable<Scene>;
  35436. /**
  35437. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  35438. * @ignorenaming
  35439. */
  35440. static UseFallbackTexture: boolean;
  35441. /**
  35442. * Texture content used if a texture cannot loaded
  35443. * @ignorenaming
  35444. */
  35445. static FallbackTexture: string;
  35446. }
  35447. }
  35448. declare module "babylonjs/Misc/promise" {
  35449. /**
  35450. * Helper class that provides a small promise polyfill
  35451. */
  35452. export class PromisePolyfill {
  35453. /**
  35454. * Static function used to check if the polyfill is required
  35455. * If this is the case then the function will inject the polyfill to window.Promise
  35456. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  35457. */
  35458. static Apply(force?: boolean): void;
  35459. }
  35460. }
  35461. declare module "babylonjs/Misc/interfaces/screenshotSize" {
  35462. /**
  35463. * Interface for screenshot methods with describe argument called `size` as object with options
  35464. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  35465. */
  35466. export interface IScreenshotSize {
  35467. /**
  35468. * number in pixels for canvas height
  35469. */
  35470. height?: number;
  35471. /**
  35472. * multiplier allowing render at a higher or lower resolution
  35473. * If value is defined then height and width will be ignored and taken from camera
  35474. */
  35475. precision?: number;
  35476. /**
  35477. * number in pixels for canvas width
  35478. */
  35479. width?: number;
  35480. }
  35481. }
  35482. declare module "babylonjs/Misc/tools" {
  35483. import { Nullable, float } from "babylonjs/types";
  35484. import { DomManagement } from "babylonjs/Misc/domManagement";
  35485. import { WebRequest } from "babylonjs/Misc/webRequest";
  35486. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  35487. import { ReadFileError } from "babylonjs/Misc/fileTools";
  35488. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  35489. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  35490. import { Camera } from "babylonjs/Cameras/camera";
  35491. import { Engine } from "babylonjs/Engines/engine";
  35492. interface IColor4Like {
  35493. r: float;
  35494. g: float;
  35495. b: float;
  35496. a: float;
  35497. }
  35498. /**
  35499. * Class containing a set of static utilities functions
  35500. */
  35501. export class Tools {
  35502. /**
  35503. * Gets or sets the base URL to use to load assets
  35504. */
  35505. static get BaseUrl(): string;
  35506. static set BaseUrl(value: string);
  35507. /**
  35508. * Enable/Disable Custom HTTP Request Headers globally.
  35509. * default = false
  35510. * @see CustomRequestHeaders
  35511. */
  35512. static UseCustomRequestHeaders: boolean;
  35513. /**
  35514. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  35515. * i.e. when loading files, where the server/service expects an Authorization header
  35516. */
  35517. static CustomRequestHeaders: {
  35518. [key: string]: string;
  35519. };
  35520. /**
  35521. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  35522. */
  35523. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  35524. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  35525. /**
  35526. * Default behaviour for cors in the application.
  35527. * It can be a string if the expected behavior is identical in the entire app.
  35528. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  35529. */
  35530. static get CorsBehavior(): string | ((url: string | string[]) => string);
  35531. static set CorsBehavior(value: string | ((url: string | string[]) => string));
  35532. /**
  35533. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  35534. * @ignorenaming
  35535. */
  35536. static get UseFallbackTexture(): boolean;
  35537. static set UseFallbackTexture(value: boolean);
  35538. /**
  35539. * Use this object to register external classes like custom textures or material
  35540. * to allow the laoders to instantiate them
  35541. */
  35542. static get RegisteredExternalClasses(): {
  35543. [key: string]: Object;
  35544. };
  35545. static set RegisteredExternalClasses(classes: {
  35546. [key: string]: Object;
  35547. });
  35548. /**
  35549. * Texture content used if a texture cannot loaded
  35550. * @ignorenaming
  35551. */
  35552. static get fallbackTexture(): string;
  35553. static set fallbackTexture(value: string);
  35554. /**
  35555. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  35556. * @param u defines the coordinate on X axis
  35557. * @param v defines the coordinate on Y axis
  35558. * @param width defines the width of the source data
  35559. * @param height defines the height of the source data
  35560. * @param pixels defines the source byte array
  35561. * @param color defines the output color
  35562. */
  35563. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  35564. /**
  35565. * Interpolates between a and b via alpha
  35566. * @param a The lower value (returned when alpha = 0)
  35567. * @param b The upper value (returned when alpha = 1)
  35568. * @param alpha The interpolation-factor
  35569. * @return The mixed value
  35570. */
  35571. static Mix(a: number, b: number, alpha: number): number;
  35572. /**
  35573. * Tries to instantiate a new object from a given class name
  35574. * @param className defines the class name to instantiate
  35575. * @returns the new object or null if the system was not able to do the instantiation
  35576. */
  35577. static Instantiate(className: string): any;
  35578. /**
  35579. * Provides a slice function that will work even on IE
  35580. * @param data defines the array to slice
  35581. * @param start defines the start of the data (optional)
  35582. * @param end defines the end of the data (optional)
  35583. * @returns the new sliced array
  35584. */
  35585. static Slice<T>(data: T, start?: number, end?: number): T;
  35586. /**
  35587. * Polyfill for setImmediate
  35588. * @param action defines the action to execute after the current execution block
  35589. */
  35590. static SetImmediate(action: () => void): void;
  35591. /**
  35592. * Function indicating if a number is an exponent of 2
  35593. * @param value defines the value to test
  35594. * @returns true if the value is an exponent of 2
  35595. */
  35596. static IsExponentOfTwo(value: number): boolean;
  35597. private static _tmpFloatArray;
  35598. /**
  35599. * Returns the nearest 32-bit single precision float representation of a Number
  35600. * @param value A Number. If the parameter is of a different type, it will get converted
  35601. * to a number or to NaN if it cannot be converted
  35602. * @returns number
  35603. */
  35604. static FloatRound(value: number): number;
  35605. /**
  35606. * Extracts the filename from a path
  35607. * @param path defines the path to use
  35608. * @returns the filename
  35609. */
  35610. static GetFilename(path: string): string;
  35611. /**
  35612. * Extracts the "folder" part of a path (everything before the filename).
  35613. * @param uri The URI to extract the info from
  35614. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  35615. * @returns The "folder" part of the path
  35616. */
  35617. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  35618. /**
  35619. * Extracts text content from a DOM element hierarchy
  35620. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  35621. */
  35622. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  35623. /**
  35624. * Convert an angle in radians to degrees
  35625. * @param angle defines the angle to convert
  35626. * @returns the angle in degrees
  35627. */
  35628. static ToDegrees(angle: number): number;
  35629. /**
  35630. * Convert an angle in degrees to radians
  35631. * @param angle defines the angle to convert
  35632. * @returns the angle in radians
  35633. */
  35634. static ToRadians(angle: number): number;
  35635. /**
  35636. * Returns an array if obj is not an array
  35637. * @param obj defines the object to evaluate as an array
  35638. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  35639. * @returns either obj directly if obj is an array or a new array containing obj
  35640. */
  35641. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  35642. /**
  35643. * Gets the pointer prefix to use
  35644. * @returns "pointer" if touch is enabled. Else returns "mouse"
  35645. */
  35646. static GetPointerPrefix(): string;
  35647. /**
  35648. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  35649. * @param url define the url we are trying
  35650. * @param element define the dom element where to configure the cors policy
  35651. */
  35652. static SetCorsBehavior(url: string | string[], element: {
  35653. crossOrigin: string | null;
  35654. }): void;
  35655. /**
  35656. * Removes unwanted characters from an url
  35657. * @param url defines the url to clean
  35658. * @returns the cleaned url
  35659. */
  35660. static CleanUrl(url: string): string;
  35661. /**
  35662. * Gets or sets a function used to pre-process url before using them to load assets
  35663. */
  35664. static get PreprocessUrl(): (url: string) => string;
  35665. static set PreprocessUrl(processor: (url: string) => string);
  35666. /**
  35667. * Loads an image as an HTMLImageElement.
  35668. * @param input url string, ArrayBuffer, or Blob to load
  35669. * @param onLoad callback called when the image successfully loads
  35670. * @param onError callback called when the image fails to load
  35671. * @param offlineProvider offline provider for caching
  35672. * @param mimeType optional mime type
  35673. * @returns the HTMLImageElement of the loaded image
  35674. */
  35675. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  35676. /**
  35677. * Loads a file from a url
  35678. * @param url url string, ArrayBuffer, or Blob to load
  35679. * @param onSuccess callback called when the file successfully loads
  35680. * @param onProgress callback called while file is loading (if the server supports this mode)
  35681. * @param offlineProvider defines the offline provider for caching
  35682. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  35683. * @param onError callback called when the file fails to load
  35684. * @returns a file request object
  35685. */
  35686. 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;
  35687. /**
  35688. * Loads a file from a url
  35689. * @param url the file url to load
  35690. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  35691. * @returns a promise containing an ArrayBuffer corresponding to the loaded file
  35692. */
  35693. static LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>;
  35694. /**
  35695. * Load a script (identified by an url). When the url returns, the
  35696. * content of this file is added into a new script element, attached to the DOM (body element)
  35697. * @param scriptUrl defines the url of the script to laod
  35698. * @param onSuccess defines the callback called when the script is loaded
  35699. * @param onError defines the callback to call if an error occurs
  35700. * @param scriptId defines the id of the script element
  35701. */
  35702. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  35703. /**
  35704. * Load an asynchronous script (identified by an url). When the url returns, the
  35705. * content of this file is added into a new script element, attached to the DOM (body element)
  35706. * @param scriptUrl defines the url of the script to laod
  35707. * @param scriptId defines the id of the script element
  35708. * @returns a promise request object
  35709. */
  35710. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  35711. /**
  35712. * Loads a file from a blob
  35713. * @param fileToLoad defines the blob to use
  35714. * @param callback defines the callback to call when data is loaded
  35715. * @param progressCallback defines the callback to call during loading process
  35716. * @returns a file request object
  35717. */
  35718. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  35719. /**
  35720. * Reads a file from a File object
  35721. * @param file defines the file to load
  35722. * @param onSuccess defines the callback to call when data is loaded
  35723. * @param onProgress defines the callback to call during loading process
  35724. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  35725. * @param onError defines the callback to call when an error occurs
  35726. * @returns a file request object
  35727. */
  35728. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  35729. /**
  35730. * Creates a data url from a given string content
  35731. * @param content defines the content to convert
  35732. * @returns the new data url link
  35733. */
  35734. static FileAsURL(content: string): string;
  35735. /**
  35736. * Format the given number to a specific decimal format
  35737. * @param value defines the number to format
  35738. * @param decimals defines the number of decimals to use
  35739. * @returns the formatted string
  35740. */
  35741. static Format(value: number, decimals?: number): string;
  35742. /**
  35743. * Tries to copy an object by duplicating every property
  35744. * @param source defines the source object
  35745. * @param destination defines the target object
  35746. * @param doNotCopyList defines a list of properties to avoid
  35747. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  35748. */
  35749. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  35750. /**
  35751. * Gets a boolean indicating if the given object has no own property
  35752. * @param obj defines the object to test
  35753. * @returns true if object has no own property
  35754. */
  35755. static IsEmpty(obj: any): boolean;
  35756. /**
  35757. * Function used to register events at window level
  35758. * @param windowElement defines the Window object to use
  35759. * @param events defines the events to register
  35760. */
  35761. static RegisterTopRootEvents(windowElement: Window, events: {
  35762. name: string;
  35763. handler: Nullable<(e: FocusEvent) => any>;
  35764. }[]): void;
  35765. /**
  35766. * Function used to unregister events from window level
  35767. * @param windowElement defines the Window object to use
  35768. * @param events defines the events to unregister
  35769. */
  35770. static UnregisterTopRootEvents(windowElement: Window, events: {
  35771. name: string;
  35772. handler: Nullable<(e: FocusEvent) => any>;
  35773. }[]): void;
  35774. /**
  35775. * @ignore
  35776. */
  35777. static _ScreenshotCanvas: HTMLCanvasElement;
  35778. /**
  35779. * Dumps the current bound framebuffer
  35780. * @param width defines the rendering width
  35781. * @param height defines the rendering height
  35782. * @param engine defines the hosting engine
  35783. * @param successCallback defines the callback triggered once the data are available
  35784. * @param mimeType defines the mime type of the result
  35785. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  35786. */
  35787. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  35788. /**
  35789. * Converts the canvas data to blob.
  35790. * This acts as a polyfill for browsers not supporting the to blob function.
  35791. * @param canvas Defines the canvas to extract the data from
  35792. * @param successCallback Defines the callback triggered once the data are available
  35793. * @param mimeType Defines the mime type of the result
  35794. */
  35795. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  35796. /**
  35797. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  35798. * @param successCallback defines the callback triggered once the data are available
  35799. * @param mimeType defines the mime type of the result
  35800. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  35801. */
  35802. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  35803. /**
  35804. * Downloads a blob in the browser
  35805. * @param blob defines the blob to download
  35806. * @param fileName defines the name of the downloaded file
  35807. */
  35808. static Download(blob: Blob, fileName: string): void;
  35809. /**
  35810. * Captures a screenshot of the current rendering
  35811. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  35812. * @param engine defines the rendering engine
  35813. * @param camera defines the source camera
  35814. * @param size This parameter can be set to a single number or to an object with the
  35815. * following (optional) properties: precision, width, height. If a single number is passed,
  35816. * it will be used for both width and height. If an object is passed, the screenshot size
  35817. * will be derived from the parameters. The precision property is a multiplier allowing
  35818. * rendering at a higher or lower resolution
  35819. * @param successCallback defines the callback receives a single parameter which contains the
  35820. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  35821. * src parameter of an <img> to display it
  35822. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  35823. * Check your browser for supported MIME types
  35824. */
  35825. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  35826. /**
  35827. * Captures a screenshot of the current rendering
  35828. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  35829. * @param engine defines the rendering engine
  35830. * @param camera defines the source camera
  35831. * @param size This parameter can be set to a single number or to an object with the
  35832. * following (optional) properties: precision, width, height. If a single number is passed,
  35833. * it will be used for both width and height. If an object is passed, the screenshot size
  35834. * will be derived from the parameters. The precision property is a multiplier allowing
  35835. * rendering at a higher or lower resolution
  35836. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  35837. * Check your browser for supported MIME types
  35838. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  35839. * to the src parameter of an <img> to display it
  35840. */
  35841. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  35842. /**
  35843. * Generates an image screenshot from the specified camera.
  35844. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  35845. * @param engine The engine to use for rendering
  35846. * @param camera The camera to use for rendering
  35847. * @param size This parameter can be set to a single number or to an object with the
  35848. * following (optional) properties: precision, width, height. If a single number is passed,
  35849. * it will be used for both width and height. If an object is passed, the screenshot size
  35850. * will be derived from the parameters. The precision property is a multiplier allowing
  35851. * rendering at a higher or lower resolution
  35852. * @param successCallback The callback receives a single parameter which contains the
  35853. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  35854. * src parameter of an <img> to display it
  35855. * @param mimeType The MIME type of the screenshot image (default: image/png).
  35856. * Check your browser for supported MIME types
  35857. * @param samples Texture samples (default: 1)
  35858. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  35859. * @param fileName A name for for the downloaded file.
  35860. */
  35861. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  35862. /**
  35863. * Generates an image screenshot from the specified camera.
  35864. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  35865. * @param engine The engine to use for rendering
  35866. * @param camera The camera to use for rendering
  35867. * @param size This parameter can be set to a single number or to an object with the
  35868. * following (optional) properties: precision, width, height. If a single number is passed,
  35869. * it will be used for both width and height. If an object is passed, the screenshot size
  35870. * will be derived from the parameters. The precision property is a multiplier allowing
  35871. * rendering at a higher or lower resolution
  35872. * @param mimeType The MIME type of the screenshot image (default: image/png).
  35873. * Check your browser for supported MIME types
  35874. * @param samples Texture samples (default: 1)
  35875. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  35876. * @param fileName A name for for the downloaded file.
  35877. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  35878. * to the src parameter of an <img> to display it
  35879. */
  35880. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  35881. /**
  35882. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  35883. * Be aware Math.random() could cause collisions, but:
  35884. * "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"
  35885. * @returns a pseudo random id
  35886. */
  35887. static RandomId(): string;
  35888. /**
  35889. * Test if the given uri is a base64 string
  35890. * @param uri The uri to test
  35891. * @return True if the uri is a base64 string or false otherwise
  35892. */
  35893. static IsBase64(uri: string): boolean;
  35894. /**
  35895. * Decode the given base64 uri.
  35896. * @param uri The uri to decode
  35897. * @return The decoded base64 data.
  35898. */
  35899. static DecodeBase64(uri: string): ArrayBuffer;
  35900. /**
  35901. * Gets the absolute url.
  35902. * @param url the input url
  35903. * @return the absolute url
  35904. */
  35905. static GetAbsoluteUrl(url: string): string;
  35906. /**
  35907. * No log
  35908. */
  35909. static readonly NoneLogLevel: number;
  35910. /**
  35911. * Only message logs
  35912. */
  35913. static readonly MessageLogLevel: number;
  35914. /**
  35915. * Only warning logs
  35916. */
  35917. static readonly WarningLogLevel: number;
  35918. /**
  35919. * Only error logs
  35920. */
  35921. static readonly ErrorLogLevel: number;
  35922. /**
  35923. * All logs
  35924. */
  35925. static readonly AllLogLevel: number;
  35926. /**
  35927. * Gets a value indicating the number of loading errors
  35928. * @ignorenaming
  35929. */
  35930. static get errorsCount(): number;
  35931. /**
  35932. * Callback called when a new log is added
  35933. */
  35934. static OnNewCacheEntry: (entry: string) => void;
  35935. /**
  35936. * Log a message to the console
  35937. * @param message defines the message to log
  35938. */
  35939. static Log(message: string): void;
  35940. /**
  35941. * Write a warning message to the console
  35942. * @param message defines the message to log
  35943. */
  35944. static Warn(message: string): void;
  35945. /**
  35946. * Write an error message to the console
  35947. * @param message defines the message to log
  35948. */
  35949. static Error(message: string): void;
  35950. /**
  35951. * Gets current log cache (list of logs)
  35952. */
  35953. static get LogCache(): string;
  35954. /**
  35955. * Clears the log cache
  35956. */
  35957. static ClearLogCache(): void;
  35958. /**
  35959. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  35960. */
  35961. static set LogLevels(level: number);
  35962. /**
  35963. * Checks if the window object exists
  35964. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  35965. */
  35966. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  35967. /**
  35968. * No performance log
  35969. */
  35970. static readonly PerformanceNoneLogLevel: number;
  35971. /**
  35972. * Use user marks to log performance
  35973. */
  35974. static readonly PerformanceUserMarkLogLevel: number;
  35975. /**
  35976. * Log performance to the console
  35977. */
  35978. static readonly PerformanceConsoleLogLevel: number;
  35979. private static _performance;
  35980. /**
  35981. * Sets the current performance log level
  35982. */
  35983. static set PerformanceLogLevel(level: number);
  35984. private static _StartPerformanceCounterDisabled;
  35985. private static _EndPerformanceCounterDisabled;
  35986. private static _StartUserMark;
  35987. private static _EndUserMark;
  35988. private static _StartPerformanceConsole;
  35989. private static _EndPerformanceConsole;
  35990. /**
  35991. * Starts a performance counter
  35992. */
  35993. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  35994. /**
  35995. * Ends a specific performance coutner
  35996. */
  35997. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  35998. /**
  35999. * Gets either window.performance.now() if supported or Date.now() else
  36000. */
  36001. static get Now(): number;
  36002. /**
  36003. * This method will return the name of the class used to create the instance of the given object.
  36004. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  36005. * @param object the object to get the class name from
  36006. * @param isType defines if the object is actually a type
  36007. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  36008. */
  36009. static GetClassName(object: any, isType?: boolean): string;
  36010. /**
  36011. * Gets the first element of an array satisfying a given predicate
  36012. * @param array defines the array to browse
  36013. * @param predicate defines the predicate to use
  36014. * @returns null if not found or the element
  36015. */
  36016. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  36017. /**
  36018. * This method will return the name of the full name of the class, including its owning module (if any).
  36019. * 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).
  36020. * @param object the object to get the class name from
  36021. * @param isType defines if the object is actually a type
  36022. * @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.
  36023. * @ignorenaming
  36024. */
  36025. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  36026. /**
  36027. * Returns a promise that resolves after the given amount of time.
  36028. * @param delay Number of milliseconds to delay
  36029. * @returns Promise that resolves after the given amount of time
  36030. */
  36031. static DelayAsync(delay: number): Promise<void>;
  36032. /**
  36033. * Utility function to detect if the current user agent is Safari
  36034. * @returns whether or not the current user agent is safari
  36035. */
  36036. static IsSafari(): boolean;
  36037. }
  36038. /**
  36039. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  36040. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  36041. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  36042. * @param name The name of the class, case should be preserved
  36043. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  36044. */
  36045. export function className(name: string, module?: string): (target: Object) => void;
  36046. /**
  36047. * An implementation of a loop for asynchronous functions.
  36048. */
  36049. export class AsyncLoop {
  36050. /**
  36051. * Defines the number of iterations for the loop
  36052. */
  36053. iterations: number;
  36054. /**
  36055. * Defines the current index of the loop.
  36056. */
  36057. index: number;
  36058. private _done;
  36059. private _fn;
  36060. private _successCallback;
  36061. /**
  36062. * Constructor.
  36063. * @param iterations the number of iterations.
  36064. * @param func the function to run each iteration
  36065. * @param successCallback the callback that will be called upon succesful execution
  36066. * @param offset starting offset.
  36067. */
  36068. constructor(
  36069. /**
  36070. * Defines the number of iterations for the loop
  36071. */
  36072. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  36073. /**
  36074. * Execute the next iteration. Must be called after the last iteration was finished.
  36075. */
  36076. executeNext(): void;
  36077. /**
  36078. * Break the loop and run the success callback.
  36079. */
  36080. breakLoop(): void;
  36081. /**
  36082. * Create and run an async loop.
  36083. * @param iterations the number of iterations.
  36084. * @param fn the function to run each iteration
  36085. * @param successCallback the callback that will be called upon succesful execution
  36086. * @param offset starting offset.
  36087. * @returns the created async loop object
  36088. */
  36089. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  36090. /**
  36091. * A for-loop that will run a given number of iterations synchronous and the rest async.
  36092. * @param iterations total number of iterations
  36093. * @param syncedIterations number of synchronous iterations in each async iteration.
  36094. * @param fn the function to call each iteration.
  36095. * @param callback a success call back that will be called when iterating stops.
  36096. * @param breakFunction a break condition (optional)
  36097. * @param timeout timeout settings for the setTimeout function. default - 0.
  36098. * @returns the created async loop object
  36099. */
  36100. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  36101. }
  36102. }
  36103. declare module "babylonjs/Misc/stringDictionary" {
  36104. import { Nullable } from "babylonjs/types";
  36105. /**
  36106. * This class implement a typical dictionary using a string as key and the generic type T as value.
  36107. * The underlying implementation relies on an associative array to ensure the best performances.
  36108. * The value can be anything including 'null' but except 'undefined'
  36109. */
  36110. export class StringDictionary<T> {
  36111. /**
  36112. * This will clear this dictionary and copy the content from the 'source' one.
  36113. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  36114. * @param source the dictionary to take the content from and copy to this dictionary
  36115. */
  36116. copyFrom(source: StringDictionary<T>): void;
  36117. /**
  36118. * Get a value based from its key
  36119. * @param key the given key to get the matching value from
  36120. * @return the value if found, otherwise undefined is returned
  36121. */
  36122. get(key: string): T | undefined;
  36123. /**
  36124. * Get a value from its key or add it if it doesn't exist.
  36125. * This method will ensure you that a given key/data will be present in the dictionary.
  36126. * @param key the given key to get the matching value from
  36127. * @param factory the factory that will create the value if the key is not present in the dictionary.
  36128. * The factory will only be invoked if there's no data for the given key.
  36129. * @return the value corresponding to the key.
  36130. */
  36131. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  36132. /**
  36133. * Get a value from its key if present in the dictionary otherwise add it
  36134. * @param key the key to get the value from
  36135. * @param val if there's no such key/value pair in the dictionary add it with this value
  36136. * @return the value corresponding to the key
  36137. */
  36138. getOrAdd(key: string, val: T): T;
  36139. /**
  36140. * Check if there's a given key in the dictionary
  36141. * @param key the key to check for
  36142. * @return true if the key is present, false otherwise
  36143. */
  36144. contains(key: string): boolean;
  36145. /**
  36146. * Add a new key and its corresponding value
  36147. * @param key the key to add
  36148. * @param value the value corresponding to the key
  36149. * @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
  36150. */
  36151. add(key: string, value: T): boolean;
  36152. /**
  36153. * Update a specific value associated to a key
  36154. * @param key defines the key to use
  36155. * @param value defines the value to store
  36156. * @returns true if the value was updated (or false if the key was not found)
  36157. */
  36158. set(key: string, value: T): boolean;
  36159. /**
  36160. * Get the element of the given key and remove it from the dictionary
  36161. * @param key defines the key to search
  36162. * @returns the value associated with the key or null if not found
  36163. */
  36164. getAndRemove(key: string): Nullable<T>;
  36165. /**
  36166. * Remove a key/value from the dictionary.
  36167. * @param key the key to remove
  36168. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  36169. */
  36170. remove(key: string): boolean;
  36171. /**
  36172. * Clear the whole content of the dictionary
  36173. */
  36174. clear(): void;
  36175. /**
  36176. * Gets the current count
  36177. */
  36178. get count(): number;
  36179. /**
  36180. * Execute a callback on each key/val of the dictionary.
  36181. * Note that you can remove any element in this dictionary in the callback implementation
  36182. * @param callback the callback to execute on a given key/value pair
  36183. */
  36184. forEach(callback: (key: string, val: T) => void): void;
  36185. /**
  36186. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  36187. * If the callback returns null or undefined the method will iterate to the next key/value pair
  36188. * Note that you can remove any element in this dictionary in the callback implementation
  36189. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  36190. * @returns the first item
  36191. */
  36192. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  36193. private _count;
  36194. private _data;
  36195. }
  36196. }
  36197. declare module "babylonjs/Collisions/collisionCoordinator" {
  36198. import { Nullable } from "babylonjs/types";
  36199. import { Scene } from "babylonjs/scene";
  36200. import { Vector3 } from "babylonjs/Maths/math.vector";
  36201. import { Collider } from "babylonjs/Collisions/collider";
  36202. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36203. /** @hidden */
  36204. export interface ICollisionCoordinator {
  36205. createCollider(): Collider;
  36206. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  36207. init(scene: Scene): void;
  36208. }
  36209. /** @hidden */
  36210. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  36211. private _scene;
  36212. private _scaledPosition;
  36213. private _scaledVelocity;
  36214. private _finalPosition;
  36215. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  36216. createCollider(): Collider;
  36217. init(scene: Scene): void;
  36218. private _collideWithWorld;
  36219. }
  36220. }
  36221. declare module "babylonjs/Inputs/scene.inputManager" {
  36222. import { Nullable } from "babylonjs/types";
  36223. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  36224. import { Vector2 } from "babylonjs/Maths/math.vector";
  36225. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36226. import { Scene } from "babylonjs/scene";
  36227. /**
  36228. * Class used to manage all inputs for the scene.
  36229. */
  36230. export class InputManager {
  36231. /** The distance in pixel that you have to move to prevent some events */
  36232. static DragMovementThreshold: number;
  36233. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  36234. static LongPressDelay: number;
  36235. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  36236. static DoubleClickDelay: number;
  36237. /** If you need to check double click without raising a single click at first click, enable this flag */
  36238. static ExclusiveDoubleClickMode: boolean;
  36239. private _wheelEventName;
  36240. private _onPointerMove;
  36241. private _onPointerDown;
  36242. private _onPointerUp;
  36243. private _initClickEvent;
  36244. private _initActionManager;
  36245. private _delayedSimpleClick;
  36246. private _delayedSimpleClickTimeout;
  36247. private _previousDelayedSimpleClickTimeout;
  36248. private _meshPickProceed;
  36249. private _previousButtonPressed;
  36250. private _currentPickResult;
  36251. private _previousPickResult;
  36252. private _totalPointersPressed;
  36253. private _doubleClickOccured;
  36254. private _pointerOverMesh;
  36255. private _pickedDownMesh;
  36256. private _pickedUpMesh;
  36257. private _pointerX;
  36258. private _pointerY;
  36259. private _unTranslatedPointerX;
  36260. private _unTranslatedPointerY;
  36261. private _startingPointerPosition;
  36262. private _previousStartingPointerPosition;
  36263. private _startingPointerTime;
  36264. private _previousStartingPointerTime;
  36265. private _pointerCaptures;
  36266. private _onKeyDown;
  36267. private _onKeyUp;
  36268. private _onCanvasFocusObserver;
  36269. private _onCanvasBlurObserver;
  36270. private _scene;
  36271. /**
  36272. * Creates a new InputManager
  36273. * @param scene defines the hosting scene
  36274. */
  36275. constructor(scene: Scene);
  36276. /**
  36277. * Gets the mesh that is currently under the pointer
  36278. */
  36279. get meshUnderPointer(): Nullable<AbstractMesh>;
  36280. /**
  36281. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  36282. */
  36283. get unTranslatedPointer(): Vector2;
  36284. /**
  36285. * Gets or sets the current on-screen X position of the pointer
  36286. */
  36287. get pointerX(): number;
  36288. set pointerX(value: number);
  36289. /**
  36290. * Gets or sets the current on-screen Y position of the pointer
  36291. */
  36292. get pointerY(): number;
  36293. set pointerY(value: number);
  36294. private _updatePointerPosition;
  36295. private _processPointerMove;
  36296. private _setRayOnPointerInfo;
  36297. private _checkPrePointerObservable;
  36298. /**
  36299. * Use this method to simulate a pointer move on a mesh
  36300. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  36301. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  36302. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  36303. */
  36304. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  36305. /**
  36306. * Use this method to simulate a pointer down on a mesh
  36307. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  36308. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  36309. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  36310. */
  36311. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  36312. private _processPointerDown;
  36313. /** @hidden */
  36314. _isPointerSwiping(): boolean;
  36315. /**
  36316. * Use this method to simulate a pointer up on a mesh
  36317. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  36318. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  36319. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  36320. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  36321. */
  36322. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  36323. private _processPointerUp;
  36324. /**
  36325. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  36326. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  36327. * @returns true if the pointer was captured
  36328. */
  36329. isPointerCaptured(pointerId?: number): boolean;
  36330. /**
  36331. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  36332. * @param attachUp defines if you want to attach events to pointerup
  36333. * @param attachDown defines if you want to attach events to pointerdown
  36334. * @param attachMove defines if you want to attach events to pointermove
  36335. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  36336. */
  36337. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  36338. /**
  36339. * Detaches all event handlers
  36340. */
  36341. detachControl(): void;
  36342. /**
  36343. * Force the value of meshUnderPointer
  36344. * @param mesh defines the mesh to use
  36345. */
  36346. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  36347. /**
  36348. * Gets the mesh under the pointer
  36349. * @returns a Mesh or null if no mesh is under the pointer
  36350. */
  36351. getPointerOverMesh(): Nullable<AbstractMesh>;
  36352. }
  36353. }
  36354. declare module "babylonjs/Misc/uniqueIdGenerator" {
  36355. /**
  36356. * Helper class used to generate session unique ID
  36357. */
  36358. export class UniqueIdGenerator {
  36359. private static _UniqueIdCounter;
  36360. /**
  36361. * Gets an unique (relatively to the current scene) Id
  36362. */
  36363. static get UniqueId(): number;
  36364. }
  36365. }
  36366. declare module "babylonjs/Animations/animationGroup" {
  36367. import { Animatable } from "babylonjs/Animations/animatable";
  36368. import { Animation } from "babylonjs/Animations/animation";
  36369. import { Scene, IDisposable } from "babylonjs/scene";
  36370. import { Observable } from "babylonjs/Misc/observable";
  36371. import { Nullable } from "babylonjs/types";
  36372. import "babylonjs/Animations/animatable";
  36373. /**
  36374. * This class defines the direct association between an animation and a target
  36375. */
  36376. export class TargetedAnimation {
  36377. /**
  36378. * Animation to perform
  36379. */
  36380. animation: Animation;
  36381. /**
  36382. * Target to animate
  36383. */
  36384. target: any;
  36385. /**
  36386. * Serialize the object
  36387. * @returns the JSON object representing the current entity
  36388. */
  36389. serialize(): any;
  36390. }
  36391. /**
  36392. * Use this class to create coordinated animations on multiple targets
  36393. */
  36394. export class AnimationGroup implements IDisposable {
  36395. /** The name of the animation group */
  36396. name: string;
  36397. private _scene;
  36398. private _targetedAnimations;
  36399. private _animatables;
  36400. private _from;
  36401. private _to;
  36402. private _isStarted;
  36403. private _isPaused;
  36404. private _speedRatio;
  36405. private _loopAnimation;
  36406. private _isAdditive;
  36407. /**
  36408. * Gets or sets the unique id of the node
  36409. */
  36410. uniqueId: number;
  36411. /**
  36412. * This observable will notify when one animation have ended
  36413. */
  36414. onAnimationEndObservable: Observable<TargetedAnimation>;
  36415. /**
  36416. * Observer raised when one animation loops
  36417. */
  36418. onAnimationLoopObservable: Observable<TargetedAnimation>;
  36419. /**
  36420. * Observer raised when all animations have looped
  36421. */
  36422. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  36423. /**
  36424. * This observable will notify when all animations have ended.
  36425. */
  36426. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  36427. /**
  36428. * This observable will notify when all animations have paused.
  36429. */
  36430. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  36431. /**
  36432. * This observable will notify when all animations are playing.
  36433. */
  36434. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  36435. /**
  36436. * Gets the first frame
  36437. */
  36438. get from(): number;
  36439. /**
  36440. * Gets the last frame
  36441. */
  36442. get to(): number;
  36443. /**
  36444. * Define if the animations are started
  36445. */
  36446. get isStarted(): boolean;
  36447. /**
  36448. * Gets a value indicating that the current group is playing
  36449. */
  36450. get isPlaying(): boolean;
  36451. /**
  36452. * Gets or sets the speed ratio to use for all animations
  36453. */
  36454. get speedRatio(): number;
  36455. /**
  36456. * Gets or sets the speed ratio to use for all animations
  36457. */
  36458. set speedRatio(value: number);
  36459. /**
  36460. * Gets or sets if all animations should loop or not
  36461. */
  36462. get loopAnimation(): boolean;
  36463. set loopAnimation(value: boolean);
  36464. /**
  36465. * Gets or sets if all animations should be evaluated additively
  36466. */
  36467. get isAdditive(): boolean;
  36468. set isAdditive(value: boolean);
  36469. /**
  36470. * Gets the targeted animations for this animation group
  36471. */
  36472. get targetedAnimations(): Array<TargetedAnimation>;
  36473. /**
  36474. * returning the list of animatables controlled by this animation group.
  36475. */
  36476. get animatables(): Array<Animatable>;
  36477. /**
  36478. * Instantiates a new Animation Group.
  36479. * This helps managing several animations at once.
  36480. * @see http://doc.babylonjs.com/how_to/group
  36481. * @param name Defines the name of the group
  36482. * @param scene Defines the scene the group belongs to
  36483. */
  36484. constructor(
  36485. /** The name of the animation group */
  36486. name: string, scene?: Nullable<Scene>);
  36487. /**
  36488. * Add an animation (with its target) in the group
  36489. * @param animation defines the animation we want to add
  36490. * @param target defines the target of the animation
  36491. * @returns the TargetedAnimation object
  36492. */
  36493. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  36494. /**
  36495. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  36496. * It can add constant keys at begin or end
  36497. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  36498. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  36499. * @returns the animation group
  36500. */
  36501. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  36502. private _animationLoopCount;
  36503. private _animationLoopFlags;
  36504. private _processLoop;
  36505. /**
  36506. * Start all animations on given targets
  36507. * @param loop defines if animations must loop
  36508. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  36509. * @param from defines the from key (optional)
  36510. * @param to defines the to key (optional)
  36511. * @param isAdditive defines the additive state for the resulting animatables (optional)
  36512. * @returns the current animation group
  36513. */
  36514. start(loop?: boolean, speedRatio?: number, from?: number, to?: number, isAdditive?: boolean): AnimationGroup;
  36515. /**
  36516. * Pause all animations
  36517. * @returns the animation group
  36518. */
  36519. pause(): AnimationGroup;
  36520. /**
  36521. * Play all animations to initial state
  36522. * This function will start() the animations if they were not started or will restart() them if they were paused
  36523. * @param loop defines if animations must loop
  36524. * @returns the animation group
  36525. */
  36526. play(loop?: boolean): AnimationGroup;
  36527. /**
  36528. * Reset all animations to initial state
  36529. * @returns the animation group
  36530. */
  36531. reset(): AnimationGroup;
  36532. /**
  36533. * Restart animations from key 0
  36534. * @returns the animation group
  36535. */
  36536. restart(): AnimationGroup;
  36537. /**
  36538. * Stop all animations
  36539. * @returns the animation group
  36540. */
  36541. stop(): AnimationGroup;
  36542. /**
  36543. * Set animation weight for all animatables
  36544. * @param weight defines the weight to use
  36545. * @return the animationGroup
  36546. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  36547. */
  36548. setWeightForAllAnimatables(weight: number): AnimationGroup;
  36549. /**
  36550. * Synchronize and normalize all animatables with a source animatable
  36551. * @param root defines the root animatable to synchronize with
  36552. * @return the animationGroup
  36553. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  36554. */
  36555. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  36556. /**
  36557. * Goes to a specific frame in this animation group
  36558. * @param frame the frame number to go to
  36559. * @return the animationGroup
  36560. */
  36561. goToFrame(frame: number): AnimationGroup;
  36562. /**
  36563. * Dispose all associated resources
  36564. */
  36565. dispose(): void;
  36566. private _checkAnimationGroupEnded;
  36567. /**
  36568. * Clone the current animation group and returns a copy
  36569. * @param newName defines the name of the new group
  36570. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  36571. * @returns the new aniamtion group
  36572. */
  36573. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  36574. /**
  36575. * Serializes the animationGroup to an object
  36576. * @returns Serialized object
  36577. */
  36578. serialize(): any;
  36579. /**
  36580. * Returns a new AnimationGroup object parsed from the source provided.
  36581. * @param parsedAnimationGroup defines the source
  36582. * @param scene defines the scene that will receive the animationGroup
  36583. * @returns a new AnimationGroup
  36584. */
  36585. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  36586. /**
  36587. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  36588. * @param sourceAnimationGroup defines the AnimationGroup containing animations to convert
  36589. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  36590. * @param range defines the name of the AnimationRange belonging to the animations in the group to convert
  36591. * @param cloneOriginal defines whether or not to clone the group and convert the clone or convert the original group (default is false)
  36592. * @param clonedName defines the name of the resulting cloned AnimationGroup if cloneOriginal is true
  36593. * @returns a new AnimationGroup if cloneOriginal is true or the original AnimationGroup if cloneOriginal is false
  36594. */
  36595. static MakeAnimationAdditive(sourceAnimationGroup: AnimationGroup, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): AnimationGroup;
  36596. /**
  36597. * Returns the string "AnimationGroup"
  36598. * @returns "AnimationGroup"
  36599. */
  36600. getClassName(): string;
  36601. /**
  36602. * Creates a detailled string about the object
  36603. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  36604. * @returns a string representing the object
  36605. */
  36606. toString(fullDetails?: boolean): string;
  36607. }
  36608. }
  36609. declare module "babylonjs/scene" {
  36610. import { Nullable } from "babylonjs/types";
  36611. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  36612. import { Observable } from "babylonjs/Misc/observable";
  36613. import { SmartArrayNoDuplicate, SmartArray, ISmartArrayLike } from "babylonjs/Misc/smartArray";
  36614. import { Vector2, Vector3, Matrix } from "babylonjs/Maths/math.vector";
  36615. import { Geometry } from "babylonjs/Meshes/geometry";
  36616. import { TransformNode } from "babylonjs/Meshes/transformNode";
  36617. import { SubMesh } from "babylonjs/Meshes/subMesh";
  36618. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36619. import { Mesh } from "babylonjs/Meshes/mesh";
  36620. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  36621. import { Bone } from "babylonjs/Bones/bone";
  36622. import { Skeleton } from "babylonjs/Bones/skeleton";
  36623. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  36624. import { Camera } from "babylonjs/Cameras/camera";
  36625. import { AbstractScene } from "babylonjs/abstractScene";
  36626. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  36627. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  36628. import { Material } from "babylonjs/Materials/material";
  36629. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  36630. import { Effect } from "babylonjs/Materials/effect";
  36631. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  36632. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  36633. import { Light } from "babylonjs/Lights/light";
  36634. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  36635. import { ICollisionCoordinator } from "babylonjs/Collisions/collisionCoordinator";
  36636. import { PointerEventTypes, PointerInfoPre, PointerInfo } from "babylonjs/Events/pointerEvents";
  36637. import { KeyboardInfoPre, KeyboardInfo } from "babylonjs/Events/keyboardEvents";
  36638. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  36639. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  36640. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  36641. import { RenderingGroupInfo, IRenderingManagerAutoClearSetup } from "babylonjs/Rendering/renderingManager";
  36642. import { ISceneComponent, ISceneSerializableComponent, Stage, SimpleStageAction, RenderTargetsStageAction, RenderTargetStageAction, MeshStageAction, EvaluateSubMeshStageAction, ActiveMeshStageAction, CameraStageAction, RenderingGroupStageAction, RenderingMeshStageAction, PointerMoveStageAction, PointerUpDownStageAction, CameraStageFrameBufferAction } from "babylonjs/sceneComponent";
  36643. import { Engine } from "babylonjs/Engines/engine";
  36644. import { Node } from "babylonjs/node";
  36645. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  36646. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  36647. import { WebRequest } from "babylonjs/Misc/webRequest";
  36648. import { InputManager } from "babylonjs/Inputs/scene.inputManager";
  36649. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  36650. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  36651. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  36652. import { Plane } from "babylonjs/Maths/math.plane";
  36653. import { LoadFileError, RequestFileError, ReadFileError } from "babylonjs/Misc/fileTools";
  36654. import { Ray } from "babylonjs/Culling/ray";
  36655. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  36656. import { Animation } from "babylonjs/Animations/animation";
  36657. import { Animatable } from "babylonjs/Animations/animatable";
  36658. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  36659. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  36660. import { Collider } from "babylonjs/Collisions/collider";
  36661. /**
  36662. * Define an interface for all classes that will hold resources
  36663. */
  36664. export interface IDisposable {
  36665. /**
  36666. * Releases all held resources
  36667. */
  36668. dispose(): void;
  36669. }
  36670. /** Interface defining initialization parameters for Scene class */
  36671. export interface SceneOptions {
  36672. /**
  36673. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  36674. * It will improve performance when the number of geometries becomes important.
  36675. */
  36676. useGeometryUniqueIdsMap?: boolean;
  36677. /**
  36678. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  36679. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  36680. */
  36681. useMaterialMeshMap?: boolean;
  36682. /**
  36683. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  36684. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  36685. */
  36686. useClonedMeshMap?: boolean;
  36687. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  36688. virtual?: boolean;
  36689. }
  36690. /**
  36691. * Represents a scene to be rendered by the engine.
  36692. * @see http://doc.babylonjs.com/features/scene
  36693. */
  36694. export class Scene extends AbstractScene implements IAnimatable {
  36695. /** The fog is deactivated */
  36696. static readonly FOGMODE_NONE: number;
  36697. /** The fog density is following an exponential function */
  36698. static readonly FOGMODE_EXP: number;
  36699. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  36700. static readonly FOGMODE_EXP2: number;
  36701. /** The fog density is following a linear function. */
  36702. static readonly FOGMODE_LINEAR: number;
  36703. /**
  36704. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  36705. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  36706. */
  36707. static MinDeltaTime: number;
  36708. /**
  36709. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  36710. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  36711. */
  36712. static MaxDeltaTime: number;
  36713. /**
  36714. * Factory used to create the default material.
  36715. * @param name The name of the material to create
  36716. * @param scene The scene to create the material for
  36717. * @returns The default material
  36718. */
  36719. static DefaultMaterialFactory(scene: Scene): Material;
  36720. /**
  36721. * Factory used to create the a collision coordinator.
  36722. * @returns The collision coordinator
  36723. */
  36724. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  36725. /** @hidden */
  36726. _inputManager: InputManager;
  36727. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  36728. cameraToUseForPointers: Nullable<Camera>;
  36729. /** @hidden */
  36730. readonly _isScene: boolean;
  36731. /** @hidden */
  36732. _blockEntityCollection: boolean;
  36733. /**
  36734. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  36735. */
  36736. autoClear: boolean;
  36737. /**
  36738. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  36739. */
  36740. autoClearDepthAndStencil: boolean;
  36741. /**
  36742. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  36743. */
  36744. clearColor: Color4;
  36745. /**
  36746. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  36747. */
  36748. ambientColor: Color3;
  36749. /**
  36750. * This is use to store the default BRDF lookup for PBR materials in your scene.
  36751. * It should only be one of the following (if not the default embedded one):
  36752. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  36753. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  36754. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  36755. * The material properties need to be setup according to the type of texture in use.
  36756. */
  36757. environmentBRDFTexture: BaseTexture;
  36758. /** @hidden */
  36759. protected _environmentTexture: Nullable<BaseTexture>;
  36760. /**
  36761. * Texture used in all pbr material as the reflection texture.
  36762. * As in the majority of the scene they are the same (exception for multi room and so on),
  36763. * this is easier to reference from here than from all the materials.
  36764. */
  36765. get environmentTexture(): Nullable<BaseTexture>;
  36766. /**
  36767. * Texture used in all pbr material as the reflection texture.
  36768. * As in the majority of the scene they are the same (exception for multi room and so on),
  36769. * this is easier to set here than in all the materials.
  36770. */
  36771. set environmentTexture(value: Nullable<BaseTexture>);
  36772. /** @hidden */
  36773. protected _environmentIntensity: number;
  36774. /**
  36775. * Intensity of the environment in all pbr material.
  36776. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  36777. * As in the majority of the scene they are the same (exception for multi room and so on),
  36778. * this is easier to reference from here than from all the materials.
  36779. */
  36780. get environmentIntensity(): number;
  36781. /**
  36782. * Intensity of the environment in all pbr material.
  36783. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  36784. * As in the majority of the scene they are the same (exception for multi room and so on),
  36785. * this is easier to set here than in all the materials.
  36786. */
  36787. set environmentIntensity(value: number);
  36788. /** @hidden */
  36789. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  36790. /**
  36791. * Default image processing configuration used either in the rendering
  36792. * Forward main pass or through the imageProcessingPostProcess if present.
  36793. * As in the majority of the scene they are the same (exception for multi camera),
  36794. * this is easier to reference from here than from all the materials and post process.
  36795. *
  36796. * No setter as we it is a shared configuration, you can set the values instead.
  36797. */
  36798. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  36799. private _forceWireframe;
  36800. /**
  36801. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  36802. */
  36803. set forceWireframe(value: boolean);
  36804. get forceWireframe(): boolean;
  36805. private _skipFrustumClipping;
  36806. /**
  36807. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  36808. */
  36809. set skipFrustumClipping(value: boolean);
  36810. get skipFrustumClipping(): boolean;
  36811. private _forcePointsCloud;
  36812. /**
  36813. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  36814. */
  36815. set forcePointsCloud(value: boolean);
  36816. get forcePointsCloud(): boolean;
  36817. /**
  36818. * Gets or sets the active clipplane 1
  36819. */
  36820. clipPlane: Nullable<Plane>;
  36821. /**
  36822. * Gets or sets the active clipplane 2
  36823. */
  36824. clipPlane2: Nullable<Plane>;
  36825. /**
  36826. * Gets or sets the active clipplane 3
  36827. */
  36828. clipPlane3: Nullable<Plane>;
  36829. /**
  36830. * Gets or sets the active clipplane 4
  36831. */
  36832. clipPlane4: Nullable<Plane>;
  36833. /**
  36834. * Gets or sets the active clipplane 5
  36835. */
  36836. clipPlane5: Nullable<Plane>;
  36837. /**
  36838. * Gets or sets the active clipplane 6
  36839. */
  36840. clipPlane6: Nullable<Plane>;
  36841. /**
  36842. * Gets or sets a boolean indicating if animations are enabled
  36843. */
  36844. animationsEnabled: boolean;
  36845. private _animationPropertiesOverride;
  36846. /**
  36847. * Gets or sets the animation properties override
  36848. */
  36849. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  36850. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  36851. /**
  36852. * Gets or sets a boolean indicating if a constant deltatime has to be used
  36853. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  36854. */
  36855. useConstantAnimationDeltaTime: boolean;
  36856. /**
  36857. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  36858. * Please note that it requires to run a ray cast through the scene on every frame
  36859. */
  36860. constantlyUpdateMeshUnderPointer: boolean;
  36861. /**
  36862. * Defines the HTML cursor to use when hovering over interactive elements
  36863. */
  36864. hoverCursor: string;
  36865. /**
  36866. * Defines the HTML default cursor to use (empty by default)
  36867. */
  36868. defaultCursor: string;
  36869. /**
  36870. * Defines whether cursors are handled by the scene.
  36871. */
  36872. doNotHandleCursors: boolean;
  36873. /**
  36874. * This is used to call preventDefault() on pointer down
  36875. * in order to block unwanted artifacts like system double clicks
  36876. */
  36877. preventDefaultOnPointerDown: boolean;
  36878. /**
  36879. * This is used to call preventDefault() on pointer up
  36880. * in order to block unwanted artifacts like system double clicks
  36881. */
  36882. preventDefaultOnPointerUp: boolean;
  36883. /**
  36884. * Gets or sets user defined metadata
  36885. */
  36886. metadata: any;
  36887. /**
  36888. * For internal use only. Please do not use.
  36889. */
  36890. reservedDataStore: any;
  36891. /**
  36892. * Gets the name of the plugin used to load this scene (null by default)
  36893. */
  36894. loadingPluginName: string;
  36895. /**
  36896. * Use this array to add regular expressions used to disable offline support for specific urls
  36897. */
  36898. disableOfflineSupportExceptionRules: RegExp[];
  36899. /**
  36900. * An event triggered when the scene is disposed.
  36901. */
  36902. onDisposeObservable: Observable<Scene>;
  36903. private _onDisposeObserver;
  36904. /** Sets a function to be executed when this scene is disposed. */
  36905. set onDispose(callback: () => void);
  36906. /**
  36907. * An event triggered before rendering the scene (right after animations and physics)
  36908. */
  36909. onBeforeRenderObservable: Observable<Scene>;
  36910. private _onBeforeRenderObserver;
  36911. /** Sets a function to be executed before rendering this scene */
  36912. set beforeRender(callback: Nullable<() => void>);
  36913. /**
  36914. * An event triggered after rendering the scene
  36915. */
  36916. onAfterRenderObservable: Observable<Scene>;
  36917. /**
  36918. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  36919. */
  36920. onAfterRenderCameraObservable: Observable<Camera>;
  36921. private _onAfterRenderObserver;
  36922. /** Sets a function to be executed after rendering this scene */
  36923. set afterRender(callback: Nullable<() => void>);
  36924. /**
  36925. * An event triggered before animating the scene
  36926. */
  36927. onBeforeAnimationsObservable: Observable<Scene>;
  36928. /**
  36929. * An event triggered after animations processing
  36930. */
  36931. onAfterAnimationsObservable: Observable<Scene>;
  36932. /**
  36933. * An event triggered before draw calls are ready to be sent
  36934. */
  36935. onBeforeDrawPhaseObservable: Observable<Scene>;
  36936. /**
  36937. * An event triggered after draw calls have been sent
  36938. */
  36939. onAfterDrawPhaseObservable: Observable<Scene>;
  36940. /**
  36941. * An event triggered when the scene is ready
  36942. */
  36943. onReadyObservable: Observable<Scene>;
  36944. /**
  36945. * An event triggered before rendering a camera
  36946. */
  36947. onBeforeCameraRenderObservable: Observable<Camera>;
  36948. private _onBeforeCameraRenderObserver;
  36949. /** Sets a function to be executed before rendering a camera*/
  36950. set beforeCameraRender(callback: () => void);
  36951. /**
  36952. * An event triggered after rendering a camera
  36953. */
  36954. onAfterCameraRenderObservable: Observable<Camera>;
  36955. private _onAfterCameraRenderObserver;
  36956. /** Sets a function to be executed after rendering a camera*/
  36957. set afterCameraRender(callback: () => void);
  36958. /**
  36959. * An event triggered when active meshes evaluation is about to start
  36960. */
  36961. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  36962. /**
  36963. * An event triggered when active meshes evaluation is done
  36964. */
  36965. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  36966. /**
  36967. * An event triggered when particles rendering is about to start
  36968. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  36969. */
  36970. onBeforeParticlesRenderingObservable: Observable<Scene>;
  36971. /**
  36972. * An event triggered when particles rendering is done
  36973. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  36974. */
  36975. onAfterParticlesRenderingObservable: Observable<Scene>;
  36976. /**
  36977. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  36978. */
  36979. onDataLoadedObservable: Observable<Scene>;
  36980. /**
  36981. * An event triggered when a camera is created
  36982. */
  36983. onNewCameraAddedObservable: Observable<Camera>;
  36984. /**
  36985. * An event triggered when a camera is removed
  36986. */
  36987. onCameraRemovedObservable: Observable<Camera>;
  36988. /**
  36989. * An event triggered when a light is created
  36990. */
  36991. onNewLightAddedObservable: Observable<Light>;
  36992. /**
  36993. * An event triggered when a light is removed
  36994. */
  36995. onLightRemovedObservable: Observable<Light>;
  36996. /**
  36997. * An event triggered when a geometry is created
  36998. */
  36999. onNewGeometryAddedObservable: Observable<Geometry>;
  37000. /**
  37001. * An event triggered when a geometry is removed
  37002. */
  37003. onGeometryRemovedObservable: Observable<Geometry>;
  37004. /**
  37005. * An event triggered when a transform node is created
  37006. */
  37007. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  37008. /**
  37009. * An event triggered when a transform node is removed
  37010. */
  37011. onTransformNodeRemovedObservable: Observable<TransformNode>;
  37012. /**
  37013. * An event triggered when a mesh is created
  37014. */
  37015. onNewMeshAddedObservable: Observable<AbstractMesh>;
  37016. /**
  37017. * An event triggered when a mesh is removed
  37018. */
  37019. onMeshRemovedObservable: Observable<AbstractMesh>;
  37020. /**
  37021. * An event triggered when a skeleton is created
  37022. */
  37023. onNewSkeletonAddedObservable: Observable<Skeleton>;
  37024. /**
  37025. * An event triggered when a skeleton is removed
  37026. */
  37027. onSkeletonRemovedObservable: Observable<Skeleton>;
  37028. /**
  37029. * An event triggered when a material is created
  37030. */
  37031. onNewMaterialAddedObservable: Observable<Material>;
  37032. /**
  37033. * An event triggered when a material is removed
  37034. */
  37035. onMaterialRemovedObservable: Observable<Material>;
  37036. /**
  37037. * An event triggered when a texture is created
  37038. */
  37039. onNewTextureAddedObservable: Observable<BaseTexture>;
  37040. /**
  37041. * An event triggered when a texture is removed
  37042. */
  37043. onTextureRemovedObservable: Observable<BaseTexture>;
  37044. /**
  37045. * An event triggered when render targets are about to be rendered
  37046. * Can happen multiple times per frame.
  37047. */
  37048. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  37049. /**
  37050. * An event triggered when render targets were rendered.
  37051. * Can happen multiple times per frame.
  37052. */
  37053. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  37054. /**
  37055. * An event triggered before calculating deterministic simulation step
  37056. */
  37057. onBeforeStepObservable: Observable<Scene>;
  37058. /**
  37059. * An event triggered after calculating deterministic simulation step
  37060. */
  37061. onAfterStepObservable: Observable<Scene>;
  37062. /**
  37063. * An event triggered when the activeCamera property is updated
  37064. */
  37065. onActiveCameraChanged: Observable<Scene>;
  37066. /**
  37067. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  37068. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  37069. * 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)
  37070. */
  37071. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  37072. /**
  37073. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  37074. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  37075. * 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)
  37076. */
  37077. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  37078. /**
  37079. * This Observable will when a mesh has been imported into the scene.
  37080. */
  37081. onMeshImportedObservable: Observable<AbstractMesh>;
  37082. /**
  37083. * This Observable will when an animation file has been imported into the scene.
  37084. */
  37085. onAnimationFileImportedObservable: Observable<Scene>;
  37086. /**
  37087. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  37088. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  37089. */
  37090. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  37091. /** @hidden */
  37092. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  37093. /**
  37094. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  37095. */
  37096. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  37097. /**
  37098. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  37099. */
  37100. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  37101. /**
  37102. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  37103. */
  37104. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  37105. /** Callback called when a pointer move is detected */
  37106. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  37107. /** Callback called when a pointer down is detected */
  37108. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  37109. /** Callback called when a pointer up is detected */
  37110. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  37111. /** Callback called when a pointer pick is detected */
  37112. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  37113. /**
  37114. * 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).
  37115. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  37116. */
  37117. onPrePointerObservable: Observable<PointerInfoPre>;
  37118. /**
  37119. * Observable event triggered each time an input event is received from the rendering canvas
  37120. */
  37121. onPointerObservable: Observable<PointerInfo>;
  37122. /**
  37123. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  37124. */
  37125. get unTranslatedPointer(): Vector2;
  37126. /**
  37127. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  37128. */
  37129. static get DragMovementThreshold(): number;
  37130. static set DragMovementThreshold(value: number);
  37131. /**
  37132. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  37133. */
  37134. static get LongPressDelay(): number;
  37135. static set LongPressDelay(value: number);
  37136. /**
  37137. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  37138. */
  37139. static get DoubleClickDelay(): number;
  37140. static set DoubleClickDelay(value: number);
  37141. /** If you need to check double click without raising a single click at first click, enable this flag */
  37142. static get ExclusiveDoubleClickMode(): boolean;
  37143. static set ExclusiveDoubleClickMode(value: boolean);
  37144. /** @hidden */
  37145. _mirroredCameraPosition: Nullable<Vector3>;
  37146. /**
  37147. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  37148. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  37149. */
  37150. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  37151. /**
  37152. * Observable event triggered each time an keyboard event is received from the hosting window
  37153. */
  37154. onKeyboardObservable: Observable<KeyboardInfo>;
  37155. private _useRightHandedSystem;
  37156. /**
  37157. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  37158. */
  37159. set useRightHandedSystem(value: boolean);
  37160. get useRightHandedSystem(): boolean;
  37161. private _timeAccumulator;
  37162. private _currentStepId;
  37163. private _currentInternalStep;
  37164. /**
  37165. * Sets the step Id used by deterministic lock step
  37166. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  37167. * @param newStepId defines the step Id
  37168. */
  37169. setStepId(newStepId: number): void;
  37170. /**
  37171. * Gets the step Id used by deterministic lock step
  37172. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  37173. * @returns the step Id
  37174. */
  37175. getStepId(): number;
  37176. /**
  37177. * Gets the internal step used by deterministic lock step
  37178. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  37179. * @returns the internal step
  37180. */
  37181. getInternalStep(): number;
  37182. private _fogEnabled;
  37183. /**
  37184. * Gets or sets a boolean indicating if fog is enabled on this scene
  37185. * @see http://doc.babylonjs.com/babylon101/environment#fog
  37186. * (Default is true)
  37187. */
  37188. set fogEnabled(value: boolean);
  37189. get fogEnabled(): boolean;
  37190. private _fogMode;
  37191. /**
  37192. * Gets or sets the fog mode to use
  37193. * @see http://doc.babylonjs.com/babylon101/environment#fog
  37194. * | mode | value |
  37195. * | --- | --- |
  37196. * | FOGMODE_NONE | 0 |
  37197. * | FOGMODE_EXP | 1 |
  37198. * | FOGMODE_EXP2 | 2 |
  37199. * | FOGMODE_LINEAR | 3 |
  37200. */
  37201. set fogMode(value: number);
  37202. get fogMode(): number;
  37203. /**
  37204. * Gets or sets the fog color to use
  37205. * @see http://doc.babylonjs.com/babylon101/environment#fog
  37206. * (Default is Color3(0.2, 0.2, 0.3))
  37207. */
  37208. fogColor: Color3;
  37209. /**
  37210. * Gets or sets the fog density to use
  37211. * @see http://doc.babylonjs.com/babylon101/environment#fog
  37212. * (Default is 0.1)
  37213. */
  37214. fogDensity: number;
  37215. /**
  37216. * Gets or sets the fog start distance to use
  37217. * @see http://doc.babylonjs.com/babylon101/environment#fog
  37218. * (Default is 0)
  37219. */
  37220. fogStart: number;
  37221. /**
  37222. * Gets or sets the fog end distance to use
  37223. * @see http://doc.babylonjs.com/babylon101/environment#fog
  37224. * (Default is 1000)
  37225. */
  37226. fogEnd: number;
  37227. private _shadowsEnabled;
  37228. /**
  37229. * Gets or sets a boolean indicating if shadows are enabled on this scene
  37230. */
  37231. set shadowsEnabled(value: boolean);
  37232. get shadowsEnabled(): boolean;
  37233. private _lightsEnabled;
  37234. /**
  37235. * Gets or sets a boolean indicating if lights are enabled on this scene
  37236. */
  37237. set lightsEnabled(value: boolean);
  37238. get lightsEnabled(): boolean;
  37239. /** All of the active cameras added to this scene. */
  37240. activeCameras: Camera[];
  37241. /** @hidden */
  37242. _activeCamera: Nullable<Camera>;
  37243. /** Gets or sets the current active camera */
  37244. get activeCamera(): Nullable<Camera>;
  37245. set activeCamera(value: Nullable<Camera>);
  37246. private _defaultMaterial;
  37247. /** The default material used on meshes when no material is affected */
  37248. get defaultMaterial(): Material;
  37249. /** The default material used on meshes when no material is affected */
  37250. set defaultMaterial(value: Material);
  37251. private _texturesEnabled;
  37252. /**
  37253. * Gets or sets a boolean indicating if textures are enabled on this scene
  37254. */
  37255. set texturesEnabled(value: boolean);
  37256. get texturesEnabled(): boolean;
  37257. /**
  37258. * Gets or sets a boolean indicating if physic engines are enabled on this scene
  37259. */
  37260. physicsEnabled: boolean;
  37261. /**
  37262. * Gets or sets a boolean indicating if particles are enabled on this scene
  37263. */
  37264. particlesEnabled: boolean;
  37265. /**
  37266. * Gets or sets a boolean indicating if sprites are enabled on this scene
  37267. */
  37268. spritesEnabled: boolean;
  37269. private _skeletonsEnabled;
  37270. /**
  37271. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  37272. */
  37273. set skeletonsEnabled(value: boolean);
  37274. get skeletonsEnabled(): boolean;
  37275. /**
  37276. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  37277. */
  37278. lensFlaresEnabled: boolean;
  37279. /**
  37280. * Gets or sets a boolean indicating if collisions are enabled on this scene
  37281. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  37282. */
  37283. collisionsEnabled: boolean;
  37284. private _collisionCoordinator;
  37285. /** @hidden */
  37286. get collisionCoordinator(): ICollisionCoordinator;
  37287. /**
  37288. * Defines the gravity applied to this scene (used only for collisions)
  37289. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  37290. */
  37291. gravity: Vector3;
  37292. /**
  37293. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  37294. */
  37295. postProcessesEnabled: boolean;
  37296. /**
  37297. * The list of postprocesses added to the scene
  37298. */
  37299. postProcesses: PostProcess[];
  37300. /**
  37301. * Gets the current postprocess manager
  37302. */
  37303. postProcessManager: PostProcessManager;
  37304. /**
  37305. * Gets or sets a boolean indicating if render targets are enabled on this scene
  37306. */
  37307. renderTargetsEnabled: boolean;
  37308. /**
  37309. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  37310. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  37311. */
  37312. dumpNextRenderTargets: boolean;
  37313. /**
  37314. * The list of user defined render targets added to the scene
  37315. */
  37316. customRenderTargets: RenderTargetTexture[];
  37317. /**
  37318. * Defines if texture loading must be delayed
  37319. * If true, textures will only be loaded when they need to be rendered
  37320. */
  37321. useDelayedTextureLoading: boolean;
  37322. /**
  37323. * Gets the list of meshes imported to the scene through SceneLoader
  37324. */
  37325. importedMeshesFiles: String[];
  37326. /**
  37327. * Gets or sets a boolean indicating if probes are enabled on this scene
  37328. */
  37329. probesEnabled: boolean;
  37330. /**
  37331. * Gets or sets the current offline provider to use to store scene data
  37332. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  37333. */
  37334. offlineProvider: IOfflineProvider;
  37335. /**
  37336. * Gets or sets the action manager associated with the scene
  37337. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  37338. */
  37339. actionManager: AbstractActionManager;
  37340. private _meshesForIntersections;
  37341. /**
  37342. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  37343. */
  37344. proceduralTexturesEnabled: boolean;
  37345. private _engine;
  37346. private _totalVertices;
  37347. /** @hidden */
  37348. _activeIndices: PerfCounter;
  37349. /** @hidden */
  37350. _activeParticles: PerfCounter;
  37351. /** @hidden */
  37352. _activeBones: PerfCounter;
  37353. private _animationRatio;
  37354. /** @hidden */
  37355. _animationTimeLast: number;
  37356. /** @hidden */
  37357. _animationTime: number;
  37358. /**
  37359. * Gets or sets a general scale for animation speed
  37360. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  37361. */
  37362. animationTimeScale: number;
  37363. /** @hidden */
  37364. _cachedMaterial: Nullable<Material>;
  37365. /** @hidden */
  37366. _cachedEffect: Nullable<Effect>;
  37367. /** @hidden */
  37368. _cachedVisibility: Nullable<number>;
  37369. private _renderId;
  37370. private _frameId;
  37371. private _executeWhenReadyTimeoutId;
  37372. private _intermediateRendering;
  37373. private _viewUpdateFlag;
  37374. private _projectionUpdateFlag;
  37375. /** @hidden */
  37376. _toBeDisposed: Nullable<IDisposable>[];
  37377. private _activeRequests;
  37378. /** @hidden */
  37379. _pendingData: any[];
  37380. private _isDisposed;
  37381. /**
  37382. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  37383. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  37384. */
  37385. dispatchAllSubMeshesOfActiveMeshes: boolean;
  37386. private _activeMeshes;
  37387. private _processedMaterials;
  37388. private _renderTargets;
  37389. /** @hidden */
  37390. _activeParticleSystems: SmartArray<IParticleSystem>;
  37391. private _activeSkeletons;
  37392. private _softwareSkinnedMeshes;
  37393. private _renderingManager;
  37394. /** @hidden */
  37395. _activeAnimatables: import("babylonjs/Animations/animatable").Animatable[];
  37396. private _transformMatrix;
  37397. private _sceneUbo;
  37398. /** @hidden */
  37399. _viewMatrix: Matrix;
  37400. private _projectionMatrix;
  37401. /** @hidden */
  37402. _forcedViewPosition: Nullable<Vector3>;
  37403. /** @hidden */
  37404. _frustumPlanes: Plane[];
  37405. /**
  37406. * Gets the list of frustum planes (built from the active camera)
  37407. */
  37408. get frustumPlanes(): Plane[];
  37409. /**
  37410. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  37411. * This is useful if there are more lights that the maximum simulteanous authorized
  37412. */
  37413. requireLightSorting: boolean;
  37414. /** @hidden */
  37415. readonly useMaterialMeshMap: boolean;
  37416. /** @hidden */
  37417. readonly useClonedMeshMap: boolean;
  37418. private _externalData;
  37419. private _uid;
  37420. /**
  37421. * @hidden
  37422. * Backing store of defined scene components.
  37423. */
  37424. _components: ISceneComponent[];
  37425. /**
  37426. * @hidden
  37427. * Backing store of defined scene components.
  37428. */
  37429. _serializableComponents: ISceneSerializableComponent[];
  37430. /**
  37431. * List of components to register on the next registration step.
  37432. */
  37433. private _transientComponents;
  37434. /**
  37435. * Registers the transient components if needed.
  37436. */
  37437. private _registerTransientComponents;
  37438. /**
  37439. * @hidden
  37440. * Add a component to the scene.
  37441. * Note that the ccomponent could be registered on th next frame if this is called after
  37442. * the register component stage.
  37443. * @param component Defines the component to add to the scene
  37444. */
  37445. _addComponent(component: ISceneComponent): void;
  37446. /**
  37447. * @hidden
  37448. * Gets a component from the scene.
  37449. * @param name defines the name of the component to retrieve
  37450. * @returns the component or null if not present
  37451. */
  37452. _getComponent(name: string): Nullable<ISceneComponent>;
  37453. /**
  37454. * @hidden
  37455. * Defines the actions happening before camera updates.
  37456. */
  37457. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  37458. /**
  37459. * @hidden
  37460. * Defines the actions happening before clear the canvas.
  37461. */
  37462. _beforeClearStage: Stage<SimpleStageAction>;
  37463. /**
  37464. * @hidden
  37465. * Defines the actions when collecting render targets for the frame.
  37466. */
  37467. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  37468. /**
  37469. * @hidden
  37470. * Defines the actions happening for one camera in the frame.
  37471. */
  37472. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  37473. /**
  37474. * @hidden
  37475. * Defines the actions happening during the per mesh ready checks.
  37476. */
  37477. _isReadyForMeshStage: Stage<MeshStageAction>;
  37478. /**
  37479. * @hidden
  37480. * Defines the actions happening before evaluate active mesh checks.
  37481. */
  37482. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  37483. /**
  37484. * @hidden
  37485. * Defines the actions happening during the evaluate sub mesh checks.
  37486. */
  37487. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  37488. /**
  37489. * @hidden
  37490. * Defines the actions happening during the active mesh stage.
  37491. */
  37492. _activeMeshStage: Stage<ActiveMeshStageAction>;
  37493. /**
  37494. * @hidden
  37495. * Defines the actions happening during the per camera render target step.
  37496. */
  37497. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  37498. /**
  37499. * @hidden
  37500. * Defines the actions happening just before the active camera is drawing.
  37501. */
  37502. _beforeCameraDrawStage: Stage<CameraStageAction>;
  37503. /**
  37504. * @hidden
  37505. * Defines the actions happening just before a render target is drawing.
  37506. */
  37507. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  37508. /**
  37509. * @hidden
  37510. * Defines the actions happening just before a rendering group is drawing.
  37511. */
  37512. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  37513. /**
  37514. * @hidden
  37515. * Defines the actions happening just before a mesh is drawing.
  37516. */
  37517. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  37518. /**
  37519. * @hidden
  37520. * Defines the actions happening just after a mesh has been drawn.
  37521. */
  37522. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  37523. /**
  37524. * @hidden
  37525. * Defines the actions happening just after a rendering group has been drawn.
  37526. */
  37527. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  37528. /**
  37529. * @hidden
  37530. * Defines the actions happening just after the active camera has been drawn.
  37531. */
  37532. _afterCameraDrawStage: Stage<CameraStageAction>;
  37533. /**
  37534. * @hidden
  37535. * Defines the actions happening just after a render target has been drawn.
  37536. */
  37537. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  37538. /**
  37539. * @hidden
  37540. * Defines the actions happening just after rendering all cameras and computing intersections.
  37541. */
  37542. _afterRenderStage: Stage<SimpleStageAction>;
  37543. /**
  37544. * @hidden
  37545. * Defines the actions happening when a pointer move event happens.
  37546. */
  37547. _pointerMoveStage: Stage<PointerMoveStageAction>;
  37548. /**
  37549. * @hidden
  37550. * Defines the actions happening when a pointer down event happens.
  37551. */
  37552. _pointerDownStage: Stage<PointerUpDownStageAction>;
  37553. /**
  37554. * @hidden
  37555. * Defines the actions happening when a pointer up event happens.
  37556. */
  37557. _pointerUpStage: Stage<PointerUpDownStageAction>;
  37558. /**
  37559. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  37560. */
  37561. private geometriesByUniqueId;
  37562. /**
  37563. * Creates a new Scene
  37564. * @param engine defines the engine to use to render this scene
  37565. * @param options defines the scene options
  37566. */
  37567. constructor(engine: Engine, options?: SceneOptions);
  37568. /**
  37569. * Gets a string idenfifying the name of the class
  37570. * @returns "Scene" string
  37571. */
  37572. getClassName(): string;
  37573. private _defaultMeshCandidates;
  37574. /**
  37575. * @hidden
  37576. */
  37577. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  37578. private _defaultSubMeshCandidates;
  37579. /**
  37580. * @hidden
  37581. */
  37582. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  37583. /**
  37584. * Sets the default candidate providers for the scene.
  37585. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  37586. * and getCollidingSubMeshCandidates to their default function
  37587. */
  37588. setDefaultCandidateProviders(): void;
  37589. /**
  37590. * Gets the mesh that is currently under the pointer
  37591. */
  37592. get meshUnderPointer(): Nullable<AbstractMesh>;
  37593. /**
  37594. * Gets or sets the current on-screen X position of the pointer
  37595. */
  37596. get pointerX(): number;
  37597. set pointerX(value: number);
  37598. /**
  37599. * Gets or sets the current on-screen Y position of the pointer
  37600. */
  37601. get pointerY(): number;
  37602. set pointerY(value: number);
  37603. /**
  37604. * Gets the cached material (ie. the latest rendered one)
  37605. * @returns the cached material
  37606. */
  37607. getCachedMaterial(): Nullable<Material>;
  37608. /**
  37609. * Gets the cached effect (ie. the latest rendered one)
  37610. * @returns the cached effect
  37611. */
  37612. getCachedEffect(): Nullable<Effect>;
  37613. /**
  37614. * Gets the cached visibility state (ie. the latest rendered one)
  37615. * @returns the cached visibility state
  37616. */
  37617. getCachedVisibility(): Nullable<number>;
  37618. /**
  37619. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  37620. * @param material defines the current material
  37621. * @param effect defines the current effect
  37622. * @param visibility defines the current visibility state
  37623. * @returns true if one parameter is not cached
  37624. */
  37625. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  37626. /**
  37627. * Gets the engine associated with the scene
  37628. * @returns an Engine
  37629. */
  37630. getEngine(): Engine;
  37631. /**
  37632. * Gets the total number of vertices rendered per frame
  37633. * @returns the total number of vertices rendered per frame
  37634. */
  37635. getTotalVertices(): number;
  37636. /**
  37637. * Gets the performance counter for total vertices
  37638. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  37639. */
  37640. get totalVerticesPerfCounter(): PerfCounter;
  37641. /**
  37642. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  37643. * @returns the total number of active indices rendered per frame
  37644. */
  37645. getActiveIndices(): number;
  37646. /**
  37647. * Gets the performance counter for active indices
  37648. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  37649. */
  37650. get totalActiveIndicesPerfCounter(): PerfCounter;
  37651. /**
  37652. * Gets the total number of active particles rendered per frame
  37653. * @returns the total number of active particles rendered per frame
  37654. */
  37655. getActiveParticles(): number;
  37656. /**
  37657. * Gets the performance counter for active particles
  37658. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  37659. */
  37660. get activeParticlesPerfCounter(): PerfCounter;
  37661. /**
  37662. * Gets the total number of active bones rendered per frame
  37663. * @returns the total number of active bones rendered per frame
  37664. */
  37665. getActiveBones(): number;
  37666. /**
  37667. * Gets the performance counter for active bones
  37668. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  37669. */
  37670. get activeBonesPerfCounter(): PerfCounter;
  37671. /**
  37672. * Gets the array of active meshes
  37673. * @returns an array of AbstractMesh
  37674. */
  37675. getActiveMeshes(): SmartArray<AbstractMesh>;
  37676. /**
  37677. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  37678. * @returns a number
  37679. */
  37680. getAnimationRatio(): number;
  37681. /**
  37682. * Gets an unique Id for the current render phase
  37683. * @returns a number
  37684. */
  37685. getRenderId(): number;
  37686. /**
  37687. * Gets an unique Id for the current frame
  37688. * @returns a number
  37689. */
  37690. getFrameId(): number;
  37691. /** Call this function if you want to manually increment the render Id*/
  37692. incrementRenderId(): void;
  37693. private _createUbo;
  37694. /**
  37695. * Use this method to simulate a pointer move on a mesh
  37696. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  37697. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  37698. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  37699. * @returns the current scene
  37700. */
  37701. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  37702. /**
  37703. * Use this method to simulate a pointer down on a mesh
  37704. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  37705. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  37706. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  37707. * @returns the current scene
  37708. */
  37709. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  37710. /**
  37711. * Use this method to simulate a pointer up on a mesh
  37712. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  37713. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  37714. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  37715. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  37716. * @returns the current scene
  37717. */
  37718. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  37719. /**
  37720. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  37721. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  37722. * @returns true if the pointer was captured
  37723. */
  37724. isPointerCaptured(pointerId?: number): boolean;
  37725. /**
  37726. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  37727. * @param attachUp defines if you want to attach events to pointerup
  37728. * @param attachDown defines if you want to attach events to pointerdown
  37729. * @param attachMove defines if you want to attach events to pointermove
  37730. */
  37731. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  37732. /** Detaches all event handlers*/
  37733. detachControl(): void;
  37734. /**
  37735. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  37736. * Delay loaded resources are not taking in account
  37737. * @return true if all required resources are ready
  37738. */
  37739. isReady(): boolean;
  37740. /** Resets all cached information relative to material (including effect and visibility) */
  37741. resetCachedMaterial(): void;
  37742. /**
  37743. * Registers a function to be called before every frame render
  37744. * @param func defines the function to register
  37745. */
  37746. registerBeforeRender(func: () => void): void;
  37747. /**
  37748. * Unregisters a function called before every frame render
  37749. * @param func defines the function to unregister
  37750. */
  37751. unregisterBeforeRender(func: () => void): void;
  37752. /**
  37753. * Registers a function to be called after every frame render
  37754. * @param func defines the function to register
  37755. */
  37756. registerAfterRender(func: () => void): void;
  37757. /**
  37758. * Unregisters a function called after every frame render
  37759. * @param func defines the function to unregister
  37760. */
  37761. unregisterAfterRender(func: () => void): void;
  37762. private _executeOnceBeforeRender;
  37763. /**
  37764. * The provided function will run before render once and will be disposed afterwards.
  37765. * A timeout delay can be provided so that the function will be executed in N ms.
  37766. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  37767. * @param func The function to be executed.
  37768. * @param timeout optional delay in ms
  37769. */
  37770. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  37771. /** @hidden */
  37772. _addPendingData(data: any): void;
  37773. /** @hidden */
  37774. _removePendingData(data: any): void;
  37775. /**
  37776. * Returns the number of items waiting to be loaded
  37777. * @returns the number of items waiting to be loaded
  37778. */
  37779. getWaitingItemsCount(): number;
  37780. /**
  37781. * Returns a boolean indicating if the scene is still loading data
  37782. */
  37783. get isLoading(): boolean;
  37784. /**
  37785. * Registers a function to be executed when the scene is ready
  37786. * @param {Function} func - the function to be executed
  37787. */
  37788. executeWhenReady(func: () => void): void;
  37789. /**
  37790. * Returns a promise that resolves when the scene is ready
  37791. * @returns A promise that resolves when the scene is ready
  37792. */
  37793. whenReadyAsync(): Promise<void>;
  37794. /** @hidden */
  37795. _checkIsReady(): void;
  37796. /**
  37797. * Gets all animatable attached to the scene
  37798. */
  37799. get animatables(): Animatable[];
  37800. /**
  37801. * Resets the last animation time frame.
  37802. * Useful to override when animations start running when loading a scene for the first time.
  37803. */
  37804. resetLastAnimationTimeFrame(): void;
  37805. /**
  37806. * Gets the current view matrix
  37807. * @returns a Matrix
  37808. */
  37809. getViewMatrix(): Matrix;
  37810. /**
  37811. * Gets the current projection matrix
  37812. * @returns a Matrix
  37813. */
  37814. getProjectionMatrix(): Matrix;
  37815. /**
  37816. * Gets the current transform matrix
  37817. * @returns a Matrix made of View * Projection
  37818. */
  37819. getTransformMatrix(): Matrix;
  37820. /**
  37821. * Sets the current transform matrix
  37822. * @param viewL defines the View matrix to use
  37823. * @param projectionL defines the Projection matrix to use
  37824. * @param viewR defines the right View matrix to use (if provided)
  37825. * @param projectionR defines the right Projection matrix to use (if provided)
  37826. */
  37827. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  37828. /**
  37829. * Gets the uniform buffer used to store scene data
  37830. * @returns a UniformBuffer
  37831. */
  37832. getSceneUniformBuffer(): UniformBuffer;
  37833. /**
  37834. * Gets an unique (relatively to the current scene) Id
  37835. * @returns an unique number for the scene
  37836. */
  37837. getUniqueId(): number;
  37838. /**
  37839. * Add a mesh to the list of scene's meshes
  37840. * @param newMesh defines the mesh to add
  37841. * @param recursive if all child meshes should also be added to the scene
  37842. */
  37843. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  37844. /**
  37845. * Remove a mesh for the list of scene's meshes
  37846. * @param toRemove defines the mesh to remove
  37847. * @param recursive if all child meshes should also be removed from the scene
  37848. * @returns the index where the mesh was in the mesh list
  37849. */
  37850. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  37851. /**
  37852. * Add a transform node to the list of scene's transform nodes
  37853. * @param newTransformNode defines the transform node to add
  37854. */
  37855. addTransformNode(newTransformNode: TransformNode): void;
  37856. /**
  37857. * Remove a transform node for the list of scene's transform nodes
  37858. * @param toRemove defines the transform node to remove
  37859. * @returns the index where the transform node was in the transform node list
  37860. */
  37861. removeTransformNode(toRemove: TransformNode): number;
  37862. /**
  37863. * Remove a skeleton for the list of scene's skeletons
  37864. * @param toRemove defines the skeleton to remove
  37865. * @returns the index where the skeleton was in the skeleton list
  37866. */
  37867. removeSkeleton(toRemove: Skeleton): number;
  37868. /**
  37869. * Remove a morph target for the list of scene's morph targets
  37870. * @param toRemove defines the morph target to remove
  37871. * @returns the index where the morph target was in the morph target list
  37872. */
  37873. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  37874. /**
  37875. * Remove a light for the list of scene's lights
  37876. * @param toRemove defines the light to remove
  37877. * @returns the index where the light was in the light list
  37878. */
  37879. removeLight(toRemove: Light): number;
  37880. /**
  37881. * Remove a camera for the list of scene's cameras
  37882. * @param toRemove defines the camera to remove
  37883. * @returns the index where the camera was in the camera list
  37884. */
  37885. removeCamera(toRemove: Camera): number;
  37886. /**
  37887. * Remove a particle system for the list of scene's particle systems
  37888. * @param toRemove defines the particle system to remove
  37889. * @returns the index where the particle system was in the particle system list
  37890. */
  37891. removeParticleSystem(toRemove: IParticleSystem): number;
  37892. /**
  37893. * Remove a animation for the list of scene's animations
  37894. * @param toRemove defines the animation to remove
  37895. * @returns the index where the animation was in the animation list
  37896. */
  37897. removeAnimation(toRemove: Animation): number;
  37898. /**
  37899. * Will stop the animation of the given target
  37900. * @param target - the target
  37901. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  37902. * @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)
  37903. */
  37904. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  37905. /**
  37906. * Removes the given animation group from this scene.
  37907. * @param toRemove The animation group to remove
  37908. * @returns The index of the removed animation group
  37909. */
  37910. removeAnimationGroup(toRemove: AnimationGroup): number;
  37911. /**
  37912. * Removes the given multi-material from this scene.
  37913. * @param toRemove The multi-material to remove
  37914. * @returns The index of the removed multi-material
  37915. */
  37916. removeMultiMaterial(toRemove: MultiMaterial): number;
  37917. /**
  37918. * Removes the given material from this scene.
  37919. * @param toRemove The material to remove
  37920. * @returns The index of the removed material
  37921. */
  37922. removeMaterial(toRemove: Material): number;
  37923. /**
  37924. * Removes the given action manager from this scene.
  37925. * @param toRemove The action manager to remove
  37926. * @returns The index of the removed action manager
  37927. */
  37928. removeActionManager(toRemove: AbstractActionManager): number;
  37929. /**
  37930. * Removes the given texture from this scene.
  37931. * @param toRemove The texture to remove
  37932. * @returns The index of the removed texture
  37933. */
  37934. removeTexture(toRemove: BaseTexture): number;
  37935. /**
  37936. * Adds the given light to this scene
  37937. * @param newLight The light to add
  37938. */
  37939. addLight(newLight: Light): void;
  37940. /**
  37941. * Sorts the list list based on light priorities
  37942. */
  37943. sortLightsByPriority(): void;
  37944. /**
  37945. * Adds the given camera to this scene
  37946. * @param newCamera The camera to add
  37947. */
  37948. addCamera(newCamera: Camera): void;
  37949. /**
  37950. * Adds the given skeleton to this scene
  37951. * @param newSkeleton The skeleton to add
  37952. */
  37953. addSkeleton(newSkeleton: Skeleton): void;
  37954. /**
  37955. * Adds the given particle system to this scene
  37956. * @param newParticleSystem The particle system to add
  37957. */
  37958. addParticleSystem(newParticleSystem: IParticleSystem): void;
  37959. /**
  37960. * Adds the given animation to this scene
  37961. * @param newAnimation The animation to add
  37962. */
  37963. addAnimation(newAnimation: Animation): void;
  37964. /**
  37965. * Adds the given animation group to this scene.
  37966. * @param newAnimationGroup The animation group to add
  37967. */
  37968. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  37969. /**
  37970. * Adds the given multi-material to this scene
  37971. * @param newMultiMaterial The multi-material to add
  37972. */
  37973. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  37974. /**
  37975. * Adds the given material to this scene
  37976. * @param newMaterial The material to add
  37977. */
  37978. addMaterial(newMaterial: Material): void;
  37979. /**
  37980. * Adds the given morph target to this scene
  37981. * @param newMorphTargetManager The morph target to add
  37982. */
  37983. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  37984. /**
  37985. * Adds the given geometry to this scene
  37986. * @param newGeometry The geometry to add
  37987. */
  37988. addGeometry(newGeometry: Geometry): void;
  37989. /**
  37990. * Adds the given action manager to this scene
  37991. * @param newActionManager The action manager to add
  37992. */
  37993. addActionManager(newActionManager: AbstractActionManager): void;
  37994. /**
  37995. * Adds the given texture to this scene.
  37996. * @param newTexture The texture to add
  37997. */
  37998. addTexture(newTexture: BaseTexture): void;
  37999. /**
  38000. * Switch active camera
  38001. * @param newCamera defines the new active camera
  38002. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  38003. */
  38004. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  38005. /**
  38006. * sets the active camera of the scene using its ID
  38007. * @param id defines the camera's ID
  38008. * @return the new active camera or null if none found.
  38009. */
  38010. setActiveCameraByID(id: string): Nullable<Camera>;
  38011. /**
  38012. * sets the active camera of the scene using its name
  38013. * @param name defines the camera's name
  38014. * @returns the new active camera or null if none found.
  38015. */
  38016. setActiveCameraByName(name: string): Nullable<Camera>;
  38017. /**
  38018. * get an animation group using its name
  38019. * @param name defines the material's name
  38020. * @return the animation group or null if none found.
  38021. */
  38022. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  38023. /**
  38024. * Get a material using its unique id
  38025. * @param uniqueId defines the material's unique id
  38026. * @return the material or null if none found.
  38027. */
  38028. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  38029. /**
  38030. * get a material using its id
  38031. * @param id defines the material's ID
  38032. * @return the material or null if none found.
  38033. */
  38034. getMaterialByID(id: string): Nullable<Material>;
  38035. /**
  38036. * Gets a the last added material using a given id
  38037. * @param id defines the material's ID
  38038. * @return the last material with the given id or null if none found.
  38039. */
  38040. getLastMaterialByID(id: string): Nullable<Material>;
  38041. /**
  38042. * Gets a material using its name
  38043. * @param name defines the material's name
  38044. * @return the material or null if none found.
  38045. */
  38046. getMaterialByName(name: string): Nullable<Material>;
  38047. /**
  38048. * Get a texture using its unique id
  38049. * @param uniqueId defines the texture's unique id
  38050. * @return the texture or null if none found.
  38051. */
  38052. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  38053. /**
  38054. * Gets a camera using its id
  38055. * @param id defines the id to look for
  38056. * @returns the camera or null if not found
  38057. */
  38058. getCameraByID(id: string): Nullable<Camera>;
  38059. /**
  38060. * Gets a camera using its unique id
  38061. * @param uniqueId defines the unique id to look for
  38062. * @returns the camera or null if not found
  38063. */
  38064. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  38065. /**
  38066. * Gets a camera using its name
  38067. * @param name defines the camera's name
  38068. * @return the camera or null if none found.
  38069. */
  38070. getCameraByName(name: string): Nullable<Camera>;
  38071. /**
  38072. * Gets a bone using its id
  38073. * @param id defines the bone's id
  38074. * @return the bone or null if not found
  38075. */
  38076. getBoneByID(id: string): Nullable<Bone>;
  38077. /**
  38078. * Gets a bone using its id
  38079. * @param name defines the bone's name
  38080. * @return the bone or null if not found
  38081. */
  38082. getBoneByName(name: string): Nullable<Bone>;
  38083. /**
  38084. * Gets a light node using its name
  38085. * @param name defines the the light's name
  38086. * @return the light or null if none found.
  38087. */
  38088. getLightByName(name: string): Nullable<Light>;
  38089. /**
  38090. * Gets a light node using its id
  38091. * @param id defines the light's id
  38092. * @return the light or null if none found.
  38093. */
  38094. getLightByID(id: string): Nullable<Light>;
  38095. /**
  38096. * Gets a light node using its scene-generated unique ID
  38097. * @param uniqueId defines the light's unique id
  38098. * @return the light or null if none found.
  38099. */
  38100. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  38101. /**
  38102. * Gets a particle system by id
  38103. * @param id defines the particle system id
  38104. * @return the corresponding system or null if none found
  38105. */
  38106. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  38107. /**
  38108. * Gets a geometry using its ID
  38109. * @param id defines the geometry's id
  38110. * @return the geometry or null if none found.
  38111. */
  38112. getGeometryByID(id: string): Nullable<Geometry>;
  38113. private _getGeometryByUniqueID;
  38114. /**
  38115. * Add a new geometry to this scene
  38116. * @param geometry defines the geometry to be added to the scene.
  38117. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  38118. * @return a boolean defining if the geometry was added or not
  38119. */
  38120. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  38121. /**
  38122. * Removes an existing geometry
  38123. * @param geometry defines the geometry to be removed from the scene
  38124. * @return a boolean defining if the geometry was removed or not
  38125. */
  38126. removeGeometry(geometry: Geometry): boolean;
  38127. /**
  38128. * Gets the list of geometries attached to the scene
  38129. * @returns an array of Geometry
  38130. */
  38131. getGeometries(): Geometry[];
  38132. /**
  38133. * Gets the first added mesh found of a given ID
  38134. * @param id defines the id to search for
  38135. * @return the mesh found or null if not found at all
  38136. */
  38137. getMeshByID(id: string): Nullable<AbstractMesh>;
  38138. /**
  38139. * Gets a list of meshes using their id
  38140. * @param id defines the id to search for
  38141. * @returns a list of meshes
  38142. */
  38143. getMeshesByID(id: string): Array<AbstractMesh>;
  38144. /**
  38145. * Gets the first added transform node found of a given ID
  38146. * @param id defines the id to search for
  38147. * @return the found transform node or null if not found at all.
  38148. */
  38149. getTransformNodeByID(id: string): Nullable<TransformNode>;
  38150. /**
  38151. * Gets a transform node with its auto-generated unique id
  38152. * @param uniqueId efines the unique id to search for
  38153. * @return the found transform node or null if not found at all.
  38154. */
  38155. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  38156. /**
  38157. * Gets a list of transform nodes using their id
  38158. * @param id defines the id to search for
  38159. * @returns a list of transform nodes
  38160. */
  38161. getTransformNodesByID(id: string): Array<TransformNode>;
  38162. /**
  38163. * Gets a mesh with its auto-generated unique id
  38164. * @param uniqueId defines the unique id to search for
  38165. * @return the found mesh or null if not found at all.
  38166. */
  38167. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  38168. /**
  38169. * Gets a the last added mesh using a given id
  38170. * @param id defines the id to search for
  38171. * @return the found mesh or null if not found at all.
  38172. */
  38173. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  38174. /**
  38175. * Gets a the last added node (Mesh, Camera, Light) using a given id
  38176. * @param id defines the id to search for
  38177. * @return the found node or null if not found at all
  38178. */
  38179. getLastEntryByID(id: string): Nullable<Node>;
  38180. /**
  38181. * Gets a node (Mesh, Camera, Light) using a given id
  38182. * @param id defines the id to search for
  38183. * @return the found node or null if not found at all
  38184. */
  38185. getNodeByID(id: string): Nullable<Node>;
  38186. /**
  38187. * Gets a node (Mesh, Camera, Light) using a given name
  38188. * @param name defines the name to search for
  38189. * @return the found node or null if not found at all.
  38190. */
  38191. getNodeByName(name: string): Nullable<Node>;
  38192. /**
  38193. * Gets a mesh using a given name
  38194. * @param name defines the name to search for
  38195. * @return the found mesh or null if not found at all.
  38196. */
  38197. getMeshByName(name: string): Nullable<AbstractMesh>;
  38198. /**
  38199. * Gets a transform node using a given name
  38200. * @param name defines the name to search for
  38201. * @return the found transform node or null if not found at all.
  38202. */
  38203. getTransformNodeByName(name: string): Nullable<TransformNode>;
  38204. /**
  38205. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  38206. * @param id defines the id to search for
  38207. * @return the found skeleton or null if not found at all.
  38208. */
  38209. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  38210. /**
  38211. * Gets a skeleton using a given auto generated unique id
  38212. * @param uniqueId defines the unique id to search for
  38213. * @return the found skeleton or null if not found at all.
  38214. */
  38215. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  38216. /**
  38217. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  38218. * @param id defines the id to search for
  38219. * @return the found skeleton or null if not found at all.
  38220. */
  38221. getSkeletonById(id: string): Nullable<Skeleton>;
  38222. /**
  38223. * Gets a skeleton using a given name
  38224. * @param name defines the name to search for
  38225. * @return the found skeleton or null if not found at all.
  38226. */
  38227. getSkeletonByName(name: string): Nullable<Skeleton>;
  38228. /**
  38229. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  38230. * @param id defines the id to search for
  38231. * @return the found morph target manager or null if not found at all.
  38232. */
  38233. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  38234. /**
  38235. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  38236. * @param id defines the id to search for
  38237. * @return the found morph target or null if not found at all.
  38238. */
  38239. getMorphTargetById(id: string): Nullable<MorphTarget>;
  38240. /**
  38241. * Gets a morph target using a given name (if many are found, this function will pick the first one)
  38242. * @param name defines the name to search for
  38243. * @return the found morph target or null if not found at all.
  38244. */
  38245. getMorphTargetByName(name: string): Nullable<MorphTarget>;
  38246. /**
  38247. * Gets a boolean indicating if the given mesh is active
  38248. * @param mesh defines the mesh to look for
  38249. * @returns true if the mesh is in the active list
  38250. */
  38251. isActiveMesh(mesh: AbstractMesh): boolean;
  38252. /**
  38253. * Return a unique id as a string which can serve as an identifier for the scene
  38254. */
  38255. get uid(): string;
  38256. /**
  38257. * Add an externaly attached data from its key.
  38258. * This method call will fail and return false, if such key already exists.
  38259. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  38260. * @param key the unique key that identifies the data
  38261. * @param data the data object to associate to the key for this Engine instance
  38262. * @return true if no such key were already present and the data was added successfully, false otherwise
  38263. */
  38264. addExternalData<T>(key: string, data: T): boolean;
  38265. /**
  38266. * Get an externaly attached data from its key
  38267. * @param key the unique key that identifies the data
  38268. * @return the associated data, if present (can be null), or undefined if not present
  38269. */
  38270. getExternalData<T>(key: string): Nullable<T>;
  38271. /**
  38272. * Get an externaly attached data from its key, create it using a factory if it's not already present
  38273. * @param key the unique key that identifies the data
  38274. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  38275. * @return the associated data, can be null if the factory returned null.
  38276. */
  38277. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  38278. /**
  38279. * Remove an externaly attached data from the Engine instance
  38280. * @param key the unique key that identifies the data
  38281. * @return true if the data was successfully removed, false if it doesn't exist
  38282. */
  38283. removeExternalData(key: string): boolean;
  38284. private _evaluateSubMesh;
  38285. /**
  38286. * Clear the processed materials smart array preventing retention point in material dispose.
  38287. */
  38288. freeProcessedMaterials(): void;
  38289. private _preventFreeActiveMeshesAndRenderingGroups;
  38290. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  38291. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  38292. * when disposing several meshes in a row or a hierarchy of meshes.
  38293. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  38294. */
  38295. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  38296. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  38297. /**
  38298. * Clear the active meshes smart array preventing retention point in mesh dispose.
  38299. */
  38300. freeActiveMeshes(): void;
  38301. /**
  38302. * Clear the info related to rendering groups preventing retention points during dispose.
  38303. */
  38304. freeRenderingGroups(): void;
  38305. /** @hidden */
  38306. _isInIntermediateRendering(): boolean;
  38307. /**
  38308. * Lambda returning the list of potentially active meshes.
  38309. */
  38310. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  38311. /**
  38312. * Lambda returning the list of potentially active sub meshes.
  38313. */
  38314. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  38315. /**
  38316. * Lambda returning the list of potentially intersecting sub meshes.
  38317. */
  38318. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  38319. /**
  38320. * Lambda returning the list of potentially colliding sub meshes.
  38321. */
  38322. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  38323. private _activeMeshesFrozen;
  38324. private _skipEvaluateActiveMeshesCompletely;
  38325. /**
  38326. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  38327. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  38328. * @returns the current scene
  38329. */
  38330. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean): Scene;
  38331. /**
  38332. * Use this function to restart evaluating active meshes on every frame
  38333. * @returns the current scene
  38334. */
  38335. unfreezeActiveMeshes(): Scene;
  38336. private _evaluateActiveMeshes;
  38337. private _activeMesh;
  38338. /**
  38339. * Update the transform matrix to update from the current active camera
  38340. * @param force defines a boolean used to force the update even if cache is up to date
  38341. */
  38342. updateTransformMatrix(force?: boolean): void;
  38343. private _bindFrameBuffer;
  38344. /** @hidden */
  38345. _allowPostProcessClearColor: boolean;
  38346. /** @hidden */
  38347. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  38348. private _processSubCameras;
  38349. private _checkIntersections;
  38350. /** @hidden */
  38351. _advancePhysicsEngineStep(step: number): void;
  38352. /**
  38353. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  38354. */
  38355. getDeterministicFrameTime: () => number;
  38356. /** @hidden */
  38357. _animate(): void;
  38358. /** Execute all animations (for a frame) */
  38359. animate(): void;
  38360. /**
  38361. * Render the scene
  38362. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  38363. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  38364. */
  38365. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  38366. /**
  38367. * Freeze all materials
  38368. * A frozen material will not be updatable but should be faster to render
  38369. */
  38370. freezeMaterials(): void;
  38371. /**
  38372. * Unfreeze all materials
  38373. * A frozen material will not be updatable but should be faster to render
  38374. */
  38375. unfreezeMaterials(): void;
  38376. /**
  38377. * Releases all held ressources
  38378. */
  38379. dispose(): void;
  38380. /**
  38381. * Gets if the scene is already disposed
  38382. */
  38383. get isDisposed(): boolean;
  38384. /**
  38385. * Call this function to reduce memory footprint of the scene.
  38386. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  38387. */
  38388. clearCachedVertexData(): void;
  38389. /**
  38390. * This function will remove the local cached buffer data from texture.
  38391. * It will save memory but will prevent the texture from being rebuilt
  38392. */
  38393. cleanCachedTextureBuffer(): void;
  38394. /**
  38395. * Get the world extend vectors with an optional filter
  38396. *
  38397. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  38398. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  38399. */
  38400. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  38401. min: Vector3;
  38402. max: Vector3;
  38403. };
  38404. /**
  38405. * Creates a ray that can be used to pick in the scene
  38406. * @param x defines the x coordinate of the origin (on-screen)
  38407. * @param y defines the y coordinate of the origin (on-screen)
  38408. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  38409. * @param camera defines the camera to use for the picking
  38410. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  38411. * @returns a Ray
  38412. */
  38413. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  38414. /**
  38415. * Creates a ray that can be used to pick in the scene
  38416. * @param x defines the x coordinate of the origin (on-screen)
  38417. * @param y defines the y coordinate of the origin (on-screen)
  38418. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  38419. * @param result defines the ray where to store the picking ray
  38420. * @param camera defines the camera to use for the picking
  38421. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  38422. * @returns the current scene
  38423. */
  38424. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  38425. /**
  38426. * Creates a ray that can be used to pick in the scene
  38427. * @param x defines the x coordinate of the origin (on-screen)
  38428. * @param y defines the y coordinate of the origin (on-screen)
  38429. * @param camera defines the camera to use for the picking
  38430. * @returns a Ray
  38431. */
  38432. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  38433. /**
  38434. * Creates a ray that can be used to pick in the scene
  38435. * @param x defines the x coordinate of the origin (on-screen)
  38436. * @param y defines the y coordinate of the origin (on-screen)
  38437. * @param result defines the ray where to store the picking ray
  38438. * @param camera defines the camera to use for the picking
  38439. * @returns the current scene
  38440. */
  38441. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  38442. /** Launch a ray to try to pick a mesh in the scene
  38443. * @param x position on screen
  38444. * @param y position on screen
  38445. * @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
  38446. * @param fastCheck defines if the first intersection will be used (and not the closest)
  38447. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  38448. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  38449. * @returns a PickingInfo
  38450. */
  38451. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  38452. /** Launch a ray to try to pick a mesh in the scene using only bounding information of the main mesh (not using submeshes)
  38453. * @param x position on screen
  38454. * @param y position on screen
  38455. * @param predicate Predicate function used to determine eligible meshes. Can be set to null. In this case, a mesh must be enabled, visible and with isPickable set to true
  38456. * @param fastCheck defines if the first intersection will be used (and not the closest)
  38457. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  38458. * @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)
  38459. */
  38460. pickWithBoundingInfo(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  38461. /** Use the given ray to pick a mesh in the scene
  38462. * @param ray The ray to use to pick meshes
  38463. * @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
  38464. * @param fastCheck defines if the first intersection will be used (and not the closest)
  38465. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  38466. * @returns a PickingInfo
  38467. */
  38468. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  38469. /**
  38470. * Launch a ray to try to pick a mesh in the scene
  38471. * @param x X position on screen
  38472. * @param y Y position on screen
  38473. * @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
  38474. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  38475. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  38476. * @returns an array of PickingInfo
  38477. */
  38478. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  38479. /**
  38480. * Launch a ray to try to pick a mesh in the scene
  38481. * @param ray Ray to use
  38482. * @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
  38483. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  38484. * @returns an array of PickingInfo
  38485. */
  38486. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  38487. /**
  38488. * Force the value of meshUnderPointer
  38489. * @param mesh defines the mesh to use
  38490. */
  38491. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  38492. /**
  38493. * Gets the mesh under the pointer
  38494. * @returns a Mesh or null if no mesh is under the pointer
  38495. */
  38496. getPointerOverMesh(): Nullable<AbstractMesh>;
  38497. /** @hidden */
  38498. _rebuildGeometries(): void;
  38499. /** @hidden */
  38500. _rebuildTextures(): void;
  38501. private _getByTags;
  38502. /**
  38503. * Get a list of meshes by tags
  38504. * @param tagsQuery defines the tags query to use
  38505. * @param forEach defines a predicate used to filter results
  38506. * @returns an array of Mesh
  38507. */
  38508. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  38509. /**
  38510. * Get a list of cameras by tags
  38511. * @param tagsQuery defines the tags query to use
  38512. * @param forEach defines a predicate used to filter results
  38513. * @returns an array of Camera
  38514. */
  38515. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  38516. /**
  38517. * Get a list of lights by tags
  38518. * @param tagsQuery defines the tags query to use
  38519. * @param forEach defines a predicate used to filter results
  38520. * @returns an array of Light
  38521. */
  38522. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  38523. /**
  38524. * Get a list of materials by tags
  38525. * @param tagsQuery defines the tags query to use
  38526. * @param forEach defines a predicate used to filter results
  38527. * @returns an array of Material
  38528. */
  38529. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  38530. /**
  38531. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  38532. * This allowed control for front to back rendering or reversly depending of the special needs.
  38533. *
  38534. * @param renderingGroupId The rendering group id corresponding to its index
  38535. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  38536. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  38537. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  38538. */
  38539. 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;
  38540. /**
  38541. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  38542. *
  38543. * @param renderingGroupId The rendering group id corresponding to its index
  38544. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  38545. * @param depth Automatically clears depth between groups if true and autoClear is true.
  38546. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  38547. */
  38548. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  38549. /**
  38550. * Gets the current auto clear configuration for one rendering group of the rendering
  38551. * manager.
  38552. * @param index the rendering group index to get the information for
  38553. * @returns The auto clear setup for the requested rendering group
  38554. */
  38555. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  38556. private _blockMaterialDirtyMechanism;
  38557. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  38558. get blockMaterialDirtyMechanism(): boolean;
  38559. set blockMaterialDirtyMechanism(value: boolean);
  38560. /**
  38561. * Will flag all materials as dirty to trigger new shader compilation
  38562. * @param flag defines the flag used to specify which material part must be marked as dirty
  38563. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  38564. */
  38565. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  38566. /** @hidden */
  38567. _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;
  38568. /** @hidden */
  38569. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  38570. /** @hidden */
  38571. _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;
  38572. /** @hidden */
  38573. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  38574. /** @hidden */
  38575. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  38576. /** @hidden */
  38577. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  38578. }
  38579. }
  38580. declare module "babylonjs/assetContainer" {
  38581. import { AbstractScene } from "babylonjs/abstractScene";
  38582. import { Scene } from "babylonjs/scene";
  38583. import { Mesh } from "babylonjs/Meshes/mesh";
  38584. import { TransformNode } from "babylonjs/Meshes/transformNode";
  38585. import { Skeleton } from "babylonjs/Bones/skeleton";
  38586. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  38587. import { Animatable } from "babylonjs/Animations/animatable";
  38588. import { Nullable } from "babylonjs/types";
  38589. import { Node } from "babylonjs/node";
  38590. /**
  38591. * Set of assets to keep when moving a scene into an asset container.
  38592. */
  38593. export class KeepAssets extends AbstractScene {
  38594. }
  38595. /**
  38596. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  38597. */
  38598. export class InstantiatedEntries {
  38599. /**
  38600. * List of new root nodes (eg. nodes with no parent)
  38601. */
  38602. rootNodes: TransformNode[];
  38603. /**
  38604. * List of new skeletons
  38605. */
  38606. skeletons: Skeleton[];
  38607. /**
  38608. * List of new animation groups
  38609. */
  38610. animationGroups: AnimationGroup[];
  38611. }
  38612. /**
  38613. * Container with a set of assets that can be added or removed from a scene.
  38614. */
  38615. export class AssetContainer extends AbstractScene {
  38616. private _wasAddedToScene;
  38617. /**
  38618. * The scene the AssetContainer belongs to.
  38619. */
  38620. scene: Scene;
  38621. /**
  38622. * Instantiates an AssetContainer.
  38623. * @param scene The scene the AssetContainer belongs to.
  38624. */
  38625. constructor(scene: Scene);
  38626. /**
  38627. * Instantiate or clone all meshes and add the new ones to the scene.
  38628. * Skeletons and animation groups will all be cloned
  38629. * @param nameFunction defines an optional function used to get new names for clones
  38630. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  38631. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  38632. */
  38633. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  38634. /**
  38635. * Adds all the assets from the container to the scene.
  38636. */
  38637. addAllToScene(): void;
  38638. /**
  38639. * Removes all the assets in the container from the scene
  38640. */
  38641. removeAllFromScene(): void;
  38642. /**
  38643. * Disposes all the assets in the container
  38644. */
  38645. dispose(): void;
  38646. private _moveAssets;
  38647. /**
  38648. * Removes all the assets contained in the scene and adds them to the container.
  38649. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  38650. */
  38651. moveAllFromScene(keepAssets?: KeepAssets): void;
  38652. /**
  38653. * 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.
  38654. * @returns the root mesh
  38655. */
  38656. createRootMesh(): Mesh;
  38657. /**
  38658. * Merge animations (direct and animation groups) from this asset container into a scene
  38659. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  38660. * @param animatables set of animatables to retarget to a node from the scene
  38661. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  38662. * @returns an array of the new AnimationGroup added to the scene (empty array if none)
  38663. */
  38664. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): AnimationGroup[];
  38665. }
  38666. }
  38667. declare module "babylonjs/abstractScene" {
  38668. import { Scene } from "babylonjs/scene";
  38669. import { Nullable } from "babylonjs/types";
  38670. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38671. import { TransformNode } from "babylonjs/Meshes/transformNode";
  38672. import { Geometry } from "babylonjs/Meshes/geometry";
  38673. import { Skeleton } from "babylonjs/Bones/skeleton";
  38674. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  38675. import { AssetContainer } from "babylonjs/assetContainer";
  38676. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  38677. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  38678. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  38679. import { Material } from "babylonjs/Materials/material";
  38680. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  38681. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  38682. import { Camera } from "babylonjs/Cameras/camera";
  38683. import { Light } from "babylonjs/Lights/light";
  38684. import { Node } from "babylonjs/node";
  38685. import { Animation } from "babylonjs/Animations/animation";
  38686. /**
  38687. * Defines how the parser contract is defined.
  38688. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  38689. */
  38690. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  38691. /**
  38692. * Defines how the individual parser contract is defined.
  38693. * These parser can parse an individual asset
  38694. */
  38695. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  38696. /**
  38697. * Base class of the scene acting as a container for the different elements composing a scene.
  38698. * This class is dynamically extended by the different components of the scene increasing
  38699. * flexibility and reducing coupling
  38700. */
  38701. export abstract class AbstractScene {
  38702. /**
  38703. * Stores the list of available parsers in the application.
  38704. */
  38705. private static _BabylonFileParsers;
  38706. /**
  38707. * Stores the list of available individual parsers in the application.
  38708. */
  38709. private static _IndividualBabylonFileParsers;
  38710. /**
  38711. * Adds a parser in the list of available ones
  38712. * @param name Defines the name of the parser
  38713. * @param parser Defines the parser to add
  38714. */
  38715. static AddParser(name: string, parser: BabylonFileParser): void;
  38716. /**
  38717. * Gets a general parser from the list of avaialble ones
  38718. * @param name Defines the name of the parser
  38719. * @returns the requested parser or null
  38720. */
  38721. static GetParser(name: string): Nullable<BabylonFileParser>;
  38722. /**
  38723. * Adds n individual parser in the list of available ones
  38724. * @param name Defines the name of the parser
  38725. * @param parser Defines the parser to add
  38726. */
  38727. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  38728. /**
  38729. * Gets an individual parser from the list of avaialble ones
  38730. * @param name Defines the name of the parser
  38731. * @returns the requested parser or null
  38732. */
  38733. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  38734. /**
  38735. * Parser json data and populate both a scene and its associated container object
  38736. * @param jsonData Defines the data to parse
  38737. * @param scene Defines the scene to parse the data for
  38738. * @param container Defines the container attached to the parsing sequence
  38739. * @param rootUrl Defines the root url of the data
  38740. */
  38741. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  38742. /**
  38743. * Gets the list of root nodes (ie. nodes with no parent)
  38744. */
  38745. rootNodes: Node[];
  38746. /** All of the cameras added to this scene
  38747. * @see http://doc.babylonjs.com/babylon101/cameras
  38748. */
  38749. cameras: Camera[];
  38750. /**
  38751. * All of the lights added to this scene
  38752. * @see http://doc.babylonjs.com/babylon101/lights
  38753. */
  38754. lights: Light[];
  38755. /**
  38756. * All of the (abstract) meshes added to this scene
  38757. */
  38758. meshes: AbstractMesh[];
  38759. /**
  38760. * The list of skeletons added to the scene
  38761. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  38762. */
  38763. skeletons: Skeleton[];
  38764. /**
  38765. * All of the particle systems added to this scene
  38766. * @see http://doc.babylonjs.com/babylon101/particles
  38767. */
  38768. particleSystems: IParticleSystem[];
  38769. /**
  38770. * Gets a list of Animations associated with the scene
  38771. */
  38772. animations: Animation[];
  38773. /**
  38774. * All of the animation groups added to this scene
  38775. * @see http://doc.babylonjs.com/how_to/group
  38776. */
  38777. animationGroups: AnimationGroup[];
  38778. /**
  38779. * All of the multi-materials added to this scene
  38780. * @see http://doc.babylonjs.com/how_to/multi_materials
  38781. */
  38782. multiMaterials: MultiMaterial[];
  38783. /**
  38784. * All of the materials added to this scene
  38785. * In the context of a Scene, it is not supposed to be modified manually.
  38786. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  38787. * Note also that the order of the Material within the array is not significant and might change.
  38788. * @see http://doc.babylonjs.com/babylon101/materials
  38789. */
  38790. materials: Material[];
  38791. /**
  38792. * The list of morph target managers added to the scene
  38793. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  38794. */
  38795. morphTargetManagers: MorphTargetManager[];
  38796. /**
  38797. * The list of geometries used in the scene.
  38798. */
  38799. geometries: Geometry[];
  38800. /**
  38801. * All of the tranform nodes added to this scene
  38802. * In the context of a Scene, it is not supposed to be modified manually.
  38803. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  38804. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  38805. * @see http://doc.babylonjs.com/how_to/transformnode
  38806. */
  38807. transformNodes: TransformNode[];
  38808. /**
  38809. * ActionManagers available on the scene.
  38810. */
  38811. actionManagers: AbstractActionManager[];
  38812. /**
  38813. * Textures to keep.
  38814. */
  38815. textures: BaseTexture[];
  38816. /**
  38817. * Environment texture for the scene
  38818. */
  38819. environmentTexture: Nullable<BaseTexture>;
  38820. /**
  38821. * @returns all meshes, lights, cameras, transformNodes and bones
  38822. */
  38823. getNodes(): Array<Node>;
  38824. }
  38825. }
  38826. declare module "babylonjs/Audio/sound" {
  38827. import { Observable } from "babylonjs/Misc/observable";
  38828. import { Vector3 } from "babylonjs/Maths/math.vector";
  38829. import { Nullable } from "babylonjs/types";
  38830. import { Scene } from "babylonjs/scene";
  38831. import { TransformNode } from "babylonjs/Meshes/transformNode";
  38832. /**
  38833. * Interface used to define options for Sound class
  38834. */
  38835. export interface ISoundOptions {
  38836. /**
  38837. * Does the sound autoplay once loaded.
  38838. */
  38839. autoplay?: boolean;
  38840. /**
  38841. * Does the sound loop after it finishes playing once.
  38842. */
  38843. loop?: boolean;
  38844. /**
  38845. * Sound's volume
  38846. */
  38847. volume?: number;
  38848. /**
  38849. * Is it a spatial sound?
  38850. */
  38851. spatialSound?: boolean;
  38852. /**
  38853. * Maximum distance to hear that sound
  38854. */
  38855. maxDistance?: number;
  38856. /**
  38857. * Uses user defined attenuation function
  38858. */
  38859. useCustomAttenuation?: boolean;
  38860. /**
  38861. * Define the roll off factor of spatial sounds.
  38862. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38863. */
  38864. rolloffFactor?: number;
  38865. /**
  38866. * Define the reference distance the sound should be heard perfectly.
  38867. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38868. */
  38869. refDistance?: number;
  38870. /**
  38871. * Define the distance attenuation model the sound will follow.
  38872. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38873. */
  38874. distanceModel?: string;
  38875. /**
  38876. * Defines the playback speed (1 by default)
  38877. */
  38878. playbackRate?: number;
  38879. /**
  38880. * Defines if the sound is from a streaming source
  38881. */
  38882. streaming?: boolean;
  38883. /**
  38884. * Defines an optional length (in seconds) inside the sound file
  38885. */
  38886. length?: number;
  38887. /**
  38888. * Defines an optional offset (in seconds) inside the sound file
  38889. */
  38890. offset?: number;
  38891. /**
  38892. * If true, URLs will not be required to state the audio file codec to use.
  38893. */
  38894. skipCodecCheck?: boolean;
  38895. }
  38896. /**
  38897. * Defines a sound that can be played in the application.
  38898. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  38899. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  38900. */
  38901. export class Sound {
  38902. /**
  38903. * The name of the sound in the scene.
  38904. */
  38905. name: string;
  38906. /**
  38907. * Does the sound autoplay once loaded.
  38908. */
  38909. autoplay: boolean;
  38910. /**
  38911. * Does the sound loop after it finishes playing once.
  38912. */
  38913. loop: boolean;
  38914. /**
  38915. * Does the sound use a custom attenuation curve to simulate the falloff
  38916. * happening when the source gets further away from the camera.
  38917. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  38918. */
  38919. useCustomAttenuation: boolean;
  38920. /**
  38921. * The sound track id this sound belongs to.
  38922. */
  38923. soundTrackId: number;
  38924. /**
  38925. * Is this sound currently played.
  38926. */
  38927. isPlaying: boolean;
  38928. /**
  38929. * Is this sound currently paused.
  38930. */
  38931. isPaused: boolean;
  38932. /**
  38933. * Does this sound enables spatial sound.
  38934. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38935. */
  38936. spatialSound: boolean;
  38937. /**
  38938. * Define the reference distance the sound should be heard perfectly.
  38939. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38940. */
  38941. refDistance: number;
  38942. /**
  38943. * Define the roll off factor of spatial sounds.
  38944. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38945. */
  38946. rolloffFactor: number;
  38947. /**
  38948. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  38949. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38950. */
  38951. maxDistance: number;
  38952. /**
  38953. * Define the distance attenuation model the sound will follow.
  38954. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38955. */
  38956. distanceModel: string;
  38957. /**
  38958. * @hidden
  38959. * Back Compat
  38960. **/
  38961. onended: () => any;
  38962. /**
  38963. * Observable event when the current playing sound finishes.
  38964. */
  38965. onEndedObservable: Observable<Sound>;
  38966. private _panningModel;
  38967. private _playbackRate;
  38968. private _streaming;
  38969. private _startTime;
  38970. private _startOffset;
  38971. private _position;
  38972. /** @hidden */
  38973. _positionInEmitterSpace: boolean;
  38974. private _localDirection;
  38975. private _volume;
  38976. private _isReadyToPlay;
  38977. private _isDirectional;
  38978. private _readyToPlayCallback;
  38979. private _audioBuffer;
  38980. private _soundSource;
  38981. private _streamingSource;
  38982. private _soundPanner;
  38983. private _soundGain;
  38984. private _inputAudioNode;
  38985. private _outputAudioNode;
  38986. private _coneInnerAngle;
  38987. private _coneOuterAngle;
  38988. private _coneOuterGain;
  38989. private _scene;
  38990. private _connectedTransformNode;
  38991. private _customAttenuationFunction;
  38992. private _registerFunc;
  38993. private _isOutputConnected;
  38994. private _htmlAudioElement;
  38995. private _urlType;
  38996. private _length?;
  38997. private _offset?;
  38998. /** @hidden */
  38999. static _SceneComponentInitialization: (scene: Scene) => void;
  39000. /**
  39001. * Create a sound and attach it to a scene
  39002. * @param name Name of your sound
  39003. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  39004. * @param scene defines the scene the sound belongs to
  39005. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  39006. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  39007. */
  39008. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  39009. /**
  39010. * Release the sound and its associated resources
  39011. */
  39012. dispose(): void;
  39013. /**
  39014. * Gets if the sounds is ready to be played or not.
  39015. * @returns true if ready, otherwise false
  39016. */
  39017. isReady(): boolean;
  39018. private _soundLoaded;
  39019. /**
  39020. * Sets the data of the sound from an audiobuffer
  39021. * @param audioBuffer The audioBuffer containing the data
  39022. */
  39023. setAudioBuffer(audioBuffer: AudioBuffer): void;
  39024. /**
  39025. * Updates the current sounds options such as maxdistance, loop...
  39026. * @param options A JSON object containing values named as the object properties
  39027. */
  39028. updateOptions(options: ISoundOptions): void;
  39029. private _createSpatialParameters;
  39030. private _updateSpatialParameters;
  39031. /**
  39032. * Switch the panning model to HRTF:
  39033. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  39034. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  39035. */
  39036. switchPanningModelToHRTF(): void;
  39037. /**
  39038. * Switch the panning model to Equal Power:
  39039. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  39040. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  39041. */
  39042. switchPanningModelToEqualPower(): void;
  39043. private _switchPanningModel;
  39044. /**
  39045. * Connect this sound to a sound track audio node like gain...
  39046. * @param soundTrackAudioNode the sound track audio node to connect to
  39047. */
  39048. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  39049. /**
  39050. * Transform this sound into a directional source
  39051. * @param coneInnerAngle Size of the inner cone in degree
  39052. * @param coneOuterAngle Size of the outer cone in degree
  39053. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  39054. */
  39055. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  39056. /**
  39057. * Gets or sets the inner angle for the directional cone.
  39058. */
  39059. get directionalConeInnerAngle(): number;
  39060. /**
  39061. * Gets or sets the inner angle for the directional cone.
  39062. */
  39063. set directionalConeInnerAngle(value: number);
  39064. /**
  39065. * Gets or sets the outer angle for the directional cone.
  39066. */
  39067. get directionalConeOuterAngle(): number;
  39068. /**
  39069. * Gets or sets the outer angle for the directional cone.
  39070. */
  39071. set directionalConeOuterAngle(value: number);
  39072. /**
  39073. * Sets the position of the emitter if spatial sound is enabled
  39074. * @param newPosition Defines the new posisiton
  39075. */
  39076. setPosition(newPosition: Vector3): void;
  39077. /**
  39078. * Sets the local direction of the emitter if spatial sound is enabled
  39079. * @param newLocalDirection Defines the new local direction
  39080. */
  39081. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  39082. private _updateDirection;
  39083. /** @hidden */
  39084. updateDistanceFromListener(): void;
  39085. /**
  39086. * Sets a new custom attenuation function for the sound.
  39087. * @param callback Defines the function used for the attenuation
  39088. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  39089. */
  39090. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  39091. /**
  39092. * Play the sound
  39093. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  39094. * @param offset (optional) Start the sound at a specific time in seconds
  39095. * @param length (optional) Sound duration (in seconds)
  39096. */
  39097. play(time?: number, offset?: number, length?: number): void;
  39098. private _onended;
  39099. /**
  39100. * Stop the sound
  39101. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  39102. */
  39103. stop(time?: number): void;
  39104. /**
  39105. * Put the sound in pause
  39106. */
  39107. pause(): void;
  39108. /**
  39109. * Sets a dedicated volume for this sounds
  39110. * @param newVolume Define the new volume of the sound
  39111. * @param time Define time for gradual change to new volume
  39112. */
  39113. setVolume(newVolume: number, time?: number): void;
  39114. /**
  39115. * Set the sound play back rate
  39116. * @param newPlaybackRate Define the playback rate the sound should be played at
  39117. */
  39118. setPlaybackRate(newPlaybackRate: number): void;
  39119. /**
  39120. * Gets the volume of the sound.
  39121. * @returns the volume of the sound
  39122. */
  39123. getVolume(): number;
  39124. /**
  39125. * Attach the sound to a dedicated mesh
  39126. * @param transformNode The transform node to connect the sound with
  39127. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  39128. */
  39129. attachToMesh(transformNode: TransformNode): void;
  39130. /**
  39131. * Detach the sound from the previously attached mesh
  39132. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  39133. */
  39134. detachFromMesh(): void;
  39135. private _onRegisterAfterWorldMatrixUpdate;
  39136. /**
  39137. * Clone the current sound in the scene.
  39138. * @returns the new sound clone
  39139. */
  39140. clone(): Nullable<Sound>;
  39141. /**
  39142. * Gets the current underlying audio buffer containing the data
  39143. * @returns the audio buffer
  39144. */
  39145. getAudioBuffer(): Nullable<AudioBuffer>;
  39146. /**
  39147. * Gets the WebAudio AudioBufferSourceNode, lets you keep track of and stop instances of this Sound.
  39148. * @returns the source node
  39149. */
  39150. getSoundSource(): Nullable<AudioBufferSourceNode>;
  39151. /**
  39152. * Gets the WebAudio GainNode, gives you precise control over the gain of instances of this Sound.
  39153. * @returns the gain node
  39154. */
  39155. getSoundGain(): Nullable<GainNode>;
  39156. /**
  39157. * Serializes the Sound in a JSON representation
  39158. * @returns the JSON representation of the sound
  39159. */
  39160. serialize(): any;
  39161. /**
  39162. * Parse a JSON representation of a sound to innstantiate in a given scene
  39163. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  39164. * @param scene Define the scene the new parsed sound should be created in
  39165. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  39166. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  39167. * @returns the newly parsed sound
  39168. */
  39169. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  39170. }
  39171. }
  39172. declare module "babylonjs/Actions/directAudioActions" {
  39173. import { Action } from "babylonjs/Actions/action";
  39174. import { Condition } from "babylonjs/Actions/condition";
  39175. import { Sound } from "babylonjs/Audio/sound";
  39176. /**
  39177. * This defines an action helpful to play a defined sound on a triggered action.
  39178. */
  39179. export class PlaySoundAction extends Action {
  39180. private _sound;
  39181. /**
  39182. * Instantiate the action
  39183. * @param triggerOptions defines the trigger options
  39184. * @param sound defines the sound to play
  39185. * @param condition defines the trigger related conditions
  39186. */
  39187. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  39188. /** @hidden */
  39189. _prepare(): void;
  39190. /**
  39191. * Execute the action and play the sound.
  39192. */
  39193. execute(): void;
  39194. /**
  39195. * Serializes the actions and its related information.
  39196. * @param parent defines the object to serialize in
  39197. * @returns the serialized object
  39198. */
  39199. serialize(parent: any): any;
  39200. }
  39201. /**
  39202. * This defines an action helpful to stop a defined sound on a triggered action.
  39203. */
  39204. export class StopSoundAction extends Action {
  39205. private _sound;
  39206. /**
  39207. * Instantiate the action
  39208. * @param triggerOptions defines the trigger options
  39209. * @param sound defines the sound to stop
  39210. * @param condition defines the trigger related conditions
  39211. */
  39212. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  39213. /** @hidden */
  39214. _prepare(): void;
  39215. /**
  39216. * Execute the action and stop the sound.
  39217. */
  39218. execute(): void;
  39219. /**
  39220. * Serializes the actions and its related information.
  39221. * @param parent defines the object to serialize in
  39222. * @returns the serialized object
  39223. */
  39224. serialize(parent: any): any;
  39225. }
  39226. }
  39227. declare module "babylonjs/Actions/interpolateValueAction" {
  39228. import { Action } from "babylonjs/Actions/action";
  39229. import { Condition } from "babylonjs/Actions/condition";
  39230. import { Observable } from "babylonjs/Misc/observable";
  39231. /**
  39232. * This defines an action responsible to change the value of a property
  39233. * by interpolating between its current value and the newly set one once triggered.
  39234. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  39235. */
  39236. export class InterpolateValueAction extends Action {
  39237. /**
  39238. * Defines the path of the property where the value should be interpolated
  39239. */
  39240. propertyPath: string;
  39241. /**
  39242. * Defines the target value at the end of the interpolation.
  39243. */
  39244. value: any;
  39245. /**
  39246. * Defines the time it will take for the property to interpolate to the value.
  39247. */
  39248. duration: number;
  39249. /**
  39250. * Defines if the other scene animations should be stopped when the action has been triggered
  39251. */
  39252. stopOtherAnimations?: boolean;
  39253. /**
  39254. * Defines a callback raised once the interpolation animation has been done.
  39255. */
  39256. onInterpolationDone?: () => void;
  39257. /**
  39258. * Observable triggered once the interpolation animation has been done.
  39259. */
  39260. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  39261. private _target;
  39262. private _effectiveTarget;
  39263. private _property;
  39264. /**
  39265. * Instantiate the action
  39266. * @param triggerOptions defines the trigger options
  39267. * @param target defines the object containing the value to interpolate
  39268. * @param propertyPath defines the path to the property in the target object
  39269. * @param value defines the target value at the end of the interpolation
  39270. * @param duration deines the time it will take for the property to interpolate to the value.
  39271. * @param condition defines the trigger related conditions
  39272. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  39273. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  39274. */
  39275. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  39276. /** @hidden */
  39277. _prepare(): void;
  39278. /**
  39279. * Execute the action starts the value interpolation.
  39280. */
  39281. execute(): void;
  39282. /**
  39283. * Serializes the actions and its related information.
  39284. * @param parent defines the object to serialize in
  39285. * @returns the serialized object
  39286. */
  39287. serialize(parent: any): any;
  39288. }
  39289. }
  39290. declare module "babylonjs/Actions/index" {
  39291. export * from "babylonjs/Actions/abstractActionManager";
  39292. export * from "babylonjs/Actions/action";
  39293. export * from "babylonjs/Actions/actionEvent";
  39294. export * from "babylonjs/Actions/actionManager";
  39295. export * from "babylonjs/Actions/condition";
  39296. export * from "babylonjs/Actions/directActions";
  39297. export * from "babylonjs/Actions/directAudioActions";
  39298. export * from "babylonjs/Actions/interpolateValueAction";
  39299. }
  39300. declare module "babylonjs/Animations/index" {
  39301. export * from "babylonjs/Animations/animatable";
  39302. export * from "babylonjs/Animations/animation";
  39303. export * from "babylonjs/Animations/animationGroup";
  39304. export * from "babylonjs/Animations/animationPropertiesOverride";
  39305. export * from "babylonjs/Animations/easing";
  39306. export * from "babylonjs/Animations/runtimeAnimation";
  39307. export * from "babylonjs/Animations/animationEvent";
  39308. export * from "babylonjs/Animations/animationGroup";
  39309. export * from "babylonjs/Animations/animationKey";
  39310. export * from "babylonjs/Animations/animationRange";
  39311. export * from "babylonjs/Animations/animatable.interface";
  39312. }
  39313. declare module "babylonjs/Audio/soundTrack" {
  39314. import { Sound } from "babylonjs/Audio/sound";
  39315. import { Analyser } from "babylonjs/Audio/analyser";
  39316. import { Scene } from "babylonjs/scene";
  39317. /**
  39318. * Options allowed during the creation of a sound track.
  39319. */
  39320. export interface ISoundTrackOptions {
  39321. /**
  39322. * The volume the sound track should take during creation
  39323. */
  39324. volume?: number;
  39325. /**
  39326. * Define if the sound track is the main sound track of the scene
  39327. */
  39328. mainTrack?: boolean;
  39329. }
  39330. /**
  39331. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  39332. * It will be also used in a future release to apply effects on a specific track.
  39333. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  39334. */
  39335. export class SoundTrack {
  39336. /**
  39337. * The unique identifier of the sound track in the scene.
  39338. */
  39339. id: number;
  39340. /**
  39341. * The list of sounds included in the sound track.
  39342. */
  39343. soundCollection: Array<Sound>;
  39344. private _outputAudioNode;
  39345. private _scene;
  39346. private _connectedAnalyser;
  39347. private _options;
  39348. private _isInitialized;
  39349. /**
  39350. * Creates a new sound track.
  39351. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  39352. * @param scene Define the scene the sound track belongs to
  39353. * @param options
  39354. */
  39355. constructor(scene: Scene, options?: ISoundTrackOptions);
  39356. private _initializeSoundTrackAudioGraph;
  39357. /**
  39358. * Release the sound track and its associated resources
  39359. */
  39360. dispose(): void;
  39361. /**
  39362. * Adds a sound to this sound track
  39363. * @param sound define the cound to add
  39364. * @ignoreNaming
  39365. */
  39366. AddSound(sound: Sound): void;
  39367. /**
  39368. * Removes a sound to this sound track
  39369. * @param sound define the cound to remove
  39370. * @ignoreNaming
  39371. */
  39372. RemoveSound(sound: Sound): void;
  39373. /**
  39374. * Set a global volume for the full sound track.
  39375. * @param newVolume Define the new volume of the sound track
  39376. */
  39377. setVolume(newVolume: number): void;
  39378. /**
  39379. * Switch the panning model to HRTF:
  39380. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  39381. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  39382. */
  39383. switchPanningModelToHRTF(): void;
  39384. /**
  39385. * Switch the panning model to Equal Power:
  39386. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  39387. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  39388. */
  39389. switchPanningModelToEqualPower(): void;
  39390. /**
  39391. * Connect the sound track to an audio analyser allowing some amazing
  39392. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  39393. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  39394. * @param analyser The analyser to connect to the engine
  39395. */
  39396. connectToAnalyser(analyser: Analyser): void;
  39397. }
  39398. }
  39399. declare module "babylonjs/Audio/audioSceneComponent" {
  39400. import { Sound } from "babylonjs/Audio/sound";
  39401. import { SoundTrack } from "babylonjs/Audio/soundTrack";
  39402. import { Nullable } from "babylonjs/types";
  39403. import { Vector3 } from "babylonjs/Maths/math.vector";
  39404. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  39405. import { Scene } from "babylonjs/scene";
  39406. import { AbstractScene } from "babylonjs/abstractScene";
  39407. import "babylonjs/Audio/audioEngine";
  39408. module "babylonjs/abstractScene" {
  39409. interface AbstractScene {
  39410. /**
  39411. * The list of sounds used in the scene.
  39412. */
  39413. sounds: Nullable<Array<Sound>>;
  39414. }
  39415. }
  39416. module "babylonjs/scene" {
  39417. interface Scene {
  39418. /**
  39419. * @hidden
  39420. * Backing field
  39421. */
  39422. _mainSoundTrack: SoundTrack;
  39423. /**
  39424. * The main sound track played by the scene.
  39425. * It cotains your primary collection of sounds.
  39426. */
  39427. mainSoundTrack: SoundTrack;
  39428. /**
  39429. * The list of sound tracks added to the scene
  39430. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  39431. */
  39432. soundTracks: Nullable<Array<SoundTrack>>;
  39433. /**
  39434. * Gets a sound using a given name
  39435. * @param name defines the name to search for
  39436. * @return the found sound or null if not found at all.
  39437. */
  39438. getSoundByName(name: string): Nullable<Sound>;
  39439. /**
  39440. * Gets or sets if audio support is enabled
  39441. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  39442. */
  39443. audioEnabled: boolean;
  39444. /**
  39445. * Gets or sets if audio will be output to headphones
  39446. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  39447. */
  39448. headphone: boolean;
  39449. /**
  39450. * Gets or sets custom audio listener position provider
  39451. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  39452. */
  39453. audioListenerPositionProvider: Nullable<() => Vector3>;
  39454. /**
  39455. * Gets or sets a refresh rate when using 3D audio positioning
  39456. */
  39457. audioPositioningRefreshRate: number;
  39458. }
  39459. }
  39460. /**
  39461. * Defines the sound scene component responsible to manage any sounds
  39462. * in a given scene.
  39463. */
  39464. export class AudioSceneComponent implements ISceneSerializableComponent {
  39465. /**
  39466. * The component name helpfull to identify the component in the list of scene components.
  39467. */
  39468. readonly name: string;
  39469. /**
  39470. * The scene the component belongs to.
  39471. */
  39472. scene: Scene;
  39473. private _audioEnabled;
  39474. /**
  39475. * Gets whether audio is enabled or not.
  39476. * Please use related enable/disable method to switch state.
  39477. */
  39478. get audioEnabled(): boolean;
  39479. private _headphone;
  39480. /**
  39481. * Gets whether audio is outputing to headphone or not.
  39482. * Please use the according Switch methods to change output.
  39483. */
  39484. get headphone(): boolean;
  39485. /**
  39486. * Gets or sets a refresh rate when using 3D audio positioning
  39487. */
  39488. audioPositioningRefreshRate: number;
  39489. private _audioListenerPositionProvider;
  39490. /**
  39491. * Gets the current audio listener position provider
  39492. */
  39493. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  39494. /**
  39495. * Sets a custom listener position for all sounds in the scene
  39496. * By default, this is the position of the first active camera
  39497. */
  39498. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  39499. /**
  39500. * Creates a new instance of the component for the given scene
  39501. * @param scene Defines the scene to register the component in
  39502. */
  39503. constructor(scene: Scene);
  39504. /**
  39505. * Registers the component in a given scene
  39506. */
  39507. register(): void;
  39508. /**
  39509. * Rebuilds the elements related to this component in case of
  39510. * context lost for instance.
  39511. */
  39512. rebuild(): void;
  39513. /**
  39514. * Serializes the component data to the specified json object
  39515. * @param serializationObject The object to serialize to
  39516. */
  39517. serialize(serializationObject: any): void;
  39518. /**
  39519. * Adds all the elements from the container to the scene
  39520. * @param container the container holding the elements
  39521. */
  39522. addFromContainer(container: AbstractScene): void;
  39523. /**
  39524. * Removes all the elements in the container from the scene
  39525. * @param container contains the elements to remove
  39526. * @param dispose if the removed element should be disposed (default: false)
  39527. */
  39528. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  39529. /**
  39530. * Disposes the component and the associated ressources.
  39531. */
  39532. dispose(): void;
  39533. /**
  39534. * Disables audio in the associated scene.
  39535. */
  39536. disableAudio(): void;
  39537. /**
  39538. * Enables audio in the associated scene.
  39539. */
  39540. enableAudio(): void;
  39541. /**
  39542. * Switch audio to headphone output.
  39543. */
  39544. switchAudioModeForHeadphones(): void;
  39545. /**
  39546. * Switch audio to normal speakers.
  39547. */
  39548. switchAudioModeForNormalSpeakers(): void;
  39549. private _cachedCameraDirection;
  39550. private _cachedCameraPosition;
  39551. private _lastCheck;
  39552. private _afterRender;
  39553. }
  39554. }
  39555. declare module "babylonjs/Audio/weightedsound" {
  39556. import { Sound } from "babylonjs/Audio/sound";
  39557. /**
  39558. * Wraps one or more Sound objects and selects one with random weight for playback.
  39559. */
  39560. export class WeightedSound {
  39561. /** When true a Sound will be selected and played when the current playing Sound completes. */
  39562. loop: boolean;
  39563. private _coneInnerAngle;
  39564. private _coneOuterAngle;
  39565. private _volume;
  39566. /** A Sound is currently playing. */
  39567. isPlaying: boolean;
  39568. /** A Sound is currently paused. */
  39569. isPaused: boolean;
  39570. private _sounds;
  39571. private _weights;
  39572. private _currentIndex?;
  39573. /**
  39574. * Creates a new WeightedSound from the list of sounds given.
  39575. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  39576. * @param sounds Array of Sounds that will be selected from.
  39577. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  39578. */
  39579. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  39580. /**
  39581. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  39582. */
  39583. get directionalConeInnerAngle(): number;
  39584. /**
  39585. * The size of cone in degress for a directional sound in which there will be no attenuation.
  39586. */
  39587. set directionalConeInnerAngle(value: number);
  39588. /**
  39589. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  39590. * Listener angles between innerAngle and outerAngle will falloff linearly.
  39591. */
  39592. get directionalConeOuterAngle(): number;
  39593. /**
  39594. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  39595. * Listener angles between innerAngle and outerAngle will falloff linearly.
  39596. */
  39597. set directionalConeOuterAngle(value: number);
  39598. /**
  39599. * Playback volume.
  39600. */
  39601. get volume(): number;
  39602. /**
  39603. * Playback volume.
  39604. */
  39605. set volume(value: number);
  39606. private _onended;
  39607. /**
  39608. * Suspend playback
  39609. */
  39610. pause(): void;
  39611. /**
  39612. * Stop playback
  39613. */
  39614. stop(): void;
  39615. /**
  39616. * Start playback.
  39617. * @param startOffset Position the clip head at a specific time in seconds.
  39618. */
  39619. play(startOffset?: number): void;
  39620. }
  39621. }
  39622. declare module "babylonjs/Audio/index" {
  39623. export * from "babylonjs/Audio/analyser";
  39624. export * from "babylonjs/Audio/audioEngine";
  39625. export * from "babylonjs/Audio/audioSceneComponent";
  39626. export * from "babylonjs/Audio/sound";
  39627. export * from "babylonjs/Audio/soundTrack";
  39628. export * from "babylonjs/Audio/weightedsound";
  39629. }
  39630. declare module "babylonjs/Behaviors/Cameras/bouncingBehavior" {
  39631. import { Behavior } from "babylonjs/Behaviors/behavior";
  39632. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39633. import { BackEase } from "babylonjs/Animations/easing";
  39634. /**
  39635. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  39636. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  39637. */
  39638. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  39639. /**
  39640. * Gets the name of the behavior.
  39641. */
  39642. get name(): string;
  39643. /**
  39644. * The easing function used by animations
  39645. */
  39646. static EasingFunction: BackEase;
  39647. /**
  39648. * The easing mode used by animations
  39649. */
  39650. static EasingMode: number;
  39651. /**
  39652. * The duration of the animation, in milliseconds
  39653. */
  39654. transitionDuration: number;
  39655. /**
  39656. * Length of the distance animated by the transition when lower radius is reached
  39657. */
  39658. lowerRadiusTransitionRange: number;
  39659. /**
  39660. * Length of the distance animated by the transition when upper radius is reached
  39661. */
  39662. upperRadiusTransitionRange: number;
  39663. private _autoTransitionRange;
  39664. /**
  39665. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  39666. */
  39667. get autoTransitionRange(): boolean;
  39668. /**
  39669. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  39670. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  39671. */
  39672. set autoTransitionRange(value: boolean);
  39673. private _attachedCamera;
  39674. private _onAfterCheckInputsObserver;
  39675. private _onMeshTargetChangedObserver;
  39676. /**
  39677. * Initializes the behavior.
  39678. */
  39679. init(): void;
  39680. /**
  39681. * Attaches the behavior to its arc rotate camera.
  39682. * @param camera Defines the camera to attach the behavior to
  39683. */
  39684. attach(camera: ArcRotateCamera): void;
  39685. /**
  39686. * Detaches the behavior from its current arc rotate camera.
  39687. */
  39688. detach(): void;
  39689. private _radiusIsAnimating;
  39690. private _radiusBounceTransition;
  39691. private _animatables;
  39692. private _cachedWheelPrecision;
  39693. /**
  39694. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  39695. * @param radiusLimit The limit to check against.
  39696. * @return Bool to indicate if at limit.
  39697. */
  39698. private _isRadiusAtLimit;
  39699. /**
  39700. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  39701. * @param radiusDelta The delta by which to animate to. Can be negative.
  39702. */
  39703. private _applyBoundRadiusAnimation;
  39704. /**
  39705. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  39706. */
  39707. protected _clearAnimationLocks(): void;
  39708. /**
  39709. * Stops and removes all animations that have been applied to the camera
  39710. */
  39711. stopAllAnimations(): void;
  39712. }
  39713. }
  39714. declare module "babylonjs/Behaviors/Cameras/framingBehavior" {
  39715. import { Behavior } from "babylonjs/Behaviors/behavior";
  39716. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39717. import { ExponentialEase } from "babylonjs/Animations/easing";
  39718. import { Nullable } from "babylonjs/types";
  39719. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  39720. import { Vector3 } from "babylonjs/Maths/math.vector";
  39721. /**
  39722. * 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.
  39723. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  39724. */
  39725. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  39726. /**
  39727. * Gets the name of the behavior.
  39728. */
  39729. get name(): string;
  39730. private _mode;
  39731. private _radiusScale;
  39732. private _positionScale;
  39733. private _defaultElevation;
  39734. private _elevationReturnTime;
  39735. private _elevationReturnWaitTime;
  39736. private _zoomStopsAnimation;
  39737. private _framingTime;
  39738. /**
  39739. * The easing function used by animations
  39740. */
  39741. static EasingFunction: ExponentialEase;
  39742. /**
  39743. * The easing mode used by animations
  39744. */
  39745. static EasingMode: number;
  39746. /**
  39747. * Sets the current mode used by the behavior
  39748. */
  39749. set mode(mode: number);
  39750. /**
  39751. * Gets current mode used by the behavior.
  39752. */
  39753. get mode(): number;
  39754. /**
  39755. * Sets the scale applied to the radius (1 by default)
  39756. */
  39757. set radiusScale(radius: number);
  39758. /**
  39759. * Gets the scale applied to the radius
  39760. */
  39761. get radiusScale(): number;
  39762. /**
  39763. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  39764. */
  39765. set positionScale(scale: number);
  39766. /**
  39767. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  39768. */
  39769. get positionScale(): number;
  39770. /**
  39771. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  39772. * behaviour is triggered, in radians.
  39773. */
  39774. set defaultElevation(elevation: number);
  39775. /**
  39776. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  39777. * behaviour is triggered, in radians.
  39778. */
  39779. get defaultElevation(): number;
  39780. /**
  39781. * Sets the time (in milliseconds) taken to return to the default beta position.
  39782. * Negative value indicates camera should not return to default.
  39783. */
  39784. set elevationReturnTime(speed: number);
  39785. /**
  39786. * Gets the time (in milliseconds) taken to return to the default beta position.
  39787. * Negative value indicates camera should not return to default.
  39788. */
  39789. get elevationReturnTime(): number;
  39790. /**
  39791. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  39792. */
  39793. set elevationReturnWaitTime(time: number);
  39794. /**
  39795. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  39796. */
  39797. get elevationReturnWaitTime(): number;
  39798. /**
  39799. * Sets the flag that indicates if user zooming should stop animation.
  39800. */
  39801. set zoomStopsAnimation(flag: boolean);
  39802. /**
  39803. * Gets the flag that indicates if user zooming should stop animation.
  39804. */
  39805. get zoomStopsAnimation(): boolean;
  39806. /**
  39807. * Sets the transition time when framing the mesh, in milliseconds
  39808. */
  39809. set framingTime(time: number);
  39810. /**
  39811. * Gets the transition time when framing the mesh, in milliseconds
  39812. */
  39813. get framingTime(): number;
  39814. /**
  39815. * Define if the behavior should automatically change the configured
  39816. * camera limits and sensibilities.
  39817. */
  39818. autoCorrectCameraLimitsAndSensibility: boolean;
  39819. private _onPrePointerObservableObserver;
  39820. private _onAfterCheckInputsObserver;
  39821. private _onMeshTargetChangedObserver;
  39822. private _attachedCamera;
  39823. private _isPointerDown;
  39824. private _lastInteractionTime;
  39825. /**
  39826. * Initializes the behavior.
  39827. */
  39828. init(): void;
  39829. /**
  39830. * Attaches the behavior to its arc rotate camera.
  39831. * @param camera Defines the camera to attach the behavior to
  39832. */
  39833. attach(camera: ArcRotateCamera): void;
  39834. /**
  39835. * Detaches the behavior from its current arc rotate camera.
  39836. */
  39837. detach(): void;
  39838. private _animatables;
  39839. private _betaIsAnimating;
  39840. private _betaTransition;
  39841. private _radiusTransition;
  39842. private _vectorTransition;
  39843. /**
  39844. * Targets the given mesh and updates zoom level accordingly.
  39845. * @param mesh The mesh to target.
  39846. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  39847. * @param onAnimationEnd Callback triggered at the end of the framing animation
  39848. */
  39849. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  39850. /**
  39851. * Targets the given mesh with its children and updates zoom level accordingly.
  39852. * @param mesh The mesh to target.
  39853. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  39854. * @param onAnimationEnd Callback triggered at the end of the framing animation
  39855. */
  39856. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  39857. /**
  39858. * Targets the given meshes with their children and updates zoom level accordingly.
  39859. * @param meshes The mesh to target.
  39860. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  39861. * @param onAnimationEnd Callback triggered at the end of the framing animation
  39862. */
  39863. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  39864. /**
  39865. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  39866. * @param minimumWorld Determines the smaller position of the bounding box extend
  39867. * @param maximumWorld Determines the bigger position of the bounding box extend
  39868. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  39869. * @param onAnimationEnd Callback triggered at the end of the framing animation
  39870. */
  39871. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  39872. /**
  39873. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  39874. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  39875. * frustum width.
  39876. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  39877. * to fully enclose the mesh in the viewing frustum.
  39878. */
  39879. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  39880. /**
  39881. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  39882. * is automatically returned to its default position (expected to be above ground plane).
  39883. */
  39884. private _maintainCameraAboveGround;
  39885. /**
  39886. * Returns the frustum slope based on the canvas ratio and camera FOV
  39887. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  39888. */
  39889. private _getFrustumSlope;
  39890. /**
  39891. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  39892. */
  39893. private _clearAnimationLocks;
  39894. /**
  39895. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  39896. */
  39897. private _applyUserInteraction;
  39898. /**
  39899. * Stops and removes all animations that have been applied to the camera
  39900. */
  39901. stopAllAnimations(): void;
  39902. /**
  39903. * Gets a value indicating if the user is moving the camera
  39904. */
  39905. get isUserIsMoving(): boolean;
  39906. /**
  39907. * The camera can move all the way towards the mesh.
  39908. */
  39909. static IgnoreBoundsSizeMode: number;
  39910. /**
  39911. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  39912. */
  39913. static FitFrustumSidesMode: number;
  39914. }
  39915. }
  39916. declare module "babylonjs/Cameras/Inputs/BaseCameraPointersInput" {
  39917. import { Nullable } from "babylonjs/types";
  39918. import { Camera } from "babylonjs/Cameras/camera";
  39919. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39920. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  39921. /**
  39922. * Base class for Camera Pointer Inputs.
  39923. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  39924. * for example usage.
  39925. */
  39926. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  39927. /**
  39928. * Defines the camera the input is attached to.
  39929. */
  39930. abstract camera: Camera;
  39931. /**
  39932. * Whether keyboard modifier keys are pressed at time of last mouse event.
  39933. */
  39934. protected _altKey: boolean;
  39935. protected _ctrlKey: boolean;
  39936. protected _metaKey: boolean;
  39937. protected _shiftKey: boolean;
  39938. /**
  39939. * Which mouse buttons were pressed at time of last mouse event.
  39940. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  39941. */
  39942. protected _buttonsPressed: number;
  39943. /**
  39944. * Defines the buttons associated with the input to handle camera move.
  39945. */
  39946. buttons: number[];
  39947. /**
  39948. * Attach the input controls to a specific dom element to get the input from.
  39949. * @param element Defines the element the controls should be listened from
  39950. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39951. */
  39952. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39953. /**
  39954. * Detach the current controls from the specified dom element.
  39955. * @param element Defines the element to stop listening the inputs from
  39956. */
  39957. detachControl(element: Nullable<HTMLElement>): void;
  39958. /**
  39959. * Gets the class name of the current input.
  39960. * @returns the class name
  39961. */
  39962. getClassName(): string;
  39963. /**
  39964. * Get the friendly name associated with the input class.
  39965. * @returns the input friendly name
  39966. */
  39967. getSimpleName(): string;
  39968. /**
  39969. * Called on pointer POINTERDOUBLETAP event.
  39970. * Override this method to provide functionality on POINTERDOUBLETAP event.
  39971. */
  39972. protected onDoubleTap(type: string): void;
  39973. /**
  39974. * Called on pointer POINTERMOVE event if only a single touch is active.
  39975. * Override this method to provide functionality.
  39976. */
  39977. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  39978. /**
  39979. * Called on pointer POINTERMOVE event if multiple touches are active.
  39980. * Override this method to provide functionality.
  39981. */
  39982. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  39983. /**
  39984. * Called on JS contextmenu event.
  39985. * Override this method to provide functionality.
  39986. */
  39987. protected onContextMenu(evt: PointerEvent): void;
  39988. /**
  39989. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  39990. * press.
  39991. * Override this method to provide functionality.
  39992. */
  39993. protected onButtonDown(evt: PointerEvent): void;
  39994. /**
  39995. * Called each time a new POINTERUP event occurs. Ie, for each button
  39996. * release.
  39997. * Override this method to provide functionality.
  39998. */
  39999. protected onButtonUp(evt: PointerEvent): void;
  40000. /**
  40001. * Called when window becomes inactive.
  40002. * Override this method to provide functionality.
  40003. */
  40004. protected onLostFocus(): void;
  40005. private _pointerInput;
  40006. private _observer;
  40007. private _onLostFocus;
  40008. private pointA;
  40009. private pointB;
  40010. }
  40011. }
  40012. declare module "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput" {
  40013. import { Nullable } from "babylonjs/types";
  40014. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  40015. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  40016. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  40017. /**
  40018. * Manage the pointers inputs to control an arc rotate camera.
  40019. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40020. */
  40021. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  40022. /**
  40023. * Defines the camera the input is attached to.
  40024. */
  40025. camera: ArcRotateCamera;
  40026. /**
  40027. * Gets the class name of the current input.
  40028. * @returns the class name
  40029. */
  40030. getClassName(): string;
  40031. /**
  40032. * Defines the buttons associated with the input to handle camera move.
  40033. */
  40034. buttons: number[];
  40035. /**
  40036. * Defines the pointer angular sensibility along the X axis or how fast is
  40037. * the camera rotating.
  40038. */
  40039. angularSensibilityX: number;
  40040. /**
  40041. * Defines the pointer angular sensibility along the Y axis or how fast is
  40042. * the camera rotating.
  40043. */
  40044. angularSensibilityY: number;
  40045. /**
  40046. * Defines the pointer pinch precision or how fast is the camera zooming.
  40047. */
  40048. pinchPrecision: number;
  40049. /**
  40050. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  40051. * from 0.
  40052. * It defines the percentage of current camera.radius to use as delta when
  40053. * pinch zoom is used.
  40054. */
  40055. pinchDeltaPercentage: number;
  40056. /**
  40057. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  40058. * that any object in the plane at the camera's target point will scale
  40059. * perfectly with finger motion.
  40060. * Overrides pinchDeltaPercentage and pinchPrecision.
  40061. */
  40062. useNaturalPinchZoom: boolean;
  40063. /**
  40064. * Defines the pointer panning sensibility or how fast is the camera moving.
  40065. */
  40066. panningSensibility: number;
  40067. /**
  40068. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  40069. */
  40070. multiTouchPanning: boolean;
  40071. /**
  40072. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  40073. * zoom (pinch) through multitouch.
  40074. */
  40075. multiTouchPanAndZoom: boolean;
  40076. /**
  40077. * Revers pinch action direction.
  40078. */
  40079. pinchInwards: boolean;
  40080. private _isPanClick;
  40081. private _twoFingerActivityCount;
  40082. private _isPinching;
  40083. /**
  40084. * Called on pointer POINTERMOVE event if only a single touch is active.
  40085. */
  40086. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  40087. /**
  40088. * Called on pointer POINTERDOUBLETAP event.
  40089. */
  40090. protected onDoubleTap(type: string): void;
  40091. /**
  40092. * Called on pointer POINTERMOVE event if multiple touches are active.
  40093. */
  40094. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  40095. /**
  40096. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  40097. * press.
  40098. */
  40099. protected onButtonDown(evt: PointerEvent): void;
  40100. /**
  40101. * Called each time a new POINTERUP event occurs. Ie, for each button
  40102. * release.
  40103. */
  40104. protected onButtonUp(evt: PointerEvent): void;
  40105. /**
  40106. * Called when window becomes inactive.
  40107. */
  40108. protected onLostFocus(): void;
  40109. }
  40110. }
  40111. declare module "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput" {
  40112. import { Nullable } from "babylonjs/types";
  40113. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  40114. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  40115. /**
  40116. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  40117. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40118. */
  40119. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  40120. /**
  40121. * Defines the camera the input is attached to.
  40122. */
  40123. camera: ArcRotateCamera;
  40124. /**
  40125. * Defines the list of key codes associated with the up action (increase alpha)
  40126. */
  40127. keysUp: number[];
  40128. /**
  40129. * Defines the list of key codes associated with the down action (decrease alpha)
  40130. */
  40131. keysDown: number[];
  40132. /**
  40133. * Defines the list of key codes associated with the left action (increase beta)
  40134. */
  40135. keysLeft: number[];
  40136. /**
  40137. * Defines the list of key codes associated with the right action (decrease beta)
  40138. */
  40139. keysRight: number[];
  40140. /**
  40141. * Defines the list of key codes associated with the reset action.
  40142. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  40143. */
  40144. keysReset: number[];
  40145. /**
  40146. * Defines the panning sensibility of the inputs.
  40147. * (How fast is the camera panning)
  40148. */
  40149. panningSensibility: number;
  40150. /**
  40151. * Defines the zooming sensibility of the inputs.
  40152. * (How fast is the camera zooming)
  40153. */
  40154. zoomingSensibility: number;
  40155. /**
  40156. * Defines whether maintaining the alt key down switch the movement mode from
  40157. * orientation to zoom.
  40158. */
  40159. useAltToZoom: boolean;
  40160. /**
  40161. * Rotation speed of the camera
  40162. */
  40163. angularSpeed: number;
  40164. private _keys;
  40165. private _ctrlPressed;
  40166. private _altPressed;
  40167. private _onCanvasBlurObserver;
  40168. private _onKeyboardObserver;
  40169. private _engine;
  40170. private _scene;
  40171. /**
  40172. * Attach the input controls to a specific dom element to get the input from.
  40173. * @param element Defines the element the controls should be listened from
  40174. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40175. */
  40176. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40177. /**
  40178. * Detach the current controls from the specified dom element.
  40179. * @param element Defines the element to stop listening the inputs from
  40180. */
  40181. detachControl(element: Nullable<HTMLElement>): void;
  40182. /**
  40183. * Update the current camera state depending on the inputs that have been used this frame.
  40184. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40185. */
  40186. checkInputs(): void;
  40187. /**
  40188. * Gets the class name of the current intput.
  40189. * @returns the class name
  40190. */
  40191. getClassName(): string;
  40192. /**
  40193. * Get the friendly name associated with the input class.
  40194. * @returns the input friendly name
  40195. */
  40196. getSimpleName(): string;
  40197. }
  40198. }
  40199. declare module "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput" {
  40200. import { Nullable } from "babylonjs/types";
  40201. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  40202. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  40203. /**
  40204. * Manage the mouse wheel inputs to control an arc rotate camera.
  40205. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40206. */
  40207. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  40208. /**
  40209. * Defines the camera the input is attached to.
  40210. */
  40211. camera: ArcRotateCamera;
  40212. /**
  40213. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  40214. */
  40215. wheelPrecision: number;
  40216. /**
  40217. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  40218. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  40219. */
  40220. wheelDeltaPercentage: number;
  40221. private _wheel;
  40222. private _observer;
  40223. private computeDeltaFromMouseWheelLegacyEvent;
  40224. /**
  40225. * Attach the input controls to a specific dom element to get the input from.
  40226. * @param element Defines the element the controls should be listened from
  40227. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40228. */
  40229. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40230. /**
  40231. * Detach the current controls from the specified dom element.
  40232. * @param element Defines the element to stop listening the inputs from
  40233. */
  40234. detachControl(element: Nullable<HTMLElement>): void;
  40235. /**
  40236. * Gets the class name of the current intput.
  40237. * @returns the class name
  40238. */
  40239. getClassName(): string;
  40240. /**
  40241. * Get the friendly name associated with the input class.
  40242. * @returns the input friendly name
  40243. */
  40244. getSimpleName(): string;
  40245. }
  40246. }
  40247. declare module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  40248. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  40249. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  40250. /**
  40251. * Default Inputs manager for the ArcRotateCamera.
  40252. * It groups all the default supported inputs for ease of use.
  40253. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40254. */
  40255. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  40256. /**
  40257. * Instantiates a new ArcRotateCameraInputsManager.
  40258. * @param camera Defines the camera the inputs belong to
  40259. */
  40260. constructor(camera: ArcRotateCamera);
  40261. /**
  40262. * Add mouse wheel input support to the input manager.
  40263. * @returns the current input manager
  40264. */
  40265. addMouseWheel(): ArcRotateCameraInputsManager;
  40266. /**
  40267. * Add pointers input support to the input manager.
  40268. * @returns the current input manager
  40269. */
  40270. addPointers(): ArcRotateCameraInputsManager;
  40271. /**
  40272. * Add keyboard input support to the input manager.
  40273. * @returns the current input manager
  40274. */
  40275. addKeyboard(): ArcRotateCameraInputsManager;
  40276. }
  40277. }
  40278. declare module "babylonjs/Cameras/arcRotateCamera" {
  40279. import { Observable } from "babylonjs/Misc/observable";
  40280. import { Nullable } from "babylonjs/types";
  40281. import { Scene } from "babylonjs/scene";
  40282. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  40283. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40284. import { AutoRotationBehavior } from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  40285. import { BouncingBehavior } from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  40286. import { FramingBehavior } from "babylonjs/Behaviors/Cameras/framingBehavior";
  40287. import { Camera } from "babylonjs/Cameras/camera";
  40288. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  40289. import { ArcRotateCameraInputsManager } from "babylonjs/Cameras/arcRotateCameraInputsManager";
  40290. import { Collider } from "babylonjs/Collisions/collider";
  40291. /**
  40292. * This represents an orbital type of camera.
  40293. *
  40294. * 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.
  40295. * 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.
  40296. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  40297. */
  40298. export class ArcRotateCamera extends TargetCamera {
  40299. /**
  40300. * Defines the rotation angle of the camera along the longitudinal axis.
  40301. */
  40302. alpha: number;
  40303. /**
  40304. * Defines the rotation angle of the camera along the latitudinal axis.
  40305. */
  40306. beta: number;
  40307. /**
  40308. * Defines the radius of the camera from it s target point.
  40309. */
  40310. radius: number;
  40311. protected _target: Vector3;
  40312. protected _targetHost: Nullable<AbstractMesh>;
  40313. /**
  40314. * Defines the target point of the camera.
  40315. * The camera looks towards it form the radius distance.
  40316. */
  40317. get target(): Vector3;
  40318. set target(value: Vector3);
  40319. /**
  40320. * Define the current local position of the camera in the scene
  40321. */
  40322. get position(): Vector3;
  40323. set position(newPosition: Vector3);
  40324. protected _upVector: Vector3;
  40325. protected _upToYMatrix: Matrix;
  40326. protected _YToUpMatrix: Matrix;
  40327. /**
  40328. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  40329. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  40330. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  40331. */
  40332. set upVector(vec: Vector3);
  40333. get upVector(): Vector3;
  40334. /**
  40335. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  40336. */
  40337. setMatUp(): void;
  40338. /**
  40339. * Current inertia value on the longitudinal axis.
  40340. * The bigger this number the longer it will take for the camera to stop.
  40341. */
  40342. inertialAlphaOffset: number;
  40343. /**
  40344. * Current inertia value on the latitudinal axis.
  40345. * The bigger this number the longer it will take for the camera to stop.
  40346. */
  40347. inertialBetaOffset: number;
  40348. /**
  40349. * Current inertia value on the radius axis.
  40350. * The bigger this number the longer it will take for the camera to stop.
  40351. */
  40352. inertialRadiusOffset: number;
  40353. /**
  40354. * Minimum allowed angle on the longitudinal axis.
  40355. * This can help limiting how the Camera is able to move in the scene.
  40356. */
  40357. lowerAlphaLimit: Nullable<number>;
  40358. /**
  40359. * Maximum allowed angle on the longitudinal axis.
  40360. * This can help limiting how the Camera is able to move in the scene.
  40361. */
  40362. upperAlphaLimit: Nullable<number>;
  40363. /**
  40364. * Minimum allowed angle on the latitudinal axis.
  40365. * This can help limiting how the Camera is able to move in the scene.
  40366. */
  40367. lowerBetaLimit: number;
  40368. /**
  40369. * Maximum allowed angle on the latitudinal axis.
  40370. * This can help limiting how the Camera is able to move in the scene.
  40371. */
  40372. upperBetaLimit: number;
  40373. /**
  40374. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  40375. * This can help limiting how the Camera is able to move in the scene.
  40376. */
  40377. lowerRadiusLimit: Nullable<number>;
  40378. /**
  40379. * Maximum allowed distance of the camera to the target (The camera can not get further).
  40380. * This can help limiting how the Camera is able to move in the scene.
  40381. */
  40382. upperRadiusLimit: Nullable<number>;
  40383. /**
  40384. * Defines the current inertia value used during panning of the camera along the X axis.
  40385. */
  40386. inertialPanningX: number;
  40387. /**
  40388. * Defines the current inertia value used during panning of the camera along the Y axis.
  40389. */
  40390. inertialPanningY: number;
  40391. /**
  40392. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  40393. * Basically if your fingers moves away from more than this distance you will be considered
  40394. * in pinch mode.
  40395. */
  40396. pinchToPanMaxDistance: number;
  40397. /**
  40398. * Defines the maximum distance the camera can pan.
  40399. * This could help keeping the cammera always in your scene.
  40400. */
  40401. panningDistanceLimit: Nullable<number>;
  40402. /**
  40403. * Defines the target of the camera before paning.
  40404. */
  40405. panningOriginTarget: Vector3;
  40406. /**
  40407. * Defines the value of the inertia used during panning.
  40408. * 0 would mean stop inertia and one would mean no decelleration at all.
  40409. */
  40410. panningInertia: number;
  40411. /**
  40412. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  40413. */
  40414. get angularSensibilityX(): number;
  40415. set angularSensibilityX(value: number);
  40416. /**
  40417. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  40418. */
  40419. get angularSensibilityY(): number;
  40420. set angularSensibilityY(value: number);
  40421. /**
  40422. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  40423. */
  40424. get pinchPrecision(): number;
  40425. set pinchPrecision(value: number);
  40426. /**
  40427. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  40428. * It will be used instead of pinchDeltaPrecision if different from 0.
  40429. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  40430. */
  40431. get pinchDeltaPercentage(): number;
  40432. set pinchDeltaPercentage(value: number);
  40433. /**
  40434. * Gets or Set the pointer use natural pinch zoom to override the pinch precision
  40435. * and pinch delta percentage.
  40436. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  40437. * that any object in the plane at the camera's target point will scale
  40438. * perfectly with finger motion.
  40439. */
  40440. get useNaturalPinchZoom(): boolean;
  40441. set useNaturalPinchZoom(value: boolean);
  40442. /**
  40443. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  40444. */
  40445. get panningSensibility(): number;
  40446. set panningSensibility(value: number);
  40447. /**
  40448. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  40449. */
  40450. get keysUp(): number[];
  40451. set keysUp(value: number[]);
  40452. /**
  40453. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  40454. */
  40455. get keysDown(): number[];
  40456. set keysDown(value: number[]);
  40457. /**
  40458. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  40459. */
  40460. get keysLeft(): number[];
  40461. set keysLeft(value: number[]);
  40462. /**
  40463. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  40464. */
  40465. get keysRight(): number[];
  40466. set keysRight(value: number[]);
  40467. /**
  40468. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  40469. */
  40470. get wheelPrecision(): number;
  40471. set wheelPrecision(value: number);
  40472. /**
  40473. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  40474. * It will be used instead of pinchDeltaPrecision if different from 0.
  40475. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  40476. */
  40477. get wheelDeltaPercentage(): number;
  40478. set wheelDeltaPercentage(value: number);
  40479. /**
  40480. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  40481. */
  40482. zoomOnFactor: number;
  40483. /**
  40484. * Defines a screen offset for the camera position.
  40485. */
  40486. targetScreenOffset: Vector2;
  40487. /**
  40488. * Allows the camera to be completely reversed.
  40489. * If false the camera can not arrive upside down.
  40490. */
  40491. allowUpsideDown: boolean;
  40492. /**
  40493. * Define if double tap/click is used to restore the previously saved state of the camera.
  40494. */
  40495. useInputToRestoreState: boolean;
  40496. /** @hidden */
  40497. _viewMatrix: Matrix;
  40498. /** @hidden */
  40499. _useCtrlForPanning: boolean;
  40500. /** @hidden */
  40501. _panningMouseButton: number;
  40502. /**
  40503. * Defines the input associated to the camera.
  40504. */
  40505. inputs: ArcRotateCameraInputsManager;
  40506. /** @hidden */
  40507. _reset: () => void;
  40508. /**
  40509. * Defines the allowed panning axis.
  40510. */
  40511. panningAxis: Vector3;
  40512. protected _localDirection: Vector3;
  40513. protected _transformedDirection: Vector3;
  40514. private _bouncingBehavior;
  40515. /**
  40516. * Gets the bouncing behavior of the camera if it has been enabled.
  40517. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  40518. */
  40519. get bouncingBehavior(): Nullable<BouncingBehavior>;
  40520. /**
  40521. * Defines if the bouncing behavior of the camera is enabled on the camera.
  40522. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  40523. */
  40524. get useBouncingBehavior(): boolean;
  40525. set useBouncingBehavior(value: boolean);
  40526. private _framingBehavior;
  40527. /**
  40528. * Gets the framing behavior of the camera if it has been enabled.
  40529. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  40530. */
  40531. get framingBehavior(): Nullable<FramingBehavior>;
  40532. /**
  40533. * Defines if the framing behavior of the camera is enabled on the camera.
  40534. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  40535. */
  40536. get useFramingBehavior(): boolean;
  40537. set useFramingBehavior(value: boolean);
  40538. private _autoRotationBehavior;
  40539. /**
  40540. * Gets the auto rotation behavior of the camera if it has been enabled.
  40541. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  40542. */
  40543. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  40544. /**
  40545. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  40546. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  40547. */
  40548. get useAutoRotationBehavior(): boolean;
  40549. set useAutoRotationBehavior(value: boolean);
  40550. /**
  40551. * Observable triggered when the mesh target has been changed on the camera.
  40552. */
  40553. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  40554. /**
  40555. * Event raised when the camera is colliding with a mesh.
  40556. */
  40557. onCollide: (collidedMesh: AbstractMesh) => void;
  40558. /**
  40559. * Defines whether the camera should check collision with the objects oh the scene.
  40560. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  40561. */
  40562. checkCollisions: boolean;
  40563. /**
  40564. * Defines the collision radius of the camera.
  40565. * This simulates a sphere around the camera.
  40566. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  40567. */
  40568. collisionRadius: Vector3;
  40569. protected _collider: Collider;
  40570. protected _previousPosition: Vector3;
  40571. protected _collisionVelocity: Vector3;
  40572. protected _newPosition: Vector3;
  40573. protected _previousAlpha: number;
  40574. protected _previousBeta: number;
  40575. protected _previousRadius: number;
  40576. protected _collisionTriggered: boolean;
  40577. protected _targetBoundingCenter: Nullable<Vector3>;
  40578. private _computationVector;
  40579. /**
  40580. * Instantiates a new ArcRotateCamera in a given scene
  40581. * @param name Defines the name of the camera
  40582. * @param alpha Defines the camera rotation along the logitudinal axis
  40583. * @param beta Defines the camera rotation along the latitudinal axis
  40584. * @param radius Defines the camera distance from its target
  40585. * @param target Defines the camera target
  40586. * @param scene Defines the scene the camera belongs to
  40587. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  40588. */
  40589. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  40590. /** @hidden */
  40591. _initCache(): void;
  40592. /** @hidden */
  40593. _updateCache(ignoreParentClass?: boolean): void;
  40594. protected _getTargetPosition(): Vector3;
  40595. private _storedAlpha;
  40596. private _storedBeta;
  40597. private _storedRadius;
  40598. private _storedTarget;
  40599. private _storedTargetScreenOffset;
  40600. /**
  40601. * Stores the current state of the camera (alpha, beta, radius and target)
  40602. * @returns the camera itself
  40603. */
  40604. storeState(): Camera;
  40605. /**
  40606. * @hidden
  40607. * Restored camera state. You must call storeState() first
  40608. */
  40609. _restoreStateValues(): boolean;
  40610. /** @hidden */
  40611. _isSynchronizedViewMatrix(): boolean;
  40612. /**
  40613. * Attached controls to the current camera.
  40614. * @param element Defines the element the controls should be listened from
  40615. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40616. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  40617. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  40618. */
  40619. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  40620. /**
  40621. * Detach the current controls from the camera.
  40622. * The camera will stop reacting to inputs.
  40623. * @param element Defines the element to stop listening the inputs from
  40624. */
  40625. detachControl(element: HTMLElement): void;
  40626. /** @hidden */
  40627. _checkInputs(): void;
  40628. protected _checkLimits(): void;
  40629. /**
  40630. * Rebuilds angles (alpha, beta) and radius from the give position and target
  40631. */
  40632. rebuildAnglesAndRadius(): void;
  40633. /**
  40634. * Use a position to define the current camera related information like alpha, beta and radius
  40635. * @param position Defines the position to set the camera at
  40636. */
  40637. setPosition(position: Vector3): void;
  40638. /**
  40639. * Defines the target the camera should look at.
  40640. * This will automatically adapt alpha beta and radius to fit within the new target.
  40641. * @param target Defines the new target as a Vector or a mesh
  40642. * @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
  40643. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  40644. */
  40645. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  40646. /** @hidden */
  40647. _getViewMatrix(): Matrix;
  40648. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  40649. /**
  40650. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  40651. * @param meshes Defines the mesh to zoom on
  40652. * @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)
  40653. */
  40654. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  40655. /**
  40656. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  40657. * The target will be changed but the radius
  40658. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  40659. * @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)
  40660. */
  40661. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  40662. min: Vector3;
  40663. max: Vector3;
  40664. distance: number;
  40665. }, doNotUpdateMaxZ?: boolean): void;
  40666. /**
  40667. * @override
  40668. * Override Camera.createRigCamera
  40669. */
  40670. createRigCamera(name: string, cameraIndex: number): Camera;
  40671. /**
  40672. * @hidden
  40673. * @override
  40674. * Override Camera._updateRigCameras
  40675. */
  40676. _updateRigCameras(): void;
  40677. /**
  40678. * Destroy the camera and release the current resources hold by it.
  40679. */
  40680. dispose(): void;
  40681. /**
  40682. * Gets the current object class name.
  40683. * @return the class name
  40684. */
  40685. getClassName(): string;
  40686. }
  40687. }
  40688. declare module "babylonjs/Behaviors/Cameras/autoRotationBehavior" {
  40689. import { Behavior } from "babylonjs/Behaviors/behavior";
  40690. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  40691. /**
  40692. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  40693. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  40694. */
  40695. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  40696. /**
  40697. * Gets the name of the behavior.
  40698. */
  40699. get name(): string;
  40700. private _zoomStopsAnimation;
  40701. private _idleRotationSpeed;
  40702. private _idleRotationWaitTime;
  40703. private _idleRotationSpinupTime;
  40704. /**
  40705. * Sets the flag that indicates if user zooming should stop animation.
  40706. */
  40707. set zoomStopsAnimation(flag: boolean);
  40708. /**
  40709. * Gets the flag that indicates if user zooming should stop animation.
  40710. */
  40711. get zoomStopsAnimation(): boolean;
  40712. /**
  40713. * Sets the default speed at which the camera rotates around the model.
  40714. */
  40715. set idleRotationSpeed(speed: number);
  40716. /**
  40717. * Gets the default speed at which the camera rotates around the model.
  40718. */
  40719. get idleRotationSpeed(): number;
  40720. /**
  40721. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  40722. */
  40723. set idleRotationWaitTime(time: number);
  40724. /**
  40725. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  40726. */
  40727. get idleRotationWaitTime(): number;
  40728. /**
  40729. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  40730. */
  40731. set idleRotationSpinupTime(time: number);
  40732. /**
  40733. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  40734. */
  40735. get idleRotationSpinupTime(): number;
  40736. /**
  40737. * Gets a value indicating if the camera is currently rotating because of this behavior
  40738. */
  40739. get rotationInProgress(): boolean;
  40740. private _onPrePointerObservableObserver;
  40741. private _onAfterCheckInputsObserver;
  40742. private _attachedCamera;
  40743. private _isPointerDown;
  40744. private _lastFrameTime;
  40745. private _lastInteractionTime;
  40746. private _cameraRotationSpeed;
  40747. /**
  40748. * Initializes the behavior.
  40749. */
  40750. init(): void;
  40751. /**
  40752. * Attaches the behavior to its arc rotate camera.
  40753. * @param camera Defines the camera to attach the behavior to
  40754. */
  40755. attach(camera: ArcRotateCamera): void;
  40756. /**
  40757. * Detaches the behavior from its current arc rotate camera.
  40758. */
  40759. detach(): void;
  40760. /**
  40761. * Returns true if user is scrolling.
  40762. * @return true if user is scrolling.
  40763. */
  40764. private _userIsZooming;
  40765. private _lastFrameRadius;
  40766. private _shouldAnimationStopForInteraction;
  40767. /**
  40768. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  40769. */
  40770. private _applyUserInteraction;
  40771. private _userIsMoving;
  40772. }
  40773. }
  40774. declare module "babylonjs/Behaviors/Cameras/index" {
  40775. export * from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  40776. export * from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  40777. export * from "babylonjs/Behaviors/Cameras/framingBehavior";
  40778. }
  40779. declare module "babylonjs/Behaviors/Meshes/attachToBoxBehavior" {
  40780. import { Mesh } from "babylonjs/Meshes/mesh";
  40781. import { TransformNode } from "babylonjs/Meshes/transformNode";
  40782. import { Behavior } from "babylonjs/Behaviors/behavior";
  40783. /**
  40784. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  40785. */
  40786. export class AttachToBoxBehavior implements Behavior<Mesh> {
  40787. private ui;
  40788. /**
  40789. * The name of the behavior
  40790. */
  40791. name: string;
  40792. /**
  40793. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  40794. */
  40795. distanceAwayFromFace: number;
  40796. /**
  40797. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  40798. */
  40799. distanceAwayFromBottomOfFace: number;
  40800. private _faceVectors;
  40801. private _target;
  40802. private _scene;
  40803. private _onRenderObserver;
  40804. private _tmpMatrix;
  40805. private _tmpVector;
  40806. /**
  40807. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  40808. * @param ui The transform node that should be attched to the mesh
  40809. */
  40810. constructor(ui: TransformNode);
  40811. /**
  40812. * Initializes the behavior
  40813. */
  40814. init(): void;
  40815. private _closestFace;
  40816. private _zeroVector;
  40817. private _lookAtTmpMatrix;
  40818. private _lookAtToRef;
  40819. /**
  40820. * Attaches the AttachToBoxBehavior to the passed in mesh
  40821. * @param target The mesh that the specified node will be attached to
  40822. */
  40823. attach(target: Mesh): void;
  40824. /**
  40825. * Detaches the behavior from the mesh
  40826. */
  40827. detach(): void;
  40828. }
  40829. }
  40830. declare module "babylonjs/Behaviors/Meshes/fadeInOutBehavior" {
  40831. import { Behavior } from "babylonjs/Behaviors/behavior";
  40832. import { Mesh } from "babylonjs/Meshes/mesh";
  40833. /**
  40834. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  40835. */
  40836. export class FadeInOutBehavior implements Behavior<Mesh> {
  40837. /**
  40838. * Time in milliseconds to delay before fading in (Default: 0)
  40839. */
  40840. delay: number;
  40841. /**
  40842. * Time in milliseconds for the mesh to fade in (Default: 300)
  40843. */
  40844. fadeInTime: number;
  40845. private _millisecondsPerFrame;
  40846. private _hovered;
  40847. private _hoverValue;
  40848. private _ownerNode;
  40849. /**
  40850. * Instatiates the FadeInOutBehavior
  40851. */
  40852. constructor();
  40853. /**
  40854. * The name of the behavior
  40855. */
  40856. get name(): string;
  40857. /**
  40858. * Initializes the behavior
  40859. */
  40860. init(): void;
  40861. /**
  40862. * Attaches the fade behavior on the passed in mesh
  40863. * @param ownerNode The mesh that will be faded in/out once attached
  40864. */
  40865. attach(ownerNode: Mesh): void;
  40866. /**
  40867. * Detaches the behavior from the mesh
  40868. */
  40869. detach(): void;
  40870. /**
  40871. * Triggers the mesh to begin fading in or out
  40872. * @param value if the object should fade in or out (true to fade in)
  40873. */
  40874. fadeIn(value: boolean): void;
  40875. private _update;
  40876. private _setAllVisibility;
  40877. }
  40878. }
  40879. declare module "babylonjs/Misc/pivotTools" {
  40880. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40881. /**
  40882. * Class containing a set of static utilities functions for managing Pivots
  40883. * @hidden
  40884. */
  40885. export class PivotTools {
  40886. private static _PivotCached;
  40887. private static _OldPivotPoint;
  40888. private static _PivotTranslation;
  40889. private static _PivotTmpVector;
  40890. /** @hidden */
  40891. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  40892. /** @hidden */
  40893. static _RestorePivotPoint(mesh: AbstractMesh): void;
  40894. }
  40895. }
  40896. declare module "babylonjs/Meshes/Builders/planeBuilder" {
  40897. import { Scene } from "babylonjs/scene";
  40898. import { Vector4 } from "babylonjs/Maths/math.vector";
  40899. import { Mesh } from "babylonjs/Meshes/mesh";
  40900. import { Nullable } from "babylonjs/types";
  40901. import { Plane } from "babylonjs/Maths/math.plane";
  40902. /**
  40903. * Class containing static functions to help procedurally build meshes
  40904. */
  40905. export class PlaneBuilder {
  40906. /**
  40907. * Creates a plane mesh
  40908. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  40909. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  40910. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  40911. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  40912. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  40913. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  40914. * @param name defines the name of the mesh
  40915. * @param options defines the options used to create the mesh
  40916. * @param scene defines the hosting scene
  40917. * @returns the plane mesh
  40918. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  40919. */
  40920. static CreatePlane(name: string, options: {
  40921. size?: number;
  40922. width?: number;
  40923. height?: number;
  40924. sideOrientation?: number;
  40925. frontUVs?: Vector4;
  40926. backUVs?: Vector4;
  40927. updatable?: boolean;
  40928. sourcePlane?: Plane;
  40929. }, scene?: Nullable<Scene>): Mesh;
  40930. }
  40931. }
  40932. declare module "babylonjs/Behaviors/Meshes/pointerDragBehavior" {
  40933. import { Behavior } from "babylonjs/Behaviors/behavior";
  40934. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40935. import { Observable } from "babylonjs/Misc/observable";
  40936. import { Vector3 } from "babylonjs/Maths/math.vector";
  40937. import { Ray } from "babylonjs/Culling/ray";
  40938. import "babylonjs/Meshes/Builders/planeBuilder";
  40939. /**
  40940. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  40941. */
  40942. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  40943. private static _AnyMouseID;
  40944. /**
  40945. * Abstract mesh the behavior is set on
  40946. */
  40947. attachedNode: AbstractMesh;
  40948. private _dragPlane;
  40949. private _scene;
  40950. private _pointerObserver;
  40951. private _beforeRenderObserver;
  40952. private static _planeScene;
  40953. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  40954. /**
  40955. * 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)
  40956. */
  40957. maxDragAngle: number;
  40958. /**
  40959. * @hidden
  40960. */
  40961. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  40962. /**
  40963. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  40964. */
  40965. currentDraggingPointerID: number;
  40966. /**
  40967. * The last position where the pointer hit the drag plane in world space
  40968. */
  40969. lastDragPosition: Vector3;
  40970. /**
  40971. * If the behavior is currently in a dragging state
  40972. */
  40973. dragging: boolean;
  40974. /**
  40975. * 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)
  40976. */
  40977. dragDeltaRatio: number;
  40978. /**
  40979. * If the drag plane orientation should be updated during the dragging (Default: true)
  40980. */
  40981. updateDragPlane: boolean;
  40982. private _debugMode;
  40983. private _moving;
  40984. /**
  40985. * Fires each time the attached mesh is dragged with the pointer
  40986. * * delta between last drag position and current drag position in world space
  40987. * * dragDistance along the drag axis
  40988. * * dragPlaneNormal normal of the current drag plane used during the drag
  40989. * * dragPlanePoint in world space where the drag intersects the drag plane
  40990. */
  40991. onDragObservable: Observable<{
  40992. delta: Vector3;
  40993. dragPlanePoint: Vector3;
  40994. dragPlaneNormal: Vector3;
  40995. dragDistance: number;
  40996. pointerId: number;
  40997. }>;
  40998. /**
  40999. * Fires each time a drag begins (eg. mouse down on mesh)
  41000. */
  41001. onDragStartObservable: Observable<{
  41002. dragPlanePoint: Vector3;
  41003. pointerId: number;
  41004. }>;
  41005. /**
  41006. * Fires each time a drag ends (eg. mouse release after drag)
  41007. */
  41008. onDragEndObservable: Observable<{
  41009. dragPlanePoint: Vector3;
  41010. pointerId: number;
  41011. }>;
  41012. /**
  41013. * If the attached mesh should be moved when dragged
  41014. */
  41015. moveAttached: boolean;
  41016. /**
  41017. * If the drag behavior will react to drag events (Default: true)
  41018. */
  41019. enabled: boolean;
  41020. /**
  41021. * If pointer events should start and release the drag (Default: true)
  41022. */
  41023. startAndReleaseDragOnPointerEvents: boolean;
  41024. /**
  41025. * If camera controls should be detached during the drag
  41026. */
  41027. detachCameraControls: boolean;
  41028. /**
  41029. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  41030. */
  41031. useObjectOrientationForDragging: boolean;
  41032. private _options;
  41033. /**
  41034. * Gets the options used by the behavior
  41035. */
  41036. get options(): {
  41037. dragAxis?: Vector3;
  41038. dragPlaneNormal?: Vector3;
  41039. };
  41040. /**
  41041. * Sets the options used by the behavior
  41042. */
  41043. set options(options: {
  41044. dragAxis?: Vector3;
  41045. dragPlaneNormal?: Vector3;
  41046. });
  41047. /**
  41048. * Creates a pointer drag behavior that can be attached to a mesh
  41049. * @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)
  41050. */
  41051. constructor(options?: {
  41052. dragAxis?: Vector3;
  41053. dragPlaneNormal?: Vector3;
  41054. });
  41055. /**
  41056. * Predicate to determine if it is valid to move the object to a new position when it is moved
  41057. */
  41058. validateDrag: (targetPosition: Vector3) => boolean;
  41059. /**
  41060. * The name of the behavior
  41061. */
  41062. get name(): string;
  41063. /**
  41064. * Initializes the behavior
  41065. */
  41066. init(): void;
  41067. private _tmpVector;
  41068. private _alternatePickedPoint;
  41069. private _worldDragAxis;
  41070. private _targetPosition;
  41071. private _attachedElement;
  41072. /**
  41073. * Attaches the drag behavior the passed in mesh
  41074. * @param ownerNode The mesh that will be dragged around once attached
  41075. * @param predicate Predicate to use for pick filtering
  41076. */
  41077. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  41078. /**
  41079. * Force relase the drag action by code.
  41080. */
  41081. releaseDrag(): void;
  41082. private _startDragRay;
  41083. private _lastPointerRay;
  41084. /**
  41085. * Simulates the start of a pointer drag event on the behavior
  41086. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  41087. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  41088. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  41089. */
  41090. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  41091. private _startDrag;
  41092. private _dragDelta;
  41093. private _moveDrag;
  41094. private _pickWithRayOnDragPlane;
  41095. private _pointA;
  41096. private _pointB;
  41097. private _pointC;
  41098. private _lineA;
  41099. private _lineB;
  41100. private _localAxis;
  41101. private _lookAt;
  41102. private _updateDragPlanePosition;
  41103. /**
  41104. * Detaches the behavior from the mesh
  41105. */
  41106. detach(): void;
  41107. }
  41108. }
  41109. declare module "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior" {
  41110. import { Mesh } from "babylonjs/Meshes/mesh";
  41111. import { Behavior } from "babylonjs/Behaviors/behavior";
  41112. /**
  41113. * A behavior that when attached to a mesh will allow the mesh to be scaled
  41114. */
  41115. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  41116. private _dragBehaviorA;
  41117. private _dragBehaviorB;
  41118. private _startDistance;
  41119. private _initialScale;
  41120. private _targetScale;
  41121. private _ownerNode;
  41122. private _sceneRenderObserver;
  41123. /**
  41124. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  41125. */
  41126. constructor();
  41127. /**
  41128. * The name of the behavior
  41129. */
  41130. get name(): string;
  41131. /**
  41132. * Initializes the behavior
  41133. */
  41134. init(): void;
  41135. private _getCurrentDistance;
  41136. /**
  41137. * Attaches the scale behavior the passed in mesh
  41138. * @param ownerNode The mesh that will be scaled around once attached
  41139. */
  41140. attach(ownerNode: Mesh): void;
  41141. /**
  41142. * Detaches the behavior from the mesh
  41143. */
  41144. detach(): void;
  41145. }
  41146. }
  41147. declare module "babylonjs/Behaviors/Meshes/sixDofDragBehavior" {
  41148. import { Behavior } from "babylonjs/Behaviors/behavior";
  41149. import { Mesh } from "babylonjs/Meshes/mesh";
  41150. import { Observable } from "babylonjs/Misc/observable";
  41151. /**
  41152. * 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
  41153. */
  41154. export class SixDofDragBehavior implements Behavior<Mesh> {
  41155. private static _virtualScene;
  41156. private _ownerNode;
  41157. private _sceneRenderObserver;
  41158. private _scene;
  41159. private _targetPosition;
  41160. private _virtualOriginMesh;
  41161. private _virtualDragMesh;
  41162. private _pointerObserver;
  41163. private _moving;
  41164. private _startingOrientation;
  41165. private _attachedElement;
  41166. /**
  41167. * 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)
  41168. */
  41169. private zDragFactor;
  41170. /**
  41171. * If the object should rotate to face the drag origin
  41172. */
  41173. rotateDraggedObject: boolean;
  41174. /**
  41175. * If the behavior is currently in a dragging state
  41176. */
  41177. dragging: boolean;
  41178. /**
  41179. * 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)
  41180. */
  41181. dragDeltaRatio: number;
  41182. /**
  41183. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  41184. */
  41185. currentDraggingPointerID: number;
  41186. /**
  41187. * If camera controls should be detached during the drag
  41188. */
  41189. detachCameraControls: boolean;
  41190. /**
  41191. * Fires each time a drag starts
  41192. */
  41193. onDragStartObservable: Observable<{}>;
  41194. /**
  41195. * Fires each time a drag ends (eg. mouse release after drag)
  41196. */
  41197. onDragEndObservable: Observable<{}>;
  41198. /**
  41199. * 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
  41200. */
  41201. constructor();
  41202. /**
  41203. * The name of the behavior
  41204. */
  41205. get name(): string;
  41206. /**
  41207. * Initializes the behavior
  41208. */
  41209. init(): void;
  41210. /**
  41211. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  41212. */
  41213. private get _pointerCamera();
  41214. /**
  41215. * Attaches the scale behavior the passed in mesh
  41216. * @param ownerNode The mesh that will be scaled around once attached
  41217. */
  41218. attach(ownerNode: Mesh): void;
  41219. /**
  41220. * Detaches the behavior from the mesh
  41221. */
  41222. detach(): void;
  41223. }
  41224. }
  41225. declare module "babylonjs/Behaviors/Meshes/index" {
  41226. export * from "babylonjs/Behaviors/Meshes/attachToBoxBehavior";
  41227. export * from "babylonjs/Behaviors/Meshes/fadeInOutBehavior";
  41228. export * from "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior";
  41229. export * from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  41230. export * from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  41231. }
  41232. declare module "babylonjs/Behaviors/index" {
  41233. export * from "babylonjs/Behaviors/behavior";
  41234. export * from "babylonjs/Behaviors/Cameras/index";
  41235. export * from "babylonjs/Behaviors/Meshes/index";
  41236. }
  41237. declare module "babylonjs/Bones/boneIKController" {
  41238. import { Bone } from "babylonjs/Bones/bone";
  41239. import { Vector3 } from "babylonjs/Maths/math.vector";
  41240. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41241. import { Nullable } from "babylonjs/types";
  41242. /**
  41243. * Class used to apply inverse kinematics to bones
  41244. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  41245. */
  41246. export class BoneIKController {
  41247. private static _tmpVecs;
  41248. private static _tmpQuat;
  41249. private static _tmpMats;
  41250. /**
  41251. * Gets or sets the target mesh
  41252. */
  41253. targetMesh: AbstractMesh;
  41254. /** Gets or sets the mesh used as pole */
  41255. poleTargetMesh: AbstractMesh;
  41256. /**
  41257. * Gets or sets the bone used as pole
  41258. */
  41259. poleTargetBone: Nullable<Bone>;
  41260. /**
  41261. * Gets or sets the target position
  41262. */
  41263. targetPosition: Vector3;
  41264. /**
  41265. * Gets or sets the pole target position
  41266. */
  41267. poleTargetPosition: Vector3;
  41268. /**
  41269. * Gets or sets the pole target local offset
  41270. */
  41271. poleTargetLocalOffset: Vector3;
  41272. /**
  41273. * Gets or sets the pole angle
  41274. */
  41275. poleAngle: number;
  41276. /**
  41277. * Gets or sets the mesh associated with the controller
  41278. */
  41279. mesh: AbstractMesh;
  41280. /**
  41281. * 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)
  41282. */
  41283. slerpAmount: number;
  41284. private _bone1Quat;
  41285. private _bone1Mat;
  41286. private _bone2Ang;
  41287. private _bone1;
  41288. private _bone2;
  41289. private _bone1Length;
  41290. private _bone2Length;
  41291. private _maxAngle;
  41292. private _maxReach;
  41293. private _rightHandedSystem;
  41294. private _bendAxis;
  41295. private _slerping;
  41296. private _adjustRoll;
  41297. /**
  41298. * Gets or sets maximum allowed angle
  41299. */
  41300. get maxAngle(): number;
  41301. set maxAngle(value: number);
  41302. /**
  41303. * Creates a new BoneIKController
  41304. * @param mesh defines the mesh to control
  41305. * @param bone defines the bone to control
  41306. * @param options defines options to set up the controller
  41307. */
  41308. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  41309. targetMesh?: AbstractMesh;
  41310. poleTargetMesh?: AbstractMesh;
  41311. poleTargetBone?: Bone;
  41312. poleTargetLocalOffset?: Vector3;
  41313. poleAngle?: number;
  41314. bendAxis?: Vector3;
  41315. maxAngle?: number;
  41316. slerpAmount?: number;
  41317. });
  41318. private _setMaxAngle;
  41319. /**
  41320. * Force the controller to update the bones
  41321. */
  41322. update(): void;
  41323. }
  41324. }
  41325. declare module "babylonjs/Bones/boneLookController" {
  41326. import { Vector3 } from "babylonjs/Maths/math.vector";
  41327. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41328. import { Bone } from "babylonjs/Bones/bone";
  41329. import { Space } from "babylonjs/Maths/math.axis";
  41330. /**
  41331. * Class used to make a bone look toward a point in space
  41332. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  41333. */
  41334. export class BoneLookController {
  41335. private static _tmpVecs;
  41336. private static _tmpQuat;
  41337. private static _tmpMats;
  41338. /**
  41339. * The target Vector3 that the bone will look at
  41340. */
  41341. target: Vector3;
  41342. /**
  41343. * The mesh that the bone is attached to
  41344. */
  41345. mesh: AbstractMesh;
  41346. /**
  41347. * The bone that will be looking to the target
  41348. */
  41349. bone: Bone;
  41350. /**
  41351. * The up axis of the coordinate system that is used when the bone is rotated
  41352. */
  41353. upAxis: Vector3;
  41354. /**
  41355. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  41356. */
  41357. upAxisSpace: Space;
  41358. /**
  41359. * Used to make an adjustment to the yaw of the bone
  41360. */
  41361. adjustYaw: number;
  41362. /**
  41363. * Used to make an adjustment to the pitch of the bone
  41364. */
  41365. adjustPitch: number;
  41366. /**
  41367. * Used to make an adjustment to the roll of the bone
  41368. */
  41369. adjustRoll: number;
  41370. /**
  41371. * 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)
  41372. */
  41373. slerpAmount: number;
  41374. private _minYaw;
  41375. private _maxYaw;
  41376. private _minPitch;
  41377. private _maxPitch;
  41378. private _minYawSin;
  41379. private _minYawCos;
  41380. private _maxYawSin;
  41381. private _maxYawCos;
  41382. private _midYawConstraint;
  41383. private _minPitchTan;
  41384. private _maxPitchTan;
  41385. private _boneQuat;
  41386. private _slerping;
  41387. private _transformYawPitch;
  41388. private _transformYawPitchInv;
  41389. private _firstFrameSkipped;
  41390. private _yawRange;
  41391. private _fowardAxis;
  41392. /**
  41393. * Gets or sets the minimum yaw angle that the bone can look to
  41394. */
  41395. get minYaw(): number;
  41396. set minYaw(value: number);
  41397. /**
  41398. * Gets or sets the maximum yaw angle that the bone can look to
  41399. */
  41400. get maxYaw(): number;
  41401. set maxYaw(value: number);
  41402. /**
  41403. * Gets or sets the minimum pitch angle that the bone can look to
  41404. */
  41405. get minPitch(): number;
  41406. set minPitch(value: number);
  41407. /**
  41408. * Gets or sets the maximum pitch angle that the bone can look to
  41409. */
  41410. get maxPitch(): number;
  41411. set maxPitch(value: number);
  41412. /**
  41413. * Create a BoneLookController
  41414. * @param mesh the mesh that the bone belongs to
  41415. * @param bone the bone that will be looking to the target
  41416. * @param target the target Vector3 to look at
  41417. * @param options optional settings:
  41418. * * maxYaw: the maximum angle the bone will yaw to
  41419. * * minYaw: the minimum angle the bone will yaw to
  41420. * * maxPitch: the maximum angle the bone will pitch to
  41421. * * minPitch: the minimum angle the bone will yaw to
  41422. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  41423. * * upAxis: the up axis of the coordinate system
  41424. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  41425. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  41426. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  41427. * * adjustYaw: used to make an adjustment to the yaw of the bone
  41428. * * adjustPitch: used to make an adjustment to the pitch of the bone
  41429. * * adjustRoll: used to make an adjustment to the roll of the bone
  41430. **/
  41431. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  41432. maxYaw?: number;
  41433. minYaw?: number;
  41434. maxPitch?: number;
  41435. minPitch?: number;
  41436. slerpAmount?: number;
  41437. upAxis?: Vector3;
  41438. upAxisSpace?: Space;
  41439. yawAxis?: Vector3;
  41440. pitchAxis?: Vector3;
  41441. adjustYaw?: number;
  41442. adjustPitch?: number;
  41443. adjustRoll?: number;
  41444. });
  41445. /**
  41446. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  41447. */
  41448. update(): void;
  41449. private _getAngleDiff;
  41450. private _getAngleBetween;
  41451. private _isAngleBetween;
  41452. }
  41453. }
  41454. declare module "babylonjs/Bones/index" {
  41455. export * from "babylonjs/Bones/bone";
  41456. export * from "babylonjs/Bones/boneIKController";
  41457. export * from "babylonjs/Bones/boneLookController";
  41458. export * from "babylonjs/Bones/skeleton";
  41459. }
  41460. declare module "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput" {
  41461. import { Nullable } from "babylonjs/types";
  41462. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  41463. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  41464. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  41465. /**
  41466. * Manage the gamepad inputs to control an arc rotate camera.
  41467. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41468. */
  41469. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  41470. /**
  41471. * Defines the camera the input is attached to.
  41472. */
  41473. camera: ArcRotateCamera;
  41474. /**
  41475. * Defines the gamepad the input is gathering event from.
  41476. */
  41477. gamepad: Nullable<Gamepad>;
  41478. /**
  41479. * Defines the gamepad rotation sensiblity.
  41480. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  41481. */
  41482. gamepadRotationSensibility: number;
  41483. /**
  41484. * Defines the gamepad move sensiblity.
  41485. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  41486. */
  41487. gamepadMoveSensibility: number;
  41488. private _yAxisScale;
  41489. /**
  41490. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  41491. */
  41492. get invertYAxis(): boolean;
  41493. set invertYAxis(value: boolean);
  41494. private _onGamepadConnectedObserver;
  41495. private _onGamepadDisconnectedObserver;
  41496. /**
  41497. * Attach the input controls to a specific dom element to get the input from.
  41498. * @param element Defines the element the controls should be listened from
  41499. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41500. */
  41501. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41502. /**
  41503. * Detach the current controls from the specified dom element.
  41504. * @param element Defines the element to stop listening the inputs from
  41505. */
  41506. detachControl(element: Nullable<HTMLElement>): void;
  41507. /**
  41508. * Update the current camera state depending on the inputs that have been used this frame.
  41509. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41510. */
  41511. checkInputs(): void;
  41512. /**
  41513. * Gets the class name of the current intput.
  41514. * @returns the class name
  41515. */
  41516. getClassName(): string;
  41517. /**
  41518. * Get the friendly name associated with the input class.
  41519. * @returns the input friendly name
  41520. */
  41521. getSimpleName(): string;
  41522. }
  41523. }
  41524. declare module "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput" {
  41525. import { Nullable } from "babylonjs/types";
  41526. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  41527. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  41528. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  41529. interface ArcRotateCameraInputsManager {
  41530. /**
  41531. * Add orientation input support to the input manager.
  41532. * @returns the current input manager
  41533. */
  41534. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  41535. }
  41536. }
  41537. /**
  41538. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  41539. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41540. */
  41541. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  41542. /**
  41543. * Defines the camera the input is attached to.
  41544. */
  41545. camera: ArcRotateCamera;
  41546. /**
  41547. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  41548. */
  41549. alphaCorrection: number;
  41550. /**
  41551. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  41552. */
  41553. gammaCorrection: number;
  41554. private _alpha;
  41555. private _gamma;
  41556. private _dirty;
  41557. private _deviceOrientationHandler;
  41558. /**
  41559. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  41560. */
  41561. constructor();
  41562. /**
  41563. * Attach the input controls to a specific dom element to get the input from.
  41564. * @param element Defines the element the controls should be listened from
  41565. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41566. */
  41567. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41568. /** @hidden */
  41569. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  41570. /**
  41571. * Update the current camera state depending on the inputs that have been used this frame.
  41572. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41573. */
  41574. checkInputs(): void;
  41575. /**
  41576. * Detach the current controls from the specified dom element.
  41577. * @param element Defines the element to stop listening the inputs from
  41578. */
  41579. detachControl(element: Nullable<HTMLElement>): void;
  41580. /**
  41581. * Gets the class name of the current intput.
  41582. * @returns the class name
  41583. */
  41584. getClassName(): string;
  41585. /**
  41586. * Get the friendly name associated with the input class.
  41587. * @returns the input friendly name
  41588. */
  41589. getSimpleName(): string;
  41590. }
  41591. }
  41592. declare module "babylonjs/Cameras/Inputs/flyCameraMouseInput" {
  41593. import { Nullable } from "babylonjs/types";
  41594. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  41595. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  41596. /**
  41597. * Listen to mouse events to control the camera.
  41598. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41599. */
  41600. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  41601. /**
  41602. * Defines the camera the input is attached to.
  41603. */
  41604. camera: FlyCamera;
  41605. /**
  41606. * Defines if touch is enabled. (Default is true.)
  41607. */
  41608. touchEnabled: boolean;
  41609. /**
  41610. * Defines the buttons associated with the input to handle camera rotation.
  41611. */
  41612. buttons: number[];
  41613. /**
  41614. * Assign buttons for Yaw control.
  41615. */
  41616. buttonsYaw: number[];
  41617. /**
  41618. * Assign buttons for Pitch control.
  41619. */
  41620. buttonsPitch: number[];
  41621. /**
  41622. * Assign buttons for Roll control.
  41623. */
  41624. buttonsRoll: number[];
  41625. /**
  41626. * Detect if any button is being pressed while mouse is moved.
  41627. * -1 = Mouse locked.
  41628. * 0 = Left button.
  41629. * 1 = Middle Button.
  41630. * 2 = Right Button.
  41631. */
  41632. activeButton: number;
  41633. /**
  41634. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  41635. * Higher values reduce its sensitivity.
  41636. */
  41637. angularSensibility: number;
  41638. private _mousemoveCallback;
  41639. private _observer;
  41640. private _rollObserver;
  41641. private previousPosition;
  41642. private noPreventDefault;
  41643. private element;
  41644. /**
  41645. * Listen to mouse events to control the camera.
  41646. * @param touchEnabled Define if touch is enabled. (Default is true.)
  41647. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41648. */
  41649. constructor(touchEnabled?: boolean);
  41650. /**
  41651. * Attach the mouse control to the HTML DOM element.
  41652. * @param element Defines the element that listens to the input events.
  41653. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  41654. */
  41655. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41656. /**
  41657. * Detach the current controls from the specified dom element.
  41658. * @param element Defines the element to stop listening the inputs from
  41659. */
  41660. detachControl(element: Nullable<HTMLElement>): void;
  41661. /**
  41662. * Gets the class name of the current input.
  41663. * @returns the class name.
  41664. */
  41665. getClassName(): string;
  41666. /**
  41667. * Get the friendly name associated with the input class.
  41668. * @returns the input's friendly name.
  41669. */
  41670. getSimpleName(): string;
  41671. private _pointerInput;
  41672. private _onMouseMove;
  41673. /**
  41674. * Rotate camera by mouse offset.
  41675. */
  41676. private rotateCamera;
  41677. }
  41678. }
  41679. declare module "babylonjs/Cameras/flyCameraInputsManager" {
  41680. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  41681. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  41682. /**
  41683. * Default Inputs manager for the FlyCamera.
  41684. * It groups all the default supported inputs for ease of use.
  41685. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41686. */
  41687. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  41688. /**
  41689. * Instantiates a new FlyCameraInputsManager.
  41690. * @param camera Defines the camera the inputs belong to.
  41691. */
  41692. constructor(camera: FlyCamera);
  41693. /**
  41694. * Add keyboard input support to the input manager.
  41695. * @returns the new FlyCameraKeyboardMoveInput().
  41696. */
  41697. addKeyboard(): FlyCameraInputsManager;
  41698. /**
  41699. * Add mouse input support to the input manager.
  41700. * @param touchEnabled Enable touch screen support.
  41701. * @returns the new FlyCameraMouseInput().
  41702. */
  41703. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  41704. }
  41705. }
  41706. declare module "babylonjs/Cameras/flyCamera" {
  41707. import { Scene } from "babylonjs/scene";
  41708. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  41709. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41710. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  41711. import { FlyCameraInputsManager } from "babylonjs/Cameras/flyCameraInputsManager";
  41712. /**
  41713. * This is a flying camera, designed for 3D movement and rotation in all directions,
  41714. * such as in a 3D Space Shooter or a Flight Simulator.
  41715. */
  41716. export class FlyCamera extends TargetCamera {
  41717. /**
  41718. * Define the collision ellipsoid of the camera.
  41719. * This is helpful for simulating a camera body, like a player's body.
  41720. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  41721. */
  41722. ellipsoid: Vector3;
  41723. /**
  41724. * Define an offset for the position of the ellipsoid around the camera.
  41725. * This can be helpful if the camera is attached away from the player's body center,
  41726. * such as at its head.
  41727. */
  41728. ellipsoidOffset: Vector3;
  41729. /**
  41730. * Enable or disable collisions of the camera with the rest of the scene objects.
  41731. */
  41732. checkCollisions: boolean;
  41733. /**
  41734. * Enable or disable gravity on the camera.
  41735. */
  41736. applyGravity: boolean;
  41737. /**
  41738. * Define the current direction the camera is moving to.
  41739. */
  41740. cameraDirection: Vector3;
  41741. /**
  41742. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  41743. * This overrides and empties cameraRotation.
  41744. */
  41745. rotationQuaternion: Quaternion;
  41746. /**
  41747. * Track Roll to maintain the wanted Rolling when looking around.
  41748. */
  41749. _trackRoll: number;
  41750. /**
  41751. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  41752. */
  41753. rollCorrect: number;
  41754. /**
  41755. * Mimic a banked turn, Rolling the camera when Yawing.
  41756. * It's recommended to use rollCorrect = 10 for faster banking correction.
  41757. */
  41758. bankedTurn: boolean;
  41759. /**
  41760. * Limit in radians for how much Roll banking will add. (Default: 90°)
  41761. */
  41762. bankedTurnLimit: number;
  41763. /**
  41764. * Value of 0 disables the banked Roll.
  41765. * Value of 1 is equal to the Yaw angle in radians.
  41766. */
  41767. bankedTurnMultiplier: number;
  41768. /**
  41769. * The inputs manager loads all the input sources, such as keyboard and mouse.
  41770. */
  41771. inputs: FlyCameraInputsManager;
  41772. /**
  41773. * Gets the input sensibility for mouse input.
  41774. * Higher values reduce sensitivity.
  41775. */
  41776. get angularSensibility(): number;
  41777. /**
  41778. * Sets the input sensibility for a mouse input.
  41779. * Higher values reduce sensitivity.
  41780. */
  41781. set angularSensibility(value: number);
  41782. /**
  41783. * Get the keys for camera movement forward.
  41784. */
  41785. get keysForward(): number[];
  41786. /**
  41787. * Set the keys for camera movement forward.
  41788. */
  41789. set keysForward(value: number[]);
  41790. /**
  41791. * Get the keys for camera movement backward.
  41792. */
  41793. get keysBackward(): number[];
  41794. set keysBackward(value: number[]);
  41795. /**
  41796. * Get the keys for camera movement up.
  41797. */
  41798. get keysUp(): number[];
  41799. /**
  41800. * Set the keys for camera movement up.
  41801. */
  41802. set keysUp(value: number[]);
  41803. /**
  41804. * Get the keys for camera movement down.
  41805. */
  41806. get keysDown(): number[];
  41807. /**
  41808. * Set the keys for camera movement down.
  41809. */
  41810. set keysDown(value: number[]);
  41811. /**
  41812. * Get the keys for camera movement left.
  41813. */
  41814. get keysLeft(): number[];
  41815. /**
  41816. * Set the keys for camera movement left.
  41817. */
  41818. set keysLeft(value: number[]);
  41819. /**
  41820. * Set the keys for camera movement right.
  41821. */
  41822. get keysRight(): number[];
  41823. /**
  41824. * Set the keys for camera movement right.
  41825. */
  41826. set keysRight(value: number[]);
  41827. /**
  41828. * Event raised when the camera collides with a mesh in the scene.
  41829. */
  41830. onCollide: (collidedMesh: AbstractMesh) => void;
  41831. private _collider;
  41832. private _needMoveForGravity;
  41833. private _oldPosition;
  41834. private _diffPosition;
  41835. private _newPosition;
  41836. /** @hidden */
  41837. _localDirection: Vector3;
  41838. /** @hidden */
  41839. _transformedDirection: Vector3;
  41840. /**
  41841. * Instantiates a FlyCamera.
  41842. * This is a flying camera, designed for 3D movement and rotation in all directions,
  41843. * such as in a 3D Space Shooter or a Flight Simulator.
  41844. * @param name Define the name of the camera in the scene.
  41845. * @param position Define the starting position of the camera in the scene.
  41846. * @param scene Define the scene the camera belongs to.
  41847. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  41848. */
  41849. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  41850. /**
  41851. * Attach a control to the HTML DOM element.
  41852. * @param element Defines the element that listens to the input events.
  41853. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  41854. */
  41855. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41856. /**
  41857. * Detach a control from the HTML DOM element.
  41858. * The camera will stop reacting to that input.
  41859. * @param element Defines the element that listens to the input events.
  41860. */
  41861. detachControl(element: HTMLElement): void;
  41862. private _collisionMask;
  41863. /**
  41864. * Get the mask that the camera ignores in collision events.
  41865. */
  41866. get collisionMask(): number;
  41867. /**
  41868. * Set the mask that the camera ignores in collision events.
  41869. */
  41870. set collisionMask(mask: number);
  41871. /** @hidden */
  41872. _collideWithWorld(displacement: Vector3): void;
  41873. /** @hidden */
  41874. private _onCollisionPositionChange;
  41875. /** @hidden */
  41876. _checkInputs(): void;
  41877. /** @hidden */
  41878. _decideIfNeedsToMove(): boolean;
  41879. /** @hidden */
  41880. _updatePosition(): void;
  41881. /**
  41882. * Restore the Roll to its target value at the rate specified.
  41883. * @param rate - Higher means slower restoring.
  41884. * @hidden
  41885. */
  41886. restoreRoll(rate: number): void;
  41887. /**
  41888. * Destroy the camera and release the current resources held by it.
  41889. */
  41890. dispose(): void;
  41891. /**
  41892. * Get the current object class name.
  41893. * @returns the class name.
  41894. */
  41895. getClassName(): string;
  41896. }
  41897. }
  41898. declare module "babylonjs/Cameras/Inputs/flyCameraKeyboardInput" {
  41899. import { Nullable } from "babylonjs/types";
  41900. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  41901. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  41902. /**
  41903. * Listen to keyboard events to control the camera.
  41904. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41905. */
  41906. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  41907. /**
  41908. * Defines the camera the input is attached to.
  41909. */
  41910. camera: FlyCamera;
  41911. /**
  41912. * The list of keyboard keys used to control the forward move of the camera.
  41913. */
  41914. keysForward: number[];
  41915. /**
  41916. * The list of keyboard keys used to control the backward move of the camera.
  41917. */
  41918. keysBackward: number[];
  41919. /**
  41920. * The list of keyboard keys used to control the forward move of the camera.
  41921. */
  41922. keysUp: number[];
  41923. /**
  41924. * The list of keyboard keys used to control the backward move of the camera.
  41925. */
  41926. keysDown: number[];
  41927. /**
  41928. * The list of keyboard keys used to control the right strafe move of the camera.
  41929. */
  41930. keysRight: number[];
  41931. /**
  41932. * The list of keyboard keys used to control the left strafe move of the camera.
  41933. */
  41934. keysLeft: number[];
  41935. private _keys;
  41936. private _onCanvasBlurObserver;
  41937. private _onKeyboardObserver;
  41938. private _engine;
  41939. private _scene;
  41940. /**
  41941. * Attach the input controls to a specific dom element to get the input from.
  41942. * @param element Defines the element the controls should be listened from
  41943. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41944. */
  41945. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41946. /**
  41947. * Detach the current controls from the specified dom element.
  41948. * @param element Defines the element to stop listening the inputs from
  41949. */
  41950. detachControl(element: Nullable<HTMLElement>): void;
  41951. /**
  41952. * Gets the class name of the current intput.
  41953. * @returns the class name
  41954. */
  41955. getClassName(): string;
  41956. /** @hidden */
  41957. _onLostFocus(e: FocusEvent): void;
  41958. /**
  41959. * Get the friendly name associated with the input class.
  41960. * @returns the input friendly name
  41961. */
  41962. getSimpleName(): string;
  41963. /**
  41964. * Update the current camera state depending on the inputs that have been used this frame.
  41965. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41966. */
  41967. checkInputs(): void;
  41968. }
  41969. }
  41970. declare module "babylonjs/Cameras/Inputs/followCameraMouseWheelInput" {
  41971. import { Nullable } from "babylonjs/types";
  41972. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  41973. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  41974. /**
  41975. * Manage the mouse wheel inputs to control a follow camera.
  41976. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41977. */
  41978. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  41979. /**
  41980. * Defines the camera the input is attached to.
  41981. */
  41982. camera: FollowCamera;
  41983. /**
  41984. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  41985. */
  41986. axisControlRadius: boolean;
  41987. /**
  41988. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  41989. */
  41990. axisControlHeight: boolean;
  41991. /**
  41992. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  41993. */
  41994. axisControlRotation: boolean;
  41995. /**
  41996. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  41997. * relation to mouseWheel events.
  41998. */
  41999. wheelPrecision: number;
  42000. /**
  42001. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  42002. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  42003. */
  42004. wheelDeltaPercentage: number;
  42005. private _wheel;
  42006. private _observer;
  42007. /**
  42008. * Attach the input controls to a specific dom element to get the input from.
  42009. * @param element Defines the element the controls should be listened from
  42010. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42011. */
  42012. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42013. /**
  42014. * Detach the current controls from the specified dom element.
  42015. * @param element Defines the element to stop listening the inputs from
  42016. */
  42017. detachControl(element: Nullable<HTMLElement>): void;
  42018. /**
  42019. * Gets the class name of the current intput.
  42020. * @returns the class name
  42021. */
  42022. getClassName(): string;
  42023. /**
  42024. * Get the friendly name associated with the input class.
  42025. * @returns the input friendly name
  42026. */
  42027. getSimpleName(): string;
  42028. }
  42029. }
  42030. declare module "babylonjs/Cameras/Inputs/followCameraPointersInput" {
  42031. import { Nullable } from "babylonjs/types";
  42032. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  42033. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  42034. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  42035. /**
  42036. * Manage the pointers inputs to control an follow camera.
  42037. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  42038. */
  42039. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  42040. /**
  42041. * Defines the camera the input is attached to.
  42042. */
  42043. camera: FollowCamera;
  42044. /**
  42045. * Gets the class name of the current input.
  42046. * @returns the class name
  42047. */
  42048. getClassName(): string;
  42049. /**
  42050. * Defines the pointer angular sensibility along the X axis or how fast is
  42051. * the camera rotating.
  42052. * A negative number will reverse the axis direction.
  42053. */
  42054. angularSensibilityX: number;
  42055. /**
  42056. * Defines the pointer angular sensibility along the Y axis or how fast is
  42057. * the camera rotating.
  42058. * A negative number will reverse the axis direction.
  42059. */
  42060. angularSensibilityY: number;
  42061. /**
  42062. * Defines the pointer pinch precision or how fast is the camera zooming.
  42063. * A negative number will reverse the axis direction.
  42064. */
  42065. pinchPrecision: number;
  42066. /**
  42067. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  42068. * from 0.
  42069. * It defines the percentage of current camera.radius to use as delta when
  42070. * pinch zoom is used.
  42071. */
  42072. pinchDeltaPercentage: number;
  42073. /**
  42074. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  42075. */
  42076. axisXControlRadius: boolean;
  42077. /**
  42078. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  42079. */
  42080. axisXControlHeight: boolean;
  42081. /**
  42082. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  42083. */
  42084. axisXControlRotation: boolean;
  42085. /**
  42086. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  42087. */
  42088. axisYControlRadius: boolean;
  42089. /**
  42090. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  42091. */
  42092. axisYControlHeight: boolean;
  42093. /**
  42094. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  42095. */
  42096. axisYControlRotation: boolean;
  42097. /**
  42098. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  42099. */
  42100. axisPinchControlRadius: boolean;
  42101. /**
  42102. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  42103. */
  42104. axisPinchControlHeight: boolean;
  42105. /**
  42106. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  42107. */
  42108. axisPinchControlRotation: boolean;
  42109. /**
  42110. * Log error messages if basic misconfiguration has occurred.
  42111. */
  42112. warningEnable: boolean;
  42113. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  42114. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  42115. private _warningCounter;
  42116. private _warning;
  42117. }
  42118. }
  42119. declare module "babylonjs/Cameras/followCameraInputsManager" {
  42120. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  42121. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  42122. /**
  42123. * Default Inputs manager for the FollowCamera.
  42124. * It groups all the default supported inputs for ease of use.
  42125. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  42126. */
  42127. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  42128. /**
  42129. * Instantiates a new FollowCameraInputsManager.
  42130. * @param camera Defines the camera the inputs belong to
  42131. */
  42132. constructor(camera: FollowCamera);
  42133. /**
  42134. * Add keyboard input support to the input manager.
  42135. * @returns the current input manager
  42136. */
  42137. addKeyboard(): FollowCameraInputsManager;
  42138. /**
  42139. * Add mouse wheel input support to the input manager.
  42140. * @returns the current input manager
  42141. */
  42142. addMouseWheel(): FollowCameraInputsManager;
  42143. /**
  42144. * Add pointers input support to the input manager.
  42145. * @returns the current input manager
  42146. */
  42147. addPointers(): FollowCameraInputsManager;
  42148. /**
  42149. * Add orientation input support to the input manager.
  42150. * @returns the current input manager
  42151. */
  42152. addVRDeviceOrientation(): FollowCameraInputsManager;
  42153. }
  42154. }
  42155. declare module "babylonjs/Cameras/followCamera" {
  42156. import { Nullable } from "babylonjs/types";
  42157. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  42158. import { Scene } from "babylonjs/scene";
  42159. import { Vector3 } from "babylonjs/Maths/math.vector";
  42160. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42161. import { FollowCameraInputsManager } from "babylonjs/Cameras/followCameraInputsManager";
  42162. /**
  42163. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  42164. * an arc rotate version arcFollowCamera are available.
  42165. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  42166. */
  42167. export class FollowCamera extends TargetCamera {
  42168. /**
  42169. * Distance the follow camera should follow an object at
  42170. */
  42171. radius: number;
  42172. /**
  42173. * Minimum allowed distance of the camera to the axis of rotation
  42174. * (The camera can not get closer).
  42175. * This can help limiting how the Camera is able to move in the scene.
  42176. */
  42177. lowerRadiusLimit: Nullable<number>;
  42178. /**
  42179. * Maximum allowed distance of the camera to the axis of rotation
  42180. * (The camera can not get further).
  42181. * This can help limiting how the Camera is able to move in the scene.
  42182. */
  42183. upperRadiusLimit: Nullable<number>;
  42184. /**
  42185. * Define a rotation offset between the camera and the object it follows
  42186. */
  42187. rotationOffset: number;
  42188. /**
  42189. * Minimum allowed angle to camera position relative to target object.
  42190. * This can help limiting how the Camera is able to move in the scene.
  42191. */
  42192. lowerRotationOffsetLimit: Nullable<number>;
  42193. /**
  42194. * Maximum allowed angle to camera position relative to target object.
  42195. * This can help limiting how the Camera is able to move in the scene.
  42196. */
  42197. upperRotationOffsetLimit: Nullable<number>;
  42198. /**
  42199. * Define a height offset between the camera and the object it follows.
  42200. * It can help following an object from the top (like a car chaing a plane)
  42201. */
  42202. heightOffset: number;
  42203. /**
  42204. * Minimum allowed height of camera position relative to target object.
  42205. * This can help limiting how the Camera is able to move in the scene.
  42206. */
  42207. lowerHeightOffsetLimit: Nullable<number>;
  42208. /**
  42209. * Maximum allowed height of camera position relative to target object.
  42210. * This can help limiting how the Camera is able to move in the scene.
  42211. */
  42212. upperHeightOffsetLimit: Nullable<number>;
  42213. /**
  42214. * Define how fast the camera can accelerate to follow it s target.
  42215. */
  42216. cameraAcceleration: number;
  42217. /**
  42218. * Define the speed limit of the camera following an object.
  42219. */
  42220. maxCameraSpeed: number;
  42221. /**
  42222. * Define the target of the camera.
  42223. */
  42224. lockedTarget: Nullable<AbstractMesh>;
  42225. /**
  42226. * Defines the input associated with the camera.
  42227. */
  42228. inputs: FollowCameraInputsManager;
  42229. /**
  42230. * Instantiates the follow camera.
  42231. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  42232. * @param name Define the name of the camera in the scene
  42233. * @param position Define the position of the camera
  42234. * @param scene Define the scene the camera belong to
  42235. * @param lockedTarget Define the target of the camera
  42236. */
  42237. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  42238. private _follow;
  42239. /**
  42240. * Attached controls to the current camera.
  42241. * @param element Defines the element the controls should be listened from
  42242. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42243. */
  42244. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42245. /**
  42246. * Detach the current controls from the camera.
  42247. * The camera will stop reacting to inputs.
  42248. * @param element Defines the element to stop listening the inputs from
  42249. */
  42250. detachControl(element: HTMLElement): void;
  42251. /** @hidden */
  42252. _checkInputs(): void;
  42253. private _checkLimits;
  42254. /**
  42255. * Gets the camera class name.
  42256. * @returns the class name
  42257. */
  42258. getClassName(): string;
  42259. }
  42260. /**
  42261. * Arc Rotate version of the follow camera.
  42262. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  42263. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  42264. */
  42265. export class ArcFollowCamera extends TargetCamera {
  42266. /** The longitudinal angle of the camera */
  42267. alpha: number;
  42268. /** The latitudinal angle of the camera */
  42269. beta: number;
  42270. /** The radius of the camera from its target */
  42271. radius: number;
  42272. /** Define the camera target (the messh it should follow) */
  42273. target: Nullable<AbstractMesh>;
  42274. private _cartesianCoordinates;
  42275. /**
  42276. * Instantiates a new ArcFollowCamera
  42277. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  42278. * @param name Define the name of the camera
  42279. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  42280. * @param beta Define the rotation angle of the camera around the elevation axis
  42281. * @param radius Define the radius of the camera from its target point
  42282. * @param target Define the target of the camera
  42283. * @param scene Define the scene the camera belongs to
  42284. */
  42285. constructor(name: string,
  42286. /** The longitudinal angle of the camera */
  42287. alpha: number,
  42288. /** The latitudinal angle of the camera */
  42289. beta: number,
  42290. /** The radius of the camera from its target */
  42291. radius: number,
  42292. /** Define the camera target (the messh it should follow) */
  42293. target: Nullable<AbstractMesh>, scene: Scene);
  42294. private _follow;
  42295. /** @hidden */
  42296. _checkInputs(): void;
  42297. /**
  42298. * Returns the class name of the object.
  42299. * It is mostly used internally for serialization purposes.
  42300. */
  42301. getClassName(): string;
  42302. }
  42303. }
  42304. declare module "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput" {
  42305. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  42306. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  42307. import { Nullable } from "babylonjs/types";
  42308. /**
  42309. * Manage the keyboard inputs to control the movement of a follow camera.
  42310. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  42311. */
  42312. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  42313. /**
  42314. * Defines the camera the input is attached to.
  42315. */
  42316. camera: FollowCamera;
  42317. /**
  42318. * Defines the list of key codes associated with the up action (increase heightOffset)
  42319. */
  42320. keysHeightOffsetIncr: number[];
  42321. /**
  42322. * Defines the list of key codes associated with the down action (decrease heightOffset)
  42323. */
  42324. keysHeightOffsetDecr: number[];
  42325. /**
  42326. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  42327. */
  42328. keysHeightOffsetModifierAlt: boolean;
  42329. /**
  42330. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  42331. */
  42332. keysHeightOffsetModifierCtrl: boolean;
  42333. /**
  42334. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  42335. */
  42336. keysHeightOffsetModifierShift: boolean;
  42337. /**
  42338. * Defines the list of key codes associated with the left action (increase rotationOffset)
  42339. */
  42340. keysRotationOffsetIncr: number[];
  42341. /**
  42342. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  42343. */
  42344. keysRotationOffsetDecr: number[];
  42345. /**
  42346. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  42347. */
  42348. keysRotationOffsetModifierAlt: boolean;
  42349. /**
  42350. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  42351. */
  42352. keysRotationOffsetModifierCtrl: boolean;
  42353. /**
  42354. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  42355. */
  42356. keysRotationOffsetModifierShift: boolean;
  42357. /**
  42358. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  42359. */
  42360. keysRadiusIncr: number[];
  42361. /**
  42362. * Defines the list of key codes associated with the zoom-out action (increase radius)
  42363. */
  42364. keysRadiusDecr: number[];
  42365. /**
  42366. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  42367. */
  42368. keysRadiusModifierAlt: boolean;
  42369. /**
  42370. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  42371. */
  42372. keysRadiusModifierCtrl: boolean;
  42373. /**
  42374. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  42375. */
  42376. keysRadiusModifierShift: boolean;
  42377. /**
  42378. * Defines the rate of change of heightOffset.
  42379. */
  42380. heightSensibility: number;
  42381. /**
  42382. * Defines the rate of change of rotationOffset.
  42383. */
  42384. rotationSensibility: number;
  42385. /**
  42386. * Defines the rate of change of radius.
  42387. */
  42388. radiusSensibility: number;
  42389. private _keys;
  42390. private _ctrlPressed;
  42391. private _altPressed;
  42392. private _shiftPressed;
  42393. private _onCanvasBlurObserver;
  42394. private _onKeyboardObserver;
  42395. private _engine;
  42396. private _scene;
  42397. /**
  42398. * Attach the input controls to a specific dom element to get the input from.
  42399. * @param element Defines the element the controls should be listened from
  42400. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42401. */
  42402. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42403. /**
  42404. * Detach the current controls from the specified dom element.
  42405. * @param element Defines the element to stop listening the inputs from
  42406. */
  42407. detachControl(element: Nullable<HTMLElement>): void;
  42408. /**
  42409. * Update the current camera state depending on the inputs that have been used this frame.
  42410. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  42411. */
  42412. checkInputs(): void;
  42413. /**
  42414. * Gets the class name of the current input.
  42415. * @returns the class name
  42416. */
  42417. getClassName(): string;
  42418. /**
  42419. * Get the friendly name associated with the input class.
  42420. * @returns the input friendly name
  42421. */
  42422. getSimpleName(): string;
  42423. /**
  42424. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  42425. * allow modification of the heightOffset value.
  42426. */
  42427. private _modifierHeightOffset;
  42428. /**
  42429. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  42430. * allow modification of the rotationOffset value.
  42431. */
  42432. private _modifierRotationOffset;
  42433. /**
  42434. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  42435. * allow modification of the radius value.
  42436. */
  42437. private _modifierRadius;
  42438. }
  42439. }
  42440. declare module "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput" {
  42441. import { Nullable } from "babylonjs/types";
  42442. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  42443. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  42444. import { Observable } from "babylonjs/Misc/observable";
  42445. module "babylonjs/Cameras/freeCameraInputsManager" {
  42446. interface FreeCameraInputsManager {
  42447. /**
  42448. * @hidden
  42449. */
  42450. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  42451. /**
  42452. * Add orientation input support to the input manager.
  42453. * @returns the current input manager
  42454. */
  42455. addDeviceOrientation(): FreeCameraInputsManager;
  42456. }
  42457. }
  42458. /**
  42459. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  42460. * Screen rotation is taken into account.
  42461. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  42462. */
  42463. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  42464. private _camera;
  42465. private _screenOrientationAngle;
  42466. private _constantTranform;
  42467. private _screenQuaternion;
  42468. private _alpha;
  42469. private _beta;
  42470. private _gamma;
  42471. /**
  42472. * Can be used to detect if a device orientation sensor is available on a device
  42473. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  42474. * @returns a promise that will resolve on orientation change
  42475. */
  42476. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  42477. /**
  42478. * @hidden
  42479. */
  42480. _onDeviceOrientationChangedObservable: Observable<void>;
  42481. /**
  42482. * Instantiates a new input
  42483. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  42484. */
  42485. constructor();
  42486. /**
  42487. * Define the camera controlled by the input.
  42488. */
  42489. get camera(): FreeCamera;
  42490. set camera(camera: FreeCamera);
  42491. /**
  42492. * Attach the input controls to a specific dom element to get the input from.
  42493. * @param element Defines the element the controls should be listened from
  42494. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42495. */
  42496. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42497. private _orientationChanged;
  42498. private _deviceOrientation;
  42499. /**
  42500. * Detach the current controls from the specified dom element.
  42501. * @param element Defines the element to stop listening the inputs from
  42502. */
  42503. detachControl(element: Nullable<HTMLElement>): void;
  42504. /**
  42505. * Update the current camera state depending on the inputs that have been used this frame.
  42506. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  42507. */
  42508. checkInputs(): void;
  42509. /**
  42510. * Gets the class name of the current intput.
  42511. * @returns the class name
  42512. */
  42513. getClassName(): string;
  42514. /**
  42515. * Get the friendly name associated with the input class.
  42516. * @returns the input friendly name
  42517. */
  42518. getSimpleName(): string;
  42519. }
  42520. }
  42521. declare module "babylonjs/Cameras/Inputs/freeCameraGamepadInput" {
  42522. import { Nullable } from "babylonjs/types";
  42523. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  42524. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  42525. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  42526. /**
  42527. * Manage the gamepad inputs to control a free camera.
  42528. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  42529. */
  42530. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  42531. /**
  42532. * Define the camera the input is attached to.
  42533. */
  42534. camera: FreeCamera;
  42535. /**
  42536. * Define the Gamepad controlling the input
  42537. */
  42538. gamepad: Nullable<Gamepad>;
  42539. /**
  42540. * Defines the gamepad rotation sensiblity.
  42541. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  42542. */
  42543. gamepadAngularSensibility: number;
  42544. /**
  42545. * Defines the gamepad move sensiblity.
  42546. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  42547. */
  42548. gamepadMoveSensibility: number;
  42549. private _yAxisScale;
  42550. /**
  42551. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  42552. */
  42553. get invertYAxis(): boolean;
  42554. set invertYAxis(value: boolean);
  42555. private _onGamepadConnectedObserver;
  42556. private _onGamepadDisconnectedObserver;
  42557. private _cameraTransform;
  42558. private _deltaTransform;
  42559. private _vector3;
  42560. private _vector2;
  42561. /**
  42562. * Attach the input controls to a specific dom element to get the input from.
  42563. * @param element Defines the element the controls should be listened from
  42564. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42565. */
  42566. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42567. /**
  42568. * Detach the current controls from the specified dom element.
  42569. * @param element Defines the element to stop listening the inputs from
  42570. */
  42571. detachControl(element: Nullable<HTMLElement>): void;
  42572. /**
  42573. * Update the current camera state depending on the inputs that have been used this frame.
  42574. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  42575. */
  42576. checkInputs(): void;
  42577. /**
  42578. * Gets the class name of the current intput.
  42579. * @returns the class name
  42580. */
  42581. getClassName(): string;
  42582. /**
  42583. * Get the friendly name associated with the input class.
  42584. * @returns the input friendly name
  42585. */
  42586. getSimpleName(): string;
  42587. }
  42588. }
  42589. declare module "babylonjs/Misc/virtualJoystick" {
  42590. import { Nullable } from "babylonjs/types";
  42591. import { Vector3 } from "babylonjs/Maths/math.vector";
  42592. /**
  42593. * Defines the potential axis of a Joystick
  42594. */
  42595. export enum JoystickAxis {
  42596. /** X axis */
  42597. X = 0,
  42598. /** Y axis */
  42599. Y = 1,
  42600. /** Z axis */
  42601. Z = 2
  42602. }
  42603. /**
  42604. * Class used to define virtual joystick (used in touch mode)
  42605. */
  42606. export class VirtualJoystick {
  42607. /**
  42608. * Gets or sets a boolean indicating that left and right values must be inverted
  42609. */
  42610. reverseLeftRight: boolean;
  42611. /**
  42612. * Gets or sets a boolean indicating that up and down values must be inverted
  42613. */
  42614. reverseUpDown: boolean;
  42615. /**
  42616. * Gets the offset value for the position (ie. the change of the position value)
  42617. */
  42618. deltaPosition: Vector3;
  42619. /**
  42620. * Gets a boolean indicating if the virtual joystick was pressed
  42621. */
  42622. pressed: boolean;
  42623. /**
  42624. * Canvas the virtual joystick will render onto, default z-index of this is 5
  42625. */
  42626. static Canvas: Nullable<HTMLCanvasElement>;
  42627. private static _globalJoystickIndex;
  42628. private static vjCanvasContext;
  42629. private static vjCanvasWidth;
  42630. private static vjCanvasHeight;
  42631. private static halfWidth;
  42632. private _action;
  42633. private _axisTargetedByLeftAndRight;
  42634. private _axisTargetedByUpAndDown;
  42635. private _joystickSensibility;
  42636. private _inversedSensibility;
  42637. private _joystickPointerID;
  42638. private _joystickColor;
  42639. private _joystickPointerPos;
  42640. private _joystickPreviousPointerPos;
  42641. private _joystickPointerStartPos;
  42642. private _deltaJoystickVector;
  42643. private _leftJoystick;
  42644. private _touches;
  42645. private _onPointerDownHandlerRef;
  42646. private _onPointerMoveHandlerRef;
  42647. private _onPointerUpHandlerRef;
  42648. private _onResize;
  42649. /**
  42650. * Creates a new virtual joystick
  42651. * @param leftJoystick defines that the joystick is for left hand (false by default)
  42652. */
  42653. constructor(leftJoystick?: boolean);
  42654. /**
  42655. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  42656. * @param newJoystickSensibility defines the new sensibility
  42657. */
  42658. setJoystickSensibility(newJoystickSensibility: number): void;
  42659. private _onPointerDown;
  42660. private _onPointerMove;
  42661. private _onPointerUp;
  42662. /**
  42663. * Change the color of the virtual joystick
  42664. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  42665. */
  42666. setJoystickColor(newColor: string): void;
  42667. /**
  42668. * Defines a callback to call when the joystick is touched
  42669. * @param action defines the callback
  42670. */
  42671. setActionOnTouch(action: () => any): void;
  42672. /**
  42673. * Defines which axis you'd like to control for left & right
  42674. * @param axis defines the axis to use
  42675. */
  42676. setAxisForLeftRight(axis: JoystickAxis): void;
  42677. /**
  42678. * Defines which axis you'd like to control for up & down
  42679. * @param axis defines the axis to use
  42680. */
  42681. setAxisForUpDown(axis: JoystickAxis): void;
  42682. private _drawVirtualJoystick;
  42683. /**
  42684. * Release internal HTML canvas
  42685. */
  42686. releaseCanvas(): void;
  42687. }
  42688. }
  42689. declare module "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput" {
  42690. import { VirtualJoystick } from "babylonjs/Misc/virtualJoystick";
  42691. import { Nullable } from "babylonjs/types";
  42692. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  42693. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  42694. module "babylonjs/Cameras/freeCameraInputsManager" {
  42695. interface FreeCameraInputsManager {
  42696. /**
  42697. * Add virtual joystick input support to the input manager.
  42698. * @returns the current input manager
  42699. */
  42700. addVirtualJoystick(): FreeCameraInputsManager;
  42701. }
  42702. }
  42703. /**
  42704. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  42705. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  42706. */
  42707. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  42708. /**
  42709. * Defines the camera the input is attached to.
  42710. */
  42711. camera: FreeCamera;
  42712. private _leftjoystick;
  42713. private _rightjoystick;
  42714. /**
  42715. * Gets the left stick of the virtual joystick.
  42716. * @returns The virtual Joystick
  42717. */
  42718. getLeftJoystick(): VirtualJoystick;
  42719. /**
  42720. * Gets the right stick of the virtual joystick.
  42721. * @returns The virtual Joystick
  42722. */
  42723. getRightJoystick(): VirtualJoystick;
  42724. /**
  42725. * Update the current camera state depending on the inputs that have been used this frame.
  42726. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  42727. */
  42728. checkInputs(): void;
  42729. /**
  42730. * Attach the input controls to a specific dom element to get the input from.
  42731. * @param element Defines the element the controls should be listened from
  42732. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42733. */
  42734. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42735. /**
  42736. * Detach the current controls from the specified dom element.
  42737. * @param element Defines the element to stop listening the inputs from
  42738. */
  42739. detachControl(element: Nullable<HTMLElement>): void;
  42740. /**
  42741. * Gets the class name of the current intput.
  42742. * @returns the class name
  42743. */
  42744. getClassName(): string;
  42745. /**
  42746. * Get the friendly name associated with the input class.
  42747. * @returns the input friendly name
  42748. */
  42749. getSimpleName(): string;
  42750. }
  42751. }
  42752. declare module "babylonjs/Cameras/Inputs/index" {
  42753. export * from "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput";
  42754. export * from "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput";
  42755. export * from "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput";
  42756. export * from "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput";
  42757. export * from "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  42758. export * from "babylonjs/Cameras/Inputs/flyCameraKeyboardInput";
  42759. export * from "babylonjs/Cameras/Inputs/flyCameraMouseInput";
  42760. export * from "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput";
  42761. export * from "babylonjs/Cameras/Inputs/followCameraMouseWheelInput";
  42762. export * from "babylonjs/Cameras/Inputs/followCameraPointersInput";
  42763. export * from "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  42764. export * from "babylonjs/Cameras/Inputs/freeCameraGamepadInput";
  42765. export * from "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput";
  42766. export * from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  42767. export * from "babylonjs/Cameras/Inputs/freeCameraTouchInput";
  42768. export * from "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  42769. }
  42770. declare module "babylonjs/Cameras/touchCamera" {
  42771. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  42772. import { Scene } from "babylonjs/scene";
  42773. import { Vector3 } from "babylonjs/Maths/math.vector";
  42774. /**
  42775. * This represents a FPS type of camera controlled by touch.
  42776. * This is like a universal camera minus the Gamepad controls.
  42777. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  42778. */
  42779. export class TouchCamera extends FreeCamera {
  42780. /**
  42781. * Defines the touch sensibility for rotation.
  42782. * The higher the faster.
  42783. */
  42784. get touchAngularSensibility(): number;
  42785. set touchAngularSensibility(value: number);
  42786. /**
  42787. * Defines the touch sensibility for move.
  42788. * The higher the faster.
  42789. */
  42790. get touchMoveSensibility(): number;
  42791. set touchMoveSensibility(value: number);
  42792. /**
  42793. * Instantiates a new touch camera.
  42794. * This represents a FPS type of camera controlled by touch.
  42795. * This is like a universal camera minus the Gamepad controls.
  42796. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  42797. * @param name Define the name of the camera in the scene
  42798. * @param position Define the start position of the camera in the scene
  42799. * @param scene Define the scene the camera belongs to
  42800. */
  42801. constructor(name: string, position: Vector3, scene: Scene);
  42802. /**
  42803. * Gets the current object class name.
  42804. * @return the class name
  42805. */
  42806. getClassName(): string;
  42807. /** @hidden */
  42808. _setupInputs(): void;
  42809. }
  42810. }
  42811. declare module "babylonjs/Cameras/deviceOrientationCamera" {
  42812. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  42813. import { Scene } from "babylonjs/scene";
  42814. import { Vector3 } from "babylonjs/Maths/math.vector";
  42815. import "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  42816. import { Axis } from "babylonjs/Maths/math.axis";
  42817. /**
  42818. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  42819. * being tilted forward or back and left or right.
  42820. */
  42821. export class DeviceOrientationCamera extends FreeCamera {
  42822. private _initialQuaternion;
  42823. private _quaternionCache;
  42824. private _tmpDragQuaternion;
  42825. private _disablePointerInputWhenUsingDeviceOrientation;
  42826. /**
  42827. * Creates a new device orientation camera
  42828. * @param name The name of the camera
  42829. * @param position The start position camera
  42830. * @param scene The scene the camera belongs to
  42831. */
  42832. constructor(name: string, position: Vector3, scene: Scene);
  42833. /**
  42834. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  42835. */
  42836. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  42837. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  42838. private _dragFactor;
  42839. /**
  42840. * Enabled turning on the y axis when the orientation sensor is active
  42841. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  42842. */
  42843. enableHorizontalDragging(dragFactor?: number): void;
  42844. /**
  42845. * Gets the current instance class name ("DeviceOrientationCamera").
  42846. * This helps avoiding instanceof at run time.
  42847. * @returns the class name
  42848. */
  42849. getClassName(): string;
  42850. /**
  42851. * @hidden
  42852. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  42853. */
  42854. _checkInputs(): void;
  42855. /**
  42856. * Reset the camera to its default orientation on the specified axis only.
  42857. * @param axis The axis to reset
  42858. */
  42859. resetToCurrentRotation(axis?: Axis): void;
  42860. }
  42861. }
  42862. declare module "babylonjs/Gamepads/xboxGamepad" {
  42863. import { Observable } from "babylonjs/Misc/observable";
  42864. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  42865. /**
  42866. * Defines supported buttons for XBox360 compatible gamepads
  42867. */
  42868. export enum Xbox360Button {
  42869. /** A */
  42870. A = 0,
  42871. /** B */
  42872. B = 1,
  42873. /** X */
  42874. X = 2,
  42875. /** Y */
  42876. Y = 3,
  42877. /** Left button */
  42878. LB = 4,
  42879. /** Right button */
  42880. RB = 5,
  42881. /** Back */
  42882. Back = 8,
  42883. /** Start */
  42884. Start = 9,
  42885. /** Left stick */
  42886. LeftStick = 10,
  42887. /** Right stick */
  42888. RightStick = 11
  42889. }
  42890. /** Defines values for XBox360 DPad */
  42891. export enum Xbox360Dpad {
  42892. /** Up */
  42893. Up = 12,
  42894. /** Down */
  42895. Down = 13,
  42896. /** Left */
  42897. Left = 14,
  42898. /** Right */
  42899. Right = 15
  42900. }
  42901. /**
  42902. * Defines a XBox360 gamepad
  42903. */
  42904. export class Xbox360Pad extends Gamepad {
  42905. private _leftTrigger;
  42906. private _rightTrigger;
  42907. private _onlefttriggerchanged;
  42908. private _onrighttriggerchanged;
  42909. private _onbuttondown;
  42910. private _onbuttonup;
  42911. private _ondpaddown;
  42912. private _ondpadup;
  42913. /** Observable raised when a button is pressed */
  42914. onButtonDownObservable: Observable<Xbox360Button>;
  42915. /** Observable raised when a button is released */
  42916. onButtonUpObservable: Observable<Xbox360Button>;
  42917. /** Observable raised when a pad is pressed */
  42918. onPadDownObservable: Observable<Xbox360Dpad>;
  42919. /** Observable raised when a pad is released */
  42920. onPadUpObservable: Observable<Xbox360Dpad>;
  42921. private _buttonA;
  42922. private _buttonB;
  42923. private _buttonX;
  42924. private _buttonY;
  42925. private _buttonBack;
  42926. private _buttonStart;
  42927. private _buttonLB;
  42928. private _buttonRB;
  42929. private _buttonLeftStick;
  42930. private _buttonRightStick;
  42931. private _dPadUp;
  42932. private _dPadDown;
  42933. private _dPadLeft;
  42934. private _dPadRight;
  42935. private _isXboxOnePad;
  42936. /**
  42937. * Creates a new XBox360 gamepad object
  42938. * @param id defines the id of this gamepad
  42939. * @param index defines its index
  42940. * @param gamepad defines the internal HTML gamepad object
  42941. * @param xboxOne defines if it is a XBox One gamepad
  42942. */
  42943. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  42944. /**
  42945. * Defines the callback to call when left trigger is pressed
  42946. * @param callback defines the callback to use
  42947. */
  42948. onlefttriggerchanged(callback: (value: number) => void): void;
  42949. /**
  42950. * Defines the callback to call when right trigger is pressed
  42951. * @param callback defines the callback to use
  42952. */
  42953. onrighttriggerchanged(callback: (value: number) => void): void;
  42954. /**
  42955. * Gets the left trigger value
  42956. */
  42957. get leftTrigger(): number;
  42958. /**
  42959. * Sets the left trigger value
  42960. */
  42961. set leftTrigger(newValue: number);
  42962. /**
  42963. * Gets the right trigger value
  42964. */
  42965. get rightTrigger(): number;
  42966. /**
  42967. * Sets the right trigger value
  42968. */
  42969. set rightTrigger(newValue: number);
  42970. /**
  42971. * Defines the callback to call when a button is pressed
  42972. * @param callback defines the callback to use
  42973. */
  42974. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  42975. /**
  42976. * Defines the callback to call when a button is released
  42977. * @param callback defines the callback to use
  42978. */
  42979. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  42980. /**
  42981. * Defines the callback to call when a pad is pressed
  42982. * @param callback defines the callback to use
  42983. */
  42984. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  42985. /**
  42986. * Defines the callback to call when a pad is released
  42987. * @param callback defines the callback to use
  42988. */
  42989. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  42990. private _setButtonValue;
  42991. private _setDPadValue;
  42992. /**
  42993. * Gets the value of the `A` button
  42994. */
  42995. get buttonA(): number;
  42996. /**
  42997. * Sets the value of the `A` button
  42998. */
  42999. set buttonA(value: number);
  43000. /**
  43001. * Gets the value of the `B` button
  43002. */
  43003. get buttonB(): number;
  43004. /**
  43005. * Sets the value of the `B` button
  43006. */
  43007. set buttonB(value: number);
  43008. /**
  43009. * Gets the value of the `X` button
  43010. */
  43011. get buttonX(): number;
  43012. /**
  43013. * Sets the value of the `X` button
  43014. */
  43015. set buttonX(value: number);
  43016. /**
  43017. * Gets the value of the `Y` button
  43018. */
  43019. get buttonY(): number;
  43020. /**
  43021. * Sets the value of the `Y` button
  43022. */
  43023. set buttonY(value: number);
  43024. /**
  43025. * Gets the value of the `Start` button
  43026. */
  43027. get buttonStart(): number;
  43028. /**
  43029. * Sets the value of the `Start` button
  43030. */
  43031. set buttonStart(value: number);
  43032. /**
  43033. * Gets the value of the `Back` button
  43034. */
  43035. get buttonBack(): number;
  43036. /**
  43037. * Sets the value of the `Back` button
  43038. */
  43039. set buttonBack(value: number);
  43040. /**
  43041. * Gets the value of the `Left` button
  43042. */
  43043. get buttonLB(): number;
  43044. /**
  43045. * Sets the value of the `Left` button
  43046. */
  43047. set buttonLB(value: number);
  43048. /**
  43049. * Gets the value of the `Right` button
  43050. */
  43051. get buttonRB(): number;
  43052. /**
  43053. * Sets the value of the `Right` button
  43054. */
  43055. set buttonRB(value: number);
  43056. /**
  43057. * Gets the value of the Left joystick
  43058. */
  43059. get buttonLeftStick(): number;
  43060. /**
  43061. * Sets the value of the Left joystick
  43062. */
  43063. set buttonLeftStick(value: number);
  43064. /**
  43065. * Gets the value of the Right joystick
  43066. */
  43067. get buttonRightStick(): number;
  43068. /**
  43069. * Sets the value of the Right joystick
  43070. */
  43071. set buttonRightStick(value: number);
  43072. /**
  43073. * Gets the value of D-pad up
  43074. */
  43075. get dPadUp(): number;
  43076. /**
  43077. * Sets the value of D-pad up
  43078. */
  43079. set dPadUp(value: number);
  43080. /**
  43081. * Gets the value of D-pad down
  43082. */
  43083. get dPadDown(): number;
  43084. /**
  43085. * Sets the value of D-pad down
  43086. */
  43087. set dPadDown(value: number);
  43088. /**
  43089. * Gets the value of D-pad left
  43090. */
  43091. get dPadLeft(): number;
  43092. /**
  43093. * Sets the value of D-pad left
  43094. */
  43095. set dPadLeft(value: number);
  43096. /**
  43097. * Gets the value of D-pad right
  43098. */
  43099. get dPadRight(): number;
  43100. /**
  43101. * Sets the value of D-pad right
  43102. */
  43103. set dPadRight(value: number);
  43104. /**
  43105. * Force the gamepad to synchronize with device values
  43106. */
  43107. update(): void;
  43108. /**
  43109. * Disposes the gamepad
  43110. */
  43111. dispose(): void;
  43112. }
  43113. }
  43114. declare module "babylonjs/Gamepads/dualShockGamepad" {
  43115. import { Observable } from "babylonjs/Misc/observable";
  43116. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  43117. /**
  43118. * Defines supported buttons for DualShock compatible gamepads
  43119. */
  43120. export enum DualShockButton {
  43121. /** Cross */
  43122. Cross = 0,
  43123. /** Circle */
  43124. Circle = 1,
  43125. /** Square */
  43126. Square = 2,
  43127. /** Triangle */
  43128. Triangle = 3,
  43129. /** L1 */
  43130. L1 = 4,
  43131. /** R1 */
  43132. R1 = 5,
  43133. /** Share */
  43134. Share = 8,
  43135. /** Options */
  43136. Options = 9,
  43137. /** Left stick */
  43138. LeftStick = 10,
  43139. /** Right stick */
  43140. RightStick = 11
  43141. }
  43142. /** Defines values for DualShock DPad */
  43143. export enum DualShockDpad {
  43144. /** Up */
  43145. Up = 12,
  43146. /** Down */
  43147. Down = 13,
  43148. /** Left */
  43149. Left = 14,
  43150. /** Right */
  43151. Right = 15
  43152. }
  43153. /**
  43154. * Defines a DualShock gamepad
  43155. */
  43156. export class DualShockPad extends Gamepad {
  43157. private _leftTrigger;
  43158. private _rightTrigger;
  43159. private _onlefttriggerchanged;
  43160. private _onrighttriggerchanged;
  43161. private _onbuttondown;
  43162. private _onbuttonup;
  43163. private _ondpaddown;
  43164. private _ondpadup;
  43165. /** Observable raised when a button is pressed */
  43166. onButtonDownObservable: Observable<DualShockButton>;
  43167. /** Observable raised when a button is released */
  43168. onButtonUpObservable: Observable<DualShockButton>;
  43169. /** Observable raised when a pad is pressed */
  43170. onPadDownObservable: Observable<DualShockDpad>;
  43171. /** Observable raised when a pad is released */
  43172. onPadUpObservable: Observable<DualShockDpad>;
  43173. private _buttonCross;
  43174. private _buttonCircle;
  43175. private _buttonSquare;
  43176. private _buttonTriangle;
  43177. private _buttonShare;
  43178. private _buttonOptions;
  43179. private _buttonL1;
  43180. private _buttonR1;
  43181. private _buttonLeftStick;
  43182. private _buttonRightStick;
  43183. private _dPadUp;
  43184. private _dPadDown;
  43185. private _dPadLeft;
  43186. private _dPadRight;
  43187. /**
  43188. * Creates a new DualShock gamepad object
  43189. * @param id defines the id of this gamepad
  43190. * @param index defines its index
  43191. * @param gamepad defines the internal HTML gamepad object
  43192. */
  43193. constructor(id: string, index: number, gamepad: any);
  43194. /**
  43195. * Defines the callback to call when left trigger is pressed
  43196. * @param callback defines the callback to use
  43197. */
  43198. onlefttriggerchanged(callback: (value: number) => void): void;
  43199. /**
  43200. * Defines the callback to call when right trigger is pressed
  43201. * @param callback defines the callback to use
  43202. */
  43203. onrighttriggerchanged(callback: (value: number) => void): void;
  43204. /**
  43205. * Gets the left trigger value
  43206. */
  43207. get leftTrigger(): number;
  43208. /**
  43209. * Sets the left trigger value
  43210. */
  43211. set leftTrigger(newValue: number);
  43212. /**
  43213. * Gets the right trigger value
  43214. */
  43215. get rightTrigger(): number;
  43216. /**
  43217. * Sets the right trigger value
  43218. */
  43219. set rightTrigger(newValue: number);
  43220. /**
  43221. * Defines the callback to call when a button is pressed
  43222. * @param callback defines the callback to use
  43223. */
  43224. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  43225. /**
  43226. * Defines the callback to call when a button is released
  43227. * @param callback defines the callback to use
  43228. */
  43229. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  43230. /**
  43231. * Defines the callback to call when a pad is pressed
  43232. * @param callback defines the callback to use
  43233. */
  43234. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  43235. /**
  43236. * Defines the callback to call when a pad is released
  43237. * @param callback defines the callback to use
  43238. */
  43239. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  43240. private _setButtonValue;
  43241. private _setDPadValue;
  43242. /**
  43243. * Gets the value of the `Cross` button
  43244. */
  43245. get buttonCross(): number;
  43246. /**
  43247. * Sets the value of the `Cross` button
  43248. */
  43249. set buttonCross(value: number);
  43250. /**
  43251. * Gets the value of the `Circle` button
  43252. */
  43253. get buttonCircle(): number;
  43254. /**
  43255. * Sets the value of the `Circle` button
  43256. */
  43257. set buttonCircle(value: number);
  43258. /**
  43259. * Gets the value of the `Square` button
  43260. */
  43261. get buttonSquare(): number;
  43262. /**
  43263. * Sets the value of the `Square` button
  43264. */
  43265. set buttonSquare(value: number);
  43266. /**
  43267. * Gets the value of the `Triangle` button
  43268. */
  43269. get buttonTriangle(): number;
  43270. /**
  43271. * Sets the value of the `Triangle` button
  43272. */
  43273. set buttonTriangle(value: number);
  43274. /**
  43275. * Gets the value of the `Options` button
  43276. */
  43277. get buttonOptions(): number;
  43278. /**
  43279. * Sets the value of the `Options` button
  43280. */
  43281. set buttonOptions(value: number);
  43282. /**
  43283. * Gets the value of the `Share` button
  43284. */
  43285. get buttonShare(): number;
  43286. /**
  43287. * Sets the value of the `Share` button
  43288. */
  43289. set buttonShare(value: number);
  43290. /**
  43291. * Gets the value of the `L1` button
  43292. */
  43293. get buttonL1(): number;
  43294. /**
  43295. * Sets the value of the `L1` button
  43296. */
  43297. set buttonL1(value: number);
  43298. /**
  43299. * Gets the value of the `R1` button
  43300. */
  43301. get buttonR1(): number;
  43302. /**
  43303. * Sets the value of the `R1` button
  43304. */
  43305. set buttonR1(value: number);
  43306. /**
  43307. * Gets the value of the Left joystick
  43308. */
  43309. get buttonLeftStick(): number;
  43310. /**
  43311. * Sets the value of the Left joystick
  43312. */
  43313. set buttonLeftStick(value: number);
  43314. /**
  43315. * Gets the value of the Right joystick
  43316. */
  43317. get buttonRightStick(): number;
  43318. /**
  43319. * Sets the value of the Right joystick
  43320. */
  43321. set buttonRightStick(value: number);
  43322. /**
  43323. * Gets the value of D-pad up
  43324. */
  43325. get dPadUp(): number;
  43326. /**
  43327. * Sets the value of D-pad up
  43328. */
  43329. set dPadUp(value: number);
  43330. /**
  43331. * Gets the value of D-pad down
  43332. */
  43333. get dPadDown(): number;
  43334. /**
  43335. * Sets the value of D-pad down
  43336. */
  43337. set dPadDown(value: number);
  43338. /**
  43339. * Gets the value of D-pad left
  43340. */
  43341. get dPadLeft(): number;
  43342. /**
  43343. * Sets the value of D-pad left
  43344. */
  43345. set dPadLeft(value: number);
  43346. /**
  43347. * Gets the value of D-pad right
  43348. */
  43349. get dPadRight(): number;
  43350. /**
  43351. * Sets the value of D-pad right
  43352. */
  43353. set dPadRight(value: number);
  43354. /**
  43355. * Force the gamepad to synchronize with device values
  43356. */
  43357. update(): void;
  43358. /**
  43359. * Disposes the gamepad
  43360. */
  43361. dispose(): void;
  43362. }
  43363. }
  43364. declare module "babylonjs/Gamepads/gamepadManager" {
  43365. import { Observable } from "babylonjs/Misc/observable";
  43366. import { Nullable } from "babylonjs/types";
  43367. import { Scene } from "babylonjs/scene";
  43368. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  43369. /**
  43370. * Manager for handling gamepads
  43371. */
  43372. export class GamepadManager {
  43373. private _scene?;
  43374. private _babylonGamepads;
  43375. private _oneGamepadConnected;
  43376. /** @hidden */
  43377. _isMonitoring: boolean;
  43378. private _gamepadEventSupported;
  43379. private _gamepadSupport?;
  43380. /**
  43381. * observable to be triggered when the gamepad controller has been connected
  43382. */
  43383. onGamepadConnectedObservable: Observable<Gamepad>;
  43384. /**
  43385. * observable to be triggered when the gamepad controller has been disconnected
  43386. */
  43387. onGamepadDisconnectedObservable: Observable<Gamepad>;
  43388. private _onGamepadConnectedEvent;
  43389. private _onGamepadDisconnectedEvent;
  43390. /**
  43391. * Initializes the gamepad manager
  43392. * @param _scene BabylonJS scene
  43393. */
  43394. constructor(_scene?: Scene | undefined);
  43395. /**
  43396. * The gamepads in the game pad manager
  43397. */
  43398. get gamepads(): Gamepad[];
  43399. /**
  43400. * Get the gamepad controllers based on type
  43401. * @param type The type of gamepad controller
  43402. * @returns Nullable gamepad
  43403. */
  43404. getGamepadByType(type?: number): Nullable<Gamepad>;
  43405. /**
  43406. * Disposes the gamepad manager
  43407. */
  43408. dispose(): void;
  43409. private _addNewGamepad;
  43410. private _startMonitoringGamepads;
  43411. private _stopMonitoringGamepads;
  43412. /** @hidden */
  43413. _checkGamepadsStatus(): void;
  43414. private _updateGamepadObjects;
  43415. }
  43416. }
  43417. declare module "babylonjs/Gamepads/gamepadSceneComponent" {
  43418. import { Nullable } from "babylonjs/types";
  43419. import { Scene } from "babylonjs/scene";
  43420. import { ISceneComponent } from "babylonjs/sceneComponent";
  43421. import { GamepadManager } from "babylonjs/Gamepads/gamepadManager";
  43422. module "babylonjs/scene" {
  43423. interface Scene {
  43424. /** @hidden */
  43425. _gamepadManager: Nullable<GamepadManager>;
  43426. /**
  43427. * Gets the gamepad manager associated with the scene
  43428. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  43429. */
  43430. gamepadManager: GamepadManager;
  43431. }
  43432. }
  43433. module "babylonjs/Cameras/freeCameraInputsManager" {
  43434. /**
  43435. * Interface representing a free camera inputs manager
  43436. */
  43437. interface FreeCameraInputsManager {
  43438. /**
  43439. * Adds gamepad input support to the FreeCameraInputsManager.
  43440. * @returns the FreeCameraInputsManager
  43441. */
  43442. addGamepad(): FreeCameraInputsManager;
  43443. }
  43444. }
  43445. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  43446. /**
  43447. * Interface representing an arc rotate camera inputs manager
  43448. */
  43449. interface ArcRotateCameraInputsManager {
  43450. /**
  43451. * Adds gamepad input support to the ArcRotateCamera InputManager.
  43452. * @returns the camera inputs manager
  43453. */
  43454. addGamepad(): ArcRotateCameraInputsManager;
  43455. }
  43456. }
  43457. /**
  43458. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  43459. */
  43460. export class GamepadSystemSceneComponent implements ISceneComponent {
  43461. /**
  43462. * The component name helpfull to identify the component in the list of scene components.
  43463. */
  43464. readonly name: string;
  43465. /**
  43466. * The scene the component belongs to.
  43467. */
  43468. scene: Scene;
  43469. /**
  43470. * Creates a new instance of the component for the given scene
  43471. * @param scene Defines the scene to register the component in
  43472. */
  43473. constructor(scene: Scene);
  43474. /**
  43475. * Registers the component in a given scene
  43476. */
  43477. register(): void;
  43478. /**
  43479. * Rebuilds the elements related to this component in case of
  43480. * context lost for instance.
  43481. */
  43482. rebuild(): void;
  43483. /**
  43484. * Disposes the component and the associated ressources
  43485. */
  43486. dispose(): void;
  43487. private _beforeCameraUpdate;
  43488. }
  43489. }
  43490. declare module "babylonjs/Cameras/universalCamera" {
  43491. import { TouchCamera } from "babylonjs/Cameras/touchCamera";
  43492. import { Scene } from "babylonjs/scene";
  43493. import { Vector3 } from "babylonjs/Maths/math.vector";
  43494. import "babylonjs/Gamepads/gamepadSceneComponent";
  43495. /**
  43496. * 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,
  43497. * which still works and will still be found in many Playgrounds.
  43498. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  43499. */
  43500. export class UniversalCamera extends TouchCamera {
  43501. /**
  43502. * Defines the gamepad rotation sensiblity.
  43503. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  43504. */
  43505. get gamepadAngularSensibility(): number;
  43506. set gamepadAngularSensibility(value: number);
  43507. /**
  43508. * Defines the gamepad move sensiblity.
  43509. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  43510. */
  43511. get gamepadMoveSensibility(): number;
  43512. set gamepadMoveSensibility(value: number);
  43513. /**
  43514. * 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,
  43515. * which still works and will still be found in many Playgrounds.
  43516. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  43517. * @param name Define the name of the camera in the scene
  43518. * @param position Define the start position of the camera in the scene
  43519. * @param scene Define the scene the camera belongs to
  43520. */
  43521. constructor(name: string, position: Vector3, scene: Scene);
  43522. /**
  43523. * Gets the current object class name.
  43524. * @return the class name
  43525. */
  43526. getClassName(): string;
  43527. }
  43528. }
  43529. declare module "babylonjs/Cameras/gamepadCamera" {
  43530. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  43531. import { Scene } from "babylonjs/scene";
  43532. import { Vector3 } from "babylonjs/Maths/math.vector";
  43533. /**
  43534. * This represents a FPS type of camera. This is only here for back compat purpose.
  43535. * Please use the UniversalCamera instead as both are identical.
  43536. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  43537. */
  43538. export class GamepadCamera extends UniversalCamera {
  43539. /**
  43540. * Instantiates a new Gamepad Camera
  43541. * This represents a FPS type of camera. This is only here for back compat purpose.
  43542. * Please use the UniversalCamera instead as both are identical.
  43543. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  43544. * @param name Define the name of the camera in the scene
  43545. * @param position Define the start position of the camera in the scene
  43546. * @param scene Define the scene the camera belongs to
  43547. */
  43548. constructor(name: string, position: Vector3, scene: Scene);
  43549. /**
  43550. * Gets the current object class name.
  43551. * @return the class name
  43552. */
  43553. getClassName(): string;
  43554. }
  43555. }
  43556. declare module "babylonjs/Shaders/pass.fragment" {
  43557. /** @hidden */
  43558. export var passPixelShader: {
  43559. name: string;
  43560. shader: string;
  43561. };
  43562. }
  43563. declare module "babylonjs/Shaders/passCube.fragment" {
  43564. /** @hidden */
  43565. export var passCubePixelShader: {
  43566. name: string;
  43567. shader: string;
  43568. };
  43569. }
  43570. declare module "babylonjs/PostProcesses/passPostProcess" {
  43571. import { Nullable } from "babylonjs/types";
  43572. import { Camera } from "babylonjs/Cameras/camera";
  43573. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  43574. import { Engine } from "babylonjs/Engines/engine";
  43575. import "babylonjs/Shaders/pass.fragment";
  43576. import "babylonjs/Shaders/passCube.fragment";
  43577. /**
  43578. * PassPostProcess which produces an output the same as it's input
  43579. */
  43580. export class PassPostProcess extends PostProcess {
  43581. /**
  43582. * Creates the PassPostProcess
  43583. * @param name The name of the effect.
  43584. * @param options The required width/height ratio to downsize to before computing the render pass.
  43585. * @param camera The camera to apply the render pass to.
  43586. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  43587. * @param engine The engine which the post process will be applied. (default: current engine)
  43588. * @param reusable If the post process can be reused on the same frame. (default: false)
  43589. * @param textureType The type of texture to be used when performing the post processing.
  43590. * @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)
  43591. */
  43592. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  43593. }
  43594. /**
  43595. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  43596. */
  43597. export class PassCubePostProcess extends PostProcess {
  43598. private _face;
  43599. /**
  43600. * Gets or sets the cube face to display.
  43601. * * 0 is +X
  43602. * * 1 is -X
  43603. * * 2 is +Y
  43604. * * 3 is -Y
  43605. * * 4 is +Z
  43606. * * 5 is -Z
  43607. */
  43608. get face(): number;
  43609. set face(value: number);
  43610. /**
  43611. * Creates the PassCubePostProcess
  43612. * @param name The name of the effect.
  43613. * @param options The required width/height ratio to downsize to before computing the render pass.
  43614. * @param camera The camera to apply the render pass to.
  43615. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  43616. * @param engine The engine which the post process will be applied. (default: current engine)
  43617. * @param reusable If the post process can be reused on the same frame. (default: false)
  43618. * @param textureType The type of texture to be used when performing the post processing.
  43619. * @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)
  43620. */
  43621. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  43622. }
  43623. }
  43624. declare module "babylonjs/Shaders/anaglyph.fragment" {
  43625. /** @hidden */
  43626. export var anaglyphPixelShader: {
  43627. name: string;
  43628. shader: string;
  43629. };
  43630. }
  43631. declare module "babylonjs/PostProcesses/anaglyphPostProcess" {
  43632. import { Engine } from "babylonjs/Engines/engine";
  43633. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  43634. import { Camera } from "babylonjs/Cameras/camera";
  43635. import "babylonjs/Shaders/anaglyph.fragment";
  43636. /**
  43637. * Postprocess used to generate anaglyphic rendering
  43638. */
  43639. export class AnaglyphPostProcess extends PostProcess {
  43640. private _passedProcess;
  43641. /**
  43642. * Creates a new AnaglyphPostProcess
  43643. * @param name defines postprocess name
  43644. * @param options defines creation options or target ratio scale
  43645. * @param rigCameras defines cameras using this postprocess
  43646. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  43647. * @param engine defines hosting engine
  43648. * @param reusable defines if the postprocess will be reused multiple times per frame
  43649. */
  43650. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  43651. }
  43652. }
  43653. declare module "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode" { }
  43654. declare module "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera" {
  43655. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  43656. import { Scene } from "babylonjs/scene";
  43657. import { Vector3 } from "babylonjs/Maths/math.vector";
  43658. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  43659. /**
  43660. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  43661. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  43662. */
  43663. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  43664. /**
  43665. * Creates a new AnaglyphArcRotateCamera
  43666. * @param name defines camera name
  43667. * @param alpha defines alpha angle (in radians)
  43668. * @param beta defines beta angle (in radians)
  43669. * @param radius defines radius
  43670. * @param target defines camera target
  43671. * @param interaxialDistance defines distance between each color axis
  43672. * @param scene defines the hosting scene
  43673. */
  43674. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  43675. /**
  43676. * Gets camera class name
  43677. * @returns AnaglyphArcRotateCamera
  43678. */
  43679. getClassName(): string;
  43680. }
  43681. }
  43682. declare module "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera" {
  43683. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  43684. import { Scene } from "babylonjs/scene";
  43685. import { Vector3 } from "babylonjs/Maths/math.vector";
  43686. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  43687. /**
  43688. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  43689. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  43690. */
  43691. export class AnaglyphFreeCamera extends FreeCamera {
  43692. /**
  43693. * Creates a new AnaglyphFreeCamera
  43694. * @param name defines camera name
  43695. * @param position defines initial position
  43696. * @param interaxialDistance defines distance between each color axis
  43697. * @param scene defines the hosting scene
  43698. */
  43699. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  43700. /**
  43701. * Gets camera class name
  43702. * @returns AnaglyphFreeCamera
  43703. */
  43704. getClassName(): string;
  43705. }
  43706. }
  43707. declare module "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera" {
  43708. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  43709. import { Scene } from "babylonjs/scene";
  43710. import { Vector3 } from "babylonjs/Maths/math.vector";
  43711. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  43712. /**
  43713. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  43714. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  43715. */
  43716. export class AnaglyphGamepadCamera extends GamepadCamera {
  43717. /**
  43718. * Creates a new AnaglyphGamepadCamera
  43719. * @param name defines camera name
  43720. * @param position defines initial position
  43721. * @param interaxialDistance defines distance between each color axis
  43722. * @param scene defines the hosting scene
  43723. */
  43724. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  43725. /**
  43726. * Gets camera class name
  43727. * @returns AnaglyphGamepadCamera
  43728. */
  43729. getClassName(): string;
  43730. }
  43731. }
  43732. declare module "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera" {
  43733. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  43734. import { Scene } from "babylonjs/scene";
  43735. import { Vector3 } from "babylonjs/Maths/math.vector";
  43736. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  43737. /**
  43738. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  43739. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  43740. */
  43741. export class AnaglyphUniversalCamera extends UniversalCamera {
  43742. /**
  43743. * Creates a new AnaglyphUniversalCamera
  43744. * @param name defines camera name
  43745. * @param position defines initial position
  43746. * @param interaxialDistance defines distance between each color axis
  43747. * @param scene defines the hosting scene
  43748. */
  43749. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  43750. /**
  43751. * Gets camera class name
  43752. * @returns AnaglyphUniversalCamera
  43753. */
  43754. getClassName(): string;
  43755. }
  43756. }
  43757. declare module "babylonjs/Cameras/RigModes/stereoscopicRigMode" { }
  43758. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera" {
  43759. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  43760. import { Scene } from "babylonjs/scene";
  43761. import { Vector3 } from "babylonjs/Maths/math.vector";
  43762. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  43763. /**
  43764. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  43765. * @see http://doc.babylonjs.com/features/cameras
  43766. */
  43767. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  43768. /**
  43769. * Creates a new StereoscopicArcRotateCamera
  43770. * @param name defines camera name
  43771. * @param alpha defines alpha angle (in radians)
  43772. * @param beta defines beta angle (in radians)
  43773. * @param radius defines radius
  43774. * @param target defines camera target
  43775. * @param interaxialDistance defines distance between each color axis
  43776. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  43777. * @param scene defines the hosting scene
  43778. */
  43779. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  43780. /**
  43781. * Gets camera class name
  43782. * @returns StereoscopicArcRotateCamera
  43783. */
  43784. getClassName(): string;
  43785. }
  43786. }
  43787. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera" {
  43788. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  43789. import { Scene } from "babylonjs/scene";
  43790. import { Vector3 } from "babylonjs/Maths/math.vector";
  43791. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  43792. /**
  43793. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  43794. * @see http://doc.babylonjs.com/features/cameras
  43795. */
  43796. export class StereoscopicFreeCamera extends FreeCamera {
  43797. /**
  43798. * Creates a new StereoscopicFreeCamera
  43799. * @param name defines camera name
  43800. * @param position defines initial position
  43801. * @param interaxialDistance defines distance between each color axis
  43802. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  43803. * @param scene defines the hosting scene
  43804. */
  43805. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  43806. /**
  43807. * Gets camera class name
  43808. * @returns StereoscopicFreeCamera
  43809. */
  43810. getClassName(): string;
  43811. }
  43812. }
  43813. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera" {
  43814. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  43815. import { Scene } from "babylonjs/scene";
  43816. import { Vector3 } from "babylonjs/Maths/math.vector";
  43817. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  43818. /**
  43819. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  43820. * @see http://doc.babylonjs.com/features/cameras
  43821. */
  43822. export class StereoscopicGamepadCamera extends GamepadCamera {
  43823. /**
  43824. * Creates a new StereoscopicGamepadCamera
  43825. * @param name defines camera name
  43826. * @param position defines initial position
  43827. * @param interaxialDistance defines distance between each color axis
  43828. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  43829. * @param scene defines the hosting scene
  43830. */
  43831. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  43832. /**
  43833. * Gets camera class name
  43834. * @returns StereoscopicGamepadCamera
  43835. */
  43836. getClassName(): string;
  43837. }
  43838. }
  43839. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera" {
  43840. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  43841. import { Scene } from "babylonjs/scene";
  43842. import { Vector3 } from "babylonjs/Maths/math.vector";
  43843. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  43844. /**
  43845. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  43846. * @see http://doc.babylonjs.com/features/cameras
  43847. */
  43848. export class StereoscopicUniversalCamera extends UniversalCamera {
  43849. /**
  43850. * Creates a new StereoscopicUniversalCamera
  43851. * @param name defines camera name
  43852. * @param position defines initial position
  43853. * @param interaxialDistance defines distance between each color axis
  43854. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  43855. * @param scene defines the hosting scene
  43856. */
  43857. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  43858. /**
  43859. * Gets camera class name
  43860. * @returns StereoscopicUniversalCamera
  43861. */
  43862. getClassName(): string;
  43863. }
  43864. }
  43865. declare module "babylonjs/Cameras/Stereoscopic/index" {
  43866. export * from "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera";
  43867. export * from "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera";
  43868. export * from "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera";
  43869. export * from "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera";
  43870. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera";
  43871. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera";
  43872. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera";
  43873. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera";
  43874. }
  43875. declare module "babylonjs/Cameras/virtualJoysticksCamera" {
  43876. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  43877. import { Scene } from "babylonjs/scene";
  43878. import { Vector3 } from "babylonjs/Maths/math.vector";
  43879. import "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  43880. /**
  43881. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  43882. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  43883. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  43884. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  43885. */
  43886. export class VirtualJoysticksCamera extends FreeCamera {
  43887. /**
  43888. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  43889. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  43890. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  43891. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  43892. * @param name Define the name of the camera in the scene
  43893. * @param position Define the start position of the camera in the scene
  43894. * @param scene Define the scene the camera belongs to
  43895. */
  43896. constructor(name: string, position: Vector3, scene: Scene);
  43897. /**
  43898. * Gets the current object class name.
  43899. * @return the class name
  43900. */
  43901. getClassName(): string;
  43902. }
  43903. }
  43904. declare module "babylonjs/Cameras/VR/vrCameraMetrics" {
  43905. import { Matrix } from "babylonjs/Maths/math.vector";
  43906. /**
  43907. * This represents all the required metrics to create a VR camera.
  43908. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  43909. */
  43910. export class VRCameraMetrics {
  43911. /**
  43912. * Define the horizontal resolution off the screen.
  43913. */
  43914. hResolution: number;
  43915. /**
  43916. * Define the vertical resolution off the screen.
  43917. */
  43918. vResolution: number;
  43919. /**
  43920. * Define the horizontal screen size.
  43921. */
  43922. hScreenSize: number;
  43923. /**
  43924. * Define the vertical screen size.
  43925. */
  43926. vScreenSize: number;
  43927. /**
  43928. * Define the vertical screen center position.
  43929. */
  43930. vScreenCenter: number;
  43931. /**
  43932. * Define the distance of the eyes to the screen.
  43933. */
  43934. eyeToScreenDistance: number;
  43935. /**
  43936. * Define the distance between both lenses
  43937. */
  43938. lensSeparationDistance: number;
  43939. /**
  43940. * Define the distance between both viewer's eyes.
  43941. */
  43942. interpupillaryDistance: number;
  43943. /**
  43944. * Define the distortion factor of the VR postprocess.
  43945. * Please, touch with care.
  43946. */
  43947. distortionK: number[];
  43948. /**
  43949. * Define the chromatic aberration correction factors for the VR post process.
  43950. */
  43951. chromaAbCorrection: number[];
  43952. /**
  43953. * Define the scale factor of the post process.
  43954. * The smaller the better but the slower.
  43955. */
  43956. postProcessScaleFactor: number;
  43957. /**
  43958. * Define an offset for the lens center.
  43959. */
  43960. lensCenterOffset: number;
  43961. /**
  43962. * Define if the current vr camera should compensate the distortion of the lense or not.
  43963. */
  43964. compensateDistortion: boolean;
  43965. /**
  43966. * Defines if multiview should be enabled when rendering (Default: false)
  43967. */
  43968. multiviewEnabled: boolean;
  43969. /**
  43970. * Gets the rendering aspect ratio based on the provided resolutions.
  43971. */
  43972. get aspectRatio(): number;
  43973. /**
  43974. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  43975. */
  43976. get aspectRatioFov(): number;
  43977. /**
  43978. * @hidden
  43979. */
  43980. get leftHMatrix(): Matrix;
  43981. /**
  43982. * @hidden
  43983. */
  43984. get rightHMatrix(): Matrix;
  43985. /**
  43986. * @hidden
  43987. */
  43988. get leftPreViewMatrix(): Matrix;
  43989. /**
  43990. * @hidden
  43991. */
  43992. get rightPreViewMatrix(): Matrix;
  43993. /**
  43994. * Get the default VRMetrics based on the most generic setup.
  43995. * @returns the default vr metrics
  43996. */
  43997. static GetDefault(): VRCameraMetrics;
  43998. }
  43999. }
  44000. declare module "babylonjs/Shaders/vrDistortionCorrection.fragment" {
  44001. /** @hidden */
  44002. export var vrDistortionCorrectionPixelShader: {
  44003. name: string;
  44004. shader: string;
  44005. };
  44006. }
  44007. declare module "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess" {
  44008. import { Camera } from "babylonjs/Cameras/camera";
  44009. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  44010. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  44011. import "babylonjs/Shaders/vrDistortionCorrection.fragment";
  44012. /**
  44013. * VRDistortionCorrectionPostProcess used for mobile VR
  44014. */
  44015. export class VRDistortionCorrectionPostProcess extends PostProcess {
  44016. private _isRightEye;
  44017. private _distortionFactors;
  44018. private _postProcessScaleFactor;
  44019. private _lensCenterOffset;
  44020. private _scaleIn;
  44021. private _scaleFactor;
  44022. private _lensCenter;
  44023. /**
  44024. * Initializes the VRDistortionCorrectionPostProcess
  44025. * @param name The name of the effect.
  44026. * @param camera The camera to apply the render pass to.
  44027. * @param isRightEye If this is for the right eye distortion
  44028. * @param vrMetrics All the required metrics for the VR camera
  44029. */
  44030. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  44031. }
  44032. }
  44033. declare module "babylonjs/Cameras/RigModes/vrRigMode" { }
  44034. declare module "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera" {
  44035. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  44036. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  44037. import { Scene } from "babylonjs/scene";
  44038. import { Vector3 } from "babylonjs/Maths/math.vector";
  44039. import "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  44040. import "babylonjs/Cameras/RigModes/vrRigMode";
  44041. /**
  44042. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  44043. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  44044. */
  44045. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  44046. /**
  44047. * Creates a new VRDeviceOrientationArcRotateCamera
  44048. * @param name defines camera name
  44049. * @param alpha defines the camera rotation along the logitudinal axis
  44050. * @param beta defines the camera rotation along the latitudinal axis
  44051. * @param radius defines the camera distance from its target
  44052. * @param target defines the camera target
  44053. * @param scene defines the scene the camera belongs to
  44054. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  44055. * @param vrCameraMetrics defines the vr metrics associated to the camera
  44056. */
  44057. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  44058. /**
  44059. * Gets camera class name
  44060. * @returns VRDeviceOrientationArcRotateCamera
  44061. */
  44062. getClassName(): string;
  44063. }
  44064. }
  44065. declare module "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera" {
  44066. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  44067. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  44068. import { Scene } from "babylonjs/scene";
  44069. import { Vector3 } from "babylonjs/Maths/math.vector";
  44070. import "babylonjs/Cameras/RigModes/vrRigMode";
  44071. /**
  44072. * Camera used to simulate VR rendering (based on FreeCamera)
  44073. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  44074. */
  44075. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  44076. /**
  44077. * Creates a new VRDeviceOrientationFreeCamera
  44078. * @param name defines camera name
  44079. * @param position defines the start position of the camera
  44080. * @param scene defines the scene the camera belongs to
  44081. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  44082. * @param vrCameraMetrics defines the vr metrics associated to the camera
  44083. */
  44084. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  44085. /**
  44086. * Gets camera class name
  44087. * @returns VRDeviceOrientationFreeCamera
  44088. */
  44089. getClassName(): string;
  44090. }
  44091. }
  44092. declare module "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera" {
  44093. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  44094. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  44095. import { Scene } from "babylonjs/scene";
  44096. import { Vector3 } from "babylonjs/Maths/math.vector";
  44097. import "babylonjs/Gamepads/gamepadSceneComponent";
  44098. /**
  44099. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  44100. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  44101. */
  44102. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  44103. /**
  44104. * Creates a new VRDeviceOrientationGamepadCamera
  44105. * @param name defines camera name
  44106. * @param position defines the start position of the camera
  44107. * @param scene defines the scene the camera belongs to
  44108. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  44109. * @param vrCameraMetrics defines the vr metrics associated to the camera
  44110. */
  44111. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  44112. /**
  44113. * Gets camera class name
  44114. * @returns VRDeviceOrientationGamepadCamera
  44115. */
  44116. getClassName(): string;
  44117. }
  44118. }
  44119. declare module "babylonjs/Shaders/imageProcessing.fragment" {
  44120. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  44121. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  44122. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  44123. /** @hidden */
  44124. export var imageProcessingPixelShader: {
  44125. name: string;
  44126. shader: string;
  44127. };
  44128. }
  44129. declare module "babylonjs/PostProcesses/imageProcessingPostProcess" {
  44130. import { Nullable } from "babylonjs/types";
  44131. import { Color4 } from "babylonjs/Maths/math.color";
  44132. import { Camera } from "babylonjs/Cameras/camera";
  44133. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  44134. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  44135. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  44136. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  44137. import { Engine } from "babylonjs/Engines/engine";
  44138. import "babylonjs/Shaders/imageProcessing.fragment";
  44139. import "babylonjs/Shaders/postprocess.vertex";
  44140. /**
  44141. * ImageProcessingPostProcess
  44142. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  44143. */
  44144. export class ImageProcessingPostProcess extends PostProcess {
  44145. /**
  44146. * Default configuration related to image processing available in the PBR Material.
  44147. */
  44148. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  44149. /**
  44150. * Gets the image processing configuration used either in this material.
  44151. */
  44152. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  44153. /**
  44154. * Sets the Default image processing configuration used either in the this material.
  44155. *
  44156. * If sets to null, the scene one is in use.
  44157. */
  44158. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  44159. /**
  44160. * Keep track of the image processing observer to allow dispose and replace.
  44161. */
  44162. private _imageProcessingObserver;
  44163. /**
  44164. * Attaches a new image processing configuration to the PBR Material.
  44165. * @param configuration
  44166. */
  44167. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  44168. /**
  44169. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  44170. */
  44171. get colorCurves(): Nullable<ColorCurves>;
  44172. /**
  44173. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  44174. */
  44175. set colorCurves(value: Nullable<ColorCurves>);
  44176. /**
  44177. * Gets wether the color curves effect is enabled.
  44178. */
  44179. get colorCurvesEnabled(): boolean;
  44180. /**
  44181. * Sets wether the color curves effect is enabled.
  44182. */
  44183. set colorCurvesEnabled(value: boolean);
  44184. /**
  44185. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  44186. */
  44187. get colorGradingTexture(): Nullable<BaseTexture>;
  44188. /**
  44189. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  44190. */
  44191. set colorGradingTexture(value: Nullable<BaseTexture>);
  44192. /**
  44193. * Gets wether the color grading effect is enabled.
  44194. */
  44195. get colorGradingEnabled(): boolean;
  44196. /**
  44197. * Gets wether the color grading effect is enabled.
  44198. */
  44199. set colorGradingEnabled(value: boolean);
  44200. /**
  44201. * Gets exposure used in the effect.
  44202. */
  44203. get exposure(): number;
  44204. /**
  44205. * Sets exposure used in the effect.
  44206. */
  44207. set exposure(value: number);
  44208. /**
  44209. * Gets wether tonemapping is enabled or not.
  44210. */
  44211. get toneMappingEnabled(): boolean;
  44212. /**
  44213. * Sets wether tonemapping is enabled or not
  44214. */
  44215. set toneMappingEnabled(value: boolean);
  44216. /**
  44217. * Gets the type of tone mapping effect.
  44218. */
  44219. get toneMappingType(): number;
  44220. /**
  44221. * Sets the type of tone mapping effect.
  44222. */
  44223. set toneMappingType(value: number);
  44224. /**
  44225. * Gets contrast used in the effect.
  44226. */
  44227. get contrast(): number;
  44228. /**
  44229. * Sets contrast used in the effect.
  44230. */
  44231. set contrast(value: number);
  44232. /**
  44233. * Gets Vignette stretch size.
  44234. */
  44235. get vignetteStretch(): number;
  44236. /**
  44237. * Sets Vignette stretch size.
  44238. */
  44239. set vignetteStretch(value: number);
  44240. /**
  44241. * Gets Vignette centre X Offset.
  44242. */
  44243. get vignetteCentreX(): number;
  44244. /**
  44245. * Sets Vignette centre X Offset.
  44246. */
  44247. set vignetteCentreX(value: number);
  44248. /**
  44249. * Gets Vignette centre Y Offset.
  44250. */
  44251. get vignetteCentreY(): number;
  44252. /**
  44253. * Sets Vignette centre Y Offset.
  44254. */
  44255. set vignetteCentreY(value: number);
  44256. /**
  44257. * Gets Vignette weight or intensity of the vignette effect.
  44258. */
  44259. get vignetteWeight(): number;
  44260. /**
  44261. * Sets Vignette weight or intensity of the vignette effect.
  44262. */
  44263. set vignetteWeight(value: number);
  44264. /**
  44265. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  44266. * if vignetteEnabled is set to true.
  44267. */
  44268. get vignetteColor(): Color4;
  44269. /**
  44270. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  44271. * if vignetteEnabled is set to true.
  44272. */
  44273. set vignetteColor(value: Color4);
  44274. /**
  44275. * Gets Camera field of view used by the Vignette effect.
  44276. */
  44277. get vignetteCameraFov(): number;
  44278. /**
  44279. * Sets Camera field of view used by the Vignette effect.
  44280. */
  44281. set vignetteCameraFov(value: number);
  44282. /**
  44283. * Gets the vignette blend mode allowing different kind of effect.
  44284. */
  44285. get vignetteBlendMode(): number;
  44286. /**
  44287. * Sets the vignette blend mode allowing different kind of effect.
  44288. */
  44289. set vignetteBlendMode(value: number);
  44290. /**
  44291. * Gets wether the vignette effect is enabled.
  44292. */
  44293. get vignetteEnabled(): boolean;
  44294. /**
  44295. * Sets wether the vignette effect is enabled.
  44296. */
  44297. set vignetteEnabled(value: boolean);
  44298. private _fromLinearSpace;
  44299. /**
  44300. * Gets wether the input of the processing is in Gamma or Linear Space.
  44301. */
  44302. get fromLinearSpace(): boolean;
  44303. /**
  44304. * Sets wether the input of the processing is in Gamma or Linear Space.
  44305. */
  44306. set fromLinearSpace(value: boolean);
  44307. /**
  44308. * Defines cache preventing GC.
  44309. */
  44310. private _defines;
  44311. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  44312. /**
  44313. * "ImageProcessingPostProcess"
  44314. * @returns "ImageProcessingPostProcess"
  44315. */
  44316. getClassName(): string;
  44317. protected _updateParameters(): void;
  44318. dispose(camera?: Camera): void;
  44319. }
  44320. }
  44321. declare module "babylonjs/Meshes/Builders/groundBuilder" {
  44322. import { Scene } from "babylonjs/scene";
  44323. import { Color3 } from "babylonjs/Maths/math.color";
  44324. import { Mesh } from "babylonjs/Meshes/mesh";
  44325. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  44326. import { Nullable } from "babylonjs/types";
  44327. /**
  44328. * Class containing static functions to help procedurally build meshes
  44329. */
  44330. export class GroundBuilder {
  44331. /**
  44332. * Creates a ground mesh
  44333. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  44334. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  44335. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44336. * @param name defines the name of the mesh
  44337. * @param options defines the options used to create the mesh
  44338. * @param scene defines the hosting scene
  44339. * @returns the ground mesh
  44340. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  44341. */
  44342. static CreateGround(name: string, options: {
  44343. width?: number;
  44344. height?: number;
  44345. subdivisions?: number;
  44346. subdivisionsX?: number;
  44347. subdivisionsY?: number;
  44348. updatable?: boolean;
  44349. }, scene: any): Mesh;
  44350. /**
  44351. * Creates a tiled ground mesh
  44352. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  44353. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  44354. * * 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
  44355. * * 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
  44356. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  44357. * @param name defines the name of the mesh
  44358. * @param options defines the options used to create the mesh
  44359. * @param scene defines the hosting scene
  44360. * @returns the tiled ground mesh
  44361. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  44362. */
  44363. static CreateTiledGround(name: string, options: {
  44364. xmin: number;
  44365. zmin: number;
  44366. xmax: number;
  44367. zmax: number;
  44368. subdivisions?: {
  44369. w: number;
  44370. h: number;
  44371. };
  44372. precision?: {
  44373. w: number;
  44374. h: number;
  44375. };
  44376. updatable?: boolean;
  44377. }, scene?: Nullable<Scene>): Mesh;
  44378. /**
  44379. * Creates a ground mesh from a height map
  44380. * * The parameter `url` sets the URL of the height map image resource.
  44381. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  44382. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  44383. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  44384. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  44385. * * 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.
  44386. * * 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).
  44387. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  44388. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  44389. * @param name defines the name of the mesh
  44390. * @param url defines the url to the height map
  44391. * @param options defines the options used to create the mesh
  44392. * @param scene defines the hosting scene
  44393. * @returns the ground mesh
  44394. * @see https://doc.babylonjs.com/babylon101/height_map
  44395. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  44396. */
  44397. static CreateGroundFromHeightMap(name: string, url: string, options: {
  44398. width?: number;
  44399. height?: number;
  44400. subdivisions?: number;
  44401. minHeight?: number;
  44402. maxHeight?: number;
  44403. colorFilter?: Color3;
  44404. alphaFilter?: number;
  44405. updatable?: boolean;
  44406. onReady?: (mesh: GroundMesh) => void;
  44407. }, scene?: Nullable<Scene>): GroundMesh;
  44408. }
  44409. }
  44410. declare module "babylonjs/Meshes/Builders/torusBuilder" {
  44411. import { Vector4 } from "babylonjs/Maths/math.vector";
  44412. import { Mesh } from "babylonjs/Meshes/mesh";
  44413. /**
  44414. * Class containing static functions to help procedurally build meshes
  44415. */
  44416. export class TorusBuilder {
  44417. /**
  44418. * Creates a torus mesh
  44419. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  44420. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  44421. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  44422. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  44423. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  44424. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  44425. * @param name defines the name of the mesh
  44426. * @param options defines the options used to create the mesh
  44427. * @param scene defines the hosting scene
  44428. * @returns the torus mesh
  44429. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  44430. */
  44431. static CreateTorus(name: string, options: {
  44432. diameter?: number;
  44433. thickness?: number;
  44434. tessellation?: number;
  44435. updatable?: boolean;
  44436. sideOrientation?: number;
  44437. frontUVs?: Vector4;
  44438. backUVs?: Vector4;
  44439. }, scene: any): Mesh;
  44440. }
  44441. }
  44442. declare module "babylonjs/Meshes/Builders/cylinderBuilder" {
  44443. import { Vector4 } from "babylonjs/Maths/math.vector";
  44444. import { Color4 } from "babylonjs/Maths/math.color";
  44445. import { Mesh } from "babylonjs/Meshes/mesh";
  44446. /**
  44447. * Class containing static functions to help procedurally build meshes
  44448. */
  44449. export class CylinderBuilder {
  44450. /**
  44451. * Creates a cylinder or a cone mesh
  44452. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  44453. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  44454. * * 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.
  44455. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  44456. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  44457. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  44458. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  44459. * * 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).
  44460. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  44461. * * 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).
  44462. * * 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
  44463. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  44464. * * 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
  44465. * * 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.
  44466. * * If `enclose` is false, a ring surface is one element.
  44467. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  44468. * * 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
  44469. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  44470. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  44471. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  44472. * @param name defines the name of the mesh
  44473. * @param options defines the options used to create the mesh
  44474. * @param scene defines the hosting scene
  44475. * @returns the cylinder mesh
  44476. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  44477. */
  44478. static CreateCylinder(name: string, options: {
  44479. height?: number;
  44480. diameterTop?: number;
  44481. diameterBottom?: number;
  44482. diameter?: number;
  44483. tessellation?: number;
  44484. subdivisions?: number;
  44485. arc?: number;
  44486. faceColors?: Color4[];
  44487. faceUV?: Vector4[];
  44488. updatable?: boolean;
  44489. hasRings?: boolean;
  44490. enclose?: boolean;
  44491. cap?: number;
  44492. sideOrientation?: number;
  44493. frontUVs?: Vector4;
  44494. backUVs?: Vector4;
  44495. }, scene: any): Mesh;
  44496. }
  44497. }
  44498. declare module "babylonjs/XR/webXRTypes" {
  44499. import { Nullable } from "babylonjs/types";
  44500. import { IDisposable } from "babylonjs/scene";
  44501. /**
  44502. * States of the webXR experience
  44503. */
  44504. export enum WebXRState {
  44505. /**
  44506. * Transitioning to being in XR mode
  44507. */
  44508. ENTERING_XR = 0,
  44509. /**
  44510. * Transitioning to non XR mode
  44511. */
  44512. EXITING_XR = 1,
  44513. /**
  44514. * In XR mode and presenting
  44515. */
  44516. IN_XR = 2,
  44517. /**
  44518. * Not entered XR mode
  44519. */
  44520. NOT_IN_XR = 3
  44521. }
  44522. /**
  44523. * Abstraction of the XR render target
  44524. */
  44525. export interface WebXRRenderTarget extends IDisposable {
  44526. /**
  44527. * xrpresent context of the canvas which can be used to display/mirror xr content
  44528. */
  44529. canvasContext: WebGLRenderingContext;
  44530. /**
  44531. * xr layer for the canvas
  44532. */
  44533. xrLayer: Nullable<XRWebGLLayer>;
  44534. /**
  44535. * Initializes the xr layer for the session
  44536. * @param xrSession xr session
  44537. * @returns a promise that will resolve once the XR Layer has been created
  44538. */
  44539. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  44540. }
  44541. }
  44542. declare module "babylonjs/XR/webXRManagedOutputCanvas" {
  44543. import { Nullable } from "babylonjs/types";
  44544. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  44545. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  44546. /**
  44547. * COnfiguration object for WebXR output canvas
  44548. */
  44549. export class WebXRManagedOutputCanvasOptions {
  44550. /**
  44551. * An optional canvas in case you wish to create it yourself and provide it here.
  44552. * If not provided, a new canvas will be created
  44553. */
  44554. canvasElement?: HTMLCanvasElement;
  44555. /**
  44556. * Options for this XR Layer output
  44557. */
  44558. canvasOptions?: XRWebGLLayerOptions;
  44559. /**
  44560. * CSS styling for a newly created canvas (if not provided)
  44561. */
  44562. newCanvasCssStyle?: string;
  44563. /**
  44564. * Get the default values of the configuration object
  44565. * @returns default values of this configuration object
  44566. */
  44567. static GetDefaults(): WebXRManagedOutputCanvasOptions;
  44568. }
  44569. /**
  44570. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  44571. */
  44572. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  44573. private _options;
  44574. private _canvas;
  44575. private _engine;
  44576. /**
  44577. * Rendering context of the canvas which can be used to display/mirror xr content
  44578. */
  44579. canvasContext: WebGLRenderingContext;
  44580. /**
  44581. * xr layer for the canvas
  44582. */
  44583. xrLayer: Nullable<XRWebGLLayer>;
  44584. /**
  44585. * Initializes the canvas to be added/removed upon entering/exiting xr
  44586. * @param _xrSessionManager The XR Session manager
  44587. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  44588. */
  44589. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  44590. /**
  44591. * Disposes of the object
  44592. */
  44593. dispose(): void;
  44594. /**
  44595. * Initializes the xr layer for the session
  44596. * @param xrSession xr session
  44597. * @returns a promise that will resolve once the XR Layer has been created
  44598. */
  44599. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  44600. private _addCanvas;
  44601. private _removeCanvas;
  44602. private _setManagedOutputCanvas;
  44603. }
  44604. }
  44605. declare module "babylonjs/XR/webXRSessionManager" {
  44606. import { Observable } from "babylonjs/Misc/observable";
  44607. import { Nullable } from "babylonjs/types";
  44608. import { IDisposable, Scene } from "babylonjs/scene";
  44609. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  44610. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  44611. import { WebXRManagedOutputCanvasOptions } from "babylonjs/XR/webXRManagedOutputCanvas";
  44612. /**
  44613. * Manages an XRSession to work with Babylon's engine
  44614. * @see https://doc.babylonjs.com/how_to/webxr
  44615. */
  44616. export class WebXRSessionManager implements IDisposable {
  44617. /** The scene which the session should be created for */
  44618. scene: Scene;
  44619. private _referenceSpace;
  44620. private _rttProvider;
  44621. private _sessionEnded;
  44622. private _xrNavigator;
  44623. private baseLayer;
  44624. /**
  44625. * The base reference space from which the session started. good if you want to reset your
  44626. * reference space
  44627. */
  44628. baseReferenceSpace: XRReferenceSpace;
  44629. /**
  44630. * Current XR frame
  44631. */
  44632. currentFrame: Nullable<XRFrame>;
  44633. /** WebXR timestamp updated every frame */
  44634. currentTimestamp: number;
  44635. /**
  44636. * Used just in case of a failure to initialize an immersive session.
  44637. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  44638. */
  44639. defaultHeightCompensation: number;
  44640. /**
  44641. * Fires every time a new xrFrame arrives which can be used to update the camera
  44642. */
  44643. onXRFrameObservable: Observable<XRFrame>;
  44644. /**
  44645. * Fires when the reference space changed
  44646. */
  44647. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  44648. /**
  44649. * Fires when the xr session is ended either by the device or manually done
  44650. */
  44651. onXRSessionEnded: Observable<any>;
  44652. /**
  44653. * Fires when the xr session is ended either by the device or manually done
  44654. */
  44655. onXRSessionInit: Observable<XRSession>;
  44656. /**
  44657. * Underlying xr session
  44658. */
  44659. session: XRSession;
  44660. /**
  44661. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  44662. * or get the offset the player is currently at.
  44663. */
  44664. viewerReferenceSpace: XRReferenceSpace;
  44665. /**
  44666. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  44667. * @param scene The scene which the session should be created for
  44668. */
  44669. constructor(
  44670. /** The scene which the session should be created for */
  44671. scene: Scene);
  44672. /**
  44673. * The current reference space used in this session. This reference space can constantly change!
  44674. * It is mainly used to offset the camera's position.
  44675. */
  44676. get referenceSpace(): XRReferenceSpace;
  44677. /**
  44678. * Set a new reference space and triggers the observable
  44679. */
  44680. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  44681. /**
  44682. * Disposes of the session manager
  44683. */
  44684. dispose(): void;
  44685. /**
  44686. * Stops the xrSession and restores the render loop
  44687. * @returns Promise which resolves after it exits XR
  44688. */
  44689. exitXRAsync(): Promise<void>;
  44690. /**
  44691. * Gets the correct render target texture to be rendered this frame for this eye
  44692. * @param eye the eye for which to get the render target
  44693. * @returns the render target for the specified eye
  44694. */
  44695. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  44696. /**
  44697. * Creates a WebXRRenderTarget object for the XR session
  44698. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  44699. * @param options optional options to provide when creating a new render target
  44700. * @returns a WebXR render target to which the session can render
  44701. */
  44702. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  44703. /**
  44704. * Initializes the manager
  44705. * After initialization enterXR can be called to start an XR session
  44706. * @returns Promise which resolves after it is initialized
  44707. */
  44708. initializeAsync(): Promise<void>;
  44709. /**
  44710. * Initializes an xr session
  44711. * @param xrSessionMode mode to initialize
  44712. * @param xrSessionInit defines optional and required values to pass to the session builder
  44713. * @returns a promise which will resolve once the session has been initialized
  44714. */
  44715. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  44716. /**
  44717. * Checks if a session would be supported for the creation options specified
  44718. * @param sessionMode session mode to check if supported eg. immersive-vr
  44719. * @returns A Promise that resolves to true if supported and false if not
  44720. */
  44721. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  44722. /**
  44723. * Resets the reference space to the one started the session
  44724. */
  44725. resetReferenceSpace(): void;
  44726. /**
  44727. * Starts rendering to the xr layer
  44728. */
  44729. runXRRenderLoop(): void;
  44730. /**
  44731. * Sets the reference space on the xr session
  44732. * @param referenceSpaceType space to set
  44733. * @returns a promise that will resolve once the reference space has been set
  44734. */
  44735. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  44736. /**
  44737. * Updates the render state of the session
  44738. * @param state state to set
  44739. * @returns a promise that resolves once the render state has been updated
  44740. */
  44741. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  44742. /**
  44743. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  44744. * @param sessionMode defines the session to test
  44745. * @returns a promise with boolean as final value
  44746. */
  44747. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  44748. private _createRenderTargetTexture;
  44749. }
  44750. }
  44751. declare module "babylonjs/XR/webXRCamera" {
  44752. import { Scene } from "babylonjs/scene";
  44753. import { Camera } from "babylonjs/Cameras/camera";
  44754. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  44755. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  44756. /**
  44757. * WebXR Camera which holds the views for the xrSession
  44758. * @see https://doc.babylonjs.com/how_to/webxr_camera
  44759. */
  44760. export class WebXRCamera extends FreeCamera {
  44761. private _xrSessionManager;
  44762. private _firstFrame;
  44763. private _referenceQuaternion;
  44764. private _referencedPosition;
  44765. private _xrInvPositionCache;
  44766. private _xrInvQuaternionCache;
  44767. /**
  44768. * Should position compensation execute on first frame.
  44769. * This is used when copying the position from a native (non XR) camera
  44770. */
  44771. compensateOnFirstFrame: boolean;
  44772. /**
  44773. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  44774. * @param name the name of the camera
  44775. * @param scene the scene to add the camera to
  44776. * @param _xrSessionManager a constructed xr session manager
  44777. */
  44778. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  44779. /**
  44780. * Return the user's height, unrelated to the current ground.
  44781. * This will be the y position of this camera, when ground level is 0.
  44782. */
  44783. get realWorldHeight(): number;
  44784. /** @hidden */
  44785. _updateForDualEyeDebugging(): void;
  44786. /**
  44787. * Sets this camera's transformation based on a non-vr camera
  44788. * @param otherCamera the non-vr camera to copy the transformation from
  44789. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  44790. */
  44791. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  44792. /**
  44793. * Gets the current instance class name ("WebXRCamera").
  44794. * @returns the class name
  44795. */
  44796. getClassName(): string;
  44797. private _updateFromXRSession;
  44798. private _updateNumberOfRigCameras;
  44799. private _updateReferenceSpace;
  44800. private _updateReferenceSpaceOffset;
  44801. }
  44802. }
  44803. declare module "babylonjs/XR/webXRFeaturesManager" {
  44804. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  44805. import { IDisposable } from "babylonjs/scene";
  44806. /**
  44807. * Defining the interface required for a (webxr) feature
  44808. */
  44809. export interface IWebXRFeature extends IDisposable {
  44810. /**
  44811. * Is this feature attached
  44812. */
  44813. attached: boolean;
  44814. /**
  44815. * Should auto-attach be disabled?
  44816. */
  44817. disableAutoAttach: boolean;
  44818. /**
  44819. * Attach the feature to the session
  44820. * Will usually be called by the features manager
  44821. *
  44822. * @param force should attachment be forced (even when already attached)
  44823. * @returns true if successful.
  44824. */
  44825. attach(force?: boolean): boolean;
  44826. /**
  44827. * Detach the feature from the session
  44828. * Will usually be called by the features manager
  44829. *
  44830. * @returns true if successful.
  44831. */
  44832. detach(): boolean;
  44833. }
  44834. /**
  44835. * A list of the currently available features without referencing them
  44836. */
  44837. export class WebXRFeatureName {
  44838. /**
  44839. * The name of the anchor system feature
  44840. */
  44841. static ANCHOR_SYSTEM: string;
  44842. /**
  44843. * The name of the background remover feature
  44844. */
  44845. static BACKGROUND_REMOVER: string;
  44846. /**
  44847. * The name of the hit test feature
  44848. */
  44849. static HIT_TEST: string;
  44850. /**
  44851. * physics impostors for xr controllers feature
  44852. */
  44853. static PHYSICS_CONTROLLERS: string;
  44854. /**
  44855. * The name of the plane detection feature
  44856. */
  44857. static PLANE_DETECTION: string;
  44858. /**
  44859. * The name of the pointer selection feature
  44860. */
  44861. static POINTER_SELECTION: string;
  44862. /**
  44863. * The name of the teleportation feature
  44864. */
  44865. static TELEPORTATION: string;
  44866. }
  44867. /**
  44868. * Defining the constructor of a feature. Used to register the modules.
  44869. */
  44870. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => (() => IWebXRFeature);
  44871. /**
  44872. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  44873. * It is mainly used in AR sessions.
  44874. *
  44875. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  44876. */
  44877. export class WebXRFeaturesManager implements IDisposable {
  44878. private _xrSessionManager;
  44879. private static readonly _AvailableFeatures;
  44880. private _features;
  44881. /**
  44882. * constructs a new features manages.
  44883. *
  44884. * @param _xrSessionManager an instance of WebXRSessionManager
  44885. */
  44886. constructor(_xrSessionManager: WebXRSessionManager);
  44887. /**
  44888. * Used to register a module. After calling this function a developer can use this feature in the scene.
  44889. * Mainly used internally.
  44890. *
  44891. * @param featureName the name of the feature to register
  44892. * @param constructorFunction the function used to construct the module
  44893. * @param version the (babylon) version of the module
  44894. * @param stable is that a stable version of this module
  44895. */
  44896. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  44897. /**
  44898. * Returns a constructor of a specific feature.
  44899. *
  44900. * @param featureName the name of the feature to construct
  44901. * @param version the version of the feature to load
  44902. * @param xrSessionManager the xrSessionManager. Used to construct the module
  44903. * @param options optional options provided to the module.
  44904. * @returns a function that, when called, will return a new instance of this feature
  44905. */
  44906. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): (() => IWebXRFeature);
  44907. /**
  44908. * Can be used to return the list of features currently registered
  44909. *
  44910. * @returns an Array of available features
  44911. */
  44912. static GetAvailableFeatures(): string[];
  44913. /**
  44914. * Gets the versions available for a specific feature
  44915. * @param featureName the name of the feature
  44916. * @returns an array with the available versions
  44917. */
  44918. static GetAvailableVersions(featureName: string): string[];
  44919. /**
  44920. * Return the latest unstable version of this feature
  44921. * @param featureName the name of the feature to search
  44922. * @returns the version number. if not found will return -1
  44923. */
  44924. static GetLatestVersionOfFeature(featureName: string): number;
  44925. /**
  44926. * Return the latest stable version of this feature
  44927. * @param featureName the name of the feature to search
  44928. * @returns the version number. if not found will return -1
  44929. */
  44930. static GetStableVersionOfFeature(featureName: string): number;
  44931. /**
  44932. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  44933. * Can be used during a session to start a feature
  44934. * @param featureName the name of feature to attach
  44935. */
  44936. attachFeature(featureName: string): void;
  44937. /**
  44938. * Can be used inside a session or when the session ends to detach a specific feature
  44939. * @param featureName the name of the feature to detach
  44940. */
  44941. detachFeature(featureName: string): void;
  44942. /**
  44943. * Used to disable an already-enabled feature
  44944. * The feature will be disposed and will be recreated once enabled.
  44945. * @param featureName the feature to disable
  44946. * @returns true if disable was successful
  44947. */
  44948. disableFeature(featureName: string | {
  44949. Name: string;
  44950. }): boolean;
  44951. /**
  44952. * dispose this features manager
  44953. */
  44954. dispose(): void;
  44955. /**
  44956. * 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.
  44957. * 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.
  44958. *
  44959. * @param featureName the name of the feature to load or the class of the feature
  44960. * @param version optional version to load. if not provided the latest version will be enabled
  44961. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  44962. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  44963. * @returns a new constructed feature or throws an error if feature not found.
  44964. */
  44965. enableFeature(featureName: string | {
  44966. Name: string;
  44967. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean): IWebXRFeature;
  44968. /**
  44969. * get the implementation of an enabled feature.
  44970. * @param featureName the name of the feature to load
  44971. * @returns the feature class, if found
  44972. */
  44973. getEnabledFeature(featureName: string): IWebXRFeature;
  44974. /**
  44975. * Get the list of enabled features
  44976. * @returns an array of enabled features
  44977. */
  44978. getEnabledFeatures(): string[];
  44979. }
  44980. }
  44981. declare module "babylonjs/XR/webXRExperienceHelper" {
  44982. import { Observable } from "babylonjs/Misc/observable";
  44983. import { IDisposable, Scene } from "babylonjs/scene";
  44984. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  44985. import { WebXRCamera } from "babylonjs/XR/webXRCamera";
  44986. import { WebXRState, WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  44987. import { WebXRFeaturesManager } from "babylonjs/XR/webXRFeaturesManager";
  44988. /**
  44989. * Base set of functionality needed to create an XR experience (WebXRSessionManager, Camera, StateManagement, etc.)
  44990. * @see https://doc.babylonjs.com/how_to/webxr
  44991. */
  44992. export class WebXRExperienceHelper implements IDisposable {
  44993. private scene;
  44994. private _nonVRCamera;
  44995. private _originalSceneAutoClear;
  44996. private _supported;
  44997. /**
  44998. * Camera used to render xr content
  44999. */
  45000. camera: WebXRCamera;
  45001. /** A features manager for this xr session */
  45002. featuresManager: WebXRFeaturesManager;
  45003. /**
  45004. * Observers registered here will be triggered after the camera's initial transformation is set
  45005. * This can be used to set a different ground level or an extra rotation.
  45006. *
  45007. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  45008. * to the position set after this observable is done executing.
  45009. */
  45010. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  45011. /**
  45012. * Fires when the state of the experience helper has changed
  45013. */
  45014. onStateChangedObservable: Observable<WebXRState>;
  45015. /** Session manager used to keep track of xr session */
  45016. sessionManager: WebXRSessionManager;
  45017. /**
  45018. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  45019. */
  45020. state: WebXRState;
  45021. /**
  45022. * Creates a WebXRExperienceHelper
  45023. * @param scene The scene the helper should be created in
  45024. */
  45025. private constructor();
  45026. /**
  45027. * Creates the experience helper
  45028. * @param scene the scene to attach the experience helper to
  45029. * @returns a promise for the experience helper
  45030. */
  45031. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  45032. /**
  45033. * Disposes of the experience helper
  45034. */
  45035. dispose(): void;
  45036. /**
  45037. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  45038. * @param sessionMode options for the XR session
  45039. * @param referenceSpaceType frame of reference of the XR session
  45040. * @param renderTarget the output canvas that will be used to enter XR mode
  45041. * @returns promise that resolves after xr mode has entered
  45042. */
  45043. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget): Promise<WebXRSessionManager>;
  45044. /**
  45045. * Exits XR mode and returns the scene to its original state
  45046. * @returns promise that resolves after xr mode has exited
  45047. */
  45048. exitXRAsync(): Promise<void>;
  45049. private _nonXRToXRCamera;
  45050. private _setState;
  45051. }
  45052. }
  45053. declare module "babylonjs/XR/motionController/webXRControllerComponent" {
  45054. import { IMinimalMotionControllerObject, MotionControllerComponentType } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  45055. import { Observable } from "babylonjs/Misc/observable";
  45056. import { IDisposable } from "babylonjs/scene";
  45057. /**
  45058. * X-Y values for axes in WebXR
  45059. */
  45060. export interface IWebXRMotionControllerAxesValue {
  45061. /**
  45062. * The value of the x axis
  45063. */
  45064. x: number;
  45065. /**
  45066. * The value of the y-axis
  45067. */
  45068. y: number;
  45069. }
  45070. /**
  45071. * changed / previous values for the values of this component
  45072. */
  45073. export interface IWebXRMotionControllerComponentChangesValues<T> {
  45074. /**
  45075. * current (this frame) value
  45076. */
  45077. current: T;
  45078. /**
  45079. * previous (last change) value
  45080. */
  45081. previous: T;
  45082. }
  45083. /**
  45084. * Represents changes in the component between current frame and last values recorded
  45085. */
  45086. export interface IWebXRMotionControllerComponentChanges {
  45087. /**
  45088. * will be populated with previous and current values if axes changed
  45089. */
  45090. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  45091. /**
  45092. * will be populated with previous and current values if pressed changed
  45093. */
  45094. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  45095. /**
  45096. * will be populated with previous and current values if touched changed
  45097. */
  45098. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  45099. /**
  45100. * will be populated with previous and current values if value changed
  45101. */
  45102. value?: IWebXRMotionControllerComponentChangesValues<number>;
  45103. }
  45104. /**
  45105. * This class represents a single component (for example button or thumbstick) of a motion controller
  45106. */
  45107. export class WebXRControllerComponent implements IDisposable {
  45108. /**
  45109. * the id of this component
  45110. */
  45111. id: string;
  45112. /**
  45113. * the type of the component
  45114. */
  45115. type: MotionControllerComponentType;
  45116. private _buttonIndex;
  45117. private _axesIndices;
  45118. private _axes;
  45119. private _changes;
  45120. private _currentValue;
  45121. private _hasChanges;
  45122. private _pressed;
  45123. private _touched;
  45124. /**
  45125. * button component type
  45126. */
  45127. static BUTTON_TYPE: MotionControllerComponentType;
  45128. /**
  45129. * squeeze component type
  45130. */
  45131. static SQUEEZE_TYPE: MotionControllerComponentType;
  45132. /**
  45133. * Thumbstick component type
  45134. */
  45135. static THUMBSTICK_TYPE: MotionControllerComponentType;
  45136. /**
  45137. * Touchpad component type
  45138. */
  45139. static TOUCHPAD_TYPE: MotionControllerComponentType;
  45140. /**
  45141. * trigger component type
  45142. */
  45143. static TRIGGER_TYPE: MotionControllerComponentType;
  45144. /**
  45145. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  45146. * the axes data changes
  45147. */
  45148. onAxisValueChangedObservable: Observable<{
  45149. x: number;
  45150. y: number;
  45151. }>;
  45152. /**
  45153. * Observers registered here will be triggered when the state of a button changes
  45154. * State change is either pressed / touched / value
  45155. */
  45156. onButtonStateChangedObservable: Observable<WebXRControllerComponent>;
  45157. /**
  45158. * Creates a new component for a motion controller.
  45159. * It is created by the motion controller itself
  45160. *
  45161. * @param id the id of this component
  45162. * @param type the type of the component
  45163. * @param _buttonIndex index in the buttons array of the gamepad
  45164. * @param _axesIndices indices of the values in the axes array of the gamepad
  45165. */
  45166. constructor(
  45167. /**
  45168. * the id of this component
  45169. */
  45170. id: string,
  45171. /**
  45172. * the type of the component
  45173. */
  45174. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  45175. /**
  45176. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  45177. */
  45178. get axes(): IWebXRMotionControllerAxesValue;
  45179. /**
  45180. * Get the changes. Elements will be populated only if they changed with their previous and current value
  45181. */
  45182. get changes(): IWebXRMotionControllerComponentChanges;
  45183. /**
  45184. * Return whether or not the component changed the last frame
  45185. */
  45186. get hasChanges(): boolean;
  45187. /**
  45188. * is the button currently pressed
  45189. */
  45190. get pressed(): boolean;
  45191. /**
  45192. * is the button currently touched
  45193. */
  45194. get touched(): boolean;
  45195. /**
  45196. * Get the current value of this component
  45197. */
  45198. get value(): number;
  45199. /**
  45200. * Dispose this component
  45201. */
  45202. dispose(): void;
  45203. /**
  45204. * Are there axes correlating to this component
  45205. * @return true is axes data is available
  45206. */
  45207. isAxes(): boolean;
  45208. /**
  45209. * Is this component a button (hence - pressable)
  45210. * @returns true if can be pressed
  45211. */
  45212. isButton(): boolean;
  45213. /**
  45214. * update this component using the gamepad object it is in. Called on every frame
  45215. * @param nativeController the native gamepad controller object
  45216. */
  45217. update(nativeController: IMinimalMotionControllerObject): void;
  45218. }
  45219. }
  45220. declare module "babylonjs/Loading/sceneLoader" {
  45221. import { Observable } from "babylonjs/Misc/observable";
  45222. import { Nullable } from "babylonjs/types";
  45223. import { Scene } from "babylonjs/scene";
  45224. import { Engine } from "babylonjs/Engines/engine";
  45225. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45226. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  45227. import { AssetContainer } from "babylonjs/assetContainer";
  45228. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  45229. import { Skeleton } from "babylonjs/Bones/skeleton";
  45230. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  45231. import { WebRequest } from "babylonjs/Misc/webRequest";
  45232. /**
  45233. * Class used to represent data loading progression
  45234. */
  45235. export class SceneLoaderProgressEvent {
  45236. /** defines if data length to load can be evaluated */
  45237. readonly lengthComputable: boolean;
  45238. /** defines the loaded data length */
  45239. readonly loaded: number;
  45240. /** defines the data length to load */
  45241. readonly total: number;
  45242. /**
  45243. * Create a new progress event
  45244. * @param lengthComputable defines if data length to load can be evaluated
  45245. * @param loaded defines the loaded data length
  45246. * @param total defines the data length to load
  45247. */
  45248. constructor(
  45249. /** defines if data length to load can be evaluated */
  45250. lengthComputable: boolean,
  45251. /** defines the loaded data length */
  45252. loaded: number,
  45253. /** defines the data length to load */
  45254. total: number);
  45255. /**
  45256. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  45257. * @param event defines the source event
  45258. * @returns a new SceneLoaderProgressEvent
  45259. */
  45260. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  45261. }
  45262. /**
  45263. * Interface used by SceneLoader plugins to define supported file extensions
  45264. */
  45265. export interface ISceneLoaderPluginExtensions {
  45266. /**
  45267. * Defines the list of supported extensions
  45268. */
  45269. [extension: string]: {
  45270. isBinary: boolean;
  45271. };
  45272. }
  45273. /**
  45274. * Interface used by SceneLoader plugin factory
  45275. */
  45276. export interface ISceneLoaderPluginFactory {
  45277. /**
  45278. * Defines the name of the factory
  45279. */
  45280. name: string;
  45281. /**
  45282. * Function called to create a new plugin
  45283. * @return the new plugin
  45284. */
  45285. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  45286. /**
  45287. * The callback that returns true if the data can be directly loaded.
  45288. * @param data string containing the file data
  45289. * @returns if the data can be loaded directly
  45290. */
  45291. canDirectLoad?(data: string): boolean;
  45292. }
  45293. /**
  45294. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  45295. */
  45296. export interface ISceneLoaderPluginBase {
  45297. /**
  45298. * The friendly name of this plugin.
  45299. */
  45300. name: string;
  45301. /**
  45302. * The file extensions supported by this plugin.
  45303. */
  45304. extensions: string | ISceneLoaderPluginExtensions;
  45305. /**
  45306. * The callback called when loading from a url.
  45307. * @param scene scene loading this url
  45308. * @param url url to load
  45309. * @param onSuccess callback called when the file successfully loads
  45310. * @param onProgress callback called while file is loading (if the server supports this mode)
  45311. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  45312. * @param onError callback called when the file fails to load
  45313. * @returns a file request object
  45314. */
  45315. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  45316. /**
  45317. * The callback called when loading from a file object.
  45318. * @param scene scene loading this file
  45319. * @param file defines the file to load
  45320. * @param onSuccess defines the callback to call when data is loaded
  45321. * @param onProgress defines the callback to call during loading process
  45322. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  45323. * @param onError defines the callback to call when an error occurs
  45324. * @returns a file request object
  45325. */
  45326. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  45327. /**
  45328. * The callback that returns true if the data can be directly loaded.
  45329. * @param data string containing the file data
  45330. * @returns if the data can be loaded directly
  45331. */
  45332. canDirectLoad?(data: string): boolean;
  45333. /**
  45334. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  45335. * @param scene scene loading this data
  45336. * @param data string containing the data
  45337. * @returns data to pass to the plugin
  45338. */
  45339. directLoad?(scene: Scene, data: string): any;
  45340. /**
  45341. * The callback that allows custom handling of the root url based on the response url.
  45342. * @param rootUrl the original root url
  45343. * @param responseURL the response url if available
  45344. * @returns the new root url
  45345. */
  45346. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  45347. }
  45348. /**
  45349. * Interface used to define a SceneLoader plugin
  45350. */
  45351. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  45352. /**
  45353. * Import meshes into a scene.
  45354. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  45355. * @param scene The scene to import into
  45356. * @param data The data to import
  45357. * @param rootUrl The root url for scene and resources
  45358. * @param meshes The meshes array to import into
  45359. * @param particleSystems The particle systems array to import into
  45360. * @param skeletons The skeletons array to import into
  45361. * @param onError The callback when import fails
  45362. * @returns True if successful or false otherwise
  45363. */
  45364. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  45365. /**
  45366. * Load into a scene.
  45367. * @param scene The scene to load into
  45368. * @param data The data to import
  45369. * @param rootUrl The root url for scene and resources
  45370. * @param onError The callback when import fails
  45371. * @returns True if successful or false otherwise
  45372. */
  45373. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  45374. /**
  45375. * Load into an asset container.
  45376. * @param scene The scene to load into
  45377. * @param data The data to import
  45378. * @param rootUrl The root url for scene and resources
  45379. * @param onError The callback when import fails
  45380. * @returns The loaded asset container
  45381. */
  45382. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  45383. }
  45384. /**
  45385. * Interface used to define an async SceneLoader plugin
  45386. */
  45387. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  45388. /**
  45389. * Import meshes into a scene.
  45390. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  45391. * @param scene The scene to import into
  45392. * @param data The data to import
  45393. * @param rootUrl The root url for scene and resources
  45394. * @param onProgress The callback when the load progresses
  45395. * @param fileName Defines the name of the file to load
  45396. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  45397. */
  45398. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  45399. meshes: AbstractMesh[];
  45400. particleSystems: IParticleSystem[];
  45401. skeletons: Skeleton[];
  45402. animationGroups: AnimationGroup[];
  45403. }>;
  45404. /**
  45405. * Load into a scene.
  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 onProgress The callback when the load progresses
  45410. * @param fileName Defines the name of the file to load
  45411. * @returns Nothing
  45412. */
  45413. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  45414. /**
  45415. * Load into an asset container.
  45416. * @param scene The scene to load into
  45417. * @param data The data to import
  45418. * @param rootUrl The root url for scene and resources
  45419. * @param onProgress The callback when the load progresses
  45420. * @param fileName Defines the name of the file to load
  45421. * @returns The loaded asset container
  45422. */
  45423. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  45424. }
  45425. /**
  45426. * Mode that determines how to handle old animation groups before loading new ones.
  45427. */
  45428. export enum SceneLoaderAnimationGroupLoadingMode {
  45429. /**
  45430. * Reset all old animations to initial state then dispose them.
  45431. */
  45432. Clean = 0,
  45433. /**
  45434. * Stop all old animations.
  45435. */
  45436. Stop = 1,
  45437. /**
  45438. * Restart old animations from first frame.
  45439. */
  45440. Sync = 2,
  45441. /**
  45442. * Old animations remains untouched.
  45443. */
  45444. NoSync = 3
  45445. }
  45446. /**
  45447. * Class used to load scene from various file formats using registered plugins
  45448. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  45449. */
  45450. export class SceneLoader {
  45451. /**
  45452. * No logging while loading
  45453. */
  45454. static readonly NO_LOGGING: number;
  45455. /**
  45456. * Minimal logging while loading
  45457. */
  45458. static readonly MINIMAL_LOGGING: number;
  45459. /**
  45460. * Summary logging while loading
  45461. */
  45462. static readonly SUMMARY_LOGGING: number;
  45463. /**
  45464. * Detailled logging while loading
  45465. */
  45466. static readonly DETAILED_LOGGING: number;
  45467. /**
  45468. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  45469. */
  45470. static get ForceFullSceneLoadingForIncremental(): boolean;
  45471. static set ForceFullSceneLoadingForIncremental(value: boolean);
  45472. /**
  45473. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  45474. */
  45475. static get ShowLoadingScreen(): boolean;
  45476. static set ShowLoadingScreen(value: boolean);
  45477. /**
  45478. * Defines the current logging level (while loading the scene)
  45479. * @ignorenaming
  45480. */
  45481. static get loggingLevel(): number;
  45482. static set loggingLevel(value: number);
  45483. /**
  45484. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  45485. */
  45486. static get CleanBoneMatrixWeights(): boolean;
  45487. static set CleanBoneMatrixWeights(value: boolean);
  45488. /**
  45489. * Event raised when a plugin is used to load a scene
  45490. */
  45491. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  45492. private static _registeredPlugins;
  45493. private static _getDefaultPlugin;
  45494. private static _getPluginForExtension;
  45495. private static _getPluginForDirectLoad;
  45496. private static _getPluginForFilename;
  45497. private static _getDirectLoad;
  45498. private static _loadData;
  45499. private static _getFileInfo;
  45500. /**
  45501. * Gets a plugin that can load the given extension
  45502. * @param extension defines the extension to load
  45503. * @returns a plugin or null if none works
  45504. */
  45505. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  45506. /**
  45507. * Gets a boolean indicating that the given extension can be loaded
  45508. * @param extension defines the extension to load
  45509. * @returns true if the extension is supported
  45510. */
  45511. static IsPluginForExtensionAvailable(extension: string): boolean;
  45512. /**
  45513. * Adds a new plugin to the list of registered plugins
  45514. * @param plugin defines the plugin to add
  45515. */
  45516. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  45517. /**
  45518. * Import meshes into a scene
  45519. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  45520. * @param rootUrl a string that defines the root url for the scene and resources or the concatenation of rootURL and filename (e.g. http://example.com/test.glb)
  45521. * @param sceneFilename a string that defines the name of the scene file or starts with "data:" following by the stringified version of the scene or a File object (default: empty string)
  45522. * @param scene the instance of BABYLON.Scene to append to
  45523. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  45524. * @param onProgress a callback with a progress event for each file being loaded
  45525. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  45526. * @param pluginExtension the extension used to determine the plugin
  45527. * @returns The loaded plugin
  45528. */
  45529. static 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>;
  45530. /**
  45531. * Import meshes into a scene
  45532. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  45533. * @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)
  45534. * @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)
  45535. * @param scene the instance of BABYLON.Scene to append to
  45536. * @param onProgress a callback with a progress event for each file being loaded
  45537. * @param pluginExtension the extension used to determine the plugin
  45538. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  45539. */
  45540. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  45541. meshes: AbstractMesh[];
  45542. particleSystems: IParticleSystem[];
  45543. skeletons: Skeleton[];
  45544. animationGroups: AnimationGroup[];
  45545. }>;
  45546. /**
  45547. * Load a scene
  45548. * @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)
  45549. * @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)
  45550. * @param engine is the instance of BABYLON.Engine to use to create the scene
  45551. * @param onSuccess a callback with the scene when import succeeds
  45552. * @param onProgress a callback with a progress event for each file being loaded
  45553. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  45554. * @param pluginExtension the extension used to determine the plugin
  45555. * @returns The loaded plugin
  45556. */
  45557. 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>;
  45558. /**
  45559. * Load a scene
  45560. * @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)
  45561. * @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)
  45562. * @param engine is the instance of BABYLON.Engine to use to create the scene
  45563. * @param onProgress a callback with a progress event for each file being loaded
  45564. * @param pluginExtension the extension used to determine the plugin
  45565. * @returns The loaded scene
  45566. */
  45567. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  45568. /**
  45569. * Append a scene
  45570. * @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)
  45571. * @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)
  45572. * @param scene is the instance of BABYLON.Scene to append to
  45573. * @param onSuccess a callback with the scene when import succeeds
  45574. * @param onProgress a callback with a progress event for each file being loaded
  45575. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  45576. * @param pluginExtension the extension used to determine the plugin
  45577. * @returns The loaded plugin
  45578. */
  45579. 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>;
  45580. /**
  45581. * Append a scene
  45582. * @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)
  45583. * @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)
  45584. * @param scene is the instance of BABYLON.Scene to append to
  45585. * @param onProgress a callback with a progress event for each file being loaded
  45586. * @param pluginExtension the extension used to determine the plugin
  45587. * @returns The given scene
  45588. */
  45589. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  45590. /**
  45591. * Load a scene into an asset container
  45592. * @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)
  45593. * @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)
  45594. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  45595. * @param onSuccess a callback with the scene when import succeeds
  45596. * @param onProgress a callback with a progress event for each file being loaded
  45597. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  45598. * @param pluginExtension the extension used to determine the plugin
  45599. * @returns The loaded plugin
  45600. */
  45601. 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>;
  45602. /**
  45603. * Load a scene into an asset container
  45604. * @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)
  45605. * @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)
  45606. * @param scene is the instance of Scene to append to
  45607. * @param onProgress a callback with a progress event for each file being loaded
  45608. * @param pluginExtension the extension used to determine the plugin
  45609. * @returns The loaded asset container
  45610. */
  45611. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  45612. /**
  45613. * Import animations from a file into a scene
  45614. * @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)
  45615. * @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)
  45616. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  45617. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  45618. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  45619. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  45620. * @param onSuccess a callback with the scene when import succeeds
  45621. * @param onProgress a callback with a progress event for each file being loaded
  45622. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  45623. */
  45624. 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;
  45625. /**
  45626. * Import animations from a file into a scene
  45627. * @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)
  45628. * @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)
  45629. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  45630. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  45631. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  45632. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  45633. * @param onSuccess a callback with the scene when import succeeds
  45634. * @param onProgress a callback with a progress event for each file being loaded
  45635. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  45636. * @returns the updated scene with imported animations
  45637. */
  45638. 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>;
  45639. }
  45640. }
  45641. declare module "babylonjs/XR/motionController/webXRAbstractMotionController" {
  45642. import { IDisposable, Scene } from "babylonjs/scene";
  45643. import { WebXRControllerComponent } from "babylonjs/XR/motionController/webXRControllerComponent";
  45644. import { Observable } from "babylonjs/Misc/observable";
  45645. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45646. import { Nullable } from "babylonjs/types";
  45647. /**
  45648. * Handedness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  45649. */
  45650. export type MotionControllerHandedness = "none" | "left" | "right";
  45651. /**
  45652. * The type of components available in motion controllers.
  45653. * This is not the name of the component.
  45654. */
  45655. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  45656. /**
  45657. * The state of a controller component
  45658. */
  45659. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  45660. /**
  45661. * The schema of motion controller layout.
  45662. * No object will be initialized using this interface
  45663. * This is used just to define the profile.
  45664. */
  45665. export interface IMotionControllerLayout {
  45666. /**
  45667. * Path to load the assets. Usually relative to the base path
  45668. */
  45669. assetPath: string;
  45670. /**
  45671. * Available components (unsorted)
  45672. */
  45673. components: {
  45674. /**
  45675. * A map of component Ids
  45676. */
  45677. [componentId: string]: {
  45678. /**
  45679. * The type of input the component outputs
  45680. */
  45681. type: MotionControllerComponentType;
  45682. /**
  45683. * The indices of this component in the gamepad object
  45684. */
  45685. gamepadIndices: {
  45686. /**
  45687. * Index of button
  45688. */
  45689. button?: number;
  45690. /**
  45691. * If available, index of x-axis
  45692. */
  45693. xAxis?: number;
  45694. /**
  45695. * If available, index of y-axis
  45696. */
  45697. yAxis?: number;
  45698. };
  45699. /**
  45700. * The mesh's root node name
  45701. */
  45702. rootNodeName: string;
  45703. /**
  45704. * Animation definitions for this model
  45705. */
  45706. visualResponses: {
  45707. [stateKey: string]: {
  45708. /**
  45709. * What property will be animated
  45710. */
  45711. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  45712. /**
  45713. * What states influence this visual response
  45714. */
  45715. states: MotionControllerComponentStateType[];
  45716. /**
  45717. * Type of animation - movement or visibility
  45718. */
  45719. valueNodeProperty: "transform" | "visibility";
  45720. /**
  45721. * Base node name to move. Its position will be calculated according to the min and max nodes
  45722. */
  45723. valueNodeName?: string;
  45724. /**
  45725. * Minimum movement node
  45726. */
  45727. minNodeName?: string;
  45728. /**
  45729. * Max movement node
  45730. */
  45731. maxNodeName?: string;
  45732. };
  45733. };
  45734. /**
  45735. * If touch enabled, what is the name of node to display user feedback
  45736. */
  45737. touchPointNodeName?: string;
  45738. };
  45739. };
  45740. /**
  45741. * Is it xr standard mapping or not
  45742. */
  45743. gamepadMapping: "" | "xr-standard";
  45744. /**
  45745. * Base root node of this entire model
  45746. */
  45747. rootNodeName: string;
  45748. /**
  45749. * Defines the main button component id
  45750. */
  45751. selectComponentId: string;
  45752. }
  45753. /**
  45754. * A definition for the layout map in the input profile
  45755. */
  45756. export interface IMotionControllerLayoutMap {
  45757. /**
  45758. * Layouts with handedness type as a key
  45759. */
  45760. [handedness: string]: IMotionControllerLayout;
  45761. }
  45762. /**
  45763. * The XR Input profile schema
  45764. * Profiles can be found here:
  45765. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  45766. */
  45767. export interface IMotionControllerProfile {
  45768. /**
  45769. * fallback profiles for this profileId
  45770. */
  45771. fallbackProfileIds: string[];
  45772. /**
  45773. * The layout map, with handedness as key
  45774. */
  45775. layouts: IMotionControllerLayoutMap;
  45776. /**
  45777. * The id of this profile
  45778. * correlates to the profile(s) in the xrInput.profiles array
  45779. */
  45780. profileId: string;
  45781. }
  45782. /**
  45783. * A helper-interface for the 3 meshes needed for controller button animation
  45784. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  45785. */
  45786. export interface IMotionControllerButtonMeshMap {
  45787. /**
  45788. * the mesh that defines the pressed value mesh position.
  45789. * This is used to find the max-position of this button
  45790. */
  45791. pressedMesh: AbstractMesh;
  45792. /**
  45793. * the mesh that defines the unpressed value mesh position.
  45794. * This is used to find the min (or initial) position of this button
  45795. */
  45796. unpressedMesh: AbstractMesh;
  45797. /**
  45798. * The mesh that will be changed when value changes
  45799. */
  45800. valueMesh: AbstractMesh;
  45801. }
  45802. /**
  45803. * A helper-interface for the 3 meshes needed for controller axis animation.
  45804. * This will be expanded when touchpad animations are fully supported
  45805. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  45806. */
  45807. export interface IMotionControllerMeshMap {
  45808. /**
  45809. * the mesh that defines the maximum value mesh position.
  45810. */
  45811. maxMesh?: AbstractMesh;
  45812. /**
  45813. * the mesh that defines the minimum value mesh position.
  45814. */
  45815. minMesh?: AbstractMesh;
  45816. /**
  45817. * The mesh that will be changed when axis value changes
  45818. */
  45819. valueMesh: AbstractMesh;
  45820. }
  45821. /**
  45822. * The elements needed for change-detection of the gamepad objects in motion controllers
  45823. */
  45824. export interface IMinimalMotionControllerObject {
  45825. /**
  45826. * Available axes of this controller
  45827. */
  45828. axes: number[];
  45829. /**
  45830. * An array of available buttons
  45831. */
  45832. buttons: Array<{
  45833. /**
  45834. * Value of the button/trigger
  45835. */
  45836. value: number;
  45837. /**
  45838. * If the button/trigger is currently touched
  45839. */
  45840. touched: boolean;
  45841. /**
  45842. * If the button/trigger is currently pressed
  45843. */
  45844. pressed: boolean;
  45845. }>;
  45846. }
  45847. /**
  45848. * An Abstract Motion controller
  45849. * This class receives an xrInput and a profile layout and uses those to initialize the components
  45850. * Each component has an observable to check for changes in value and state
  45851. */
  45852. export abstract class WebXRAbstractMotionController implements IDisposable {
  45853. protected scene: Scene;
  45854. protected layout: IMotionControllerLayout;
  45855. /**
  45856. * The gamepad object correlating to this controller
  45857. */
  45858. gamepadObject: IMinimalMotionControllerObject;
  45859. /**
  45860. * handedness (left/right/none) of this controller
  45861. */
  45862. handedness: MotionControllerHandedness;
  45863. private _initComponent;
  45864. private _modelReady;
  45865. /**
  45866. * A map of components (WebXRControllerComponent) in this motion controller
  45867. * Components have a ComponentType and can also have both button and axis definitions
  45868. */
  45869. readonly components: {
  45870. [id: string]: WebXRControllerComponent;
  45871. };
  45872. /**
  45873. * Disable the model's animation. Can be set at any time.
  45874. */
  45875. disableAnimation: boolean;
  45876. /**
  45877. * Observers registered here will be triggered when the model of this controller is done loading
  45878. */
  45879. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  45880. /**
  45881. * The profile id of this motion controller
  45882. */
  45883. abstract profileId: string;
  45884. /**
  45885. * The root mesh of the model. It is null if the model was not yet initialized
  45886. */
  45887. rootMesh: Nullable<AbstractMesh>;
  45888. /**
  45889. * constructs a new abstract motion controller
  45890. * @param scene the scene to which the model of the controller will be added
  45891. * @param layout The profile layout to load
  45892. * @param gamepadObject The gamepad object correlating to this controller
  45893. * @param handedness handedness (left/right/none) of this controller
  45894. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  45895. */
  45896. constructor(scene: Scene, layout: IMotionControllerLayout,
  45897. /**
  45898. * The gamepad object correlating to this controller
  45899. */
  45900. gamepadObject: IMinimalMotionControllerObject,
  45901. /**
  45902. * handedness (left/right/none) of this controller
  45903. */
  45904. handedness: MotionControllerHandedness, _doNotLoadControllerMesh?: boolean);
  45905. /**
  45906. * Dispose this controller, the model mesh and all its components
  45907. */
  45908. dispose(): void;
  45909. /**
  45910. * Returns all components of specific type
  45911. * @param type the type to search for
  45912. * @return an array of components with this type
  45913. */
  45914. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  45915. /**
  45916. * get a component based an its component id as defined in layout.components
  45917. * @param id the id of the component
  45918. * @returns the component correlates to the id or undefined if not found
  45919. */
  45920. getComponent(id: string): WebXRControllerComponent;
  45921. /**
  45922. * Get the list of components available in this motion controller
  45923. * @returns an array of strings correlating to available components
  45924. */
  45925. getComponentIds(): string[];
  45926. /**
  45927. * Get the first component of specific type
  45928. * @param type type of component to find
  45929. * @return a controller component or null if not found
  45930. */
  45931. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  45932. /**
  45933. * Get the main (Select) component of this controller as defined in the layout
  45934. * @returns the main component of this controller
  45935. */
  45936. getMainComponent(): WebXRControllerComponent;
  45937. /**
  45938. * Loads the model correlating to this controller
  45939. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  45940. * @returns A promise fulfilled with the result of the model loading
  45941. */
  45942. loadModel(): Promise<boolean>;
  45943. /**
  45944. * Update this model using the current XRFrame
  45945. * @param xrFrame the current xr frame to use and update the model
  45946. */
  45947. updateFromXRFrame(xrFrame: XRFrame): void;
  45948. /**
  45949. * Backwards compatibility due to a deeply-integrated typo
  45950. */
  45951. get handness(): XREye;
  45952. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh;
  45953. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh;
  45954. /**
  45955. * Moves the axis on the controller mesh based on its current state
  45956. * @param axis the index of the axis
  45957. * @param axisValue the value of the axis which determines the meshes new position
  45958. * @hidden
  45959. */
  45960. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  45961. /**
  45962. * Update the model itself with the current frame data
  45963. * @param xrFrame the frame to use for updating the model mesh
  45964. */
  45965. protected updateModel(xrFrame: XRFrame): void;
  45966. /**
  45967. * Get the filename and path for this controller's model
  45968. * @returns a map of filename and path
  45969. */
  45970. protected abstract _getFilenameAndPath(): {
  45971. filename: string;
  45972. path: string;
  45973. };
  45974. /**
  45975. * This function is called before the mesh is loaded. It checks for loading constraints.
  45976. * For example, this function can check if the GLB loader is available
  45977. * If this function returns false, the generic controller will be loaded instead
  45978. * @returns Is the client ready to load the mesh
  45979. */
  45980. protected abstract _getModelLoadingConstraints(): boolean;
  45981. /**
  45982. * This function will be called after the model was successfully loaded and can be used
  45983. * for mesh transformations before it is available for the user
  45984. * @param meshes the loaded meshes
  45985. */
  45986. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  45987. /**
  45988. * Set the root mesh for this controller. Important for the WebXR controller class
  45989. * @param meshes the loaded meshes
  45990. */
  45991. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  45992. /**
  45993. * A function executed each frame that updates the mesh (if needed)
  45994. * @param xrFrame the current xrFrame
  45995. */
  45996. protected abstract _updateModel(xrFrame: XRFrame): void;
  45997. private _getGenericFilenameAndPath;
  45998. private _getGenericParentMesh;
  45999. }
  46000. }
  46001. declare module "babylonjs/XR/motionController/webXRGenericMotionController" {
  46002. import { WebXRAbstractMotionController, IMinimalMotionControllerObject, MotionControllerHandedness } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  46003. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46004. import { Scene } from "babylonjs/scene";
  46005. /**
  46006. * A generic trigger-only motion controller for WebXR
  46007. */
  46008. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  46009. /**
  46010. * Static version of the profile id of this controller
  46011. */
  46012. static ProfileId: string;
  46013. profileId: string;
  46014. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  46015. protected _getFilenameAndPath(): {
  46016. filename: string;
  46017. path: string;
  46018. };
  46019. protected _getModelLoadingConstraints(): boolean;
  46020. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  46021. protected _setRootMesh(meshes: AbstractMesh[]): void;
  46022. protected _updateModel(): void;
  46023. }
  46024. }
  46025. declare module "babylonjs/Meshes/Builders/sphereBuilder" {
  46026. import { Vector4 } from "babylonjs/Maths/math.vector";
  46027. import { Mesh } from "babylonjs/Meshes/mesh";
  46028. import { Scene } from "babylonjs/scene";
  46029. import { Nullable } from "babylonjs/types";
  46030. /**
  46031. * Class containing static functions to help procedurally build meshes
  46032. */
  46033. export class SphereBuilder {
  46034. /**
  46035. * Creates a sphere mesh
  46036. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  46037. * * 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`)
  46038. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  46039. * * 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
  46040. * * 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)
  46041. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  46042. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  46043. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46044. * @param name defines the name of the mesh
  46045. * @param options defines the options used to create the mesh
  46046. * @param scene defines the hosting scene
  46047. * @returns the sphere mesh
  46048. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  46049. */
  46050. static CreateSphere(name: string, options: {
  46051. segments?: number;
  46052. diameter?: number;
  46053. diameterX?: number;
  46054. diameterY?: number;
  46055. diameterZ?: number;
  46056. arc?: number;
  46057. slice?: number;
  46058. sideOrientation?: number;
  46059. frontUVs?: Vector4;
  46060. backUVs?: Vector4;
  46061. updatable?: boolean;
  46062. }, scene?: Nullable<Scene>): Mesh;
  46063. }
  46064. }
  46065. declare module "babylonjs/XR/motionController/webXRProfiledMotionController" {
  46066. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46067. import { WebXRAbstractMotionController, IMotionControllerProfile } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  46068. import { Scene } from "babylonjs/scene";
  46069. /**
  46070. * A profiled motion controller has its profile loaded from an online repository.
  46071. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  46072. */
  46073. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  46074. private _repositoryUrl;
  46075. private _buttonMeshMapping;
  46076. private _touchDots;
  46077. /**
  46078. * The profile ID of this controller. Will be populated when the controller initializes.
  46079. */
  46080. profileId: string;
  46081. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  46082. dispose(): void;
  46083. protected _getFilenameAndPath(): {
  46084. filename: string;
  46085. path: string;
  46086. };
  46087. protected _getModelLoadingConstraints(): boolean;
  46088. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  46089. protected _setRootMesh(meshes: AbstractMesh[]): void;
  46090. protected _updateModel(_xrFrame: XRFrame): void;
  46091. }
  46092. }
  46093. declare module "babylonjs/XR/motionController/webXRMotionControllerManager" {
  46094. import { WebXRAbstractMotionController } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  46095. import { Scene } from "babylonjs/scene";
  46096. /**
  46097. * A construction function type to create a new controller based on an xrInput object
  46098. */
  46099. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  46100. /**
  46101. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  46102. *
  46103. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  46104. * it should be replaced with auto-loaded controllers.
  46105. *
  46106. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  46107. */
  46108. export class WebXRMotionControllerManager {
  46109. private static _AvailableControllers;
  46110. private static _Fallbacks;
  46111. private static _ProfileLoadingPromises;
  46112. private static _ProfilesList;
  46113. /**
  46114. * The base URL of the online controller repository. Can be changed at any time.
  46115. */
  46116. static BaseRepositoryUrl: string;
  46117. /**
  46118. * Which repository gets priority - local or online
  46119. */
  46120. static PrioritizeOnlineRepository: boolean;
  46121. /**
  46122. * Use the online repository, or use only locally-defined controllers
  46123. */
  46124. static UseOnlineRepository: boolean;
  46125. /**
  46126. * Clear the cache used for profile loading and reload when requested again
  46127. */
  46128. static ClearProfilesCache(): void;
  46129. /**
  46130. * Register the default fallbacks.
  46131. * This function is called automatically when this file is imported.
  46132. */
  46133. static DefaultFallbacks(): void;
  46134. /**
  46135. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  46136. * @param profileId the profile to which a fallback needs to be found
  46137. * @return an array with corresponding fallback profiles
  46138. */
  46139. static FindFallbackWithProfileId(profileId: string): string[];
  46140. /**
  46141. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  46142. * The order of search:
  46143. *
  46144. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  46145. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  46146. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  46147. * 4) return the generic trigger controller if none were found
  46148. *
  46149. * @param xrInput the xrInput to which a new controller is initialized
  46150. * @param scene the scene to which the model will be added
  46151. * @param forceProfile force a certain profile for this controller
  46152. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  46153. */
  46154. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  46155. /**
  46156. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  46157. *
  46158. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  46159. *
  46160. * @param type the profile type to register
  46161. * @param constructFunction the function to be called when loading this profile
  46162. */
  46163. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  46164. /**
  46165. * Register a fallback to a specific profile.
  46166. * @param profileId the profileId that will receive the fallbacks
  46167. * @param fallbacks A list of fallback profiles
  46168. */
  46169. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  46170. /**
  46171. * Will update the list of profiles available in the repository
  46172. * @return a promise that resolves to a map of profiles available online
  46173. */
  46174. static UpdateProfilesList(): Promise<{
  46175. [profile: string]: string;
  46176. }>;
  46177. private static _LoadProfileFromRepository;
  46178. private static _LoadProfilesFromAvailableControllers;
  46179. }
  46180. }
  46181. declare module "babylonjs/XR/webXRInputSource" {
  46182. import { Observable } from "babylonjs/Misc/observable";
  46183. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46184. import { Ray } from "babylonjs/Culling/ray";
  46185. import { Scene } from "babylonjs/scene";
  46186. import { WebXRAbstractMotionController } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  46187. /**
  46188. * Configuration options for the WebXR controller creation
  46189. */
  46190. export interface IWebXRControllerOptions {
  46191. /**
  46192. * Should the controller mesh be animated when a user interacts with it
  46193. * The pressed buttons / thumbstick and touchpad animations will be disabled
  46194. */
  46195. disableMotionControllerAnimation?: boolean;
  46196. /**
  46197. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  46198. */
  46199. doNotLoadControllerMesh?: boolean;
  46200. /**
  46201. * Force a specific controller type for this controller.
  46202. * This can be used when creating your own profile or when testing different controllers
  46203. */
  46204. forceControllerProfile?: string;
  46205. }
  46206. /**
  46207. * Represents an XR controller
  46208. */
  46209. export class WebXRInputSource {
  46210. private _scene;
  46211. /** The underlying input source for the controller */
  46212. inputSource: XRInputSource;
  46213. private _options;
  46214. private _tmpQuaternion;
  46215. private _tmpVector;
  46216. private _uniqueId;
  46217. /**
  46218. * 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
  46219. */
  46220. grip?: AbstractMesh;
  46221. /**
  46222. * If available, this is the gamepad object related to this controller.
  46223. * Using this object it is possible to get click events and trackpad changes of the
  46224. * webxr controller that is currently being used.
  46225. */
  46226. motionController?: WebXRAbstractMotionController;
  46227. /**
  46228. * Event that fires when the controller is removed/disposed.
  46229. * The object provided as event data is this controller, after associated assets were disposed.
  46230. * uniqueId is still available.
  46231. */
  46232. onDisposeObservable: Observable<WebXRInputSource>;
  46233. /**
  46234. * Will be triggered when the mesh associated with the motion controller is done loading.
  46235. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  46236. * A shortened version of controller -> motion controller -> on mesh loaded.
  46237. */
  46238. onMeshLoadedObservable: Observable<AbstractMesh>;
  46239. /**
  46240. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  46241. */
  46242. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  46243. /**
  46244. * Pointer which can be used to select objects or attach a visible laser to
  46245. */
  46246. pointer: AbstractMesh;
  46247. /**
  46248. * Creates the controller
  46249. * @see https://doc.babylonjs.com/how_to/webxr
  46250. * @param _scene the scene which the controller should be associated to
  46251. * @param inputSource the underlying input source for the controller
  46252. * @param _options options for this controller creation
  46253. */
  46254. constructor(_scene: Scene,
  46255. /** The underlying input source for the controller */
  46256. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  46257. /**
  46258. * Get this controllers unique id
  46259. */
  46260. get uniqueId(): string;
  46261. /**
  46262. * Disposes of the object
  46263. */
  46264. dispose(): void;
  46265. /**
  46266. * Gets a world space ray coming from the pointer or grip
  46267. * @param result the resulting ray
  46268. * @param gripIfAvailable use the grip mesh instead of the pointer, if available
  46269. */
  46270. getWorldPointerRayToRef(result: Ray, gripIfAvailable?: boolean): void;
  46271. /**
  46272. * Updates the controller pose based on the given XRFrame
  46273. * @param xrFrame xr frame to update the pose with
  46274. * @param referenceSpace reference space to use
  46275. */
  46276. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  46277. }
  46278. }
  46279. declare module "babylonjs/XR/webXRInput" {
  46280. import { Observable } from "babylonjs/Misc/observable";
  46281. import { IDisposable } from "babylonjs/scene";
  46282. import { WebXRInputSource } from "babylonjs/XR/webXRInputSource";
  46283. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  46284. import { WebXRCamera } from "babylonjs/XR/webXRCamera";
  46285. /**
  46286. * The schema for initialization options of the XR Input class
  46287. */
  46288. export interface IWebXRInputOptions {
  46289. /**
  46290. * If set to true no model will be automatically loaded
  46291. */
  46292. doNotLoadControllerMeshes?: boolean;
  46293. /**
  46294. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  46295. * If not found, the xr input profile data will be used.
  46296. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  46297. */
  46298. forceInputProfile?: string;
  46299. /**
  46300. * Do not send a request to the controller repository to load the profile.
  46301. *
  46302. * Instead, use the controllers available in babylon itself.
  46303. */
  46304. disableOnlineControllerRepository?: boolean;
  46305. /**
  46306. * A custom URL for the controllers repository
  46307. */
  46308. customControllersRepositoryURL?: string;
  46309. /**
  46310. * Should the controller model's components not move according to the user input
  46311. */
  46312. disableControllerAnimation?: boolean;
  46313. }
  46314. /**
  46315. * XR input used to track XR inputs such as controllers/rays
  46316. */
  46317. export class WebXRInput implements IDisposable {
  46318. /**
  46319. * the xr session manager for this session
  46320. */
  46321. xrSessionManager: WebXRSessionManager;
  46322. /**
  46323. * the WebXR camera for this session. Mainly used for teleportation
  46324. */
  46325. xrCamera: WebXRCamera;
  46326. private readonly options;
  46327. /**
  46328. * XR controllers being tracked
  46329. */
  46330. controllers: Array<WebXRInputSource>;
  46331. private _frameObserver;
  46332. private _sessionEndedObserver;
  46333. private _sessionInitObserver;
  46334. /**
  46335. * Event when a controller has been connected/added
  46336. */
  46337. onControllerAddedObservable: Observable<WebXRInputSource>;
  46338. /**
  46339. * Event when a controller has been removed/disconnected
  46340. */
  46341. onControllerRemovedObservable: Observable<WebXRInputSource>;
  46342. /**
  46343. * Initializes the WebXRInput
  46344. * @param xrSessionManager the xr session manager for this session
  46345. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  46346. * @param options = initialization options for this xr input
  46347. */
  46348. constructor(
  46349. /**
  46350. * the xr session manager for this session
  46351. */
  46352. xrSessionManager: WebXRSessionManager,
  46353. /**
  46354. * the WebXR camera for this session. Mainly used for teleportation
  46355. */
  46356. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  46357. private _onInputSourcesChange;
  46358. private _addAndRemoveControllers;
  46359. /**
  46360. * Disposes of the object
  46361. */
  46362. dispose(): void;
  46363. }
  46364. }
  46365. declare module "babylonjs/XR/features/WebXRAbstractFeature" {
  46366. import { IWebXRFeature } from "babylonjs/XR/webXRFeaturesManager";
  46367. import { Observable, EventState } from "babylonjs/Misc/observable";
  46368. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  46369. /**
  46370. * This is the base class for all WebXR features.
  46371. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  46372. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  46373. */
  46374. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  46375. protected _xrSessionManager: WebXRSessionManager;
  46376. private _attached;
  46377. private _removeOnDetach;
  46378. /**
  46379. * Should auto-attach be disabled?
  46380. */
  46381. disableAutoAttach: boolean;
  46382. /**
  46383. * Construct a new (abstract) WebXR feature
  46384. * @param _xrSessionManager the xr session manager for this feature
  46385. */
  46386. constructor(_xrSessionManager: WebXRSessionManager);
  46387. /**
  46388. * Is this feature attached
  46389. */
  46390. get attached(): boolean;
  46391. /**
  46392. * attach this feature
  46393. *
  46394. * @param force should attachment be forced (even when already attached)
  46395. * @returns true if successful, false is failed or already attached
  46396. */
  46397. attach(force?: boolean): boolean;
  46398. /**
  46399. * detach this feature.
  46400. *
  46401. * @returns true if successful, false if failed or already detached
  46402. */
  46403. detach(): boolean;
  46404. /**
  46405. * Dispose this feature and all of the resources attached
  46406. */
  46407. dispose(): void;
  46408. /**
  46409. * This is used to register callbacks that will automatically be removed when detach is called.
  46410. * @param observable the observable to which the observer will be attached
  46411. * @param callback the callback to register
  46412. */
  46413. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  46414. /**
  46415. * Code in this function will be executed on each xrFrame received from the browser.
  46416. * This function will not execute after the feature is detached.
  46417. * @param _xrFrame the current frame
  46418. */
  46419. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  46420. }
  46421. }
  46422. declare module "babylonjs/Rendering/utilityLayerRenderer" {
  46423. import { IDisposable, Scene } from "babylonjs/scene";
  46424. import { Nullable } from "babylonjs/types";
  46425. import { Observable } from "babylonjs/Misc/observable";
  46426. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46427. import { HemisphericLight } from "babylonjs/Lights/hemisphericLight";
  46428. import { Camera } from "babylonjs/Cameras/camera";
  46429. /**
  46430. * Renders a layer on top of an existing scene
  46431. */
  46432. export class UtilityLayerRenderer implements IDisposable {
  46433. /** the original scene that will be rendered on top of */
  46434. originalScene: Scene;
  46435. private _pointerCaptures;
  46436. private _lastPointerEvents;
  46437. private static _DefaultUtilityLayer;
  46438. private static _DefaultKeepDepthUtilityLayer;
  46439. private _sharedGizmoLight;
  46440. private _renderCamera;
  46441. /**
  46442. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  46443. * @param getRigParentIfPossible if the current active camera is a rig camera, should its parent camera be returned
  46444. * @returns the camera that is used when rendering the utility layer
  46445. */
  46446. getRenderCamera(getRigParentIfPossible?: boolean): Camera;
  46447. /**
  46448. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  46449. * @param cam the camera that should be used when rendering the utility layer
  46450. */
  46451. setRenderCamera(cam: Nullable<Camera>): void;
  46452. /**
  46453. * @hidden
  46454. * Light which used by gizmos to get light shading
  46455. */
  46456. _getSharedGizmoLight(): HemisphericLight;
  46457. /**
  46458. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  46459. */
  46460. pickUtilitySceneFirst: boolean;
  46461. /**
  46462. * 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)
  46463. */
  46464. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  46465. /**
  46466. * 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)
  46467. */
  46468. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  46469. /**
  46470. * The scene that is rendered on top of the original scene
  46471. */
  46472. utilityLayerScene: Scene;
  46473. /**
  46474. * If the utility layer should automatically be rendered on top of existing scene
  46475. */
  46476. shouldRender: boolean;
  46477. /**
  46478. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  46479. */
  46480. onlyCheckPointerDownEvents: boolean;
  46481. /**
  46482. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  46483. */
  46484. processAllEvents: boolean;
  46485. /**
  46486. * Observable raised when the pointer move from the utility layer scene to the main scene
  46487. */
  46488. onPointerOutObservable: Observable<number>;
  46489. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  46490. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  46491. private _afterRenderObserver;
  46492. private _sceneDisposeObserver;
  46493. private _originalPointerObserver;
  46494. /**
  46495. * Instantiates a UtilityLayerRenderer
  46496. * @param originalScene the original scene that will be rendered on top of
  46497. * @param handleEvents boolean indicating if the utility layer should handle events
  46498. */
  46499. constructor(
  46500. /** the original scene that will be rendered on top of */
  46501. originalScene: Scene, handleEvents?: boolean);
  46502. private _notifyObservers;
  46503. /**
  46504. * Renders the utility layers scene on top of the original scene
  46505. */
  46506. render(): void;
  46507. /**
  46508. * Disposes of the renderer
  46509. */
  46510. dispose(): void;
  46511. private _updateCamera;
  46512. }
  46513. }
  46514. declare module "babylonjs/XR/features/WebXRControllerPointerSelection" {
  46515. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  46516. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46517. import { WebXRInput } from "babylonjs/XR/webXRInput";
  46518. import { WebXRInputSource } from "babylonjs/XR/webXRInputSource";
  46519. import { Scene } from "babylonjs/scene";
  46520. import { Nullable } from "babylonjs/types";
  46521. import { Color3 } from "babylonjs/Maths/math.color";
  46522. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  46523. /**
  46524. * Options interface for the pointer selection module
  46525. */
  46526. export interface IWebXRControllerPointerSelectionOptions {
  46527. /**
  46528. * if provided, this scene will be used to render meshes.
  46529. */
  46530. customUtilityLayerScene?: Scene;
  46531. /**
  46532. * 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)
  46533. * If not disabled, the last picked point will be used to execute a pointer up event
  46534. * If disabled, pointer up event will be triggered right after the pointer down event.
  46535. * Used in screen and gaze target ray mode only
  46536. */
  46537. disablePointerUpOnTouchOut: boolean;
  46538. /**
  46539. * For gaze mode (time to select instead of press)
  46540. */
  46541. forceGazeMode: boolean;
  46542. /**
  46543. * 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
  46544. * to start a new countdown to the pointer down event.
  46545. * Defaults to 1.
  46546. */
  46547. gazeModePointerMovedFactor?: number;
  46548. /**
  46549. * Different button type to use instead of the main component
  46550. */
  46551. overrideButtonId?: string;
  46552. /**
  46553. * use this rendering group id for the meshes (optional)
  46554. */
  46555. renderingGroupId?: number;
  46556. /**
  46557. * The amount of time in milliseconds it takes between pick found something to a pointer down event.
  46558. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  46559. * 3000 means 3 seconds between pointing at something and selecting it
  46560. */
  46561. timeToSelect?: number;
  46562. /**
  46563. * Should meshes created here be added to a utility layer or the main scene
  46564. */
  46565. useUtilityLayer?: boolean;
  46566. /**
  46567. * the xr input to use with this pointer selection
  46568. */
  46569. xrInput: WebXRInput;
  46570. }
  46571. /**
  46572. * A module that will enable pointer selection for motion controllers of XR Input Sources
  46573. */
  46574. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  46575. private readonly _options;
  46576. private static _idCounter;
  46577. private _attachController;
  46578. private _controllers;
  46579. private _scene;
  46580. private _tmpVectorForPickCompare;
  46581. /**
  46582. * The module's name
  46583. */
  46584. static readonly Name: string;
  46585. /**
  46586. * The (Babylon) version of this module.
  46587. * This is an integer representing the implementation version.
  46588. * This number does not correspond to the WebXR specs version
  46589. */
  46590. static readonly Version: number;
  46591. /**
  46592. * Disable lighting on the laser pointer (so it will always be visible)
  46593. */
  46594. disablePointerLighting: boolean;
  46595. /**
  46596. * Disable lighting on the selection mesh (so it will always be visible)
  46597. */
  46598. disableSelectionMeshLighting: boolean;
  46599. /**
  46600. * Should the laser pointer be displayed
  46601. */
  46602. displayLaserPointer: boolean;
  46603. /**
  46604. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  46605. */
  46606. displaySelectionMesh: boolean;
  46607. /**
  46608. * This color will be set to the laser pointer when selection is triggered
  46609. */
  46610. laserPointerPickedColor: Color3;
  46611. /**
  46612. * Default color of the laser pointer
  46613. */
  46614. lasterPointerDefaultColor: Color3;
  46615. /**
  46616. * default color of the selection ring
  46617. */
  46618. selectionMeshDefaultColor: Color3;
  46619. /**
  46620. * This color will be applied to the selection ring when selection is triggered
  46621. */
  46622. selectionMeshPickedColor: Color3;
  46623. /**
  46624. * Optional filter to be used for ray selection. This predicate shares behavior with
  46625. * scene.pointerMovePredicate which takes priority if it is also assigned.
  46626. */
  46627. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  46628. /**
  46629. * constructs a new background remover module
  46630. * @param _xrSessionManager the session manager for this module
  46631. * @param _options read-only options to be used in this module
  46632. */
  46633. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  46634. /**
  46635. * attach this feature
  46636. * Will usually be called by the features manager
  46637. *
  46638. * @returns true if successful.
  46639. */
  46640. attach(): boolean;
  46641. /**
  46642. * detach this feature.
  46643. * Will usually be called by the features manager
  46644. *
  46645. * @returns true if successful.
  46646. */
  46647. detach(): boolean;
  46648. /**
  46649. * Will get the mesh under a specific pointer.
  46650. * `scene.meshUnderPointer` will only return one mesh - either left or right.
  46651. * @param controllerId the controllerId to check
  46652. * @returns The mesh under pointer or null if no mesh is under the pointer
  46653. */
  46654. getMeshUnderPointer(controllerId: string): Nullable<AbstractMesh>;
  46655. /**
  46656. * Get the xr controller that correlates to the pointer id in the pointer event
  46657. *
  46658. * @param id the pointer id to search for
  46659. * @returns the controller that correlates to this id or null if not found
  46660. */
  46661. getXRControllerByPointerId(id: number): Nullable<WebXRInputSource>;
  46662. protected _onXRFrame(_xrFrame: XRFrame): void;
  46663. private _attachGazeMode;
  46664. private _attachScreenRayMode;
  46665. private _attachTrackedPointerRayMode;
  46666. private _convertNormalToDirectionOfRay;
  46667. private _detachController;
  46668. private _generateNewMeshPair;
  46669. private _pickingMoved;
  46670. private _updatePointerDistance;
  46671. }
  46672. }
  46673. declare module "babylonjs/XR/webXREnterExitUI" {
  46674. import { Nullable } from "babylonjs/types";
  46675. import { Observable } from "babylonjs/Misc/observable";
  46676. import { IDisposable, Scene } from "babylonjs/scene";
  46677. import { WebXRExperienceHelper } from "babylonjs/XR/webXRExperienceHelper";
  46678. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  46679. /**
  46680. * Button which can be used to enter a different mode of XR
  46681. */
  46682. export class WebXREnterExitUIButton {
  46683. /** button element */
  46684. element: HTMLElement;
  46685. /** XR initialization options for the button */
  46686. sessionMode: XRSessionMode;
  46687. /** Reference space type */
  46688. referenceSpaceType: XRReferenceSpaceType;
  46689. /**
  46690. * Creates a WebXREnterExitUIButton
  46691. * @param element button element
  46692. * @param sessionMode XR initialization session mode
  46693. * @param referenceSpaceType the type of reference space to be used
  46694. */
  46695. constructor(
  46696. /** button element */
  46697. element: HTMLElement,
  46698. /** XR initialization options for the button */
  46699. sessionMode: XRSessionMode,
  46700. /** Reference space type */
  46701. referenceSpaceType: XRReferenceSpaceType);
  46702. /**
  46703. * Extendable function which can be used to update the button's visuals when the state changes
  46704. * @param activeButton the current active button in the UI
  46705. */
  46706. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  46707. }
  46708. /**
  46709. * Options to create the webXR UI
  46710. */
  46711. export class WebXREnterExitUIOptions {
  46712. /**
  46713. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  46714. */
  46715. customButtons?: Array<WebXREnterExitUIButton>;
  46716. /**
  46717. * A reference space type to use when creating the default button.
  46718. * Default is local-floor
  46719. */
  46720. referenceSpaceType?: XRReferenceSpaceType;
  46721. /**
  46722. * Context to enter xr with
  46723. */
  46724. renderTarget?: Nullable<WebXRRenderTarget>;
  46725. /**
  46726. * A session mode to use when creating the default button.
  46727. * Default is immersive-vr
  46728. */
  46729. sessionMode?: XRSessionMode;
  46730. }
  46731. /**
  46732. * UI to allow the user to enter/exit XR mode
  46733. */
  46734. export class WebXREnterExitUI implements IDisposable {
  46735. private scene;
  46736. /** version of the options passed to this UI */
  46737. options: WebXREnterExitUIOptions;
  46738. private _activeButton;
  46739. private _buttons;
  46740. private _overlay;
  46741. /**
  46742. * Fired every time the active button is changed.
  46743. *
  46744. * When xr is entered via a button that launches xr that button will be the callback parameter
  46745. *
  46746. * When exiting xr the callback parameter will be null)
  46747. */
  46748. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  46749. /**
  46750. *
  46751. * @param scene babylon scene object to use
  46752. * @param options (read-only) version of the options passed to this UI
  46753. */
  46754. private constructor();
  46755. /**
  46756. * Creates UI to allow the user to enter/exit XR mode
  46757. * @param scene the scene to add the ui to
  46758. * @param helper the xr experience helper to enter/exit xr with
  46759. * @param options options to configure the UI
  46760. * @returns the created ui
  46761. */
  46762. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  46763. /**
  46764. * Disposes of the XR UI component
  46765. */
  46766. dispose(): void;
  46767. private _updateButtons;
  46768. }
  46769. }
  46770. declare module "babylonjs/Meshes/Builders/linesBuilder" {
  46771. import { Vector3 } from "babylonjs/Maths/math.vector";
  46772. import { Color4 } from "babylonjs/Maths/math.color";
  46773. import { Nullable } from "babylonjs/types";
  46774. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  46775. import { Scene } from "babylonjs/scene";
  46776. /**
  46777. * Class containing static functions to help procedurally build meshes
  46778. */
  46779. export class LinesBuilder {
  46780. /**
  46781. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  46782. * * 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
  46783. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  46784. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  46785. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  46786. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  46787. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  46788. * * 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
  46789. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  46790. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46791. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  46792. * @param name defines the name of the new line system
  46793. * @param options defines the options used to create the line system
  46794. * @param scene defines the hosting scene
  46795. * @returns a new line system mesh
  46796. */
  46797. static CreateLineSystem(name: string, options: {
  46798. lines: Vector3[][];
  46799. updatable?: boolean;
  46800. instance?: Nullable<LinesMesh>;
  46801. colors?: Nullable<Color4[][]>;
  46802. useVertexAlpha?: boolean;
  46803. }, scene: Nullable<Scene>): LinesMesh;
  46804. /**
  46805. * Creates a line mesh
  46806. * 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
  46807. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  46808. * * The parameter `points` is an array successive Vector3
  46809. * * 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
  46810. * * The optional parameter `colors` is an array of successive Color4, one per line point
  46811. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  46812. * * When updating an instance, remember that only point positions can change, not the number of points
  46813. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46814. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  46815. * @param name defines the name of the new line system
  46816. * @param options defines the options used to create the line system
  46817. * @param scene defines the hosting scene
  46818. * @returns a new line mesh
  46819. */
  46820. static CreateLines(name: string, options: {
  46821. points: Vector3[];
  46822. updatable?: boolean;
  46823. instance?: Nullable<LinesMesh>;
  46824. colors?: Color4[];
  46825. useVertexAlpha?: boolean;
  46826. }, scene?: Nullable<Scene>): LinesMesh;
  46827. /**
  46828. * Creates a dashed line mesh
  46829. * * 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
  46830. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  46831. * * The parameter `points` is an array successive Vector3
  46832. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  46833. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  46834. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  46835. * * 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
  46836. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  46837. * * When updating an instance, remember that only point positions can change, not the number of points
  46838. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46839. * @param name defines the name of the mesh
  46840. * @param options defines the options used to create the mesh
  46841. * @param scene defines the hosting scene
  46842. * @returns the dashed line mesh
  46843. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  46844. */
  46845. static CreateDashedLines(name: string, options: {
  46846. points: Vector3[];
  46847. dashSize?: number;
  46848. gapSize?: number;
  46849. dashNb?: number;
  46850. updatable?: boolean;
  46851. instance?: LinesMesh;
  46852. useVertexAlpha?: boolean;
  46853. }, scene?: Nullable<Scene>): LinesMesh;
  46854. }
  46855. }
  46856. declare module "babylonjs/XR/features/WebXRControllerTeleportation" {
  46857. import { IWebXRFeature } from "babylonjs/XR/webXRFeaturesManager";
  46858. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  46859. import { WebXRInput } from "babylonjs/XR/webXRInput";
  46860. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46861. import { Vector3 } from "babylonjs/Maths/math.vector";
  46862. import { Material } from "babylonjs/Materials/material";
  46863. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  46864. import { Scene } from "babylonjs/scene";
  46865. /**
  46866. * The options container for the teleportation module
  46867. */
  46868. export interface IWebXRTeleportationOptions {
  46869. /**
  46870. * if provided, this scene will be used to render meshes.
  46871. */
  46872. customUtilityLayerScene?: Scene;
  46873. /**
  46874. * Values to configure the default target mesh
  46875. */
  46876. defaultTargetMeshOptions?: {
  46877. /**
  46878. * Fill color of the teleportation area
  46879. */
  46880. teleportationFillColor?: string;
  46881. /**
  46882. * Border color for the teleportation area
  46883. */
  46884. teleportationBorderColor?: string;
  46885. /**
  46886. * Disable the mesh's animation sequence
  46887. */
  46888. disableAnimation?: boolean;
  46889. /**
  46890. * Disable lighting on the material or the ring and arrow
  46891. */
  46892. disableLighting?: boolean;
  46893. /**
  46894. * Override the default material of the torus and arrow
  46895. */
  46896. torusArrowMaterial?: Material;
  46897. };
  46898. /**
  46899. * A list of meshes to use as floor meshes.
  46900. * Meshes can be added and removed after initializing the feature using the
  46901. * addFloorMesh and removeFloorMesh functions
  46902. * If empty, rotation will still work
  46903. */
  46904. floorMeshes?: AbstractMesh[];
  46905. /**
  46906. * use this rendering group id for the meshes (optional)
  46907. */
  46908. renderingGroupId?: number;
  46909. /**
  46910. * Should teleportation move only to snap points
  46911. */
  46912. snapPointsOnly?: boolean;
  46913. /**
  46914. * An array of points to which the teleportation will snap to.
  46915. * If the teleportation ray is in the proximity of one of those points, it will be corrected to this point.
  46916. */
  46917. snapPositions?: Vector3[];
  46918. /**
  46919. * How close should the teleportation ray be in order to snap to position.
  46920. * Default to 0.8 units (meters)
  46921. */
  46922. snapToPositionRadius?: number;
  46923. /**
  46924. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  46925. * If you want to support rotation, make sure your mesh has a direction indicator.
  46926. *
  46927. * When left untouched, the default mesh will be initialized.
  46928. */
  46929. teleportationTargetMesh?: AbstractMesh;
  46930. /**
  46931. * If main component is used (no thumbstick), how long should the "long press" take before teleport
  46932. */
  46933. timeToTeleport?: number;
  46934. /**
  46935. * Disable using the thumbstick and use the main component (usually trigger) on long press.
  46936. * This will be automatically true if the controller doesn't have a thumbstick or touchpad.
  46937. */
  46938. useMainComponentOnly?: boolean;
  46939. /**
  46940. * Should meshes created here be added to a utility layer or the main scene
  46941. */
  46942. useUtilityLayer?: boolean;
  46943. /**
  46944. * Babylon XR Input class for controller
  46945. */
  46946. xrInput: WebXRInput;
  46947. }
  46948. /**
  46949. * This is a teleportation feature to be used with WebXR-enabled motion controllers.
  46950. * When enabled and attached, the feature will allow a user to move around and rotate in the scene using
  46951. * the input of the attached controllers.
  46952. */
  46953. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  46954. private _options;
  46955. private _controllers;
  46956. private _currentTeleportationControllerId;
  46957. private _floorMeshes;
  46958. private _quadraticBezierCurve;
  46959. private _selectionFeature;
  46960. private _snapToPositions;
  46961. private _snappedToPoint;
  46962. private _teleportationRingMaterial?;
  46963. private _tmpRay;
  46964. private _tmpVector;
  46965. /**
  46966. * The module's name
  46967. */
  46968. static readonly Name: string;
  46969. /**
  46970. * The (Babylon) version of this module.
  46971. * This is an integer representing the implementation version.
  46972. * This number does not correspond to the webxr specs version
  46973. */
  46974. static readonly Version: number;
  46975. /**
  46976. * Is movement backwards enabled
  46977. */
  46978. backwardsMovementEnabled: boolean;
  46979. /**
  46980. * Distance to travel when moving backwards
  46981. */
  46982. backwardsTeleportationDistance: number;
  46983. /**
  46984. * The distance from the user to the inspection point in the direction of the controller
  46985. * A higher number will allow the user to move further
  46986. * defaults to 5 (meters, in xr units)
  46987. */
  46988. parabolicCheckRadius: number;
  46989. /**
  46990. * Should the module support parabolic ray on top of direct ray
  46991. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  46992. * Very helpful when moving between floors / different heights
  46993. */
  46994. parabolicRayEnabled: boolean;
  46995. /**
  46996. * How much rotation should be applied when rotating right and left
  46997. */
  46998. rotationAngle: number;
  46999. /**
  47000. * Is rotation enabled when moving forward?
  47001. * Disabling this feature will prevent the user from deciding the direction when teleporting
  47002. */
  47003. rotationEnabled: boolean;
  47004. /**
  47005. * constructs a new anchor system
  47006. * @param _xrSessionManager an instance of WebXRSessionManager
  47007. * @param _options configuration object for this feature
  47008. */
  47009. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  47010. /**
  47011. * Get the snapPointsOnly flag
  47012. */
  47013. get snapPointsOnly(): boolean;
  47014. /**
  47015. * Sets the snapPointsOnly flag
  47016. * @param snapToPoints should teleportation be exclusively to snap points
  47017. */
  47018. set snapPointsOnly(snapToPoints: boolean);
  47019. /**
  47020. * Add a new mesh to the floor meshes array
  47021. * @param mesh the mesh to use as floor mesh
  47022. */
  47023. addFloorMesh(mesh: AbstractMesh): void;
  47024. /**
  47025. * Add a new snap-to point to fix teleportation to this position
  47026. * @param newSnapPoint The new Snap-To point
  47027. */
  47028. addSnapPoint(newSnapPoint: Vector3): void;
  47029. attach(): boolean;
  47030. detach(): boolean;
  47031. dispose(): void;
  47032. /**
  47033. * Remove a mesh from the floor meshes array
  47034. * @param mesh the mesh to remove
  47035. */
  47036. removeFloorMesh(mesh: AbstractMesh): void;
  47037. /**
  47038. * Remove a mesh from the floor meshes array using its name
  47039. * @param name the mesh name to remove
  47040. */
  47041. removeFloorMeshByName(name: string): void;
  47042. /**
  47043. * 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
  47044. * @param snapPointToRemove the point (or a clone of it) to be removed from the array
  47045. * @returns was the point found and removed or not
  47046. */
  47047. removeSnapPoint(snapPointToRemove: Vector3): boolean;
  47048. /**
  47049. * This function sets a selection feature that will be disabled when
  47050. * the forward ray is shown and will be reattached when hidden.
  47051. * This is used to remove the selection rays when moving.
  47052. * @param selectionFeature the feature to disable when forward movement is enabled
  47053. */
  47054. setSelectionFeature(selectionFeature: IWebXRFeature): void;
  47055. protected _onXRFrame(_xrFrame: XRFrame): void;
  47056. private _attachController;
  47057. private _createDefaultTargetMesh;
  47058. private _detachController;
  47059. private _findClosestSnapPointWithRadius;
  47060. private _setTargetMeshPosition;
  47061. private _setTargetMeshVisibility;
  47062. private _showParabolicPath;
  47063. private _teleportForward;
  47064. }
  47065. }
  47066. declare module "babylonjs/XR/webXRDefaultExperience" {
  47067. import { WebXRExperienceHelper } from "babylonjs/XR/webXRExperienceHelper";
  47068. import { Scene } from "babylonjs/scene";
  47069. import { WebXRInput, IWebXRInputOptions } from "babylonjs/XR/webXRInput";
  47070. import { WebXRControllerPointerSelection } from "babylonjs/XR/features/WebXRControllerPointerSelection";
  47071. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  47072. import { WebXREnterExitUI, WebXREnterExitUIOptions } from "babylonjs/XR/webXREnterExitUI";
  47073. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47074. import { WebXRManagedOutputCanvasOptions } from "babylonjs/XR/webXRManagedOutputCanvas";
  47075. import { WebXRMotionControllerTeleportation } from "babylonjs/XR/features/WebXRControllerTeleportation";
  47076. /**
  47077. * Options for the default xr helper
  47078. */
  47079. export class WebXRDefaultExperienceOptions {
  47080. /**
  47081. * Enable or disable default UI to enter XR
  47082. */
  47083. disableDefaultUI?: boolean;
  47084. /**
  47085. * Should teleportation not initialize. defaults to false.
  47086. */
  47087. disableTeleportation?: boolean;
  47088. /**
  47089. * Floor meshes that will be used for teleport
  47090. */
  47091. floorMeshes?: Array<AbstractMesh>;
  47092. /**
  47093. * If set to true, the first frame will not be used to reset position
  47094. * The first frame is mainly used when copying transformation from the old camera
  47095. * Mainly used in AR
  47096. */
  47097. ignoreNativeCameraTransformation?: boolean;
  47098. /**
  47099. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  47100. */
  47101. inputOptions?: IWebXRInputOptions;
  47102. /**
  47103. * optional configuration for the output canvas
  47104. */
  47105. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  47106. /**
  47107. * optional UI options. This can be used among other to change session mode and reference space type
  47108. */
  47109. uiOptions?: WebXREnterExitUIOptions;
  47110. /**
  47111. * When loading teleportation and pointer select, use stable versions instead of latest.
  47112. */
  47113. useStablePlugins?: boolean;
  47114. }
  47115. /**
  47116. * Default experience which provides a similar setup to the previous webVRExperience
  47117. */
  47118. export class WebXRDefaultExperience {
  47119. /**
  47120. * Base experience
  47121. */
  47122. baseExperience: WebXRExperienceHelper;
  47123. /**
  47124. * Enables ui for entering/exiting xr
  47125. */
  47126. enterExitUI: WebXREnterExitUI;
  47127. /**
  47128. * Input experience extension
  47129. */
  47130. input: WebXRInput;
  47131. /**
  47132. * Enables laser pointer and selection
  47133. */
  47134. pointerSelection: WebXRControllerPointerSelection;
  47135. /**
  47136. * Default target xr should render to
  47137. */
  47138. renderTarget: WebXRRenderTarget;
  47139. /**
  47140. * Enables teleportation
  47141. */
  47142. teleportation: WebXRMotionControllerTeleportation;
  47143. private constructor();
  47144. /**
  47145. * Creates the default xr experience
  47146. * @param scene scene
  47147. * @param options options for basic configuration
  47148. * @returns resulting WebXRDefaultExperience
  47149. */
  47150. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  47151. /**
  47152. * DIsposes of the experience helper
  47153. */
  47154. dispose(): void;
  47155. }
  47156. }
  47157. declare module "babylonjs/Cameras/VR/vrExperienceHelper" {
  47158. import { Observable } from "babylonjs/Misc/observable";
  47159. import { Nullable } from "babylonjs/types";
  47160. import { Camera } from "babylonjs/Cameras/camera";
  47161. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  47162. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  47163. import { WebVROptions, WebVRFreeCamera } from "babylonjs/Cameras/VR/webVRCamera";
  47164. import { Scene } from "babylonjs/scene";
  47165. import { Vector3 } from "babylonjs/Maths/math.vector";
  47166. import { Color3 } from "babylonjs/Maths/math.color";
  47167. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  47168. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47169. import { Mesh } from "babylonjs/Meshes/mesh";
  47170. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  47171. import { EasingFunction } from "babylonjs/Animations/easing";
  47172. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  47173. import "babylonjs/Meshes/Builders/groundBuilder";
  47174. import "babylonjs/Meshes/Builders/torusBuilder";
  47175. import "babylonjs/Meshes/Builders/cylinderBuilder";
  47176. import "babylonjs/Gamepads/gamepadSceneComponent";
  47177. import "babylonjs/Animations/animatable";
  47178. import { WebXRDefaultExperience } from "babylonjs/XR/webXRDefaultExperience";
  47179. /**
  47180. * Options to modify the vr teleportation behavior.
  47181. */
  47182. export interface VRTeleportationOptions {
  47183. /**
  47184. * The name of the mesh which should be used as the teleportation floor. (default: null)
  47185. */
  47186. floorMeshName?: string;
  47187. /**
  47188. * A list of meshes to be used as the teleportation floor. (default: empty)
  47189. */
  47190. floorMeshes?: Mesh[];
  47191. /**
  47192. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  47193. */
  47194. teleportationMode?: number;
  47195. /**
  47196. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  47197. */
  47198. teleportationTime?: number;
  47199. /**
  47200. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  47201. */
  47202. teleportationSpeed?: number;
  47203. /**
  47204. * The easing function used in the animation or null for Linear. (default CircleEase)
  47205. */
  47206. easingFunction?: EasingFunction;
  47207. }
  47208. /**
  47209. * Options to modify the vr experience helper's behavior.
  47210. */
  47211. export interface VRExperienceHelperOptions extends WebVROptions {
  47212. /**
  47213. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  47214. */
  47215. createDeviceOrientationCamera?: boolean;
  47216. /**
  47217. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  47218. */
  47219. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  47220. /**
  47221. * Uses the main button on the controller to toggle the laser casted. (default: true)
  47222. */
  47223. laserToggle?: boolean;
  47224. /**
  47225. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  47226. */
  47227. floorMeshes?: Mesh[];
  47228. /**
  47229. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  47230. */
  47231. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  47232. /**
  47233. * Defines if WebXR should be used instead of WebVR (if available)
  47234. */
  47235. useXR?: boolean;
  47236. }
  47237. /**
  47238. * Event containing information after VR has been entered
  47239. */
  47240. export class OnAfterEnteringVRObservableEvent {
  47241. /**
  47242. * If entering vr was successful
  47243. */
  47244. success: boolean;
  47245. }
  47246. /**
  47247. * Helps to quickly add VR support to an existing scene.
  47248. * See http://doc.babylonjs.com/how_to/webvr_helper
  47249. */
  47250. export class VRExperienceHelper {
  47251. /** Options to modify the vr experience helper's behavior. */
  47252. webVROptions: VRExperienceHelperOptions;
  47253. private _scene;
  47254. private _position;
  47255. private _btnVR;
  47256. private _btnVRDisplayed;
  47257. private _webVRsupported;
  47258. private _webVRready;
  47259. private _webVRrequesting;
  47260. private _webVRpresenting;
  47261. private _hasEnteredVR;
  47262. private _fullscreenVRpresenting;
  47263. private _inputElement;
  47264. private _webVRCamera;
  47265. private _vrDeviceOrientationCamera;
  47266. private _deviceOrientationCamera;
  47267. private _existingCamera;
  47268. private _onKeyDown;
  47269. private _onVrDisplayPresentChange;
  47270. private _onVRDisplayChanged;
  47271. private _onVRRequestPresentStart;
  47272. private _onVRRequestPresentComplete;
  47273. /**
  47274. * 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)
  47275. */
  47276. enableGazeEvenWhenNoPointerLock: boolean;
  47277. /**
  47278. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  47279. */
  47280. exitVROnDoubleTap: boolean;
  47281. /**
  47282. * Observable raised right before entering VR.
  47283. */
  47284. onEnteringVRObservable: Observable<VRExperienceHelper>;
  47285. /**
  47286. * Observable raised when entering VR has completed.
  47287. */
  47288. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  47289. /**
  47290. * Observable raised when exiting VR.
  47291. */
  47292. onExitingVRObservable: Observable<VRExperienceHelper>;
  47293. /**
  47294. * Observable raised when controller mesh is loaded.
  47295. */
  47296. onControllerMeshLoadedObservable: Observable<WebVRController>;
  47297. /** Return this.onEnteringVRObservable
  47298. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  47299. */
  47300. get onEnteringVR(): Observable<VRExperienceHelper>;
  47301. /** Return this.onExitingVRObservable
  47302. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  47303. */
  47304. get onExitingVR(): Observable<VRExperienceHelper>;
  47305. /** Return this.onControllerMeshLoadedObservable
  47306. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  47307. */
  47308. get onControllerMeshLoaded(): Observable<WebVRController>;
  47309. private _rayLength;
  47310. private _useCustomVRButton;
  47311. private _teleportationRequested;
  47312. private _teleportActive;
  47313. private _floorMeshName;
  47314. private _floorMeshesCollection;
  47315. private _teleportationMode;
  47316. private _teleportationTime;
  47317. private _teleportationSpeed;
  47318. private _teleportationEasing;
  47319. private _rotationAllowed;
  47320. private _teleportBackwardsVector;
  47321. private _teleportationTarget;
  47322. private _isDefaultTeleportationTarget;
  47323. private _postProcessMove;
  47324. private _teleportationFillColor;
  47325. private _teleportationBorderColor;
  47326. private _rotationAngle;
  47327. private _haloCenter;
  47328. private _cameraGazer;
  47329. private _padSensibilityUp;
  47330. private _padSensibilityDown;
  47331. private _leftController;
  47332. private _rightController;
  47333. private _gazeColor;
  47334. private _laserColor;
  47335. private _pickedLaserColor;
  47336. private _pickedGazeColor;
  47337. /**
  47338. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  47339. */
  47340. onNewMeshSelected: Observable<AbstractMesh>;
  47341. /**
  47342. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  47343. * This observable will provide the mesh and the controller used to select the mesh
  47344. */
  47345. onMeshSelectedWithController: Observable<{
  47346. mesh: AbstractMesh;
  47347. controller: WebVRController;
  47348. }>;
  47349. /**
  47350. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  47351. */
  47352. onNewMeshPicked: Observable<PickingInfo>;
  47353. private _circleEase;
  47354. /**
  47355. * Observable raised before camera teleportation
  47356. */
  47357. onBeforeCameraTeleport: Observable<Vector3>;
  47358. /**
  47359. * Observable raised after camera teleportation
  47360. */
  47361. onAfterCameraTeleport: Observable<Vector3>;
  47362. /**
  47363. * Observable raised when current selected mesh gets unselected
  47364. */
  47365. onSelectedMeshUnselected: Observable<AbstractMesh>;
  47366. private _raySelectionPredicate;
  47367. /**
  47368. * To be optionaly changed by user to define custom ray selection
  47369. */
  47370. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  47371. /**
  47372. * To be optionaly changed by user to define custom selection logic (after ray selection)
  47373. */
  47374. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  47375. /**
  47376. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  47377. */
  47378. teleportationEnabled: boolean;
  47379. private _defaultHeight;
  47380. private _teleportationInitialized;
  47381. private _interactionsEnabled;
  47382. private _interactionsRequested;
  47383. private _displayGaze;
  47384. private _displayLaserPointer;
  47385. /**
  47386. * The mesh used to display where the user is going to teleport.
  47387. */
  47388. get teleportationTarget(): Mesh;
  47389. /**
  47390. * Sets the mesh to be used to display where the user is going to teleport.
  47391. */
  47392. set teleportationTarget(value: Mesh);
  47393. /**
  47394. * 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
  47395. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  47396. * See http://doc.babylonjs.com/resources/baking_transformations
  47397. */
  47398. get gazeTrackerMesh(): Mesh;
  47399. set gazeTrackerMesh(value: Mesh);
  47400. /**
  47401. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  47402. */
  47403. updateGazeTrackerScale: boolean;
  47404. /**
  47405. * If the gaze trackers color should be updated when selecting meshes
  47406. */
  47407. updateGazeTrackerColor: boolean;
  47408. /**
  47409. * If the controller laser color should be updated when selecting meshes
  47410. */
  47411. updateControllerLaserColor: boolean;
  47412. /**
  47413. * The gaze tracking mesh corresponding to the left controller
  47414. */
  47415. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  47416. /**
  47417. * The gaze tracking mesh corresponding to the right controller
  47418. */
  47419. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  47420. /**
  47421. * If the ray of the gaze should be displayed.
  47422. */
  47423. get displayGaze(): boolean;
  47424. /**
  47425. * Sets if the ray of the gaze should be displayed.
  47426. */
  47427. set displayGaze(value: boolean);
  47428. /**
  47429. * If the ray of the LaserPointer should be displayed.
  47430. */
  47431. get displayLaserPointer(): boolean;
  47432. /**
  47433. * Sets if the ray of the LaserPointer should be displayed.
  47434. */
  47435. set displayLaserPointer(value: boolean);
  47436. /**
  47437. * The deviceOrientationCamera used as the camera when not in VR.
  47438. */
  47439. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  47440. /**
  47441. * Based on the current WebVR support, returns the current VR camera used.
  47442. */
  47443. get currentVRCamera(): Nullable<Camera>;
  47444. /**
  47445. * The webVRCamera which is used when in VR.
  47446. */
  47447. get webVRCamera(): WebVRFreeCamera;
  47448. /**
  47449. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  47450. */
  47451. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  47452. /**
  47453. * The html button that is used to trigger entering into VR.
  47454. */
  47455. get vrButton(): Nullable<HTMLButtonElement>;
  47456. private get _teleportationRequestInitiated();
  47457. /**
  47458. * Defines whether or not Pointer lock should be requested when switching to
  47459. * full screen.
  47460. */
  47461. requestPointerLockOnFullScreen: boolean;
  47462. /**
  47463. * If asking to force XR, this will be populated with the default xr experience
  47464. */
  47465. xr: WebXRDefaultExperience;
  47466. /**
  47467. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  47468. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  47469. */
  47470. xrTestDone: boolean;
  47471. /**
  47472. * Instantiates a VRExperienceHelper.
  47473. * Helps to quickly add VR support to an existing scene.
  47474. * @param scene The scene the VRExperienceHelper belongs to.
  47475. * @param webVROptions Options to modify the vr experience helper's behavior.
  47476. */
  47477. constructor(scene: Scene,
  47478. /** Options to modify the vr experience helper's behavior. */
  47479. webVROptions?: VRExperienceHelperOptions);
  47480. private completeVRInit;
  47481. private _onDefaultMeshLoaded;
  47482. private _onResize;
  47483. private _onFullscreenChange;
  47484. /**
  47485. * Gets a value indicating if we are currently in VR mode.
  47486. */
  47487. get isInVRMode(): boolean;
  47488. private onVrDisplayPresentChange;
  47489. private onVRDisplayChanged;
  47490. private moveButtonToBottomRight;
  47491. private displayVRButton;
  47492. private updateButtonVisibility;
  47493. private _cachedAngularSensibility;
  47494. /**
  47495. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  47496. * Otherwise, will use the fullscreen API.
  47497. */
  47498. enterVR(): void;
  47499. /**
  47500. * Attempt to exit VR, or fullscreen.
  47501. */
  47502. exitVR(): void;
  47503. /**
  47504. * The position of the vr experience helper.
  47505. */
  47506. get position(): Vector3;
  47507. /**
  47508. * Sets the position of the vr experience helper.
  47509. */
  47510. set position(value: Vector3);
  47511. /**
  47512. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  47513. */
  47514. enableInteractions(): void;
  47515. private get _noControllerIsActive();
  47516. private beforeRender;
  47517. private _isTeleportationFloor;
  47518. /**
  47519. * Adds a floor mesh to be used for teleportation.
  47520. * @param floorMesh the mesh to be used for teleportation.
  47521. */
  47522. addFloorMesh(floorMesh: Mesh): void;
  47523. /**
  47524. * Removes a floor mesh from being used for teleportation.
  47525. * @param floorMesh the mesh to be removed.
  47526. */
  47527. removeFloorMesh(floorMesh: Mesh): void;
  47528. /**
  47529. * Enables interactions and teleportation using the VR controllers and gaze.
  47530. * @param vrTeleportationOptions options to modify teleportation behavior.
  47531. */
  47532. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  47533. private _onNewGamepadConnected;
  47534. private _tryEnableInteractionOnController;
  47535. private _onNewGamepadDisconnected;
  47536. private _enableInteractionOnController;
  47537. private _checkTeleportWithRay;
  47538. private _checkRotate;
  47539. private _checkTeleportBackwards;
  47540. private _enableTeleportationOnController;
  47541. private _createTeleportationCircles;
  47542. private _displayTeleportationTarget;
  47543. private _hideTeleportationTarget;
  47544. private _rotateCamera;
  47545. private _moveTeleportationSelectorTo;
  47546. private _workingVector;
  47547. private _workingQuaternion;
  47548. private _workingMatrix;
  47549. /**
  47550. * Time Constant Teleportation Mode
  47551. */
  47552. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  47553. /**
  47554. * Speed Constant Teleportation Mode
  47555. */
  47556. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  47557. /**
  47558. * Teleports the users feet to the desired location
  47559. * @param location The location where the user's feet should be placed
  47560. */
  47561. teleportCamera(location: Vector3): void;
  47562. private _convertNormalToDirectionOfRay;
  47563. private _castRayAndSelectObject;
  47564. private _notifySelectedMeshUnselected;
  47565. /**
  47566. * Permanently set new colors for the laser pointer
  47567. * @param color the new laser color
  47568. * @param pickedColor the new laser color when picked mesh detected
  47569. */
  47570. setLaserColor(color: Color3, pickedColor?: Color3): void;
  47571. /**
  47572. * Set lighting enabled / disabled on the laser pointer of both controllers
  47573. * @param enabled should the lighting be enabled on the laser pointer
  47574. */
  47575. setLaserLightingState(enabled?: boolean): void;
  47576. /**
  47577. * Permanently set new colors for the gaze pointer
  47578. * @param color the new gaze color
  47579. * @param pickedColor the new gaze color when picked mesh detected
  47580. */
  47581. setGazeColor(color: Color3, pickedColor?: Color3): void;
  47582. /**
  47583. * Sets the color of the laser ray from the vr controllers.
  47584. * @param color new color for the ray.
  47585. */
  47586. changeLaserColor(color: Color3): void;
  47587. /**
  47588. * Sets the color of the ray from the vr headsets gaze.
  47589. * @param color new color for the ray.
  47590. */
  47591. changeGazeColor(color: Color3): void;
  47592. /**
  47593. * Exits VR and disposes of the vr experience helper
  47594. */
  47595. dispose(): void;
  47596. /**
  47597. * Gets the name of the VRExperienceHelper class
  47598. * @returns "VRExperienceHelper"
  47599. */
  47600. getClassName(): string;
  47601. }
  47602. }
  47603. declare module "babylonjs/Cameras/VR/index" {
  47604. export * from "babylonjs/Cameras/VR/vrCameraMetrics";
  47605. export * from "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera";
  47606. export * from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  47607. export * from "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera";
  47608. export * from "babylonjs/Cameras/VR/vrExperienceHelper";
  47609. export * from "babylonjs/Cameras/VR/webVRCamera";
  47610. }
  47611. declare module "babylonjs/Cameras/RigModes/index" {
  47612. export * from "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  47613. export * from "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  47614. export * from "babylonjs/Cameras/RigModes/vrRigMode";
  47615. export * from "babylonjs/Cameras/RigModes/webVRRigMode";
  47616. }
  47617. declare module "babylonjs/Cameras/index" {
  47618. export * from "babylonjs/Cameras/Inputs/index";
  47619. export * from "babylonjs/Cameras/cameraInputsManager";
  47620. export * from "babylonjs/Cameras/camera";
  47621. export * from "babylonjs/Cameras/targetCamera";
  47622. export * from "babylonjs/Cameras/freeCamera";
  47623. export * from "babylonjs/Cameras/freeCameraInputsManager";
  47624. export * from "babylonjs/Cameras/touchCamera";
  47625. export * from "babylonjs/Cameras/arcRotateCamera";
  47626. export * from "babylonjs/Cameras/arcRotateCameraInputsManager";
  47627. export * from "babylonjs/Cameras/deviceOrientationCamera";
  47628. export * from "babylonjs/Cameras/flyCamera";
  47629. export * from "babylonjs/Cameras/flyCameraInputsManager";
  47630. export * from "babylonjs/Cameras/followCamera";
  47631. export * from "babylonjs/Cameras/followCameraInputsManager";
  47632. export * from "babylonjs/Cameras/gamepadCamera";
  47633. export * from "babylonjs/Cameras/Stereoscopic/index";
  47634. export * from "babylonjs/Cameras/universalCamera";
  47635. export * from "babylonjs/Cameras/virtualJoysticksCamera";
  47636. export * from "babylonjs/Cameras/VR/index";
  47637. export * from "babylonjs/Cameras/RigModes/index";
  47638. }
  47639. declare module "babylonjs/Collisions/index" {
  47640. export * from "babylonjs/Collisions/collider";
  47641. export * from "babylonjs/Collisions/collisionCoordinator";
  47642. export * from "babylonjs/Collisions/pickingInfo";
  47643. export * from "babylonjs/Collisions/intersectionInfo";
  47644. export * from "babylonjs/Collisions/meshCollisionData";
  47645. }
  47646. declare module "babylonjs/Culling/Octrees/octreeBlock" {
  47647. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  47648. import { Vector3 } from "babylonjs/Maths/math.vector";
  47649. import { Ray } from "babylonjs/Culling/ray";
  47650. import { Plane } from "babylonjs/Maths/math.plane";
  47651. /**
  47652. * Contains an array of blocks representing the octree
  47653. */
  47654. export interface IOctreeContainer<T> {
  47655. /**
  47656. * Blocks within the octree
  47657. */
  47658. blocks: Array<OctreeBlock<T>>;
  47659. }
  47660. /**
  47661. * Class used to store a cell in an octree
  47662. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  47663. */
  47664. export class OctreeBlock<T> {
  47665. /**
  47666. * Gets the content of the current block
  47667. */
  47668. entries: T[];
  47669. /**
  47670. * Gets the list of block children
  47671. */
  47672. blocks: Array<OctreeBlock<T>>;
  47673. private _depth;
  47674. private _maxDepth;
  47675. private _capacity;
  47676. private _minPoint;
  47677. private _maxPoint;
  47678. private _boundingVectors;
  47679. private _creationFunc;
  47680. /**
  47681. * Creates a new block
  47682. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  47683. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  47684. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  47685. * @param depth defines the current depth of this block in the octree
  47686. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  47687. * @param creationFunc defines a callback to call when an element is added to the block
  47688. */
  47689. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  47690. /**
  47691. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  47692. */
  47693. get capacity(): number;
  47694. /**
  47695. * Gets the minimum vector (in world space) of the block's bounding box
  47696. */
  47697. get minPoint(): Vector3;
  47698. /**
  47699. * Gets the maximum vector (in world space) of the block's bounding box
  47700. */
  47701. get maxPoint(): Vector3;
  47702. /**
  47703. * Add a new element to this block
  47704. * @param entry defines the element to add
  47705. */
  47706. addEntry(entry: T): void;
  47707. /**
  47708. * Remove an element from this block
  47709. * @param entry defines the element to remove
  47710. */
  47711. removeEntry(entry: T): void;
  47712. /**
  47713. * Add an array of elements to this block
  47714. * @param entries defines the array of elements to add
  47715. */
  47716. addEntries(entries: T[]): void;
  47717. /**
  47718. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  47719. * @param frustumPlanes defines the frustum planes to test
  47720. * @param selection defines the array to store current content if selection is positive
  47721. * @param allowDuplicate defines if the selection array can contains duplicated entries
  47722. */
  47723. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  47724. /**
  47725. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  47726. * @param sphereCenter defines the bounding sphere center
  47727. * @param sphereRadius defines the bounding sphere radius
  47728. * @param selection defines the array to store current content if selection is positive
  47729. * @param allowDuplicate defines if the selection array can contains duplicated entries
  47730. */
  47731. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  47732. /**
  47733. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  47734. * @param ray defines the ray to test with
  47735. * @param selection defines the array to store current content if selection is positive
  47736. */
  47737. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  47738. /**
  47739. * Subdivide the content into child blocks (this block will then be empty)
  47740. */
  47741. createInnerBlocks(): void;
  47742. /**
  47743. * @hidden
  47744. */
  47745. 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;
  47746. }
  47747. }
  47748. declare module "babylonjs/Culling/Octrees/octree" {
  47749. import { SmartArray } from "babylonjs/Misc/smartArray";
  47750. import { Vector3 } from "babylonjs/Maths/math.vector";
  47751. import { SubMesh } from "babylonjs/Meshes/subMesh";
  47752. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47753. import { Ray } from "babylonjs/Culling/ray";
  47754. import { OctreeBlock } from "babylonjs/Culling/Octrees/octreeBlock";
  47755. import { Plane } from "babylonjs/Maths/math.plane";
  47756. /**
  47757. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  47758. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  47759. */
  47760. export class Octree<T> {
  47761. /** 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.) */
  47762. maxDepth: number;
  47763. /**
  47764. * Blocks within the octree containing objects
  47765. */
  47766. blocks: Array<OctreeBlock<T>>;
  47767. /**
  47768. * Content stored in the octree
  47769. */
  47770. dynamicContent: T[];
  47771. private _maxBlockCapacity;
  47772. private _selectionContent;
  47773. private _creationFunc;
  47774. /**
  47775. * Creates a octree
  47776. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  47777. * @param creationFunc function to be used to instatiate the octree
  47778. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  47779. * @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.)
  47780. */
  47781. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  47782. /** 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.) */
  47783. maxDepth?: number);
  47784. /**
  47785. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  47786. * @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);
  47787. * @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);
  47788. * @param entries meshes to be added to the octree blocks
  47789. */
  47790. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  47791. /**
  47792. * Adds a mesh to the octree
  47793. * @param entry Mesh to add to the octree
  47794. */
  47795. addMesh(entry: T): void;
  47796. /**
  47797. * Remove an element from the octree
  47798. * @param entry defines the element to remove
  47799. */
  47800. removeMesh(entry: T): void;
  47801. /**
  47802. * Selects an array of meshes within the frustum
  47803. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  47804. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  47805. * @returns array of meshes within the frustum
  47806. */
  47807. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  47808. /**
  47809. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  47810. * @param sphereCenter defines the bounding sphere center
  47811. * @param sphereRadius defines the bounding sphere radius
  47812. * @param allowDuplicate defines if the selection array can contains duplicated entries
  47813. * @returns an array of objects that intersect the sphere
  47814. */
  47815. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  47816. /**
  47817. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  47818. * @param ray defines the ray to test with
  47819. * @returns array of intersected objects
  47820. */
  47821. intersectsRay(ray: Ray): SmartArray<T>;
  47822. /**
  47823. * Adds a mesh into the octree block if it intersects the block
  47824. */
  47825. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  47826. /**
  47827. * Adds a submesh into the octree block if it intersects the block
  47828. */
  47829. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  47830. }
  47831. }
  47832. declare module "babylonjs/Culling/Octrees/octreeSceneComponent" {
  47833. import { ISmartArrayLike } from "babylonjs/Misc/smartArray";
  47834. import { Scene } from "babylonjs/scene";
  47835. import { SubMesh } from "babylonjs/Meshes/subMesh";
  47836. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47837. import { Ray } from "babylonjs/Culling/ray";
  47838. import { Octree } from "babylonjs/Culling/Octrees/octree";
  47839. import { Collider } from "babylonjs/Collisions/collider";
  47840. module "babylonjs/scene" {
  47841. interface Scene {
  47842. /**
  47843. * @hidden
  47844. * Backing Filed
  47845. */
  47846. _selectionOctree: Octree<AbstractMesh>;
  47847. /**
  47848. * Gets the octree used to boost mesh selection (picking)
  47849. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  47850. */
  47851. selectionOctree: Octree<AbstractMesh>;
  47852. /**
  47853. * Creates or updates the octree used to boost selection (picking)
  47854. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  47855. * @param maxCapacity defines the maximum capacity per leaf
  47856. * @param maxDepth defines the maximum depth of the octree
  47857. * @returns an octree of AbstractMesh
  47858. */
  47859. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  47860. }
  47861. }
  47862. module "babylonjs/Meshes/abstractMesh" {
  47863. interface AbstractMesh {
  47864. /**
  47865. * @hidden
  47866. * Backing Field
  47867. */
  47868. _submeshesOctree: Octree<SubMesh>;
  47869. /**
  47870. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  47871. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  47872. * @param maxCapacity defines the maximum size of each block (64 by default)
  47873. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  47874. * @returns the new octree
  47875. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  47876. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  47877. */
  47878. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  47879. }
  47880. }
  47881. /**
  47882. * Defines the octree scene component responsible to manage any octrees
  47883. * in a given scene.
  47884. */
  47885. export class OctreeSceneComponent {
  47886. /**
  47887. * The component name help to identify the component in the list of scene components.
  47888. */
  47889. readonly name: string;
  47890. /**
  47891. * The scene the component belongs to.
  47892. */
  47893. scene: Scene;
  47894. /**
  47895. * Indicates if the meshes have been checked to make sure they are isEnabled()
  47896. */
  47897. readonly checksIsEnabled: boolean;
  47898. /**
  47899. * Creates a new instance of the component for the given scene
  47900. * @param scene Defines the scene to register the component in
  47901. */
  47902. constructor(scene: Scene);
  47903. /**
  47904. * Registers the component in a given scene
  47905. */
  47906. register(): void;
  47907. /**
  47908. * Return the list of active meshes
  47909. * @returns the list of active meshes
  47910. */
  47911. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  47912. /**
  47913. * Return the list of active sub meshes
  47914. * @param mesh The mesh to get the candidates sub meshes from
  47915. * @returns the list of active sub meshes
  47916. */
  47917. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  47918. private _tempRay;
  47919. /**
  47920. * Return the list of sub meshes intersecting with a given local ray
  47921. * @param mesh defines the mesh to find the submesh for
  47922. * @param localRay defines the ray in local space
  47923. * @returns the list of intersecting sub meshes
  47924. */
  47925. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  47926. /**
  47927. * Return the list of sub meshes colliding with a collider
  47928. * @param mesh defines the mesh to find the submesh for
  47929. * @param collider defines the collider to evaluate the collision against
  47930. * @returns the list of colliding sub meshes
  47931. */
  47932. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  47933. /**
  47934. * Rebuilds the elements related to this component in case of
  47935. * context lost for instance.
  47936. */
  47937. rebuild(): void;
  47938. /**
  47939. * Disposes the component and the associated ressources.
  47940. */
  47941. dispose(): void;
  47942. }
  47943. }
  47944. declare module "babylonjs/Culling/Octrees/index" {
  47945. export * from "babylonjs/Culling/Octrees/octree";
  47946. export * from "babylonjs/Culling/Octrees/octreeBlock";
  47947. export * from "babylonjs/Culling/Octrees/octreeSceneComponent";
  47948. }
  47949. declare module "babylonjs/Culling/index" {
  47950. export * from "babylonjs/Culling/boundingBox";
  47951. export * from "babylonjs/Culling/boundingInfo";
  47952. export * from "babylonjs/Culling/boundingSphere";
  47953. export * from "babylonjs/Culling/Octrees/index";
  47954. export * from "babylonjs/Culling/ray";
  47955. }
  47956. declare module "babylonjs/Gizmos/gizmo" {
  47957. import { Nullable } from "babylonjs/types";
  47958. import { IDisposable } from "babylonjs/scene";
  47959. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47960. import { Mesh } from "babylonjs/Meshes/mesh";
  47961. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  47962. /**
  47963. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  47964. */
  47965. export class Gizmo implements IDisposable {
  47966. /** The utility layer the gizmo will be added to */
  47967. gizmoLayer: UtilityLayerRenderer;
  47968. /**
  47969. * The root mesh of the gizmo
  47970. */
  47971. _rootMesh: Mesh;
  47972. private _attachedMesh;
  47973. /**
  47974. * Ratio for the scale of the gizmo (Default: 1)
  47975. */
  47976. scaleRatio: number;
  47977. /**
  47978. * If a custom mesh has been set (Default: false)
  47979. */
  47980. protected _customMeshSet: boolean;
  47981. /**
  47982. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  47983. * * When set, interactions will be enabled
  47984. */
  47985. get attachedMesh(): Nullable<AbstractMesh>;
  47986. set attachedMesh(value: Nullable<AbstractMesh>);
  47987. /**
  47988. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  47989. * @param mesh The mesh to replace the default mesh of the gizmo
  47990. */
  47991. setCustomMesh(mesh: Mesh): void;
  47992. /**
  47993. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  47994. */
  47995. updateGizmoRotationToMatchAttachedMesh: boolean;
  47996. /**
  47997. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  47998. */
  47999. updateGizmoPositionToMatchAttachedMesh: boolean;
  48000. /**
  48001. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  48002. */
  48003. updateScale: boolean;
  48004. protected _interactionsEnabled: boolean;
  48005. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  48006. private _beforeRenderObserver;
  48007. private _tempVector;
  48008. /**
  48009. * Creates a gizmo
  48010. * @param gizmoLayer The utility layer the gizmo will be added to
  48011. */
  48012. constructor(
  48013. /** The utility layer the gizmo will be added to */
  48014. gizmoLayer?: UtilityLayerRenderer);
  48015. /**
  48016. * Updates the gizmo to match the attached mesh's position/rotation
  48017. */
  48018. protected _update(): void;
  48019. /**
  48020. * Disposes of the gizmo
  48021. */
  48022. dispose(): void;
  48023. }
  48024. }
  48025. declare module "babylonjs/Gizmos/planeDragGizmo" {
  48026. import { Observable } from "babylonjs/Misc/observable";
  48027. import { Nullable } from "babylonjs/types";
  48028. import { Vector3 } from "babylonjs/Maths/math.vector";
  48029. import { Color3 } from "babylonjs/Maths/math.color";
  48030. import { TransformNode } from "babylonjs/Meshes/transformNode";
  48031. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48032. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  48033. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  48034. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  48035. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  48036. import { Scene } from "babylonjs/scene";
  48037. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  48038. /**
  48039. * Single plane drag gizmo
  48040. */
  48041. export class PlaneDragGizmo extends Gizmo {
  48042. /**
  48043. * Drag behavior responsible for the gizmos dragging interactions
  48044. */
  48045. dragBehavior: PointerDragBehavior;
  48046. private _pointerObserver;
  48047. /**
  48048. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  48049. */
  48050. snapDistance: number;
  48051. /**
  48052. * Event that fires each time the gizmo snaps to a new location.
  48053. * * snapDistance is the the change in distance
  48054. */
  48055. onSnapObservable: Observable<{
  48056. snapDistance: number;
  48057. }>;
  48058. private _plane;
  48059. private _coloredMaterial;
  48060. private _hoverMaterial;
  48061. private _isEnabled;
  48062. private _parent;
  48063. /** @hidden */
  48064. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  48065. /** @hidden */
  48066. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  48067. /**
  48068. * Creates a PlaneDragGizmo
  48069. * @param gizmoLayer The utility layer the gizmo will be added to
  48070. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  48071. * @param color The color of the gizmo
  48072. */
  48073. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  48074. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  48075. /**
  48076. * If the gizmo is enabled
  48077. */
  48078. set isEnabled(value: boolean);
  48079. get isEnabled(): boolean;
  48080. /**
  48081. * Disposes of the gizmo
  48082. */
  48083. dispose(): void;
  48084. }
  48085. }
  48086. declare module "babylonjs/Gizmos/positionGizmo" {
  48087. import { Observable } from "babylonjs/Misc/observable";
  48088. import { Nullable } from "babylonjs/types";
  48089. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48090. import { Mesh } from "babylonjs/Meshes/mesh";
  48091. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  48092. import { AxisDragGizmo } from "babylonjs/Gizmos/axisDragGizmo";
  48093. import { PlaneDragGizmo } from "babylonjs/Gizmos/planeDragGizmo";
  48094. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  48095. /**
  48096. * Gizmo that enables dragging a mesh along 3 axis
  48097. */
  48098. export class PositionGizmo extends Gizmo {
  48099. /**
  48100. * Internal gizmo used for interactions on the x axis
  48101. */
  48102. xGizmo: AxisDragGizmo;
  48103. /**
  48104. * Internal gizmo used for interactions on the y axis
  48105. */
  48106. yGizmo: AxisDragGizmo;
  48107. /**
  48108. * Internal gizmo used for interactions on the z axis
  48109. */
  48110. zGizmo: AxisDragGizmo;
  48111. /**
  48112. * Internal gizmo used for interactions on the yz plane
  48113. */
  48114. xPlaneGizmo: PlaneDragGizmo;
  48115. /**
  48116. * Internal gizmo used for interactions on the xz plane
  48117. */
  48118. yPlaneGizmo: PlaneDragGizmo;
  48119. /**
  48120. * Internal gizmo used for interactions on the xy plane
  48121. */
  48122. zPlaneGizmo: PlaneDragGizmo;
  48123. /**
  48124. * private variables
  48125. */
  48126. private _meshAttached;
  48127. private _updateGizmoRotationToMatchAttachedMesh;
  48128. private _snapDistance;
  48129. private _scaleRatio;
  48130. /** Fires an event when any of it's sub gizmos are dragged */
  48131. onDragStartObservable: Observable<unknown>;
  48132. /** Fires an event when any of it's sub gizmos are released from dragging */
  48133. onDragEndObservable: Observable<unknown>;
  48134. /**
  48135. * If set to true, planar drag is enabled
  48136. */
  48137. private _planarGizmoEnabled;
  48138. get attachedMesh(): Nullable<AbstractMesh>;
  48139. set attachedMesh(mesh: Nullable<AbstractMesh>);
  48140. /**
  48141. * Creates a PositionGizmo
  48142. * @param gizmoLayer The utility layer the gizmo will be added to
  48143. */
  48144. constructor(gizmoLayer?: UtilityLayerRenderer);
  48145. /**
  48146. * If the planar drag gizmo is enabled
  48147. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  48148. */
  48149. set planarGizmoEnabled(value: boolean);
  48150. get planarGizmoEnabled(): boolean;
  48151. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  48152. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  48153. /**
  48154. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  48155. */
  48156. set snapDistance(value: number);
  48157. get snapDistance(): number;
  48158. /**
  48159. * Ratio for the scale of the gizmo (Default: 1)
  48160. */
  48161. set scaleRatio(value: number);
  48162. get scaleRatio(): number;
  48163. /**
  48164. * Disposes of the gizmo
  48165. */
  48166. dispose(): void;
  48167. /**
  48168. * CustomMeshes are not supported by this gizmo
  48169. * @param mesh The mesh to replace the default mesh of the gizmo
  48170. */
  48171. setCustomMesh(mesh: Mesh): void;
  48172. }
  48173. }
  48174. declare module "babylonjs/Gizmos/axisDragGizmo" {
  48175. import { Observable } from "babylonjs/Misc/observable";
  48176. import { Nullable } from "babylonjs/types";
  48177. import { Vector3 } from "babylonjs/Maths/math.vector";
  48178. import { TransformNode } from "babylonjs/Meshes/transformNode";
  48179. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48180. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  48181. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  48182. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  48183. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  48184. import { Scene } from "babylonjs/scene";
  48185. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  48186. import { Color3 } from "babylonjs/Maths/math.color";
  48187. /**
  48188. * Single axis drag gizmo
  48189. */
  48190. export class AxisDragGizmo extends Gizmo {
  48191. /**
  48192. * Drag behavior responsible for the gizmos dragging interactions
  48193. */
  48194. dragBehavior: PointerDragBehavior;
  48195. private _pointerObserver;
  48196. /**
  48197. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  48198. */
  48199. snapDistance: number;
  48200. /**
  48201. * Event that fires each time the gizmo snaps to a new location.
  48202. * * snapDistance is the the change in distance
  48203. */
  48204. onSnapObservable: Observable<{
  48205. snapDistance: number;
  48206. }>;
  48207. private _isEnabled;
  48208. private _parent;
  48209. private _arrow;
  48210. private _coloredMaterial;
  48211. private _hoverMaterial;
  48212. /** @hidden */
  48213. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  48214. /** @hidden */
  48215. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  48216. /**
  48217. * Creates an AxisDragGizmo
  48218. * @param gizmoLayer The utility layer the gizmo will be added to
  48219. * @param dragAxis The axis which the gizmo will be able to drag on
  48220. * @param color The color of the gizmo
  48221. */
  48222. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  48223. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  48224. /**
  48225. * If the gizmo is enabled
  48226. */
  48227. set isEnabled(value: boolean);
  48228. get isEnabled(): boolean;
  48229. /**
  48230. * Disposes of the gizmo
  48231. */
  48232. dispose(): void;
  48233. }
  48234. }
  48235. declare module "babylonjs/Debug/axesViewer" {
  48236. import { Vector3 } from "babylonjs/Maths/math.vector";
  48237. import { Nullable } from "babylonjs/types";
  48238. import { Scene } from "babylonjs/scene";
  48239. import { TransformNode } from "babylonjs/Meshes/transformNode";
  48240. /**
  48241. * The Axes viewer will show 3 axes in a specific point in space
  48242. */
  48243. export class AxesViewer {
  48244. private _xAxis;
  48245. private _yAxis;
  48246. private _zAxis;
  48247. private _scaleLinesFactor;
  48248. private _instanced;
  48249. /**
  48250. * Gets the hosting scene
  48251. */
  48252. scene: Scene;
  48253. /**
  48254. * Gets or sets a number used to scale line length
  48255. */
  48256. scaleLines: number;
  48257. /** Gets the node hierarchy used to render x-axis */
  48258. get xAxis(): TransformNode;
  48259. /** Gets the node hierarchy used to render y-axis */
  48260. get yAxis(): TransformNode;
  48261. /** Gets the node hierarchy used to render z-axis */
  48262. get zAxis(): TransformNode;
  48263. /**
  48264. * Creates a new AxesViewer
  48265. * @param scene defines the hosting scene
  48266. * @param scaleLines defines a number used to scale line length (1 by default)
  48267. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  48268. * @param xAxis defines the node hierarchy used to render the x-axis
  48269. * @param yAxis defines the node hierarchy used to render the y-axis
  48270. * @param zAxis defines the node hierarchy used to render the z-axis
  48271. */
  48272. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  48273. /**
  48274. * Force the viewer to update
  48275. * @param position defines the position of the viewer
  48276. * @param xaxis defines the x axis of the viewer
  48277. * @param yaxis defines the y axis of the viewer
  48278. * @param zaxis defines the z axis of the viewer
  48279. */
  48280. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  48281. /**
  48282. * Creates an instance of this axes viewer.
  48283. * @returns a new axes viewer with instanced meshes
  48284. */
  48285. createInstance(): AxesViewer;
  48286. /** Releases resources */
  48287. dispose(): void;
  48288. private static _SetRenderingGroupId;
  48289. }
  48290. }
  48291. declare module "babylonjs/Debug/boneAxesViewer" {
  48292. import { Nullable } from "babylonjs/types";
  48293. import { AxesViewer } from "babylonjs/Debug/axesViewer";
  48294. import { Vector3 } from "babylonjs/Maths/math.vector";
  48295. import { Mesh } from "babylonjs/Meshes/mesh";
  48296. import { Bone } from "babylonjs/Bones/bone";
  48297. import { Scene } from "babylonjs/scene";
  48298. /**
  48299. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  48300. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  48301. */
  48302. export class BoneAxesViewer extends AxesViewer {
  48303. /**
  48304. * Gets or sets the target mesh where to display the axes viewer
  48305. */
  48306. mesh: Nullable<Mesh>;
  48307. /**
  48308. * Gets or sets the target bone where to display the axes viewer
  48309. */
  48310. bone: Nullable<Bone>;
  48311. /** Gets current position */
  48312. pos: Vector3;
  48313. /** Gets direction of X axis */
  48314. xaxis: Vector3;
  48315. /** Gets direction of Y axis */
  48316. yaxis: Vector3;
  48317. /** Gets direction of Z axis */
  48318. zaxis: Vector3;
  48319. /**
  48320. * Creates a new BoneAxesViewer
  48321. * @param scene defines the hosting scene
  48322. * @param bone defines the target bone
  48323. * @param mesh defines the target mesh
  48324. * @param scaleLines defines a scaling factor for line length (1 by default)
  48325. */
  48326. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  48327. /**
  48328. * Force the viewer to update
  48329. */
  48330. update(): void;
  48331. /** Releases resources */
  48332. dispose(): void;
  48333. }
  48334. }
  48335. declare module "babylonjs/Debug/debugLayer" {
  48336. import { Scene } from "babylonjs/scene";
  48337. /**
  48338. * Interface used to define scene explorer extensibility option
  48339. */
  48340. export interface IExplorerExtensibilityOption {
  48341. /**
  48342. * Define the option label
  48343. */
  48344. label: string;
  48345. /**
  48346. * Defines the action to execute on click
  48347. */
  48348. action: (entity: any) => void;
  48349. }
  48350. /**
  48351. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  48352. */
  48353. export interface IExplorerExtensibilityGroup {
  48354. /**
  48355. * Defines a predicate to test if a given type mut be extended
  48356. */
  48357. predicate: (entity: any) => boolean;
  48358. /**
  48359. * Gets the list of options added to a type
  48360. */
  48361. entries: IExplorerExtensibilityOption[];
  48362. }
  48363. /**
  48364. * Interface used to define the options to use to create the Inspector
  48365. */
  48366. export interface IInspectorOptions {
  48367. /**
  48368. * Display in overlay mode (default: false)
  48369. */
  48370. overlay?: boolean;
  48371. /**
  48372. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  48373. */
  48374. globalRoot?: HTMLElement;
  48375. /**
  48376. * Display the Scene explorer
  48377. */
  48378. showExplorer?: boolean;
  48379. /**
  48380. * Display the property inspector
  48381. */
  48382. showInspector?: boolean;
  48383. /**
  48384. * Display in embed mode (both panes on the right)
  48385. */
  48386. embedMode?: boolean;
  48387. /**
  48388. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  48389. */
  48390. handleResize?: boolean;
  48391. /**
  48392. * Allow the panes to popup (default: true)
  48393. */
  48394. enablePopup?: boolean;
  48395. /**
  48396. * Allow the panes to be closed by users (default: true)
  48397. */
  48398. enableClose?: boolean;
  48399. /**
  48400. * Optional list of extensibility entries
  48401. */
  48402. explorerExtensibility?: IExplorerExtensibilityGroup[];
  48403. /**
  48404. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  48405. */
  48406. inspectorURL?: string;
  48407. /**
  48408. * Optional initial tab (default to DebugLayerTab.Properties)
  48409. */
  48410. initialTab?: DebugLayerTab;
  48411. }
  48412. module "babylonjs/scene" {
  48413. interface Scene {
  48414. /**
  48415. * @hidden
  48416. * Backing field
  48417. */
  48418. _debugLayer: DebugLayer;
  48419. /**
  48420. * Gets the debug layer (aka Inspector) associated with the scene
  48421. * @see http://doc.babylonjs.com/features/playground_debuglayer
  48422. */
  48423. debugLayer: DebugLayer;
  48424. }
  48425. }
  48426. /**
  48427. * Enum of inspector action tab
  48428. */
  48429. export enum DebugLayerTab {
  48430. /**
  48431. * Properties tag (default)
  48432. */
  48433. Properties = 0,
  48434. /**
  48435. * Debug tab
  48436. */
  48437. Debug = 1,
  48438. /**
  48439. * Statistics tab
  48440. */
  48441. Statistics = 2,
  48442. /**
  48443. * Tools tab
  48444. */
  48445. Tools = 3,
  48446. /**
  48447. * Settings tab
  48448. */
  48449. Settings = 4
  48450. }
  48451. /**
  48452. * The debug layer (aka Inspector) is the go to tool in order to better understand
  48453. * what is happening in your scene
  48454. * @see http://doc.babylonjs.com/features/playground_debuglayer
  48455. */
  48456. export class DebugLayer {
  48457. /**
  48458. * Define the url to get the inspector script from.
  48459. * By default it uses the babylonjs CDN.
  48460. * @ignoreNaming
  48461. */
  48462. static InspectorURL: string;
  48463. private _scene;
  48464. private BJSINSPECTOR;
  48465. private _onPropertyChangedObservable?;
  48466. /**
  48467. * Observable triggered when a property is changed through the inspector.
  48468. */
  48469. get onPropertyChangedObservable(): any;
  48470. /**
  48471. * Instantiates a new debug layer.
  48472. * The debug layer (aka Inspector) is the go to tool in order to better understand
  48473. * what is happening in your scene
  48474. * @see http://doc.babylonjs.com/features/playground_debuglayer
  48475. * @param scene Defines the scene to inspect
  48476. */
  48477. constructor(scene: Scene);
  48478. /** Creates the inspector window. */
  48479. private _createInspector;
  48480. /**
  48481. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  48482. * @param entity defines the entity to select
  48483. * @param lineContainerTitle defines the specific block to highlight
  48484. */
  48485. select(entity: any, lineContainerTitle?: string): void;
  48486. /** Get the inspector from bundle or global */
  48487. private _getGlobalInspector;
  48488. /**
  48489. * Get if the inspector is visible or not.
  48490. * @returns true if visible otherwise, false
  48491. */
  48492. isVisible(): boolean;
  48493. /**
  48494. * Hide the inspector and close its window.
  48495. */
  48496. hide(): void;
  48497. /**
  48498. * Launch the debugLayer.
  48499. * @param config Define the configuration of the inspector
  48500. * @return a promise fulfilled when the debug layer is visible
  48501. */
  48502. show(config?: IInspectorOptions): Promise<DebugLayer>;
  48503. }
  48504. }
  48505. declare module "babylonjs/Meshes/Builders/boxBuilder" {
  48506. import { Nullable } from "babylonjs/types";
  48507. import { Scene } from "babylonjs/scene";
  48508. import { Vector4 } from "babylonjs/Maths/math.vector";
  48509. import { Color4 } from "babylonjs/Maths/math.color";
  48510. import { Mesh } from "babylonjs/Meshes/mesh";
  48511. /**
  48512. * Class containing static functions to help procedurally build meshes
  48513. */
  48514. export class BoxBuilder {
  48515. /**
  48516. * Creates a box mesh
  48517. * * The parameter `size` sets the size (float) of each box side (default 1)
  48518. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  48519. * * 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)
  48520. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  48521. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  48522. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  48523. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  48524. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  48525. * @param name defines the name of the mesh
  48526. * @param options defines the options used to create the mesh
  48527. * @param scene defines the hosting scene
  48528. * @returns the box mesh
  48529. */
  48530. static CreateBox(name: string, options: {
  48531. size?: number;
  48532. width?: number;
  48533. height?: number;
  48534. depth?: number;
  48535. faceUV?: Vector4[];
  48536. faceColors?: Color4[];
  48537. sideOrientation?: number;
  48538. frontUVs?: Vector4;
  48539. backUVs?: Vector4;
  48540. wrap?: boolean;
  48541. topBaseAt?: number;
  48542. bottomBaseAt?: number;
  48543. updatable?: boolean;
  48544. }, scene?: Nullable<Scene>): Mesh;
  48545. }
  48546. }
  48547. declare module "babylonjs/Debug/physicsViewer" {
  48548. import { Nullable } from "babylonjs/types";
  48549. import { Scene } from "babylonjs/scene";
  48550. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48551. import { Mesh } from "babylonjs/Meshes/mesh";
  48552. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  48553. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  48554. /**
  48555. * Used to show the physics impostor around the specific mesh
  48556. */
  48557. export class PhysicsViewer {
  48558. /** @hidden */
  48559. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  48560. /** @hidden */
  48561. protected _meshes: Array<Nullable<AbstractMesh>>;
  48562. /** @hidden */
  48563. protected _scene: Nullable<Scene>;
  48564. /** @hidden */
  48565. protected _numMeshes: number;
  48566. /** @hidden */
  48567. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  48568. private _renderFunction;
  48569. private _utilityLayer;
  48570. private _debugBoxMesh;
  48571. private _debugSphereMesh;
  48572. private _debugCylinderMesh;
  48573. private _debugMaterial;
  48574. private _debugMeshMeshes;
  48575. /**
  48576. * Creates a new PhysicsViewer
  48577. * @param scene defines the hosting scene
  48578. */
  48579. constructor(scene: Scene);
  48580. /** @hidden */
  48581. protected _updateDebugMeshes(): void;
  48582. /**
  48583. * Renders a specified physic impostor
  48584. * @param impostor defines the impostor to render
  48585. * @param targetMesh defines the mesh represented by the impostor
  48586. * @returns the new debug mesh used to render the impostor
  48587. */
  48588. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  48589. /**
  48590. * Hides a specified physic impostor
  48591. * @param impostor defines the impostor to hide
  48592. */
  48593. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  48594. private _getDebugMaterial;
  48595. private _getDebugBoxMesh;
  48596. private _getDebugSphereMesh;
  48597. private _getDebugCylinderMesh;
  48598. private _getDebugMeshMesh;
  48599. private _getDebugMesh;
  48600. /** Releases all resources */
  48601. dispose(): void;
  48602. }
  48603. }
  48604. declare module "babylonjs/Debug/rayHelper" {
  48605. import { Nullable } from "babylonjs/types";
  48606. import { Ray } from "babylonjs/Culling/ray";
  48607. import { Vector3 } from "babylonjs/Maths/math.vector";
  48608. import { Color3 } from "babylonjs/Maths/math.color";
  48609. import { Scene } from "babylonjs/scene";
  48610. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48611. import "babylonjs/Meshes/Builders/linesBuilder";
  48612. /**
  48613. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  48614. * in order to better appreciate the issue one might have.
  48615. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  48616. */
  48617. export class RayHelper {
  48618. /**
  48619. * Defines the ray we are currently tryin to visualize.
  48620. */
  48621. ray: Nullable<Ray>;
  48622. private _renderPoints;
  48623. private _renderLine;
  48624. private _renderFunction;
  48625. private _scene;
  48626. private _updateToMeshFunction;
  48627. private _attachedToMesh;
  48628. private _meshSpaceDirection;
  48629. private _meshSpaceOrigin;
  48630. /**
  48631. * Helper function to create a colored helper in a scene in one line.
  48632. * @param ray Defines the ray we are currently tryin to visualize
  48633. * @param scene Defines the scene the ray is used in
  48634. * @param color Defines the color we want to see the ray in
  48635. * @returns The newly created ray helper.
  48636. */
  48637. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  48638. /**
  48639. * Instantiate a new ray helper.
  48640. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  48641. * in order to better appreciate the issue one might have.
  48642. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  48643. * @param ray Defines the ray we are currently tryin to visualize
  48644. */
  48645. constructor(ray: Ray);
  48646. /**
  48647. * Shows the ray we are willing to debug.
  48648. * @param scene Defines the scene the ray needs to be rendered in
  48649. * @param color Defines the color the ray needs to be rendered in
  48650. */
  48651. show(scene: Scene, color?: Color3): void;
  48652. /**
  48653. * Hides the ray we are debugging.
  48654. */
  48655. hide(): void;
  48656. private _render;
  48657. /**
  48658. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  48659. * @param mesh Defines the mesh we want the helper attached to
  48660. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  48661. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  48662. * @param length Defines the length of the ray
  48663. */
  48664. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  48665. /**
  48666. * Detach the ray helper from the mesh it has previously been attached to.
  48667. */
  48668. detachFromMesh(): void;
  48669. private _updateToMesh;
  48670. /**
  48671. * Dispose the helper and release its associated resources.
  48672. */
  48673. dispose(): void;
  48674. }
  48675. }
  48676. declare module "babylonjs/Debug/skeletonViewer" {
  48677. import { Color3 } from "babylonjs/Maths/math.color";
  48678. import { Scene } from "babylonjs/scene";
  48679. import { Nullable } from "babylonjs/types";
  48680. import { Skeleton } from "babylonjs/Bones/skeleton";
  48681. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48682. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  48683. /**
  48684. * Class used to render a debug view of a given skeleton
  48685. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  48686. */
  48687. export class SkeletonViewer {
  48688. /** defines the skeleton to render */
  48689. skeleton: Skeleton;
  48690. /** defines the mesh attached to the skeleton */
  48691. mesh: AbstractMesh;
  48692. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  48693. autoUpdateBonesMatrices: boolean;
  48694. /** defines the rendering group id to use with the viewer */
  48695. renderingGroupId: number;
  48696. /** Gets or sets the color used to render the skeleton */
  48697. color: Color3;
  48698. private _scene;
  48699. private _debugLines;
  48700. private _debugMesh;
  48701. private _isEnabled;
  48702. private _renderFunction;
  48703. private _utilityLayer;
  48704. /**
  48705. * Returns the mesh used to render the bones
  48706. */
  48707. get debugMesh(): Nullable<LinesMesh>;
  48708. /**
  48709. * Creates a new SkeletonViewer
  48710. * @param skeleton defines the skeleton to render
  48711. * @param mesh defines the mesh attached to the skeleton
  48712. * @param scene defines the hosting scene
  48713. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  48714. * @param renderingGroupId defines the rendering group id to use with the viewer
  48715. */
  48716. constructor(
  48717. /** defines the skeleton to render */
  48718. skeleton: Skeleton,
  48719. /** defines the mesh attached to the skeleton */
  48720. mesh: AbstractMesh, scene: Scene,
  48721. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  48722. autoUpdateBonesMatrices?: boolean,
  48723. /** defines the rendering group id to use with the viewer */
  48724. renderingGroupId?: number);
  48725. /** Gets or sets a boolean indicating if the viewer is enabled */
  48726. set isEnabled(value: boolean);
  48727. get isEnabled(): boolean;
  48728. private _getBonePosition;
  48729. private _getLinesForBonesWithLength;
  48730. private _getLinesForBonesNoLength;
  48731. /** Update the viewer to sync with current skeleton state */
  48732. update(): void;
  48733. /** Release associated resources */
  48734. dispose(): void;
  48735. }
  48736. }
  48737. declare module "babylonjs/Debug/index" {
  48738. export * from "babylonjs/Debug/axesViewer";
  48739. export * from "babylonjs/Debug/boneAxesViewer";
  48740. export * from "babylonjs/Debug/debugLayer";
  48741. export * from "babylonjs/Debug/physicsViewer";
  48742. export * from "babylonjs/Debug/rayHelper";
  48743. export * from "babylonjs/Debug/skeletonViewer";
  48744. }
  48745. declare module "babylonjs/DeviceInput/deviceInputSystem" {
  48746. import { Observable } from "babylonjs/Misc/observable";
  48747. import { Engine } from "babylonjs/Engines/engine";
  48748. import { IDisposable } from "babylonjs/scene";
  48749. import { Nullable } from "babylonjs/types";
  48750. /**
  48751. * This class will take all inputs from Keyboard, Pointer, and
  48752. * any Gamepads and provide a polling system that all devices
  48753. * will use. This class assumes that there will only be one
  48754. * pointer device and one keyboard.
  48755. */
  48756. export class DeviceInputSystem implements IDisposable {
  48757. /** POINTER_DEVICE */
  48758. static readonly POINTER_DEVICE: string;
  48759. /** KEYBOARD_DEVICE */
  48760. static readonly KEYBOARD_DEVICE: string;
  48761. /**
  48762. * Observable to be triggered when a device is connected
  48763. */
  48764. onDeviceConnectedObservable: Observable<string>;
  48765. /**
  48766. * Observable to be triggered when a device is disconnected
  48767. */
  48768. onDeviceDisconnectedObservable: Observable<string>;
  48769. private _inputs;
  48770. private _gamepads;
  48771. private _keyboardActive;
  48772. private _pointerActive;
  48773. private _elementToAttachTo;
  48774. private _keyboardDownEvent;
  48775. private _keyboardUpEvent;
  48776. private _pointerMoveEvent;
  48777. private _pointerDownEvent;
  48778. private _pointerUpEvent;
  48779. private _gamepadConnectedEvent;
  48780. private _gamepadDisconnectedEvent;
  48781. private static _MAX_KEYCODES;
  48782. private static _MAX_POINTER_INPUTS;
  48783. /**
  48784. * Default Constructor
  48785. * @param engine - engine to pull input element from
  48786. */
  48787. constructor(engine: Engine);
  48788. /**
  48789. * Checks for current device input value, given an id and input index
  48790. * @param deviceName Id of connected device
  48791. * @param inputIndex Index of device input
  48792. * @returns Current value of input
  48793. */
  48794. pollInput(deviceName: string, inputIndex: number): Nullable<number>;
  48795. /**
  48796. * Dispose of all the eventlisteners and clears the observables
  48797. */
  48798. dispose(): void;
  48799. /**
  48800. * Add device and inputs to device map
  48801. * @param deviceName Assigned name of device (may be SN)
  48802. * @param numberOfInputs Number of input entries to create for given device
  48803. */
  48804. private _registerDevice;
  48805. /**
  48806. * Given a specific device name, remove that device from the device map
  48807. * @param deviceName Name of device to be removed
  48808. */
  48809. private _unregisterDevice;
  48810. /**
  48811. * Handle all actions that come from keyboard interaction
  48812. */
  48813. private _handleKeyActions;
  48814. /**
  48815. * Handle all actions that come from pointer interaction
  48816. */
  48817. private _handlePointerActions;
  48818. /**
  48819. * Handle all actions that come from gamepad interaction
  48820. */
  48821. private _handleGamepadActions;
  48822. /**
  48823. * Update all non-event based devices with each frame
  48824. */
  48825. private _updateDevice;
  48826. }
  48827. }
  48828. declare module "babylonjs/DeviceInput/index" {
  48829. export * from "babylonjs/DeviceInput/deviceInputSystem";
  48830. }
  48831. declare module "babylonjs/Engines/nullEngine" {
  48832. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  48833. import { Engine } from "babylonjs/Engines/engine";
  48834. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  48835. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  48836. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48837. import { Effect } from "babylonjs/Materials/effect";
  48838. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  48839. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  48840. import { IColor4Like, IViewportLike } from "babylonjs/Maths/math.like";
  48841. import { ISceneLike } from "babylonjs/Engines/thinEngine";
  48842. /**
  48843. * Options to create the null engine
  48844. */
  48845. export class NullEngineOptions {
  48846. /**
  48847. * Render width (Default: 512)
  48848. */
  48849. renderWidth: number;
  48850. /**
  48851. * Render height (Default: 256)
  48852. */
  48853. renderHeight: number;
  48854. /**
  48855. * Texture size (Default: 512)
  48856. */
  48857. textureSize: number;
  48858. /**
  48859. * If delta time between frames should be constant
  48860. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  48861. */
  48862. deterministicLockstep: boolean;
  48863. /**
  48864. * Maximum about of steps between frames (Default: 4)
  48865. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  48866. */
  48867. lockstepMaxSteps: number;
  48868. }
  48869. /**
  48870. * The null engine class provides support for headless version of babylon.js.
  48871. * This can be used in server side scenario or for testing purposes
  48872. */
  48873. export class NullEngine extends Engine {
  48874. private _options;
  48875. /**
  48876. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  48877. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  48878. * @returns true if engine is in deterministic lock step mode
  48879. */
  48880. isDeterministicLockStep(): boolean;
  48881. /**
  48882. * Gets the max steps when engine is running in deterministic lock step
  48883. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  48884. * @returns the max steps
  48885. */
  48886. getLockstepMaxSteps(): number;
  48887. /**
  48888. * Gets the current hardware scaling level.
  48889. * By default the hardware scaling level is computed from the window device ratio.
  48890. * 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.
  48891. * @returns a number indicating the current hardware scaling level
  48892. */
  48893. getHardwareScalingLevel(): number;
  48894. constructor(options?: NullEngineOptions);
  48895. /**
  48896. * Creates a vertex buffer
  48897. * @param vertices the data for the vertex buffer
  48898. * @returns the new WebGL static buffer
  48899. */
  48900. createVertexBuffer(vertices: FloatArray): DataBuffer;
  48901. /**
  48902. * Creates a new index buffer
  48903. * @param indices defines the content of the index buffer
  48904. * @param updatable defines if the index buffer must be updatable
  48905. * @returns a new webGL buffer
  48906. */
  48907. createIndexBuffer(indices: IndicesArray): DataBuffer;
  48908. /**
  48909. * Clear the current render buffer or the current render target (if any is set up)
  48910. * @param color defines the color to use
  48911. * @param backBuffer defines if the back buffer must be cleared
  48912. * @param depth defines if the depth buffer must be cleared
  48913. * @param stencil defines if the stencil buffer must be cleared
  48914. */
  48915. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  48916. /**
  48917. * Gets the current render width
  48918. * @param useScreen defines if screen size must be used (or the current render target if any)
  48919. * @returns a number defining the current render width
  48920. */
  48921. getRenderWidth(useScreen?: boolean): number;
  48922. /**
  48923. * Gets the current render height
  48924. * @param useScreen defines if screen size must be used (or the current render target if any)
  48925. * @returns a number defining the current render height
  48926. */
  48927. getRenderHeight(useScreen?: boolean): number;
  48928. /**
  48929. * Set the WebGL's viewport
  48930. * @param viewport defines the viewport element to be used
  48931. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  48932. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  48933. */
  48934. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  48935. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  48936. /**
  48937. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  48938. * @param pipelineContext defines the pipeline context to use
  48939. * @param uniformsNames defines the list of uniform names
  48940. * @returns an array of webGL uniform locations
  48941. */
  48942. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  48943. /**
  48944. * Gets the lsit of active attributes for a given webGL program
  48945. * @param pipelineContext defines the pipeline context to use
  48946. * @param attributesNames defines the list of attribute names to get
  48947. * @returns an array of indices indicating the offset of each attribute
  48948. */
  48949. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  48950. /**
  48951. * Binds an effect to the webGL context
  48952. * @param effect defines the effect to bind
  48953. */
  48954. bindSamplers(effect: Effect): void;
  48955. /**
  48956. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  48957. * @param effect defines the effect to activate
  48958. */
  48959. enableEffect(effect: Effect): void;
  48960. /**
  48961. * Set various states to the webGL context
  48962. * @param culling defines backface culling state
  48963. * @param zOffset defines the value to apply to zOffset (0 by default)
  48964. * @param force defines if states must be applied even if cache is up to date
  48965. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  48966. */
  48967. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  48968. /**
  48969. * Set the value of an uniform to an array of int32
  48970. * @param uniform defines the webGL uniform location where to store the value
  48971. * @param array defines the array of int32 to store
  48972. */
  48973. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  48974. /**
  48975. * Set the value of an uniform to an array of int32 (stored as vec2)
  48976. * @param uniform defines the webGL uniform location where to store the value
  48977. * @param array defines the array of int32 to store
  48978. */
  48979. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  48980. /**
  48981. * Set the value of an uniform to an array of int32 (stored as vec3)
  48982. * @param uniform defines the webGL uniform location where to store the value
  48983. * @param array defines the array of int32 to store
  48984. */
  48985. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  48986. /**
  48987. * Set the value of an uniform to an array of int32 (stored as vec4)
  48988. * @param uniform defines the webGL uniform location where to store the value
  48989. * @param array defines the array of int32 to store
  48990. */
  48991. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  48992. /**
  48993. * Set the value of an uniform to an array of float32
  48994. * @param uniform defines the webGL uniform location where to store the value
  48995. * @param array defines the array of float32 to store
  48996. */
  48997. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  48998. /**
  48999. * Set the value of an uniform to an array of float32 (stored as vec2)
  49000. * @param uniform defines the webGL uniform location where to store the value
  49001. * @param array defines the array of float32 to store
  49002. */
  49003. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  49004. /**
  49005. * Set the value of an uniform to an array of float32 (stored as vec3)
  49006. * @param uniform defines the webGL uniform location where to store the value
  49007. * @param array defines the array of float32 to store
  49008. */
  49009. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  49010. /**
  49011. * Set the value of an uniform to an array of float32 (stored as vec4)
  49012. * @param uniform defines the webGL uniform location where to store the value
  49013. * @param array defines the array of float32 to store
  49014. */
  49015. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  49016. /**
  49017. * Set the value of an uniform to an array of number
  49018. * @param uniform defines the webGL uniform location where to store the value
  49019. * @param array defines the array of number to store
  49020. */
  49021. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  49022. /**
  49023. * Set the value of an uniform to an array of number (stored as vec2)
  49024. * @param uniform defines the webGL uniform location where to store the value
  49025. * @param array defines the array of number to store
  49026. */
  49027. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  49028. /**
  49029. * Set the value of an uniform to an array of number (stored as vec3)
  49030. * @param uniform defines the webGL uniform location where to store the value
  49031. * @param array defines the array of number to store
  49032. */
  49033. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  49034. /**
  49035. * Set the value of an uniform to an array of number (stored as vec4)
  49036. * @param uniform defines the webGL uniform location where to store the value
  49037. * @param array defines the array of number to store
  49038. */
  49039. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  49040. /**
  49041. * Set the value of an uniform to an array of float32 (stored as matrices)
  49042. * @param uniform defines the webGL uniform location where to store the value
  49043. * @param matrices defines the array of float32 to store
  49044. */
  49045. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  49046. /**
  49047. * Set the value of an uniform to a matrix (3x3)
  49048. * @param uniform defines the webGL uniform location where to store the value
  49049. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  49050. */
  49051. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  49052. /**
  49053. * Set the value of an uniform to a matrix (2x2)
  49054. * @param uniform defines the webGL uniform location where to store the value
  49055. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  49056. */
  49057. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  49058. /**
  49059. * Set the value of an uniform to a number (float)
  49060. * @param uniform defines the webGL uniform location where to store the value
  49061. * @param value defines the float number to store
  49062. */
  49063. setFloat(uniform: WebGLUniformLocation, value: number): void;
  49064. /**
  49065. * Set the value of an uniform to a vec2
  49066. * @param uniform defines the webGL uniform location where to store the value
  49067. * @param x defines the 1st component of the value
  49068. * @param y defines the 2nd component of the value
  49069. */
  49070. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  49071. /**
  49072. * Set the value of an uniform to a vec3
  49073. * @param uniform defines the webGL uniform location where to store the value
  49074. * @param x defines the 1st component of the value
  49075. * @param y defines the 2nd component of the value
  49076. * @param z defines the 3rd component of the value
  49077. */
  49078. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  49079. /**
  49080. * Set the value of an uniform to a boolean
  49081. * @param uniform defines the webGL uniform location where to store the value
  49082. * @param bool defines the boolean to store
  49083. */
  49084. setBool(uniform: WebGLUniformLocation, bool: number): void;
  49085. /**
  49086. * Set the value of an uniform to a vec4
  49087. * @param uniform defines the webGL uniform location where to store the value
  49088. * @param x defines the 1st component of the value
  49089. * @param y defines the 2nd component of the value
  49090. * @param z defines the 3rd component of the value
  49091. * @param w defines the 4th component of the value
  49092. */
  49093. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  49094. /**
  49095. * Sets the current alpha mode
  49096. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  49097. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  49098. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  49099. */
  49100. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  49101. /**
  49102. * Bind webGl buffers directly to the webGL context
  49103. * @param vertexBuffers defines the vertex buffer to bind
  49104. * @param indexBuffer defines the index buffer to bind
  49105. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  49106. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  49107. * @param effect defines the effect associated with the vertex buffer
  49108. */
  49109. bindBuffers(vertexBuffers: {
  49110. [key: string]: VertexBuffer;
  49111. }, indexBuffer: DataBuffer, effect: Effect): void;
  49112. /**
  49113. * Force the entire cache to be cleared
  49114. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  49115. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  49116. */
  49117. wipeCaches(bruteForce?: boolean): void;
  49118. /**
  49119. * Send a draw order
  49120. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  49121. * @param indexStart defines the starting index
  49122. * @param indexCount defines the number of index to draw
  49123. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  49124. */
  49125. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  49126. /**
  49127. * Draw a list of indexed primitives
  49128. * @param fillMode defines the primitive to use
  49129. * @param indexStart defines the starting index
  49130. * @param indexCount defines the number of index to draw
  49131. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  49132. */
  49133. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  49134. /**
  49135. * Draw a list of unindexed primitives
  49136. * @param fillMode defines the primitive to use
  49137. * @param verticesStart defines the index of first vertex to draw
  49138. * @param verticesCount defines the count of vertices to draw
  49139. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  49140. */
  49141. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  49142. /** @hidden */
  49143. _createTexture(): WebGLTexture;
  49144. /** @hidden */
  49145. _releaseTexture(texture: InternalTexture): void;
  49146. /**
  49147. * Usually called from Texture.ts.
  49148. * Passed information to create a WebGLTexture
  49149. * @param urlArg defines a value which contains one of the following:
  49150. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  49151. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  49152. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  49153. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  49154. * @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)
  49155. * @param scene needed for loading to the correct scene
  49156. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  49157. * @param onLoad optional callback to be called upon successful completion
  49158. * @param onError optional callback to be called upon failure
  49159. * @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
  49160. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  49161. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  49162. * @param forcedExtension defines the extension to use to pick the right loader
  49163. * @param mimeType defines an optional mime type
  49164. * @returns a InternalTexture for assignment back into BABYLON.Texture
  49165. */
  49166. 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;
  49167. /**
  49168. * Creates a new render target texture
  49169. * @param size defines the size of the texture
  49170. * @param options defines the options used to create the texture
  49171. * @returns a new render target texture stored in an InternalTexture
  49172. */
  49173. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  49174. /**
  49175. * Update the sampling mode of a given texture
  49176. * @param samplingMode defines the required sampling mode
  49177. * @param texture defines the texture to update
  49178. */
  49179. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  49180. /**
  49181. * Binds the frame buffer to the specified texture.
  49182. * @param texture The texture to render to or null for the default canvas
  49183. * @param faceIndex The face of the texture to render to in case of cube texture
  49184. * @param requiredWidth The width of the target to render to
  49185. * @param requiredHeight The height of the target to render to
  49186. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  49187. * @param lodLevel defines le lod level to bind to the frame buffer
  49188. */
  49189. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  49190. /**
  49191. * Unbind the current render target texture from the webGL context
  49192. * @param texture defines the render target texture to unbind
  49193. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  49194. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  49195. */
  49196. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  49197. /**
  49198. * Creates a dynamic vertex buffer
  49199. * @param vertices the data for the dynamic vertex buffer
  49200. * @returns the new WebGL dynamic buffer
  49201. */
  49202. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  49203. /**
  49204. * Update the content of a dynamic texture
  49205. * @param texture defines the texture to update
  49206. * @param canvas defines the canvas containing the source
  49207. * @param invertY defines if data must be stored with Y axis inverted
  49208. * @param premulAlpha defines if alpha is stored as premultiplied
  49209. * @param format defines the format of the data
  49210. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  49211. */
  49212. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  49213. /**
  49214. * Gets a boolean indicating if all created effects are ready
  49215. * @returns true if all effects are ready
  49216. */
  49217. areAllEffectsReady(): boolean;
  49218. /**
  49219. * @hidden
  49220. * Get the current error code of the webGL context
  49221. * @returns the error code
  49222. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  49223. */
  49224. getError(): number;
  49225. /** @hidden */
  49226. _getUnpackAlignement(): number;
  49227. /** @hidden */
  49228. _unpackFlipY(value: boolean): void;
  49229. /**
  49230. * Update a dynamic index buffer
  49231. * @param indexBuffer defines the target index buffer
  49232. * @param indices defines the data to update
  49233. * @param offset defines the offset in the target index buffer where update should start
  49234. */
  49235. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  49236. /**
  49237. * Updates a dynamic vertex buffer.
  49238. * @param vertexBuffer the vertex buffer to update
  49239. * @param vertices the data used to update the vertex buffer
  49240. * @param byteOffset the byte offset of the data (optional)
  49241. * @param byteLength the byte length of the data (optional)
  49242. */
  49243. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  49244. /** @hidden */
  49245. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  49246. /** @hidden */
  49247. _bindTexture(channel: number, texture: InternalTexture): void;
  49248. protected _deleteBuffer(buffer: WebGLBuffer): void;
  49249. /**
  49250. * 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
  49251. */
  49252. releaseEffects(): void;
  49253. displayLoadingUI(): void;
  49254. hideLoadingUI(): void;
  49255. /** @hidden */
  49256. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  49257. /** @hidden */
  49258. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  49259. /** @hidden */
  49260. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  49261. /** @hidden */
  49262. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  49263. }
  49264. }
  49265. declare module "babylonjs/Instrumentation/timeToken" {
  49266. import { Nullable } from "babylonjs/types";
  49267. /**
  49268. * @hidden
  49269. **/
  49270. export class _TimeToken {
  49271. _startTimeQuery: Nullable<WebGLQuery>;
  49272. _endTimeQuery: Nullable<WebGLQuery>;
  49273. _timeElapsedQuery: Nullable<WebGLQuery>;
  49274. _timeElapsedQueryEnded: boolean;
  49275. }
  49276. }
  49277. declare module "babylonjs/Engines/Extensions/engine.occlusionQuery" {
  49278. import { Nullable, int } from "babylonjs/types";
  49279. import { _TimeToken } from "babylonjs/Instrumentation/timeToken";
  49280. /** @hidden */
  49281. export class _OcclusionDataStorage {
  49282. /** @hidden */
  49283. occlusionInternalRetryCounter: number;
  49284. /** @hidden */
  49285. isOcclusionQueryInProgress: boolean;
  49286. /** @hidden */
  49287. isOccluded: boolean;
  49288. /** @hidden */
  49289. occlusionRetryCount: number;
  49290. /** @hidden */
  49291. occlusionType: number;
  49292. /** @hidden */
  49293. occlusionQueryAlgorithmType: number;
  49294. }
  49295. module "babylonjs/Engines/engine" {
  49296. interface Engine {
  49297. /**
  49298. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  49299. * @return the new query
  49300. */
  49301. createQuery(): WebGLQuery;
  49302. /**
  49303. * Delete and release a webGL query
  49304. * @param query defines the query to delete
  49305. * @return the current engine
  49306. */
  49307. deleteQuery(query: WebGLQuery): Engine;
  49308. /**
  49309. * Check if a given query has resolved and got its value
  49310. * @param query defines the query to check
  49311. * @returns true if the query got its value
  49312. */
  49313. isQueryResultAvailable(query: WebGLQuery): boolean;
  49314. /**
  49315. * Gets the value of a given query
  49316. * @param query defines the query to check
  49317. * @returns the value of the query
  49318. */
  49319. getQueryResult(query: WebGLQuery): number;
  49320. /**
  49321. * Initiates an occlusion query
  49322. * @param algorithmType defines the algorithm to use
  49323. * @param query defines the query to use
  49324. * @returns the current engine
  49325. * @see http://doc.babylonjs.com/features/occlusionquery
  49326. */
  49327. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  49328. /**
  49329. * Ends an occlusion query
  49330. * @see http://doc.babylonjs.com/features/occlusionquery
  49331. * @param algorithmType defines the algorithm to use
  49332. * @returns the current engine
  49333. */
  49334. endOcclusionQuery(algorithmType: number): Engine;
  49335. /**
  49336. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  49337. * Please note that only one query can be issued at a time
  49338. * @returns a time token used to track the time span
  49339. */
  49340. startTimeQuery(): Nullable<_TimeToken>;
  49341. /**
  49342. * Ends a time query
  49343. * @param token defines the token used to measure the time span
  49344. * @returns the time spent (in ns)
  49345. */
  49346. endTimeQuery(token: _TimeToken): int;
  49347. /** @hidden */
  49348. _currentNonTimestampToken: Nullable<_TimeToken>;
  49349. /** @hidden */
  49350. _createTimeQuery(): WebGLQuery;
  49351. /** @hidden */
  49352. _deleteTimeQuery(query: WebGLQuery): void;
  49353. /** @hidden */
  49354. _getGlAlgorithmType(algorithmType: number): number;
  49355. /** @hidden */
  49356. _getTimeQueryResult(query: WebGLQuery): any;
  49357. /** @hidden */
  49358. _getTimeQueryAvailability(query: WebGLQuery): any;
  49359. }
  49360. }
  49361. module "babylonjs/Meshes/abstractMesh" {
  49362. interface AbstractMesh {
  49363. /**
  49364. * Backing filed
  49365. * @hidden
  49366. */
  49367. __occlusionDataStorage: _OcclusionDataStorage;
  49368. /**
  49369. * Access property
  49370. * @hidden
  49371. */
  49372. _occlusionDataStorage: _OcclusionDataStorage;
  49373. /**
  49374. * 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.
  49375. * The default value is -1 which means don't break the query and wait till the result
  49376. * @see http://doc.babylonjs.com/features/occlusionquery
  49377. */
  49378. occlusionRetryCount: number;
  49379. /**
  49380. * 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:
  49381. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  49382. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  49383. * * 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.
  49384. * @see http://doc.babylonjs.com/features/occlusionquery
  49385. */
  49386. occlusionType: number;
  49387. /**
  49388. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  49389. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  49390. * * 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.
  49391. * @see http://doc.babylonjs.com/features/occlusionquery
  49392. */
  49393. occlusionQueryAlgorithmType: number;
  49394. /**
  49395. * 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
  49396. * @see http://doc.babylonjs.com/features/occlusionquery
  49397. */
  49398. isOccluded: boolean;
  49399. /**
  49400. * Flag to check the progress status of the query
  49401. * @see http://doc.babylonjs.com/features/occlusionquery
  49402. */
  49403. isOcclusionQueryInProgress: boolean;
  49404. }
  49405. }
  49406. }
  49407. declare module "babylonjs/Engines/Extensions/engine.transformFeedback" {
  49408. import { Nullable } from "babylonjs/types";
  49409. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  49410. /** @hidden */
  49411. export var _forceTransformFeedbackToBundle: boolean;
  49412. module "babylonjs/Engines/engine" {
  49413. interface Engine {
  49414. /**
  49415. * Creates a webGL transform feedback object
  49416. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  49417. * @returns the webGL transform feedback object
  49418. */
  49419. createTransformFeedback(): WebGLTransformFeedback;
  49420. /**
  49421. * Delete a webGL transform feedback object
  49422. * @param value defines the webGL transform feedback object to delete
  49423. */
  49424. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  49425. /**
  49426. * Bind a webGL transform feedback object to the webgl context
  49427. * @param value defines the webGL transform feedback object to bind
  49428. */
  49429. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  49430. /**
  49431. * Begins a transform feedback operation
  49432. * @param usePoints defines if points or triangles must be used
  49433. */
  49434. beginTransformFeedback(usePoints: boolean): void;
  49435. /**
  49436. * Ends a transform feedback operation
  49437. */
  49438. endTransformFeedback(): void;
  49439. /**
  49440. * Specify the varyings to use with transform feedback
  49441. * @param program defines the associated webGL program
  49442. * @param value defines the list of strings representing the varying names
  49443. */
  49444. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  49445. /**
  49446. * Bind a webGL buffer for a transform feedback operation
  49447. * @param value defines the webGL buffer to bind
  49448. */
  49449. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  49450. }
  49451. }
  49452. }
  49453. declare module "babylonjs/Materials/Textures/multiRenderTarget" {
  49454. import { Scene } from "babylonjs/scene";
  49455. import { Engine } from "babylonjs/Engines/engine";
  49456. import { Texture } from "babylonjs/Materials/Textures/texture";
  49457. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  49458. import "babylonjs/Engines/Extensions/engine.multiRender";
  49459. /**
  49460. * Creation options of the multi render target texture.
  49461. */
  49462. export interface IMultiRenderTargetOptions {
  49463. /**
  49464. * Define if the texture needs to create mip maps after render.
  49465. */
  49466. generateMipMaps?: boolean;
  49467. /**
  49468. * Define the types of all the draw buffers we want to create
  49469. */
  49470. types?: number[];
  49471. /**
  49472. * Define the sampling modes of all the draw buffers we want to create
  49473. */
  49474. samplingModes?: number[];
  49475. /**
  49476. * Define if a depth buffer is required
  49477. */
  49478. generateDepthBuffer?: boolean;
  49479. /**
  49480. * Define if a stencil buffer is required
  49481. */
  49482. generateStencilBuffer?: boolean;
  49483. /**
  49484. * Define if a depth texture is required instead of a depth buffer
  49485. */
  49486. generateDepthTexture?: boolean;
  49487. /**
  49488. * Define the number of desired draw buffers
  49489. */
  49490. textureCount?: number;
  49491. /**
  49492. * Define if aspect ratio should be adapted to the texture or stay the scene one
  49493. */
  49494. doNotChangeAspectRatio?: boolean;
  49495. /**
  49496. * Define the default type of the buffers we are creating
  49497. */
  49498. defaultType?: number;
  49499. }
  49500. /**
  49501. * A multi render target, like a render target provides the ability to render to a texture.
  49502. * Unlike the render target, it can render to several draw buffers in one draw.
  49503. * This is specially interesting in deferred rendering or for any effects requiring more than
  49504. * just one color from a single pass.
  49505. */
  49506. export class MultiRenderTarget extends RenderTargetTexture {
  49507. private _internalTextures;
  49508. private _textures;
  49509. private _multiRenderTargetOptions;
  49510. /**
  49511. * Get if draw buffers are currently supported by the used hardware and browser.
  49512. */
  49513. get isSupported(): boolean;
  49514. /**
  49515. * Get the list of textures generated by the multi render target.
  49516. */
  49517. get textures(): Texture[];
  49518. /**
  49519. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  49520. */
  49521. get depthTexture(): Texture;
  49522. /**
  49523. * Set the wrapping mode on U of all the textures we are rendering to.
  49524. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  49525. */
  49526. set wrapU(wrap: number);
  49527. /**
  49528. * Set the wrapping mode on V of all the textures we are rendering to.
  49529. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  49530. */
  49531. set wrapV(wrap: number);
  49532. /**
  49533. * Instantiate a new multi render target texture.
  49534. * A multi render target, like a render target provides the ability to render to a texture.
  49535. * Unlike the render target, it can render to several draw buffers in one draw.
  49536. * This is specially interesting in deferred rendering or for any effects requiring more than
  49537. * just one color from a single pass.
  49538. * @param name Define the name of the texture
  49539. * @param size Define the size of the buffers to render to
  49540. * @param count Define the number of target we are rendering into
  49541. * @param scene Define the scene the texture belongs to
  49542. * @param options Define the options used to create the multi render target
  49543. */
  49544. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  49545. /** @hidden */
  49546. _rebuild(): void;
  49547. private _createInternalTextures;
  49548. private _createTextures;
  49549. /**
  49550. * Define the number of samples used if MSAA is enabled.
  49551. */
  49552. get samples(): number;
  49553. set samples(value: number);
  49554. /**
  49555. * Resize all the textures in the multi render target.
  49556. * Be carrefull as it will recreate all the data in the new texture.
  49557. * @param size Define the new size
  49558. */
  49559. resize(size: any): void;
  49560. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  49561. /**
  49562. * Dispose the render targets and their associated resources
  49563. */
  49564. dispose(): void;
  49565. /**
  49566. * Release all the underlying texture used as draw buffers.
  49567. */
  49568. releaseInternalTextures(): void;
  49569. }
  49570. }
  49571. declare module "babylonjs/Engines/Extensions/engine.multiRender" {
  49572. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  49573. import { IMultiRenderTargetOptions } from "babylonjs/Materials/Textures/multiRenderTarget";
  49574. import { Nullable } from "babylonjs/types";
  49575. module "babylonjs/Engines/thinEngine" {
  49576. interface ThinEngine {
  49577. /**
  49578. * Unbind a list of render target textures from the webGL context
  49579. * This is used only when drawBuffer extension or webGL2 are active
  49580. * @param textures defines the render target textures to unbind
  49581. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  49582. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  49583. */
  49584. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  49585. /**
  49586. * Create a multi render target texture
  49587. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  49588. * @param size defines the size of the texture
  49589. * @param options defines the creation options
  49590. * @returns the cube texture as an InternalTexture
  49591. */
  49592. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  49593. /**
  49594. * Update the sample count for a given multiple render target texture
  49595. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  49596. * @param textures defines the textures to update
  49597. * @param samples defines the sample count to set
  49598. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  49599. */
  49600. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  49601. }
  49602. }
  49603. }
  49604. declare module "babylonjs/Engines/Extensions/engine.views" {
  49605. import { Camera } from "babylonjs/Cameras/camera";
  49606. import { Nullable } from "babylonjs/types";
  49607. /**
  49608. * Class used to define an additional view for the engine
  49609. * @see https://doc.babylonjs.com/how_to/multi_canvases
  49610. */
  49611. export class EngineView {
  49612. /** Defines the canvas where to render the view */
  49613. target: HTMLCanvasElement;
  49614. /** Defines an optional camera used to render the view (will use active camera else) */
  49615. camera?: Camera;
  49616. }
  49617. module "babylonjs/Engines/engine" {
  49618. interface Engine {
  49619. /**
  49620. * Gets or sets the HTML element to use for attaching events
  49621. */
  49622. inputElement: Nullable<HTMLElement>;
  49623. /**
  49624. * Gets the current engine view
  49625. * @see https://doc.babylonjs.com/how_to/multi_canvases
  49626. */
  49627. activeView: Nullable<EngineView>;
  49628. /** Gets or sets the list of views */
  49629. views: EngineView[];
  49630. /**
  49631. * Register a new child canvas
  49632. * @param canvas defines the canvas to register
  49633. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  49634. * @returns the associated view
  49635. */
  49636. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  49637. /**
  49638. * Remove a registered child canvas
  49639. * @param canvas defines the canvas to remove
  49640. * @returns the current engine
  49641. */
  49642. unRegisterView(canvas: HTMLCanvasElement): Engine;
  49643. }
  49644. }
  49645. }
  49646. declare module "babylonjs/Engines/Extensions/engine.textureSelector" {
  49647. import { Nullable } from "babylonjs/types";
  49648. module "babylonjs/Engines/engine" {
  49649. interface Engine {
  49650. /** @hidden */
  49651. _excludedCompressedTextures: string[];
  49652. /** @hidden */
  49653. _textureFormatInUse: string;
  49654. /**
  49655. * Gets the list of texture formats supported
  49656. */
  49657. readonly texturesSupported: Array<string>;
  49658. /**
  49659. * Gets the texture format in use
  49660. */
  49661. readonly textureFormatInUse: Nullable<string>;
  49662. /**
  49663. * Set the compressed texture extensions or file names to skip.
  49664. *
  49665. * @param skippedFiles defines the list of those texture files you want to skip
  49666. * Example: [".dds", ".env", "myfile.png"]
  49667. */
  49668. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  49669. /**
  49670. * Set the compressed texture format to use, based on the formats you have, and the formats
  49671. * supported by the hardware / browser.
  49672. *
  49673. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  49674. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  49675. * to API arguments needed to compressed textures. This puts the burden on the container
  49676. * generator to house the arcane code for determining these for current & future formats.
  49677. *
  49678. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  49679. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  49680. *
  49681. * Note: The result of this call is not taken into account when a texture is base64.
  49682. *
  49683. * @param formatsAvailable defines the list of those format families you have created
  49684. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  49685. *
  49686. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  49687. * @returns The extension selected.
  49688. */
  49689. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  49690. }
  49691. }
  49692. }
  49693. declare module "babylonjs/Engines/Extensions/index" {
  49694. export * from "babylonjs/Engines/Extensions/engine.alpha";
  49695. export * from "babylonjs/Engines/Extensions/engine.occlusionQuery";
  49696. export * from "babylonjs/Engines/Extensions/engine.transformFeedback";
  49697. export * from "babylonjs/Engines/Extensions/engine.multiview";
  49698. export * from "babylonjs/Engines/Extensions/engine.rawTexture";
  49699. export * from "babylonjs/Engines/Extensions/engine.dynamicTexture";
  49700. export * from "babylonjs/Engines/Extensions/engine.videoTexture";
  49701. export * from "babylonjs/Engines/Extensions/engine.multiRender";
  49702. export * from "babylonjs/Engines/Extensions/engine.cubeTexture";
  49703. export * from "babylonjs/Engines/Extensions/engine.renderTarget";
  49704. export * from "babylonjs/Engines/Extensions/engine.renderTargetCube";
  49705. export * from "babylonjs/Engines/Extensions/engine.webVR";
  49706. export * from "babylonjs/Engines/Extensions/engine.uniformBuffer";
  49707. export * from "babylonjs/Engines/Extensions/engine.views";
  49708. import "babylonjs/Engines/Extensions/engine.textureSelector";
  49709. export * from "babylonjs/Engines/Extensions/engine.textureSelector";
  49710. }
  49711. declare module "babylonjs/Misc/HighDynamicRange/panoramaToCubemap" {
  49712. import { Nullable } from "babylonjs/types";
  49713. /**
  49714. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  49715. */
  49716. export interface CubeMapInfo {
  49717. /**
  49718. * The pixel array for the front face.
  49719. * This is stored in format, left to right, up to down format.
  49720. */
  49721. front: Nullable<ArrayBufferView>;
  49722. /**
  49723. * The pixel array for the back face.
  49724. * This is stored in format, left to right, up to down format.
  49725. */
  49726. back: Nullable<ArrayBufferView>;
  49727. /**
  49728. * The pixel array for the left face.
  49729. * This is stored in format, left to right, up to down format.
  49730. */
  49731. left: Nullable<ArrayBufferView>;
  49732. /**
  49733. * The pixel array for the right face.
  49734. * This is stored in format, left to right, up to down format.
  49735. */
  49736. right: Nullable<ArrayBufferView>;
  49737. /**
  49738. * The pixel array for the up face.
  49739. * This is stored in format, left to right, up to down format.
  49740. */
  49741. up: Nullable<ArrayBufferView>;
  49742. /**
  49743. * The pixel array for the down face.
  49744. * This is stored in format, left to right, up to down format.
  49745. */
  49746. down: Nullable<ArrayBufferView>;
  49747. /**
  49748. * The size of the cubemap stored.
  49749. *
  49750. * Each faces will be size * size pixels.
  49751. */
  49752. size: number;
  49753. /**
  49754. * The format of the texture.
  49755. *
  49756. * RGBA, RGB.
  49757. */
  49758. format: number;
  49759. /**
  49760. * The type of the texture data.
  49761. *
  49762. * UNSIGNED_INT, FLOAT.
  49763. */
  49764. type: number;
  49765. /**
  49766. * Specifies whether the texture is in gamma space.
  49767. */
  49768. gammaSpace: boolean;
  49769. }
  49770. /**
  49771. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  49772. */
  49773. export class PanoramaToCubeMapTools {
  49774. private static FACE_FRONT;
  49775. private static FACE_BACK;
  49776. private static FACE_RIGHT;
  49777. private static FACE_LEFT;
  49778. private static FACE_DOWN;
  49779. private static FACE_UP;
  49780. /**
  49781. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  49782. *
  49783. * @param float32Array The source data.
  49784. * @param inputWidth The width of the input panorama.
  49785. * @param inputHeight The height of the input panorama.
  49786. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  49787. * @return The cubemap data
  49788. */
  49789. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  49790. private static CreateCubemapTexture;
  49791. private static CalcProjectionSpherical;
  49792. }
  49793. }
  49794. declare module "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial" {
  49795. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  49796. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49797. import { Nullable } from "babylonjs/types";
  49798. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  49799. /**
  49800. * Helper class dealing with the extraction of spherical polynomial dataArray
  49801. * from a cube map.
  49802. */
  49803. export class CubeMapToSphericalPolynomialTools {
  49804. private static FileFaces;
  49805. /**
  49806. * Converts a texture to the according Spherical Polynomial data.
  49807. * This extracts the first 3 orders only as they are the only one used in the lighting.
  49808. *
  49809. * @param texture The texture to extract the information from.
  49810. * @return The Spherical Polynomial data.
  49811. */
  49812. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  49813. /**
  49814. * Converts a cubemap to the according Spherical Polynomial data.
  49815. * This extracts the first 3 orders only as they are the only one used in the lighting.
  49816. *
  49817. * @param cubeInfo The Cube map to extract the information from.
  49818. * @return The Spherical Polynomial data.
  49819. */
  49820. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  49821. }
  49822. }
  49823. declare module "babylonjs/Materials/Textures/baseTexture.polynomial" {
  49824. import { Nullable } from "babylonjs/types";
  49825. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  49826. module "babylonjs/Materials/Textures/baseTexture" {
  49827. interface BaseTexture {
  49828. /**
  49829. * Get the polynomial representation of the texture data.
  49830. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  49831. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  49832. */
  49833. sphericalPolynomial: Nullable<SphericalPolynomial>;
  49834. }
  49835. }
  49836. }
  49837. declare module "babylonjs/Shaders/rgbdEncode.fragment" {
  49838. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  49839. /** @hidden */
  49840. export var rgbdEncodePixelShader: {
  49841. name: string;
  49842. shader: string;
  49843. };
  49844. }
  49845. declare module "babylonjs/Shaders/rgbdDecode.fragment" {
  49846. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  49847. /** @hidden */
  49848. export var rgbdDecodePixelShader: {
  49849. name: string;
  49850. shader: string;
  49851. };
  49852. }
  49853. declare module "babylonjs/Misc/environmentTextureTools" {
  49854. import { Nullable } from "babylonjs/types";
  49855. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  49856. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  49857. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  49858. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  49859. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  49860. import "babylonjs/Shaders/rgbdEncode.fragment";
  49861. import "babylonjs/Shaders/rgbdDecode.fragment";
  49862. /**
  49863. * Raw texture data and descriptor sufficient for WebGL texture upload
  49864. */
  49865. export interface EnvironmentTextureInfo {
  49866. /**
  49867. * Version of the environment map
  49868. */
  49869. version: number;
  49870. /**
  49871. * Width of image
  49872. */
  49873. width: number;
  49874. /**
  49875. * Irradiance information stored in the file.
  49876. */
  49877. irradiance: any;
  49878. /**
  49879. * Specular information stored in the file.
  49880. */
  49881. specular: any;
  49882. }
  49883. /**
  49884. * Defines One Image in the file. It requires only the position in the file
  49885. * as well as the length.
  49886. */
  49887. interface BufferImageData {
  49888. /**
  49889. * Length of the image data.
  49890. */
  49891. length: number;
  49892. /**
  49893. * Position of the data from the null terminator delimiting the end of the JSON.
  49894. */
  49895. position: number;
  49896. }
  49897. /**
  49898. * Defines the specular data enclosed in the file.
  49899. * This corresponds to the version 1 of the data.
  49900. */
  49901. export interface EnvironmentTextureSpecularInfoV1 {
  49902. /**
  49903. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  49904. */
  49905. specularDataPosition?: number;
  49906. /**
  49907. * This contains all the images data needed to reconstruct the cubemap.
  49908. */
  49909. mipmaps: Array<BufferImageData>;
  49910. /**
  49911. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  49912. */
  49913. lodGenerationScale: number;
  49914. }
  49915. /**
  49916. * Sets of helpers addressing the serialization and deserialization of environment texture
  49917. * stored in a BabylonJS env file.
  49918. * Those files are usually stored as .env files.
  49919. */
  49920. export class EnvironmentTextureTools {
  49921. /**
  49922. * Magic number identifying the env file.
  49923. */
  49924. private static _MagicBytes;
  49925. /**
  49926. * Gets the environment info from an env file.
  49927. * @param data The array buffer containing the .env bytes.
  49928. * @returns the environment file info (the json header) if successfully parsed.
  49929. */
  49930. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  49931. /**
  49932. * Creates an environment texture from a loaded cube texture.
  49933. * @param texture defines the cube texture to convert in env file
  49934. * @return a promise containing the environment data if succesfull.
  49935. */
  49936. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  49937. /**
  49938. * Creates a JSON representation of the spherical data.
  49939. * @param texture defines the texture containing the polynomials
  49940. * @return the JSON representation of the spherical info
  49941. */
  49942. private static _CreateEnvTextureIrradiance;
  49943. /**
  49944. * Creates the ArrayBufferViews used for initializing environment texture image data.
  49945. * @param data the image data
  49946. * @param info parameters that determine what views will be created for accessing the underlying buffer
  49947. * @return the views described by info providing access to the underlying buffer
  49948. */
  49949. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  49950. /**
  49951. * Uploads the texture info contained in the env file to the GPU.
  49952. * @param texture defines the internal texture to upload to
  49953. * @param data defines the data to load
  49954. * @param info defines the texture info retrieved through the GetEnvInfo method
  49955. * @returns a promise
  49956. */
  49957. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  49958. private static _OnImageReadyAsync;
  49959. /**
  49960. * Uploads the levels of image data to the GPU.
  49961. * @param texture defines the internal texture to upload to
  49962. * @param imageData defines the array buffer views of image data [mipmap][face]
  49963. * @returns a promise
  49964. */
  49965. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  49966. /**
  49967. * Uploads spherical polynomials information to the texture.
  49968. * @param texture defines the texture we are trying to upload the information to
  49969. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  49970. */
  49971. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  49972. /** @hidden */
  49973. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  49974. }
  49975. }
  49976. declare module "babylonjs/Maths/math.vertexFormat" {
  49977. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  49978. /**
  49979. * Contains position and normal vectors for a vertex
  49980. */
  49981. export class PositionNormalVertex {
  49982. /** the position of the vertex (defaut: 0,0,0) */
  49983. position: Vector3;
  49984. /** the normal of the vertex (defaut: 0,1,0) */
  49985. normal: Vector3;
  49986. /**
  49987. * Creates a PositionNormalVertex
  49988. * @param position the position of the vertex (defaut: 0,0,0)
  49989. * @param normal the normal of the vertex (defaut: 0,1,0)
  49990. */
  49991. constructor(
  49992. /** the position of the vertex (defaut: 0,0,0) */
  49993. position?: Vector3,
  49994. /** the normal of the vertex (defaut: 0,1,0) */
  49995. normal?: Vector3);
  49996. /**
  49997. * Clones the PositionNormalVertex
  49998. * @returns the cloned PositionNormalVertex
  49999. */
  50000. clone(): PositionNormalVertex;
  50001. }
  50002. /**
  50003. * Contains position, normal and uv vectors for a vertex
  50004. */
  50005. export class PositionNormalTextureVertex {
  50006. /** the position of the vertex (defaut: 0,0,0) */
  50007. position: Vector3;
  50008. /** the normal of the vertex (defaut: 0,1,0) */
  50009. normal: Vector3;
  50010. /** the uv of the vertex (default: 0,0) */
  50011. uv: Vector2;
  50012. /**
  50013. * Creates a PositionNormalTextureVertex
  50014. * @param position the position of the vertex (defaut: 0,0,0)
  50015. * @param normal the normal of the vertex (defaut: 0,1,0)
  50016. * @param uv the uv of the vertex (default: 0,0)
  50017. */
  50018. constructor(
  50019. /** the position of the vertex (defaut: 0,0,0) */
  50020. position?: Vector3,
  50021. /** the normal of the vertex (defaut: 0,1,0) */
  50022. normal?: Vector3,
  50023. /** the uv of the vertex (default: 0,0) */
  50024. uv?: Vector2);
  50025. /**
  50026. * Clones the PositionNormalTextureVertex
  50027. * @returns the cloned PositionNormalTextureVertex
  50028. */
  50029. clone(): PositionNormalTextureVertex;
  50030. }
  50031. }
  50032. declare module "babylonjs/Maths/math" {
  50033. export * from "babylonjs/Maths/math.axis";
  50034. export * from "babylonjs/Maths/math.color";
  50035. export * from "babylonjs/Maths/math.constants";
  50036. export * from "babylonjs/Maths/math.frustum";
  50037. export * from "babylonjs/Maths/math.path";
  50038. export * from "babylonjs/Maths/math.plane";
  50039. export * from "babylonjs/Maths/math.size";
  50040. export * from "babylonjs/Maths/math.vector";
  50041. export * from "babylonjs/Maths/math.vertexFormat";
  50042. export * from "babylonjs/Maths/math.viewport";
  50043. }
  50044. declare module "babylonjs/Engines/Native/nativeShaderProcessor" {
  50045. import { WebGL2ShaderProcessor } from "babylonjs/Engines/WebGL/webGL2ShaderProcessors";
  50046. /** @hidden */
  50047. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  50048. private _genericAttributeLocation;
  50049. private _varyingLocationCount;
  50050. private _varyingLocationMap;
  50051. private _replacements;
  50052. private _textureCount;
  50053. private _uniforms;
  50054. lineProcessor(line: string): string;
  50055. attributeProcessor(attribute: string): string;
  50056. varyingProcessor(varying: string, isFragment: boolean): string;
  50057. uniformProcessor(uniform: string): string;
  50058. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  50059. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  50060. }
  50061. }
  50062. declare module "babylonjs/Engines/nativeEngine" {
  50063. import { Nullable, IndicesArray, DataArray } from "babylonjs/types";
  50064. import { Engine } from "babylonjs/Engines/engine";
  50065. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  50066. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  50067. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  50068. import { Effect } from "babylonjs/Materials/effect";
  50069. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  50070. import { Matrix, Viewport, Color3 } from "babylonjs/Maths/math";
  50071. import { IColor4Like } from "babylonjs/Maths/math.like";
  50072. import { Scene } from "babylonjs/scene";
  50073. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  50074. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  50075. import { ISceneLike } from "babylonjs/Engines/thinEngine";
  50076. /**
  50077. * Container for accessors for natively-stored mesh data buffers.
  50078. */
  50079. class NativeDataBuffer extends DataBuffer {
  50080. /**
  50081. * Accessor value used to identify/retrieve a natively-stored index buffer.
  50082. */
  50083. nativeIndexBuffer?: any;
  50084. /**
  50085. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  50086. */
  50087. nativeVertexBuffer?: any;
  50088. }
  50089. /** @hidden */
  50090. class NativeTexture extends InternalTexture {
  50091. getInternalTexture(): InternalTexture;
  50092. getViewCount(): number;
  50093. }
  50094. /** @hidden */
  50095. export class NativeEngine extends Engine {
  50096. private readonly _native;
  50097. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  50098. private readonly INVALID_HANDLE;
  50099. getHardwareScalingLevel(): number;
  50100. constructor();
  50101. dispose(): void;
  50102. /**
  50103. * Can be used to override the current requestAnimationFrame requester.
  50104. * @hidden
  50105. */
  50106. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  50107. /**
  50108. * Override default engine behavior.
  50109. * @param color
  50110. * @param backBuffer
  50111. * @param depth
  50112. * @param stencil
  50113. */
  50114. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  50115. /**
  50116. * Gets host document
  50117. * @returns the host document object
  50118. */
  50119. getHostDocument(): Nullable<Document>;
  50120. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  50121. createIndexBuffer(indices: IndicesArray): NativeDataBuffer;
  50122. createVertexBuffer(data: DataArray): NativeDataBuffer;
  50123. recordVertexArrayObject(vertexBuffers: {
  50124. [key: string]: VertexBuffer;
  50125. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  50126. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  50127. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  50128. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  50129. /**
  50130. * Draw a list of indexed primitives
  50131. * @param fillMode defines the primitive to use
  50132. * @param indexStart defines the starting index
  50133. * @param indexCount defines the number of index to draw
  50134. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  50135. */
  50136. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  50137. /**
  50138. * Draw a list of unindexed primitives
  50139. * @param fillMode defines the primitive to use
  50140. * @param verticesStart defines the index of first vertex to draw
  50141. * @param verticesCount defines the count of vertices to draw
  50142. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  50143. */
  50144. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  50145. createPipelineContext(): IPipelineContext;
  50146. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  50147. /** @hidden */
  50148. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  50149. /** @hidden */
  50150. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  50151. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  50152. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  50153. protected _setProgram(program: WebGLProgram): void;
  50154. _releaseEffect(effect: Effect): void;
  50155. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  50156. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  50157. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  50158. bindSamplers(effect: Effect): void;
  50159. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  50160. getRenderWidth(useScreen?: boolean): number;
  50161. getRenderHeight(useScreen?: boolean): number;
  50162. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  50163. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  50164. /**
  50165. * Set the z offset to apply to current rendering
  50166. * @param value defines the offset to apply
  50167. */
  50168. setZOffset(value: number): void;
  50169. /**
  50170. * Gets the current value of the zOffset
  50171. * @returns the current zOffset state
  50172. */
  50173. getZOffset(): number;
  50174. /**
  50175. * Enable or disable depth buffering
  50176. * @param enable defines the state to set
  50177. */
  50178. setDepthBuffer(enable: boolean): void;
  50179. /**
  50180. * Gets a boolean indicating if depth writing is enabled
  50181. * @returns the current depth writing state
  50182. */
  50183. getDepthWrite(): boolean;
  50184. /**
  50185. * Enable or disable depth writing
  50186. * @param enable defines the state to set
  50187. */
  50188. setDepthWrite(enable: boolean): void;
  50189. /**
  50190. * Enable or disable color writing
  50191. * @param enable defines the state to set
  50192. */
  50193. setColorWrite(enable: boolean): void;
  50194. /**
  50195. * Gets a boolean indicating if color writing is enabled
  50196. * @returns the current color writing state
  50197. */
  50198. getColorWrite(): boolean;
  50199. /**
  50200. * Sets alpha constants used by some alpha blending modes
  50201. * @param r defines the red component
  50202. * @param g defines the green component
  50203. * @param b defines the blue component
  50204. * @param a defines the alpha component
  50205. */
  50206. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  50207. /**
  50208. * Sets the current alpha mode
  50209. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  50210. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  50211. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  50212. */
  50213. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  50214. /**
  50215. * Gets the current alpha mode
  50216. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  50217. * @returns the current alpha mode
  50218. */
  50219. getAlphaMode(): number;
  50220. setInt(uniform: WebGLUniformLocation, int: number): void;
  50221. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  50222. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  50223. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  50224. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  50225. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  50226. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  50227. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  50228. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  50229. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  50230. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  50231. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  50232. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  50233. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  50234. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  50235. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  50236. setFloat(uniform: WebGLUniformLocation, value: number): void;
  50237. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  50238. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  50239. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  50240. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  50241. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  50242. wipeCaches(bruteForce?: boolean): void;
  50243. _createTexture(): WebGLTexture;
  50244. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  50245. /**
  50246. * Usually called from Texture.ts.
  50247. * Passed information to create a WebGLTexture
  50248. * @param url defines a value which contains one of the following:
  50249. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  50250. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  50251. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  50252. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  50253. * @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)
  50254. * @param scene needed for loading to the correct scene
  50255. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  50256. * @param onLoad optional callback to be called upon successful completion
  50257. * @param onError optional callback to be called upon failure
  50258. * @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
  50259. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  50260. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  50261. * @param forcedExtension defines the extension to use to pick the right loader
  50262. * @param mimeType defines an optional mime type
  50263. * @returns a InternalTexture for assignment back into BABYLON.Texture
  50264. */
  50265. 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;
  50266. /**
  50267. * Creates a cube texture
  50268. * @param rootUrl defines the url where the files to load is located
  50269. * @param scene defines the current scene
  50270. * @param files defines the list of files to load (1 per face)
  50271. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  50272. * @param onLoad defines an optional callback raised when the texture is loaded
  50273. * @param onError defines an optional callback raised if there is an issue to load the texture
  50274. * @param format defines the format of the data
  50275. * @param forcedExtension defines the extension to use to pick the right loader
  50276. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  50277. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  50278. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  50279. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  50280. * @returns the cube texture as an InternalTexture
  50281. */
  50282. 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;
  50283. private _getSamplingFilter;
  50284. private static _GetNativeTextureFormat;
  50285. createRenderTargetTexture(size: number | {
  50286. width: number;
  50287. height: number;
  50288. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  50289. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  50290. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  50291. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  50292. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  50293. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  50294. /**
  50295. * Updates a dynamic vertex buffer.
  50296. * @param vertexBuffer the vertex buffer to update
  50297. * @param data the data used to update the vertex buffer
  50298. * @param byteOffset the byte offset of the data (optional)
  50299. * @param byteLength the byte length of the data (optional)
  50300. */
  50301. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  50302. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  50303. private _updateAnisotropicLevel;
  50304. private _getAddressMode;
  50305. /** @hidden */
  50306. _bindTexture(channel: number, texture: InternalTexture): void;
  50307. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  50308. releaseEffects(): void;
  50309. /** @hidden */
  50310. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  50311. /** @hidden */
  50312. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  50313. /** @hidden */
  50314. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  50315. /** @hidden */
  50316. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  50317. }
  50318. }
  50319. declare module "babylonjs/Engines/index" {
  50320. export * from "babylonjs/Engines/constants";
  50321. export * from "babylonjs/Engines/engineCapabilities";
  50322. export * from "babylonjs/Engines/instancingAttributeInfo";
  50323. export * from "babylonjs/Engines/thinEngine";
  50324. export * from "babylonjs/Engines/engine";
  50325. export * from "babylonjs/Engines/engineStore";
  50326. export * from "babylonjs/Engines/nullEngine";
  50327. export * from "babylonjs/Engines/Extensions/index";
  50328. export * from "babylonjs/Engines/IPipelineContext";
  50329. export * from "babylonjs/Engines/WebGL/webGLPipelineContext";
  50330. export * from "babylonjs/Engines/WebGL/webGL2ShaderProcessors";
  50331. export * from "babylonjs/Engines/nativeEngine";
  50332. }
  50333. declare module "babylonjs/Events/clipboardEvents" {
  50334. /**
  50335. * Gather the list of clipboard event types as constants.
  50336. */
  50337. export class ClipboardEventTypes {
  50338. /**
  50339. * The clipboard event is fired when a copy command is active (pressed).
  50340. */
  50341. static readonly COPY: number;
  50342. /**
  50343. * The clipboard event is fired when a cut command is active (pressed).
  50344. */
  50345. static readonly CUT: number;
  50346. /**
  50347. * The clipboard event is fired when a paste command is active (pressed).
  50348. */
  50349. static readonly PASTE: number;
  50350. }
  50351. /**
  50352. * This class is used to store clipboard related info for the onClipboardObservable event.
  50353. */
  50354. export class ClipboardInfo {
  50355. /**
  50356. * Defines the type of event (BABYLON.ClipboardEventTypes)
  50357. */
  50358. type: number;
  50359. /**
  50360. * Defines the related dom event
  50361. */
  50362. event: ClipboardEvent;
  50363. /**
  50364. *Creates an instance of ClipboardInfo.
  50365. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  50366. * @param event Defines the related dom event
  50367. */
  50368. constructor(
  50369. /**
  50370. * Defines the type of event (BABYLON.ClipboardEventTypes)
  50371. */
  50372. type: number,
  50373. /**
  50374. * Defines the related dom event
  50375. */
  50376. event: ClipboardEvent);
  50377. /**
  50378. * Get the clipboard event's type from the keycode.
  50379. * @param keyCode Defines the keyCode for the current keyboard event.
  50380. * @return {number}
  50381. */
  50382. static GetTypeFromCharacter(keyCode: number): number;
  50383. }
  50384. }
  50385. declare module "babylonjs/Events/index" {
  50386. export * from "babylonjs/Events/keyboardEvents";
  50387. export * from "babylonjs/Events/pointerEvents";
  50388. export * from "babylonjs/Events/clipboardEvents";
  50389. }
  50390. declare module "babylonjs/Gamepads/Controllers/daydreamController" {
  50391. import { Scene } from "babylonjs/scene";
  50392. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50393. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  50394. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  50395. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  50396. /**
  50397. * Google Daydream controller
  50398. */
  50399. export class DaydreamController extends WebVRController {
  50400. /**
  50401. * Base Url for the controller model.
  50402. */
  50403. static MODEL_BASE_URL: string;
  50404. /**
  50405. * File name for the controller model.
  50406. */
  50407. static MODEL_FILENAME: string;
  50408. /**
  50409. * Gamepad Id prefix used to identify Daydream Controller.
  50410. */
  50411. static readonly GAMEPAD_ID_PREFIX: string;
  50412. /**
  50413. * Creates a new DaydreamController from a gamepad
  50414. * @param vrGamepad the gamepad that the controller should be created from
  50415. */
  50416. constructor(vrGamepad: any);
  50417. /**
  50418. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  50419. * @param scene scene in which to add meshes
  50420. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  50421. */
  50422. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  50423. /**
  50424. * Called once for each button that changed state since the last frame
  50425. * @param buttonIdx Which button index changed
  50426. * @param state New state of the button
  50427. * @param changes Which properties on the state changed since last frame
  50428. */
  50429. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  50430. }
  50431. }
  50432. declare module "babylonjs/Gamepads/Controllers/gearVRController" {
  50433. import { Scene } from "babylonjs/scene";
  50434. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50435. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  50436. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  50437. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  50438. /**
  50439. * Gear VR Controller
  50440. */
  50441. export class GearVRController extends WebVRController {
  50442. /**
  50443. * Base Url for the controller model.
  50444. */
  50445. static MODEL_BASE_URL: string;
  50446. /**
  50447. * File name for the controller model.
  50448. */
  50449. static MODEL_FILENAME: string;
  50450. /**
  50451. * Gamepad Id prefix used to identify this controller.
  50452. */
  50453. static readonly GAMEPAD_ID_PREFIX: string;
  50454. private readonly _buttonIndexToObservableNameMap;
  50455. /**
  50456. * Creates a new GearVRController from a gamepad
  50457. * @param vrGamepad the gamepad that the controller should be created from
  50458. */
  50459. constructor(vrGamepad: any);
  50460. /**
  50461. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  50462. * @param scene scene in which to add meshes
  50463. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  50464. */
  50465. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  50466. /**
  50467. * Called once for each button that changed state since the last frame
  50468. * @param buttonIdx Which button index changed
  50469. * @param state New state of the button
  50470. * @param changes Which properties on the state changed since last frame
  50471. */
  50472. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  50473. }
  50474. }
  50475. declare module "babylonjs/Gamepads/Controllers/genericController" {
  50476. import { Scene } from "babylonjs/scene";
  50477. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50478. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  50479. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  50480. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  50481. /**
  50482. * Generic Controller
  50483. */
  50484. export class GenericController extends WebVRController {
  50485. /**
  50486. * Base Url for the controller model.
  50487. */
  50488. static readonly MODEL_BASE_URL: string;
  50489. /**
  50490. * File name for the controller model.
  50491. */
  50492. static readonly MODEL_FILENAME: string;
  50493. /**
  50494. * Creates a new GenericController from a gamepad
  50495. * @param vrGamepad the gamepad that the controller should be created from
  50496. */
  50497. constructor(vrGamepad: any);
  50498. /**
  50499. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  50500. * @param scene scene in which to add meshes
  50501. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  50502. */
  50503. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  50504. /**
  50505. * Called once for each button that changed state since the last frame
  50506. * @param buttonIdx Which button index changed
  50507. * @param state New state of the button
  50508. * @param changes Which properties on the state changed since last frame
  50509. */
  50510. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  50511. }
  50512. }
  50513. declare module "babylonjs/Gamepads/Controllers/oculusTouchController" {
  50514. import { Observable } from "babylonjs/Misc/observable";
  50515. import { Scene } from "babylonjs/scene";
  50516. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50517. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  50518. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  50519. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  50520. /**
  50521. * Oculus Touch Controller
  50522. */
  50523. export class OculusTouchController extends WebVRController {
  50524. /**
  50525. * Base Url for the controller model.
  50526. */
  50527. static MODEL_BASE_URL: string;
  50528. /**
  50529. * File name for the left controller model.
  50530. */
  50531. static MODEL_LEFT_FILENAME: string;
  50532. /**
  50533. * File name for the right controller model.
  50534. */
  50535. static MODEL_RIGHT_FILENAME: string;
  50536. /**
  50537. * Base Url for the Quest controller model.
  50538. */
  50539. static QUEST_MODEL_BASE_URL: string;
  50540. /**
  50541. * @hidden
  50542. * If the controllers are running on a device that needs the updated Quest controller models
  50543. */
  50544. static _IsQuest: boolean;
  50545. /**
  50546. * Fired when the secondary trigger on this controller is modified
  50547. */
  50548. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  50549. /**
  50550. * Fired when the thumb rest on this controller is modified
  50551. */
  50552. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  50553. /**
  50554. * Creates a new OculusTouchController 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. * Fired when the A button on this controller is modified
  50566. */
  50567. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50568. /**
  50569. * Fired when the B button on this controller is modified
  50570. */
  50571. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50572. /**
  50573. * Fired when the X button on this controller is modified
  50574. */
  50575. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50576. /**
  50577. * Fired when the Y button on this controller is modified
  50578. */
  50579. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50580. /**
  50581. * Called once for each button that changed state since the last frame
  50582. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  50583. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  50584. * 2) secondary trigger (same)
  50585. * 3) A (right) X (left), touch, pressed = value
  50586. * 4) B / Y
  50587. * 5) thumb rest
  50588. * @param buttonIdx Which button index changed
  50589. * @param state New state of the button
  50590. * @param changes Which properties on the state changed since last frame
  50591. */
  50592. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  50593. }
  50594. }
  50595. declare module "babylonjs/Gamepads/Controllers/viveController" {
  50596. import { Scene } from "babylonjs/scene";
  50597. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50598. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  50599. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  50600. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  50601. import { Observable } from "babylonjs/Misc/observable";
  50602. /**
  50603. * Vive Controller
  50604. */
  50605. export class ViveController extends WebVRController {
  50606. /**
  50607. * Base Url for the controller model.
  50608. */
  50609. static MODEL_BASE_URL: string;
  50610. /**
  50611. * File name for the controller model.
  50612. */
  50613. static MODEL_FILENAME: string;
  50614. /**
  50615. * Creates a new ViveController from a gamepad
  50616. * @param vrGamepad the gamepad that the controller should be created from
  50617. */
  50618. constructor(vrGamepad: any);
  50619. /**
  50620. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  50621. * @param scene scene in which to add meshes
  50622. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  50623. */
  50624. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  50625. /**
  50626. * Fired when the left button on this controller is modified
  50627. */
  50628. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50629. /**
  50630. * Fired when the right button on this controller is modified
  50631. */
  50632. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50633. /**
  50634. * Fired when the menu button on this controller is modified
  50635. */
  50636. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50637. /**
  50638. * Called once for each button that changed state since the last frame
  50639. * Vive mapping:
  50640. * 0: touchpad
  50641. * 1: trigger
  50642. * 2: left AND right buttons
  50643. * 3: menu button
  50644. * @param buttonIdx Which button index changed
  50645. * @param state New state of the button
  50646. * @param changes Which properties on the state changed since last frame
  50647. */
  50648. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  50649. }
  50650. }
  50651. declare module "babylonjs/Gamepads/Controllers/windowsMotionController" {
  50652. import { Observable } from "babylonjs/Misc/observable";
  50653. import { Scene } from "babylonjs/scene";
  50654. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50655. import { Ray } from "babylonjs/Culling/ray";
  50656. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  50657. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  50658. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  50659. /**
  50660. * Defines the WindowsMotionController object that the state of the windows motion controller
  50661. */
  50662. export class WindowsMotionController extends WebVRController {
  50663. /**
  50664. * The base url used to load the left and right controller models
  50665. */
  50666. static MODEL_BASE_URL: string;
  50667. /**
  50668. * The name of the left controller model file
  50669. */
  50670. static MODEL_LEFT_FILENAME: string;
  50671. /**
  50672. * The name of the right controller model file
  50673. */
  50674. static MODEL_RIGHT_FILENAME: string;
  50675. /**
  50676. * The controller name prefix for this controller type
  50677. */
  50678. static readonly GAMEPAD_ID_PREFIX: string;
  50679. /**
  50680. * The controller id pattern for this controller type
  50681. */
  50682. private static readonly GAMEPAD_ID_PATTERN;
  50683. private _loadedMeshInfo;
  50684. protected readonly _mapping: {
  50685. buttons: string[];
  50686. buttonMeshNames: {
  50687. trigger: string;
  50688. menu: string;
  50689. grip: string;
  50690. thumbstick: string;
  50691. trackpad: string;
  50692. };
  50693. buttonObservableNames: {
  50694. trigger: string;
  50695. menu: string;
  50696. grip: string;
  50697. thumbstick: string;
  50698. trackpad: string;
  50699. };
  50700. axisMeshNames: string[];
  50701. pointingPoseMeshName: string;
  50702. };
  50703. /**
  50704. * Fired when the trackpad on this controller is clicked
  50705. */
  50706. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  50707. /**
  50708. * Fired when the trackpad on this controller is modified
  50709. */
  50710. onTrackpadValuesChangedObservable: Observable<StickValues>;
  50711. /**
  50712. * The current x and y values of this controller's trackpad
  50713. */
  50714. trackpad: StickValues;
  50715. /**
  50716. * Creates a new WindowsMotionController from a gamepad
  50717. * @param vrGamepad the gamepad that the controller should be created from
  50718. */
  50719. constructor(vrGamepad: any);
  50720. /**
  50721. * Fired when the trigger on this controller is modified
  50722. */
  50723. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50724. /**
  50725. * Fired when the menu button on this controller is modified
  50726. */
  50727. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50728. /**
  50729. * Fired when the grip button on this controller is modified
  50730. */
  50731. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50732. /**
  50733. * Fired when the thumbstick button on this controller is modified
  50734. */
  50735. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50736. /**
  50737. * Fired when the touchpad button on this controller is modified
  50738. */
  50739. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50740. /**
  50741. * Fired when the touchpad values on this controller are modified
  50742. */
  50743. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  50744. protected _updateTrackpad(): void;
  50745. /**
  50746. * Called once per frame by the engine.
  50747. */
  50748. update(): void;
  50749. /**
  50750. * Called once for each button that changed state since the last frame
  50751. * @param buttonIdx Which button index changed
  50752. * @param state New state of the button
  50753. * @param changes Which properties on the state changed since last frame
  50754. */
  50755. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  50756. /**
  50757. * Moves the buttons on the controller mesh based on their current state
  50758. * @param buttonName the name of the button to move
  50759. * @param buttonValue the value of the button which determines the buttons new position
  50760. */
  50761. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  50762. /**
  50763. * Moves the axis on the controller mesh based on its current state
  50764. * @param axis the index of the axis
  50765. * @param axisValue the value of the axis which determines the meshes new position
  50766. * @hidden
  50767. */
  50768. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  50769. /**
  50770. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  50771. * @param scene scene in which to add meshes
  50772. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  50773. */
  50774. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  50775. /**
  50776. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  50777. * can be transformed by button presses and axes values, based on this._mapping.
  50778. *
  50779. * @param scene scene in which the meshes exist
  50780. * @param meshes list of meshes that make up the controller model to process
  50781. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  50782. */
  50783. private processModel;
  50784. private createMeshInfo;
  50785. /**
  50786. * Gets the ray of the controller in the direction the controller is pointing
  50787. * @param length the length the resulting ray should be
  50788. * @returns a ray in the direction the controller is pointing
  50789. */
  50790. getForwardRay(length?: number): Ray;
  50791. /**
  50792. * Disposes of the controller
  50793. */
  50794. dispose(): void;
  50795. }
  50796. /**
  50797. * This class represents a new windows motion controller in XR.
  50798. */
  50799. export class XRWindowsMotionController extends WindowsMotionController {
  50800. /**
  50801. * Changing the original WIndowsMotionController mapping to fir the new mapping
  50802. */
  50803. protected readonly _mapping: {
  50804. buttons: string[];
  50805. buttonMeshNames: {
  50806. trigger: string;
  50807. menu: string;
  50808. grip: string;
  50809. thumbstick: string;
  50810. trackpad: string;
  50811. };
  50812. buttonObservableNames: {
  50813. trigger: string;
  50814. menu: string;
  50815. grip: string;
  50816. thumbstick: string;
  50817. trackpad: string;
  50818. };
  50819. axisMeshNames: string[];
  50820. pointingPoseMeshName: string;
  50821. };
  50822. /**
  50823. * Construct a new XR-Based windows motion controller
  50824. *
  50825. * @param gamepadInfo the gamepad object from the browser
  50826. */
  50827. constructor(gamepadInfo: any);
  50828. /**
  50829. * holds the thumbstick values (X,Y)
  50830. */
  50831. thumbstickValues: StickValues;
  50832. /**
  50833. * Fired when the thumbstick on this controller is clicked
  50834. */
  50835. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  50836. /**
  50837. * Fired when the thumbstick on this controller is modified
  50838. */
  50839. onThumbstickValuesChangedObservable: Observable<StickValues>;
  50840. /**
  50841. * Fired when the touchpad button on this controller is modified
  50842. */
  50843. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  50844. /**
  50845. * Fired when the touchpad values on this controller are modified
  50846. */
  50847. onTrackpadValuesChangedObservable: Observable<StickValues>;
  50848. /**
  50849. * Fired when the thumbstick button on this controller is modified
  50850. * here to prevent breaking changes
  50851. */
  50852. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50853. /**
  50854. * updating the thumbstick(!) and not the trackpad.
  50855. * This is named this way due to the difference between WebVR and XR and to avoid
  50856. * changing the parent class.
  50857. */
  50858. protected _updateTrackpad(): void;
  50859. /**
  50860. * Disposes the class with joy
  50861. */
  50862. dispose(): void;
  50863. }
  50864. }
  50865. declare module "babylonjs/Gamepads/Controllers/index" {
  50866. export * from "babylonjs/Gamepads/Controllers/daydreamController";
  50867. export * from "babylonjs/Gamepads/Controllers/gearVRController";
  50868. export * from "babylonjs/Gamepads/Controllers/genericController";
  50869. export * from "babylonjs/Gamepads/Controllers/oculusTouchController";
  50870. export * from "babylonjs/Gamepads/Controllers/poseEnabledController";
  50871. export * from "babylonjs/Gamepads/Controllers/viveController";
  50872. export * from "babylonjs/Gamepads/Controllers/webVRController";
  50873. export * from "babylonjs/Gamepads/Controllers/windowsMotionController";
  50874. }
  50875. declare module "babylonjs/Gamepads/index" {
  50876. export * from "babylonjs/Gamepads/Controllers/index";
  50877. export * from "babylonjs/Gamepads/gamepad";
  50878. export * from "babylonjs/Gamepads/gamepadManager";
  50879. export * from "babylonjs/Gamepads/gamepadSceneComponent";
  50880. export * from "babylonjs/Gamepads/xboxGamepad";
  50881. export * from "babylonjs/Gamepads/dualShockGamepad";
  50882. }
  50883. declare module "babylonjs/Meshes/Builders/polyhedronBuilder" {
  50884. import { Scene } from "babylonjs/scene";
  50885. import { Vector4 } from "babylonjs/Maths/math.vector";
  50886. import { Color4 } from "babylonjs/Maths/math.color";
  50887. import { Mesh } from "babylonjs/Meshes/mesh";
  50888. import { Nullable } from "babylonjs/types";
  50889. /**
  50890. * Class containing static functions to help procedurally build meshes
  50891. */
  50892. export class PolyhedronBuilder {
  50893. /**
  50894. * Creates a polyhedron mesh
  50895. * * 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
  50896. * * The parameter `size` (positive float, default 1) sets the polygon size
  50897. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  50898. * * 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`
  50899. * * 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
  50900. * * 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)`)
  50901. * * 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
  50902. * * 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
  50903. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50904. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50905. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50906. * @param name defines the name of the mesh
  50907. * @param options defines the options used to create the mesh
  50908. * @param scene defines the hosting scene
  50909. * @returns the polyhedron mesh
  50910. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  50911. */
  50912. static CreatePolyhedron(name: string, options: {
  50913. type?: number;
  50914. size?: number;
  50915. sizeX?: number;
  50916. sizeY?: number;
  50917. sizeZ?: number;
  50918. custom?: any;
  50919. faceUV?: Vector4[];
  50920. faceColors?: Color4[];
  50921. flat?: boolean;
  50922. updatable?: boolean;
  50923. sideOrientation?: number;
  50924. frontUVs?: Vector4;
  50925. backUVs?: Vector4;
  50926. }, scene?: Nullable<Scene>): Mesh;
  50927. }
  50928. }
  50929. declare module "babylonjs/Gizmos/scaleGizmo" {
  50930. import { Observable } from "babylonjs/Misc/observable";
  50931. import { Nullable } from "babylonjs/types";
  50932. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50933. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  50934. import { AxisScaleGizmo } from "babylonjs/Gizmos/axisScaleGizmo";
  50935. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  50936. /**
  50937. * Gizmo that enables scaling a mesh along 3 axis
  50938. */
  50939. export class ScaleGizmo extends Gizmo {
  50940. /**
  50941. * Internal gizmo used for interactions on the x axis
  50942. */
  50943. xGizmo: AxisScaleGizmo;
  50944. /**
  50945. * Internal gizmo used for interactions on the y axis
  50946. */
  50947. yGizmo: AxisScaleGizmo;
  50948. /**
  50949. * Internal gizmo used for interactions on the z axis
  50950. */
  50951. zGizmo: AxisScaleGizmo;
  50952. /**
  50953. * Internal gizmo used to scale all axis equally
  50954. */
  50955. uniformScaleGizmo: AxisScaleGizmo;
  50956. private _meshAttached;
  50957. private _updateGizmoRotationToMatchAttachedMesh;
  50958. private _snapDistance;
  50959. private _scaleRatio;
  50960. private _uniformScalingMesh;
  50961. private _octahedron;
  50962. private _sensitivity;
  50963. /** Fires an event when any of it's sub gizmos are dragged */
  50964. onDragStartObservable: Observable<unknown>;
  50965. /** Fires an event when any of it's sub gizmos are released from dragging */
  50966. onDragEndObservable: Observable<unknown>;
  50967. get attachedMesh(): Nullable<AbstractMesh>;
  50968. set attachedMesh(mesh: Nullable<AbstractMesh>);
  50969. /**
  50970. * Creates a ScaleGizmo
  50971. * @param gizmoLayer The utility layer the gizmo will be added to
  50972. */
  50973. constructor(gizmoLayer?: UtilityLayerRenderer);
  50974. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  50975. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  50976. /**
  50977. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  50978. */
  50979. set snapDistance(value: number);
  50980. get snapDistance(): number;
  50981. /**
  50982. * Ratio for the scale of the gizmo (Default: 1)
  50983. */
  50984. set scaleRatio(value: number);
  50985. get scaleRatio(): number;
  50986. /**
  50987. * Sensitivity factor for dragging (Default: 1)
  50988. */
  50989. set sensitivity(value: number);
  50990. get sensitivity(): number;
  50991. /**
  50992. * Disposes of the gizmo
  50993. */
  50994. dispose(): void;
  50995. }
  50996. }
  50997. declare module "babylonjs/Gizmos/axisScaleGizmo" {
  50998. import { Observable } from "babylonjs/Misc/observable";
  50999. import { Nullable } from "babylonjs/types";
  51000. import { Vector3 } from "babylonjs/Maths/math.vector";
  51001. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51002. import { Mesh } from "babylonjs/Meshes/mesh";
  51003. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  51004. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  51005. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  51006. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  51007. import { Color3 } from "babylonjs/Maths/math.color";
  51008. /**
  51009. * Single axis scale gizmo
  51010. */
  51011. export class AxisScaleGizmo extends Gizmo {
  51012. /**
  51013. * Drag behavior responsible for the gizmos dragging interactions
  51014. */
  51015. dragBehavior: PointerDragBehavior;
  51016. private _pointerObserver;
  51017. /**
  51018. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  51019. */
  51020. snapDistance: number;
  51021. /**
  51022. * Event that fires each time the gizmo snaps to a new location.
  51023. * * snapDistance is the the change in distance
  51024. */
  51025. onSnapObservable: Observable<{
  51026. snapDistance: number;
  51027. }>;
  51028. /**
  51029. * If the scaling operation should be done on all axis (default: false)
  51030. */
  51031. uniformScaling: boolean;
  51032. /**
  51033. * Custom sensitivity value for the drag strength
  51034. */
  51035. sensitivity: number;
  51036. private _isEnabled;
  51037. private _parent;
  51038. private _arrow;
  51039. private _coloredMaterial;
  51040. private _hoverMaterial;
  51041. /**
  51042. * Creates an AxisScaleGizmo
  51043. * @param gizmoLayer The utility layer the gizmo will be added to
  51044. * @param dragAxis The axis which the gizmo will be able to scale on
  51045. * @param color The color of the gizmo
  51046. */
  51047. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  51048. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  51049. /**
  51050. * If the gizmo is enabled
  51051. */
  51052. set isEnabled(value: boolean);
  51053. get isEnabled(): boolean;
  51054. /**
  51055. * Disposes of the gizmo
  51056. */
  51057. dispose(): void;
  51058. /**
  51059. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  51060. * @param mesh The mesh to replace the default mesh of the gizmo
  51061. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  51062. */
  51063. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  51064. }
  51065. }
  51066. declare module "babylonjs/Gizmos/boundingBoxGizmo" {
  51067. import { Observable } from "babylonjs/Misc/observable";
  51068. import { Nullable } from "babylonjs/types";
  51069. import { Vector3 } from "babylonjs/Maths/math.vector";
  51070. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51071. import { Mesh } from "babylonjs/Meshes/mesh";
  51072. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  51073. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  51074. import { Color3 } from "babylonjs/Maths/math.color";
  51075. import "babylonjs/Meshes/Builders/boxBuilder";
  51076. /**
  51077. * Bounding box gizmo
  51078. */
  51079. export class BoundingBoxGizmo extends Gizmo {
  51080. private _lineBoundingBox;
  51081. private _rotateSpheresParent;
  51082. private _scaleBoxesParent;
  51083. private _boundingDimensions;
  51084. private _renderObserver;
  51085. private _pointerObserver;
  51086. private _scaleDragSpeed;
  51087. private _tmpQuaternion;
  51088. private _tmpVector;
  51089. private _tmpRotationMatrix;
  51090. /**
  51091. * 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)
  51092. */
  51093. ignoreChildren: boolean;
  51094. /**
  51095. * 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)
  51096. */
  51097. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  51098. /**
  51099. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  51100. */
  51101. rotationSphereSize: number;
  51102. /**
  51103. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  51104. */
  51105. scaleBoxSize: number;
  51106. /**
  51107. * 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)
  51108. */
  51109. fixedDragMeshScreenSize: boolean;
  51110. /**
  51111. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  51112. */
  51113. fixedDragMeshScreenSizeDistanceFactor: number;
  51114. /**
  51115. * Fired when a rotation sphere or scale box is dragged
  51116. */
  51117. onDragStartObservable: Observable<{}>;
  51118. /**
  51119. * Fired when a scale box is dragged
  51120. */
  51121. onScaleBoxDragObservable: Observable<{}>;
  51122. /**
  51123. * Fired when a scale box drag is ended
  51124. */
  51125. onScaleBoxDragEndObservable: Observable<{}>;
  51126. /**
  51127. * Fired when a rotation sphere is dragged
  51128. */
  51129. onRotationSphereDragObservable: Observable<{}>;
  51130. /**
  51131. * Fired when a rotation sphere drag is ended
  51132. */
  51133. onRotationSphereDragEndObservable: Observable<{}>;
  51134. /**
  51135. * 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)
  51136. */
  51137. scalePivot: Nullable<Vector3>;
  51138. /**
  51139. * Mesh used as a pivot to rotate the attached mesh
  51140. */
  51141. private _anchorMesh;
  51142. private _existingMeshScale;
  51143. private _dragMesh;
  51144. private pointerDragBehavior;
  51145. private coloredMaterial;
  51146. private hoverColoredMaterial;
  51147. /**
  51148. * Sets the color of the bounding box gizmo
  51149. * @param color the color to set
  51150. */
  51151. setColor(color: Color3): void;
  51152. /**
  51153. * Creates an BoundingBoxGizmo
  51154. * @param gizmoLayer The utility layer the gizmo will be added to
  51155. * @param color The color of the gizmo
  51156. */
  51157. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  51158. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  51159. private _selectNode;
  51160. /**
  51161. * Updates the bounding box information for the Gizmo
  51162. */
  51163. updateBoundingBox(): void;
  51164. private _updateRotationSpheres;
  51165. private _updateScaleBoxes;
  51166. /**
  51167. * Enables rotation on the specified axis and disables rotation on the others
  51168. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  51169. */
  51170. setEnabledRotationAxis(axis: string): void;
  51171. /**
  51172. * Enables/disables scaling
  51173. * @param enable if scaling should be enabled
  51174. * @param homogeneousScaling defines if scaling should only be homogeneous
  51175. */
  51176. setEnabledScaling(enable: boolean, homogeneousScaling?: boolean): void;
  51177. private _updateDummy;
  51178. /**
  51179. * Enables a pointer drag behavior on the bounding box of the gizmo
  51180. */
  51181. enableDragBehavior(): void;
  51182. /**
  51183. * Disposes of the gizmo
  51184. */
  51185. dispose(): void;
  51186. /**
  51187. * 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)
  51188. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  51189. * @returns the bounding box mesh with the passed in mesh as a child
  51190. */
  51191. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  51192. /**
  51193. * CustomMeshes are not supported by this gizmo
  51194. * @param mesh The mesh to replace the default mesh of the gizmo
  51195. */
  51196. setCustomMesh(mesh: Mesh): void;
  51197. }
  51198. }
  51199. declare module "babylonjs/Gizmos/planeRotationGizmo" {
  51200. import { Observable } from "babylonjs/Misc/observable";
  51201. import { Nullable } from "babylonjs/types";
  51202. import { Vector3 } from "babylonjs/Maths/math.vector";
  51203. import { Color3 } from "babylonjs/Maths/math.color";
  51204. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51205. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  51206. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  51207. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  51208. import "babylonjs/Meshes/Builders/linesBuilder";
  51209. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  51210. /**
  51211. * Single plane rotation gizmo
  51212. */
  51213. export class PlaneRotationGizmo extends Gizmo {
  51214. /**
  51215. * Drag behavior responsible for the gizmos dragging interactions
  51216. */
  51217. dragBehavior: PointerDragBehavior;
  51218. private _pointerObserver;
  51219. /**
  51220. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  51221. */
  51222. snapDistance: number;
  51223. /**
  51224. * Event that fires each time the gizmo snaps to a new location.
  51225. * * snapDistance is the the change in distance
  51226. */
  51227. onSnapObservable: Observable<{
  51228. snapDistance: number;
  51229. }>;
  51230. private _isEnabled;
  51231. private _parent;
  51232. /**
  51233. * Creates a PlaneRotationGizmo
  51234. * @param gizmoLayer The utility layer the gizmo will be added to
  51235. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  51236. * @param color The color of the gizmo
  51237. * @param tessellation Amount of tessellation to be used when creating rotation circles
  51238. * @param useEulerRotation Use and update Euler angle instead of quaternion
  51239. */
  51240. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  51241. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  51242. /**
  51243. * If the gizmo is enabled
  51244. */
  51245. set isEnabled(value: boolean);
  51246. get isEnabled(): boolean;
  51247. /**
  51248. * Disposes of the gizmo
  51249. */
  51250. dispose(): void;
  51251. }
  51252. }
  51253. declare module "babylonjs/Gizmos/rotationGizmo" {
  51254. import { Observable } from "babylonjs/Misc/observable";
  51255. import { Nullable } from "babylonjs/types";
  51256. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51257. import { Mesh } from "babylonjs/Meshes/mesh";
  51258. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  51259. import { PlaneRotationGizmo } from "babylonjs/Gizmos/planeRotationGizmo";
  51260. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  51261. /**
  51262. * Gizmo that enables rotating a mesh along 3 axis
  51263. */
  51264. export class RotationGizmo extends Gizmo {
  51265. /**
  51266. * Internal gizmo used for interactions on the x axis
  51267. */
  51268. xGizmo: PlaneRotationGizmo;
  51269. /**
  51270. * Internal gizmo used for interactions on the y axis
  51271. */
  51272. yGizmo: PlaneRotationGizmo;
  51273. /**
  51274. * Internal gizmo used for interactions on the z axis
  51275. */
  51276. zGizmo: PlaneRotationGizmo;
  51277. /** Fires an event when any of it's sub gizmos are dragged */
  51278. onDragStartObservable: Observable<unknown>;
  51279. /** Fires an event when any of it's sub gizmos are released from dragging */
  51280. onDragEndObservable: Observable<unknown>;
  51281. private _meshAttached;
  51282. get attachedMesh(): Nullable<AbstractMesh>;
  51283. set attachedMesh(mesh: Nullable<AbstractMesh>);
  51284. /**
  51285. * Creates a RotationGizmo
  51286. * @param gizmoLayer The utility layer the gizmo will be added to
  51287. * @param tessellation Amount of tessellation to be used when creating rotation circles
  51288. * @param useEulerRotation Use and update Euler angle instead of quaternion
  51289. */
  51290. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  51291. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  51292. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  51293. /**
  51294. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  51295. */
  51296. set snapDistance(value: number);
  51297. get snapDistance(): number;
  51298. /**
  51299. * Ratio for the scale of the gizmo (Default: 1)
  51300. */
  51301. set scaleRatio(value: number);
  51302. get scaleRatio(): number;
  51303. /**
  51304. * Disposes of the gizmo
  51305. */
  51306. dispose(): void;
  51307. /**
  51308. * CustomMeshes are not supported by this gizmo
  51309. * @param mesh The mesh to replace the default mesh of the gizmo
  51310. */
  51311. setCustomMesh(mesh: Mesh): void;
  51312. }
  51313. }
  51314. declare module "babylonjs/Gizmos/gizmoManager" {
  51315. import { Observable } from "babylonjs/Misc/observable";
  51316. import { Nullable } from "babylonjs/types";
  51317. import { Scene, IDisposable } from "babylonjs/scene";
  51318. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51319. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  51320. import { SixDofDragBehavior } from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  51321. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  51322. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  51323. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  51324. import { BoundingBoxGizmo } from "babylonjs/Gizmos/boundingBoxGizmo";
  51325. /**
  51326. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  51327. */
  51328. export class GizmoManager implements IDisposable {
  51329. private scene;
  51330. /**
  51331. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  51332. */
  51333. gizmos: {
  51334. positionGizmo: Nullable<PositionGizmo>;
  51335. rotationGizmo: Nullable<RotationGizmo>;
  51336. scaleGizmo: Nullable<ScaleGizmo>;
  51337. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  51338. };
  51339. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  51340. clearGizmoOnEmptyPointerEvent: boolean;
  51341. /** Fires an event when the manager is attached to a mesh */
  51342. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  51343. private _gizmosEnabled;
  51344. private _pointerObserver;
  51345. private _attachedMesh;
  51346. private _boundingBoxColor;
  51347. private _defaultUtilityLayer;
  51348. private _defaultKeepDepthUtilityLayer;
  51349. /**
  51350. * When bounding box gizmo is enabled, this can be used to track drag/end events
  51351. */
  51352. boundingBoxDragBehavior: SixDofDragBehavior;
  51353. /**
  51354. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  51355. */
  51356. attachableMeshes: Nullable<Array<AbstractMesh>>;
  51357. /**
  51358. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  51359. */
  51360. usePointerToAttachGizmos: boolean;
  51361. /**
  51362. * Utility layer that the bounding box gizmo belongs to
  51363. */
  51364. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  51365. /**
  51366. * Utility layer that all gizmos besides bounding box belong to
  51367. */
  51368. get utilityLayer(): UtilityLayerRenderer;
  51369. /**
  51370. * Instatiates a gizmo manager
  51371. * @param scene the scene to overlay the gizmos on top of
  51372. */
  51373. constructor(scene: Scene);
  51374. /**
  51375. * Attaches a set of gizmos to the specified mesh
  51376. * @param mesh The mesh the gizmo's should be attached to
  51377. */
  51378. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  51379. /**
  51380. * If the position gizmo is enabled
  51381. */
  51382. set positionGizmoEnabled(value: boolean);
  51383. get positionGizmoEnabled(): boolean;
  51384. /**
  51385. * If the rotation gizmo is enabled
  51386. */
  51387. set rotationGizmoEnabled(value: boolean);
  51388. get rotationGizmoEnabled(): boolean;
  51389. /**
  51390. * If the scale gizmo is enabled
  51391. */
  51392. set scaleGizmoEnabled(value: boolean);
  51393. get scaleGizmoEnabled(): boolean;
  51394. /**
  51395. * If the boundingBox gizmo is enabled
  51396. */
  51397. set boundingBoxGizmoEnabled(value: boolean);
  51398. get boundingBoxGizmoEnabled(): boolean;
  51399. /**
  51400. * Disposes of the gizmo manager
  51401. */
  51402. dispose(): void;
  51403. }
  51404. }
  51405. declare module "babylonjs/Lights/directionalLight" {
  51406. import { Camera } from "babylonjs/Cameras/camera";
  51407. import { Scene } from "babylonjs/scene";
  51408. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  51409. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51410. import { Light } from "babylonjs/Lights/light";
  51411. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  51412. import { Effect } from "babylonjs/Materials/effect";
  51413. /**
  51414. * A directional light is defined by a direction (what a surprise!).
  51415. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  51416. * 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.
  51417. * Documentation: https://doc.babylonjs.com/babylon101/lights
  51418. */
  51419. export class DirectionalLight extends ShadowLight {
  51420. private _shadowFrustumSize;
  51421. /**
  51422. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  51423. */
  51424. get shadowFrustumSize(): number;
  51425. /**
  51426. * Specifies a fix frustum size for the shadow generation.
  51427. */
  51428. set shadowFrustumSize(value: number);
  51429. private _shadowOrthoScale;
  51430. /**
  51431. * Gets the shadow projection scale against the optimal computed one.
  51432. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  51433. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  51434. */
  51435. get shadowOrthoScale(): number;
  51436. /**
  51437. * Sets the shadow projection scale against the optimal computed one.
  51438. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  51439. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  51440. */
  51441. set shadowOrthoScale(value: number);
  51442. /**
  51443. * Automatically compute the projection matrix to best fit (including all the casters)
  51444. * on each frame.
  51445. */
  51446. autoUpdateExtends: boolean;
  51447. /**
  51448. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  51449. * on each frame. autoUpdateExtends must be set to true for this to work
  51450. */
  51451. autoCalcShadowZBounds: boolean;
  51452. private _orthoLeft;
  51453. private _orthoRight;
  51454. private _orthoTop;
  51455. private _orthoBottom;
  51456. /**
  51457. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  51458. * The directional light is emitted from everywhere in the given direction.
  51459. * It can cast shadows.
  51460. * Documentation : https://doc.babylonjs.com/babylon101/lights
  51461. * @param name The friendly name of the light
  51462. * @param direction The direction of the light
  51463. * @param scene The scene the light belongs to
  51464. */
  51465. constructor(name: string, direction: Vector3, scene: Scene);
  51466. /**
  51467. * Returns the string "DirectionalLight".
  51468. * @return The class name
  51469. */
  51470. getClassName(): string;
  51471. /**
  51472. * Returns the integer 1.
  51473. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  51474. */
  51475. getTypeID(): number;
  51476. /**
  51477. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  51478. * Returns the DirectionalLight Shadow projection matrix.
  51479. */
  51480. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  51481. /**
  51482. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  51483. * Returns the DirectionalLight Shadow projection matrix.
  51484. */
  51485. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  51486. /**
  51487. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  51488. * Returns the DirectionalLight Shadow projection matrix.
  51489. */
  51490. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  51491. protected _buildUniformLayout(): void;
  51492. /**
  51493. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  51494. * @param effect The effect to update
  51495. * @param lightIndex The index of the light in the effect to update
  51496. * @returns The directional light
  51497. */
  51498. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  51499. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  51500. /**
  51501. * Gets the minZ used for shadow according to both the scene and the light.
  51502. *
  51503. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  51504. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  51505. * @param activeCamera The camera we are returning the min for
  51506. * @returns the depth min z
  51507. */
  51508. getDepthMinZ(activeCamera: Camera): number;
  51509. /**
  51510. * Gets the maxZ used for shadow according to both the scene and the light.
  51511. *
  51512. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  51513. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  51514. * @param activeCamera The camera we are returning the max for
  51515. * @returns the depth max z
  51516. */
  51517. getDepthMaxZ(activeCamera: Camera): number;
  51518. /**
  51519. * Prepares the list of defines specific to the light type.
  51520. * @param defines the list of defines
  51521. * @param lightIndex defines the index of the light for the effect
  51522. */
  51523. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  51524. }
  51525. }
  51526. declare module "babylonjs/Meshes/Builders/hemisphereBuilder" {
  51527. import { Mesh } from "babylonjs/Meshes/mesh";
  51528. /**
  51529. * Class containing static functions to help procedurally build meshes
  51530. */
  51531. export class HemisphereBuilder {
  51532. /**
  51533. * Creates a hemisphere mesh
  51534. * @param name defines the name of the mesh
  51535. * @param options defines the options used to create the mesh
  51536. * @param scene defines the hosting scene
  51537. * @returns the hemisphere mesh
  51538. */
  51539. static CreateHemisphere(name: string, options: {
  51540. segments?: number;
  51541. diameter?: number;
  51542. sideOrientation?: number;
  51543. }, scene: any): Mesh;
  51544. }
  51545. }
  51546. declare module "babylonjs/Lights/spotLight" {
  51547. import { Nullable } from "babylonjs/types";
  51548. import { Scene } from "babylonjs/scene";
  51549. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  51550. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51551. import { Effect } from "babylonjs/Materials/effect";
  51552. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51553. import { Light } from "babylonjs/Lights/light";
  51554. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  51555. /**
  51556. * A spot light is defined by a position, a direction, an angle, and an exponent.
  51557. * These values define a cone of light starting from the position, emitting toward the direction.
  51558. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  51559. * and the exponent defines the speed of the decay of the light with distance (reach).
  51560. * Documentation: https://doc.babylonjs.com/babylon101/lights
  51561. */
  51562. export class SpotLight extends ShadowLight {
  51563. private _angle;
  51564. private _innerAngle;
  51565. private _cosHalfAngle;
  51566. private _lightAngleScale;
  51567. private _lightAngleOffset;
  51568. /**
  51569. * Gets the cone angle of the spot light in Radians.
  51570. */
  51571. get angle(): number;
  51572. /**
  51573. * Sets the cone angle of the spot light in Radians.
  51574. */
  51575. set angle(value: number);
  51576. /**
  51577. * Only used in gltf falloff mode, this defines the angle where
  51578. * the directional falloff will start before cutting at angle which could be seen
  51579. * as outer angle.
  51580. */
  51581. get innerAngle(): number;
  51582. /**
  51583. * Only used in gltf falloff mode, this defines the angle where
  51584. * the directional falloff will start before cutting at angle which could be seen
  51585. * as outer angle.
  51586. */
  51587. set innerAngle(value: number);
  51588. private _shadowAngleScale;
  51589. /**
  51590. * Allows scaling the angle of the light for shadow generation only.
  51591. */
  51592. get shadowAngleScale(): number;
  51593. /**
  51594. * Allows scaling the angle of the light for shadow generation only.
  51595. */
  51596. set shadowAngleScale(value: number);
  51597. /**
  51598. * The light decay speed with the distance from the emission spot.
  51599. */
  51600. exponent: number;
  51601. private _projectionTextureMatrix;
  51602. /**
  51603. * Allows reading the projecton texture
  51604. */
  51605. get projectionTextureMatrix(): Matrix;
  51606. protected _projectionTextureLightNear: number;
  51607. /**
  51608. * Gets the near clip of the Spotlight for texture projection.
  51609. */
  51610. get projectionTextureLightNear(): number;
  51611. /**
  51612. * Sets the near clip of the Spotlight for texture projection.
  51613. */
  51614. set projectionTextureLightNear(value: number);
  51615. protected _projectionTextureLightFar: number;
  51616. /**
  51617. * Gets the far clip of the Spotlight for texture projection.
  51618. */
  51619. get projectionTextureLightFar(): number;
  51620. /**
  51621. * Sets the far clip of the Spotlight for texture projection.
  51622. */
  51623. set projectionTextureLightFar(value: number);
  51624. protected _projectionTextureUpDirection: Vector3;
  51625. /**
  51626. * Gets the Up vector of the Spotlight for texture projection.
  51627. */
  51628. get projectionTextureUpDirection(): Vector3;
  51629. /**
  51630. * Sets the Up vector of the Spotlight for texture projection.
  51631. */
  51632. set projectionTextureUpDirection(value: Vector3);
  51633. private _projectionTexture;
  51634. /**
  51635. * Gets the projection texture of the light.
  51636. */
  51637. get projectionTexture(): Nullable<BaseTexture>;
  51638. /**
  51639. * Sets the projection texture of the light.
  51640. */
  51641. set projectionTexture(value: Nullable<BaseTexture>);
  51642. private _projectionTextureViewLightDirty;
  51643. private _projectionTextureProjectionLightDirty;
  51644. private _projectionTextureDirty;
  51645. private _projectionTextureViewTargetVector;
  51646. private _projectionTextureViewLightMatrix;
  51647. private _projectionTextureProjectionLightMatrix;
  51648. private _projectionTextureScalingMatrix;
  51649. /**
  51650. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  51651. * It can cast shadows.
  51652. * Documentation : https://doc.babylonjs.com/babylon101/lights
  51653. * @param name The light friendly name
  51654. * @param position The position of the spot light in the scene
  51655. * @param direction The direction of the light in the scene
  51656. * @param angle The cone angle of the light in Radians
  51657. * @param exponent The light decay speed with the distance from the emission spot
  51658. * @param scene The scene the lights belongs to
  51659. */
  51660. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  51661. /**
  51662. * Returns the string "SpotLight".
  51663. * @returns the class name
  51664. */
  51665. getClassName(): string;
  51666. /**
  51667. * Returns the integer 2.
  51668. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  51669. */
  51670. getTypeID(): number;
  51671. /**
  51672. * Overrides the direction setter to recompute the projection texture view light Matrix.
  51673. */
  51674. protected _setDirection(value: Vector3): void;
  51675. /**
  51676. * Overrides the position setter to recompute the projection texture view light Matrix.
  51677. */
  51678. protected _setPosition(value: Vector3): void;
  51679. /**
  51680. * 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.
  51681. * Returns the SpotLight.
  51682. */
  51683. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  51684. protected _computeProjectionTextureViewLightMatrix(): void;
  51685. protected _computeProjectionTextureProjectionLightMatrix(): void;
  51686. /**
  51687. * Main function for light texture projection matrix computing.
  51688. */
  51689. protected _computeProjectionTextureMatrix(): void;
  51690. protected _buildUniformLayout(): void;
  51691. private _computeAngleValues;
  51692. /**
  51693. * Sets the passed Effect "effect" with the Light textures.
  51694. * @param effect The effect to update
  51695. * @param lightIndex The index of the light in the effect to update
  51696. * @returns The light
  51697. */
  51698. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  51699. /**
  51700. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  51701. * @param effect The effect to update
  51702. * @param lightIndex The index of the light in the effect to update
  51703. * @returns The spot light
  51704. */
  51705. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  51706. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  51707. /**
  51708. * Disposes the light and the associated resources.
  51709. */
  51710. dispose(): void;
  51711. /**
  51712. * Prepares the list of defines specific to the light type.
  51713. * @param defines the list of defines
  51714. * @param lightIndex defines the index of the light for the effect
  51715. */
  51716. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  51717. }
  51718. }
  51719. declare module "babylonjs/Gizmos/lightGizmo" {
  51720. import { Nullable } from "babylonjs/types";
  51721. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  51722. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  51723. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  51724. import { Light } from "babylonjs/Lights/light";
  51725. /**
  51726. * Gizmo that enables viewing a light
  51727. */
  51728. export class LightGizmo extends Gizmo {
  51729. private _lightMesh;
  51730. private _material;
  51731. private _cachedPosition;
  51732. private _cachedForward;
  51733. private _attachedMeshParent;
  51734. /**
  51735. * Creates a LightGizmo
  51736. * @param gizmoLayer The utility layer the gizmo will be added to
  51737. */
  51738. constructor(gizmoLayer?: UtilityLayerRenderer);
  51739. private _light;
  51740. /**
  51741. * The light that the gizmo is attached to
  51742. */
  51743. set light(light: Nullable<Light>);
  51744. get light(): Nullable<Light>;
  51745. /**
  51746. * Gets the material used to render the light gizmo
  51747. */
  51748. get material(): StandardMaterial;
  51749. /**
  51750. * @hidden
  51751. * Updates the gizmo to match the attached mesh's position/rotation
  51752. */
  51753. protected _update(): void;
  51754. private static _Scale;
  51755. /**
  51756. * Creates the lines for a light mesh
  51757. */
  51758. private static _CreateLightLines;
  51759. /**
  51760. * Disposes of the light gizmo
  51761. */
  51762. dispose(): void;
  51763. private static _CreateHemisphericLightMesh;
  51764. private static _CreatePointLightMesh;
  51765. private static _CreateSpotLightMesh;
  51766. private static _CreateDirectionalLightMesh;
  51767. }
  51768. }
  51769. declare module "babylonjs/Gizmos/index" {
  51770. export * from "babylonjs/Gizmos/axisDragGizmo";
  51771. export * from "babylonjs/Gizmos/axisScaleGizmo";
  51772. export * from "babylonjs/Gizmos/boundingBoxGizmo";
  51773. export * from "babylonjs/Gizmos/gizmo";
  51774. export * from "babylonjs/Gizmos/gizmoManager";
  51775. export * from "babylonjs/Gizmos/planeRotationGizmo";
  51776. export * from "babylonjs/Gizmos/positionGizmo";
  51777. export * from "babylonjs/Gizmos/rotationGizmo";
  51778. export * from "babylonjs/Gizmos/scaleGizmo";
  51779. export * from "babylonjs/Gizmos/lightGizmo";
  51780. export * from "babylonjs/Gizmos/planeDragGizmo";
  51781. }
  51782. declare module "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration" {
  51783. /** @hidden */
  51784. export var backgroundFragmentDeclaration: {
  51785. name: string;
  51786. shader: string;
  51787. };
  51788. }
  51789. declare module "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration" {
  51790. /** @hidden */
  51791. export var backgroundUboDeclaration: {
  51792. name: string;
  51793. shader: string;
  51794. };
  51795. }
  51796. declare module "babylonjs/Shaders/background.fragment" {
  51797. import "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration";
  51798. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  51799. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  51800. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  51801. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  51802. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  51803. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  51804. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  51805. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  51806. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  51807. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  51808. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  51809. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  51810. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  51811. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  51812. /** @hidden */
  51813. export var backgroundPixelShader: {
  51814. name: string;
  51815. shader: string;
  51816. };
  51817. }
  51818. declare module "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration" {
  51819. /** @hidden */
  51820. export var backgroundVertexDeclaration: {
  51821. name: string;
  51822. shader: string;
  51823. };
  51824. }
  51825. declare module "babylonjs/Shaders/background.vertex" {
  51826. import "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration";
  51827. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  51828. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  51829. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  51830. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  51831. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  51832. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  51833. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  51834. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  51835. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  51836. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  51837. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  51838. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  51839. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  51840. /** @hidden */
  51841. export var backgroundVertexShader: {
  51842. name: string;
  51843. shader: string;
  51844. };
  51845. }
  51846. declare module "babylonjs/Materials/Background/backgroundMaterial" {
  51847. import { Nullable, int, float } from "babylonjs/types";
  51848. import { Scene } from "babylonjs/scene";
  51849. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  51850. import { SubMesh } from "babylonjs/Meshes/subMesh";
  51851. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51852. import { Mesh } from "babylonjs/Meshes/mesh";
  51853. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  51854. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  51855. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  51856. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51857. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  51858. import { Color3 } from "babylonjs/Maths/math.color";
  51859. import "babylonjs/Shaders/background.fragment";
  51860. import "babylonjs/Shaders/background.vertex";
  51861. /**
  51862. * Background material used to create an efficient environement around your scene.
  51863. */
  51864. export class BackgroundMaterial extends PushMaterial {
  51865. /**
  51866. * Standard reflectance value at parallel view angle.
  51867. */
  51868. static StandardReflectance0: number;
  51869. /**
  51870. * Standard reflectance value at grazing angle.
  51871. */
  51872. static StandardReflectance90: number;
  51873. protected _primaryColor: Color3;
  51874. /**
  51875. * Key light Color (multiply against the environement texture)
  51876. */
  51877. primaryColor: Color3;
  51878. protected __perceptualColor: Nullable<Color3>;
  51879. /**
  51880. * Experimental Internal Use Only.
  51881. *
  51882. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  51883. * This acts as a helper to set the primary color to a more "human friendly" value.
  51884. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  51885. * output color as close as possible from the chosen value.
  51886. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  51887. * part of lighting setup.)
  51888. */
  51889. get _perceptualColor(): Nullable<Color3>;
  51890. set _perceptualColor(value: Nullable<Color3>);
  51891. protected _primaryColorShadowLevel: float;
  51892. /**
  51893. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  51894. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  51895. */
  51896. get primaryColorShadowLevel(): float;
  51897. set primaryColorShadowLevel(value: float);
  51898. protected _primaryColorHighlightLevel: float;
  51899. /**
  51900. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  51901. * The primary color is used at the level chosen to define what the white area would look.
  51902. */
  51903. get primaryColorHighlightLevel(): float;
  51904. set primaryColorHighlightLevel(value: float);
  51905. protected _reflectionTexture: Nullable<BaseTexture>;
  51906. /**
  51907. * Reflection Texture used in the material.
  51908. * Should be author in a specific way for the best result (refer to the documentation).
  51909. */
  51910. reflectionTexture: Nullable<BaseTexture>;
  51911. protected _reflectionBlur: float;
  51912. /**
  51913. * Reflection Texture level of blur.
  51914. *
  51915. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  51916. * texture twice.
  51917. */
  51918. reflectionBlur: float;
  51919. protected _diffuseTexture: Nullable<BaseTexture>;
  51920. /**
  51921. * Diffuse Texture used in the material.
  51922. * Should be author in a specific way for the best result (refer to the documentation).
  51923. */
  51924. diffuseTexture: Nullable<BaseTexture>;
  51925. protected _shadowLights: Nullable<IShadowLight[]>;
  51926. /**
  51927. * Specify the list of lights casting shadow on the material.
  51928. * All scene shadow lights will be included if null.
  51929. */
  51930. shadowLights: Nullable<IShadowLight[]>;
  51931. protected _shadowLevel: float;
  51932. /**
  51933. * Helps adjusting the shadow to a softer level if required.
  51934. * 0 means black shadows and 1 means no shadows.
  51935. */
  51936. shadowLevel: float;
  51937. protected _sceneCenter: Vector3;
  51938. /**
  51939. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  51940. * It is usually zero but might be interesting to modify according to your setup.
  51941. */
  51942. sceneCenter: Vector3;
  51943. protected _opacityFresnel: boolean;
  51944. /**
  51945. * This helps specifying that the material is falling off to the sky box at grazing angle.
  51946. * This helps ensuring a nice transition when the camera goes under the ground.
  51947. */
  51948. opacityFresnel: boolean;
  51949. protected _reflectionFresnel: boolean;
  51950. /**
  51951. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  51952. * This helps adding a mirror texture on the ground.
  51953. */
  51954. reflectionFresnel: boolean;
  51955. protected _reflectionFalloffDistance: number;
  51956. /**
  51957. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  51958. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  51959. */
  51960. reflectionFalloffDistance: number;
  51961. protected _reflectionAmount: number;
  51962. /**
  51963. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  51964. */
  51965. reflectionAmount: number;
  51966. protected _reflectionReflectance0: number;
  51967. /**
  51968. * This specifies the weight of the reflection at grazing angle.
  51969. */
  51970. reflectionReflectance0: number;
  51971. protected _reflectionReflectance90: number;
  51972. /**
  51973. * This specifies the weight of the reflection at a perpendicular point of view.
  51974. */
  51975. reflectionReflectance90: number;
  51976. /**
  51977. * Sets the reflection reflectance fresnel values according to the default standard
  51978. * empirically know to work well :-)
  51979. */
  51980. set reflectionStandardFresnelWeight(value: number);
  51981. protected _useRGBColor: boolean;
  51982. /**
  51983. * Helps to directly use the maps channels instead of their level.
  51984. */
  51985. useRGBColor: boolean;
  51986. protected _enableNoise: boolean;
  51987. /**
  51988. * This helps reducing the banding effect that could occur on the background.
  51989. */
  51990. enableNoise: boolean;
  51991. /**
  51992. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  51993. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  51994. * Recommended to be keep at 1.0 except for special cases.
  51995. */
  51996. get fovMultiplier(): number;
  51997. set fovMultiplier(value: number);
  51998. private _fovMultiplier;
  51999. /**
  52000. * Enable the FOV adjustment feature controlled by fovMultiplier.
  52001. */
  52002. useEquirectangularFOV: boolean;
  52003. private _maxSimultaneousLights;
  52004. /**
  52005. * Number of Simultaneous lights allowed on the material.
  52006. */
  52007. maxSimultaneousLights: int;
  52008. /**
  52009. * Default configuration related to image processing available in the Background Material.
  52010. */
  52011. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  52012. /**
  52013. * Keep track of the image processing observer to allow dispose and replace.
  52014. */
  52015. private _imageProcessingObserver;
  52016. /**
  52017. * Attaches a new image processing configuration to the PBR Material.
  52018. * @param configuration (if null the scene configuration will be use)
  52019. */
  52020. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  52021. /**
  52022. * Gets the image processing configuration used either in this material.
  52023. */
  52024. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  52025. /**
  52026. * Sets the Default image processing configuration used either in the this material.
  52027. *
  52028. * If sets to null, the scene one is in use.
  52029. */
  52030. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  52031. /**
  52032. * Gets wether the color curves effect is enabled.
  52033. */
  52034. get cameraColorCurvesEnabled(): boolean;
  52035. /**
  52036. * Sets wether the color curves effect is enabled.
  52037. */
  52038. set cameraColorCurvesEnabled(value: boolean);
  52039. /**
  52040. * Gets wether the color grading effect is enabled.
  52041. */
  52042. get cameraColorGradingEnabled(): boolean;
  52043. /**
  52044. * Gets wether the color grading effect is enabled.
  52045. */
  52046. set cameraColorGradingEnabled(value: boolean);
  52047. /**
  52048. * Gets wether tonemapping is enabled or not.
  52049. */
  52050. get cameraToneMappingEnabled(): boolean;
  52051. /**
  52052. * Sets wether tonemapping is enabled or not
  52053. */
  52054. set cameraToneMappingEnabled(value: boolean);
  52055. /**
  52056. * The camera exposure used on this material.
  52057. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  52058. * This corresponds to a photographic exposure.
  52059. */
  52060. get cameraExposure(): float;
  52061. /**
  52062. * The camera exposure used on this material.
  52063. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  52064. * This corresponds to a photographic exposure.
  52065. */
  52066. set cameraExposure(value: float);
  52067. /**
  52068. * Gets The camera contrast used on this material.
  52069. */
  52070. get cameraContrast(): float;
  52071. /**
  52072. * Sets The camera contrast used on this material.
  52073. */
  52074. set cameraContrast(value: float);
  52075. /**
  52076. * Gets the Color Grading 2D Lookup Texture.
  52077. */
  52078. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  52079. /**
  52080. * Sets the Color Grading 2D Lookup Texture.
  52081. */
  52082. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  52083. /**
  52084. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  52085. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  52086. * 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;
  52087. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  52088. */
  52089. get cameraColorCurves(): Nullable<ColorCurves>;
  52090. /**
  52091. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  52092. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  52093. * 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;
  52094. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  52095. */
  52096. set cameraColorCurves(value: Nullable<ColorCurves>);
  52097. /**
  52098. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  52099. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  52100. */
  52101. switchToBGR: boolean;
  52102. private _renderTargets;
  52103. private _reflectionControls;
  52104. private _white;
  52105. private _primaryShadowColor;
  52106. private _primaryHighlightColor;
  52107. /**
  52108. * Instantiates a Background Material in the given scene
  52109. * @param name The friendly name of the material
  52110. * @param scene The scene to add the material to
  52111. */
  52112. constructor(name: string, scene: Scene);
  52113. /**
  52114. * Gets a boolean indicating that current material needs to register RTT
  52115. */
  52116. get hasRenderTargetTextures(): boolean;
  52117. /**
  52118. * The entire material has been created in order to prevent overdraw.
  52119. * @returns false
  52120. */
  52121. needAlphaTesting(): boolean;
  52122. /**
  52123. * The entire material has been created in order to prevent overdraw.
  52124. * @returns true if blending is enable
  52125. */
  52126. needAlphaBlending(): boolean;
  52127. /**
  52128. * Checks wether the material is ready to be rendered for a given mesh.
  52129. * @param mesh The mesh to render
  52130. * @param subMesh The submesh to check against
  52131. * @param useInstances Specify wether or not the material is used with instances
  52132. * @returns true if all the dependencies are ready (Textures, Effects...)
  52133. */
  52134. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  52135. /**
  52136. * Compute the primary color according to the chosen perceptual color.
  52137. */
  52138. private _computePrimaryColorFromPerceptualColor;
  52139. /**
  52140. * Compute the highlights and shadow colors according to their chosen levels.
  52141. */
  52142. private _computePrimaryColors;
  52143. /**
  52144. * Build the uniform buffer used in the material.
  52145. */
  52146. buildUniformLayout(): void;
  52147. /**
  52148. * Unbind the material.
  52149. */
  52150. unbind(): void;
  52151. /**
  52152. * Bind only the world matrix to the material.
  52153. * @param world The world matrix to bind.
  52154. */
  52155. bindOnlyWorldMatrix(world: Matrix): void;
  52156. /**
  52157. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  52158. * @param world The world matrix to bind.
  52159. * @param subMesh The submesh to bind for.
  52160. */
  52161. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  52162. /**
  52163. * Checks to see if a texture is used in the material.
  52164. * @param texture - Base texture to use.
  52165. * @returns - Boolean specifying if a texture is used in the material.
  52166. */
  52167. hasTexture(texture: BaseTexture): boolean;
  52168. /**
  52169. * Dispose the material.
  52170. * @param forceDisposeEffect Force disposal of the associated effect.
  52171. * @param forceDisposeTextures Force disposal of the associated textures.
  52172. */
  52173. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  52174. /**
  52175. * Clones the material.
  52176. * @param name The cloned name.
  52177. * @returns The cloned material.
  52178. */
  52179. clone(name: string): BackgroundMaterial;
  52180. /**
  52181. * Serializes the current material to its JSON representation.
  52182. * @returns The JSON representation.
  52183. */
  52184. serialize(): any;
  52185. /**
  52186. * Gets the class name of the material
  52187. * @returns "BackgroundMaterial"
  52188. */
  52189. getClassName(): string;
  52190. /**
  52191. * Parse a JSON input to create back a background material.
  52192. * @param source The JSON data to parse
  52193. * @param scene The scene to create the parsed material in
  52194. * @param rootUrl The root url of the assets the material depends upon
  52195. * @returns the instantiated BackgroundMaterial.
  52196. */
  52197. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  52198. }
  52199. }
  52200. declare module "babylonjs/Helpers/environmentHelper" {
  52201. import { Observable } from "babylonjs/Misc/observable";
  52202. import { Nullable } from "babylonjs/types";
  52203. import { Scene } from "babylonjs/scene";
  52204. import { Vector3 } from "babylonjs/Maths/math.vector";
  52205. import { Color3 } from "babylonjs/Maths/math.color";
  52206. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52207. import { Mesh } from "babylonjs/Meshes/mesh";
  52208. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52209. import { MirrorTexture } from "babylonjs/Materials/Textures/mirrorTexture";
  52210. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  52211. import "babylonjs/Meshes/Builders/planeBuilder";
  52212. import "babylonjs/Meshes/Builders/boxBuilder";
  52213. /**
  52214. * Represents the different options available during the creation of
  52215. * a Environment helper.
  52216. *
  52217. * This can control the default ground, skybox and image processing setup of your scene.
  52218. */
  52219. export interface IEnvironmentHelperOptions {
  52220. /**
  52221. * Specifies whether or not to create a ground.
  52222. * True by default.
  52223. */
  52224. createGround: boolean;
  52225. /**
  52226. * Specifies the ground size.
  52227. * 15 by default.
  52228. */
  52229. groundSize: number;
  52230. /**
  52231. * The texture used on the ground for the main color.
  52232. * Comes from the BabylonJS CDN by default.
  52233. *
  52234. * Remarks: Can be either a texture or a url.
  52235. */
  52236. groundTexture: string | BaseTexture;
  52237. /**
  52238. * The color mixed in the ground texture by default.
  52239. * BabylonJS clearColor by default.
  52240. */
  52241. groundColor: Color3;
  52242. /**
  52243. * Specifies the ground opacity.
  52244. * 1 by default.
  52245. */
  52246. groundOpacity: number;
  52247. /**
  52248. * Enables the ground to receive shadows.
  52249. * True by default.
  52250. */
  52251. enableGroundShadow: boolean;
  52252. /**
  52253. * Helps preventing the shadow to be fully black on the ground.
  52254. * 0.5 by default.
  52255. */
  52256. groundShadowLevel: number;
  52257. /**
  52258. * Creates a mirror texture attach to the ground.
  52259. * false by default.
  52260. */
  52261. enableGroundMirror: boolean;
  52262. /**
  52263. * Specifies the ground mirror size ratio.
  52264. * 0.3 by default as the default kernel is 64.
  52265. */
  52266. groundMirrorSizeRatio: number;
  52267. /**
  52268. * Specifies the ground mirror blur kernel size.
  52269. * 64 by default.
  52270. */
  52271. groundMirrorBlurKernel: number;
  52272. /**
  52273. * Specifies the ground mirror visibility amount.
  52274. * 1 by default
  52275. */
  52276. groundMirrorAmount: number;
  52277. /**
  52278. * Specifies the ground mirror reflectance weight.
  52279. * This uses the standard weight of the background material to setup the fresnel effect
  52280. * of the mirror.
  52281. * 1 by default.
  52282. */
  52283. groundMirrorFresnelWeight: number;
  52284. /**
  52285. * Specifies the ground mirror Falloff distance.
  52286. * This can helps reducing the size of the reflection.
  52287. * 0 by Default.
  52288. */
  52289. groundMirrorFallOffDistance: number;
  52290. /**
  52291. * Specifies the ground mirror texture type.
  52292. * Unsigned Int by Default.
  52293. */
  52294. groundMirrorTextureType: number;
  52295. /**
  52296. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  52297. * the shown objects.
  52298. */
  52299. groundYBias: number;
  52300. /**
  52301. * Specifies whether or not to create a skybox.
  52302. * True by default.
  52303. */
  52304. createSkybox: boolean;
  52305. /**
  52306. * Specifies the skybox size.
  52307. * 20 by default.
  52308. */
  52309. skyboxSize: number;
  52310. /**
  52311. * The texture used on the skybox for the main color.
  52312. * Comes from the BabylonJS CDN by default.
  52313. *
  52314. * Remarks: Can be either a texture or a url.
  52315. */
  52316. skyboxTexture: string | BaseTexture;
  52317. /**
  52318. * The color mixed in the skybox texture by default.
  52319. * BabylonJS clearColor by default.
  52320. */
  52321. skyboxColor: Color3;
  52322. /**
  52323. * The background rotation around the Y axis of the scene.
  52324. * This helps aligning the key lights of your scene with the background.
  52325. * 0 by default.
  52326. */
  52327. backgroundYRotation: number;
  52328. /**
  52329. * Compute automatically the size of the elements to best fit with the scene.
  52330. */
  52331. sizeAuto: boolean;
  52332. /**
  52333. * Default position of the rootMesh if autoSize is not true.
  52334. */
  52335. rootPosition: Vector3;
  52336. /**
  52337. * Sets up the image processing in the scene.
  52338. * true by default.
  52339. */
  52340. setupImageProcessing: boolean;
  52341. /**
  52342. * The texture used as your environment texture in the scene.
  52343. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  52344. *
  52345. * Remarks: Can be either a texture or a url.
  52346. */
  52347. environmentTexture: string | BaseTexture;
  52348. /**
  52349. * The value of the exposure to apply to the scene.
  52350. * 0.6 by default if setupImageProcessing is true.
  52351. */
  52352. cameraExposure: number;
  52353. /**
  52354. * The value of the contrast to apply to the scene.
  52355. * 1.6 by default if setupImageProcessing is true.
  52356. */
  52357. cameraContrast: number;
  52358. /**
  52359. * Specifies whether or not tonemapping should be enabled in the scene.
  52360. * true by default if setupImageProcessing is true.
  52361. */
  52362. toneMappingEnabled: boolean;
  52363. }
  52364. /**
  52365. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  52366. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  52367. * It also helps with the default setup of your imageProcessing configuration.
  52368. */
  52369. export class EnvironmentHelper {
  52370. /**
  52371. * Default ground texture URL.
  52372. */
  52373. private static _groundTextureCDNUrl;
  52374. /**
  52375. * Default skybox texture URL.
  52376. */
  52377. private static _skyboxTextureCDNUrl;
  52378. /**
  52379. * Default environment texture URL.
  52380. */
  52381. private static _environmentTextureCDNUrl;
  52382. /**
  52383. * Creates the default options for the helper.
  52384. */
  52385. private static _getDefaultOptions;
  52386. private _rootMesh;
  52387. /**
  52388. * Gets the root mesh created by the helper.
  52389. */
  52390. get rootMesh(): Mesh;
  52391. private _skybox;
  52392. /**
  52393. * Gets the skybox created by the helper.
  52394. */
  52395. get skybox(): Nullable<Mesh>;
  52396. private _skyboxTexture;
  52397. /**
  52398. * Gets the skybox texture created by the helper.
  52399. */
  52400. get skyboxTexture(): Nullable<BaseTexture>;
  52401. private _skyboxMaterial;
  52402. /**
  52403. * Gets the skybox material created by the helper.
  52404. */
  52405. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  52406. private _ground;
  52407. /**
  52408. * Gets the ground mesh created by the helper.
  52409. */
  52410. get ground(): Nullable<Mesh>;
  52411. private _groundTexture;
  52412. /**
  52413. * Gets the ground texture created by the helper.
  52414. */
  52415. get groundTexture(): Nullable<BaseTexture>;
  52416. private _groundMirror;
  52417. /**
  52418. * Gets the ground mirror created by the helper.
  52419. */
  52420. get groundMirror(): Nullable<MirrorTexture>;
  52421. /**
  52422. * Gets the ground mirror render list to helps pushing the meshes
  52423. * you wish in the ground reflection.
  52424. */
  52425. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  52426. private _groundMaterial;
  52427. /**
  52428. * Gets the ground material created by the helper.
  52429. */
  52430. get groundMaterial(): Nullable<BackgroundMaterial>;
  52431. /**
  52432. * Stores the creation options.
  52433. */
  52434. private readonly _scene;
  52435. private _options;
  52436. /**
  52437. * This observable will be notified with any error during the creation of the environment,
  52438. * mainly texture creation errors.
  52439. */
  52440. onErrorObservable: Observable<{
  52441. message?: string;
  52442. exception?: any;
  52443. }>;
  52444. /**
  52445. * constructor
  52446. * @param options Defines the options we want to customize the helper
  52447. * @param scene The scene to add the material to
  52448. */
  52449. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  52450. /**
  52451. * Updates the background according to the new options
  52452. * @param options
  52453. */
  52454. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  52455. /**
  52456. * Sets the primary color of all the available elements.
  52457. * @param color the main color to affect to the ground and the background
  52458. */
  52459. setMainColor(color: Color3): void;
  52460. /**
  52461. * Setup the image processing according to the specified options.
  52462. */
  52463. private _setupImageProcessing;
  52464. /**
  52465. * Setup the environment texture according to the specified options.
  52466. */
  52467. private _setupEnvironmentTexture;
  52468. /**
  52469. * Setup the background according to the specified options.
  52470. */
  52471. private _setupBackground;
  52472. /**
  52473. * Get the scene sizes according to the setup.
  52474. */
  52475. private _getSceneSize;
  52476. /**
  52477. * Setup the ground according to the specified options.
  52478. */
  52479. private _setupGround;
  52480. /**
  52481. * Setup the ground material according to the specified options.
  52482. */
  52483. private _setupGroundMaterial;
  52484. /**
  52485. * Setup the ground diffuse texture according to the specified options.
  52486. */
  52487. private _setupGroundDiffuseTexture;
  52488. /**
  52489. * Setup the ground mirror texture according to the specified options.
  52490. */
  52491. private _setupGroundMirrorTexture;
  52492. /**
  52493. * Setup the ground to receive the mirror texture.
  52494. */
  52495. private _setupMirrorInGroundMaterial;
  52496. /**
  52497. * Setup the skybox according to the specified options.
  52498. */
  52499. private _setupSkybox;
  52500. /**
  52501. * Setup the skybox material according to the specified options.
  52502. */
  52503. private _setupSkyboxMaterial;
  52504. /**
  52505. * Setup the skybox reflection texture according to the specified options.
  52506. */
  52507. private _setupSkyboxReflectionTexture;
  52508. private _errorHandler;
  52509. /**
  52510. * Dispose all the elements created by the Helper.
  52511. */
  52512. dispose(): void;
  52513. }
  52514. }
  52515. declare module "babylonjs/Helpers/photoDome" {
  52516. import { Observable } from "babylonjs/Misc/observable";
  52517. import { Nullable } from "babylonjs/types";
  52518. import { Scene } from "babylonjs/scene";
  52519. import { TransformNode } from "babylonjs/Meshes/transformNode";
  52520. import { Mesh } from "babylonjs/Meshes/mesh";
  52521. import { Texture } from "babylonjs/Materials/Textures/texture";
  52522. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  52523. import "babylonjs/Meshes/Builders/sphereBuilder";
  52524. /**
  52525. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  52526. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  52527. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  52528. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  52529. */
  52530. export class PhotoDome extends TransformNode {
  52531. /**
  52532. * Define the image as a Monoscopic panoramic 360 image.
  52533. */
  52534. static readonly MODE_MONOSCOPIC: number;
  52535. /**
  52536. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  52537. */
  52538. static readonly MODE_TOPBOTTOM: number;
  52539. /**
  52540. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  52541. */
  52542. static readonly MODE_SIDEBYSIDE: number;
  52543. private _useDirectMapping;
  52544. /**
  52545. * The texture being displayed on the sphere
  52546. */
  52547. protected _photoTexture: Texture;
  52548. /**
  52549. * Gets or sets the texture being displayed on the sphere
  52550. */
  52551. get photoTexture(): Texture;
  52552. set photoTexture(value: Texture);
  52553. /**
  52554. * Observable raised when an error occured while loading the 360 image
  52555. */
  52556. onLoadErrorObservable: Observable<string>;
  52557. /**
  52558. * The skybox material
  52559. */
  52560. protected _material: BackgroundMaterial;
  52561. /**
  52562. * The surface used for the skybox
  52563. */
  52564. protected _mesh: Mesh;
  52565. /**
  52566. * Gets the mesh used for the skybox.
  52567. */
  52568. get mesh(): Mesh;
  52569. /**
  52570. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  52571. * Also see the options.resolution property.
  52572. */
  52573. get fovMultiplier(): number;
  52574. set fovMultiplier(value: number);
  52575. private _imageMode;
  52576. /**
  52577. * Gets or set the current video mode for the video. It can be:
  52578. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  52579. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  52580. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  52581. */
  52582. get imageMode(): number;
  52583. set imageMode(value: number);
  52584. /**
  52585. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  52586. * @param name Element's name, child elements will append suffixes for their own names.
  52587. * @param urlsOfPhoto defines the url of the photo to display
  52588. * @param options defines an object containing optional or exposed sub element properties
  52589. * @param onError defines a callback called when an error occured while loading the texture
  52590. */
  52591. constructor(name: string, urlOfPhoto: string, options: {
  52592. resolution?: number;
  52593. size?: number;
  52594. useDirectMapping?: boolean;
  52595. faceForward?: boolean;
  52596. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  52597. private _onBeforeCameraRenderObserver;
  52598. private _changeImageMode;
  52599. /**
  52600. * Releases resources associated with this node.
  52601. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  52602. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  52603. */
  52604. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  52605. }
  52606. }
  52607. declare module "babylonjs/Misc/rgbdTextureTools" {
  52608. import "babylonjs/Shaders/rgbdDecode.fragment";
  52609. import "babylonjs/Engines/Extensions/engine.renderTarget";
  52610. import { Texture } from "babylonjs/Materials/Textures/texture";
  52611. /**
  52612. * Class used to host RGBD texture specific utilities
  52613. */
  52614. export class RGBDTextureTools {
  52615. /**
  52616. * Expand the RGBD Texture from RGBD to Half Float if possible.
  52617. * @param texture the texture to expand.
  52618. */
  52619. static ExpandRGBDTexture(texture: Texture): void;
  52620. }
  52621. }
  52622. declare module "babylonjs/Misc/brdfTextureTools" {
  52623. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52624. import { Scene } from "babylonjs/scene";
  52625. /**
  52626. * Class used to host texture specific utilities
  52627. */
  52628. export class BRDFTextureTools {
  52629. /**
  52630. * Prevents texture cache collision
  52631. */
  52632. private static _instanceNumber;
  52633. /**
  52634. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  52635. * @param scene defines the hosting scene
  52636. * @returns the environment BRDF texture
  52637. */
  52638. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  52639. private static _environmentBRDFBase64Texture;
  52640. }
  52641. }
  52642. declare module "babylonjs/Materials/PBR/pbrClearCoatConfiguration" {
  52643. import { Nullable } from "babylonjs/types";
  52644. import { Color3 } from "babylonjs/Maths/math.color";
  52645. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52646. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  52647. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  52648. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  52649. import { Engine } from "babylonjs/Engines/engine";
  52650. import { Scene } from "babylonjs/scene";
  52651. /**
  52652. * @hidden
  52653. */
  52654. export interface IMaterialClearCoatDefines {
  52655. CLEARCOAT: boolean;
  52656. CLEARCOAT_DEFAULTIOR: boolean;
  52657. CLEARCOAT_TEXTURE: boolean;
  52658. CLEARCOAT_TEXTUREDIRECTUV: number;
  52659. CLEARCOAT_BUMP: boolean;
  52660. CLEARCOAT_BUMPDIRECTUV: number;
  52661. CLEARCOAT_TINT: boolean;
  52662. CLEARCOAT_TINT_TEXTURE: boolean;
  52663. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  52664. /** @hidden */
  52665. _areTexturesDirty: boolean;
  52666. }
  52667. /**
  52668. * Define the code related to the clear coat parameters of the pbr material.
  52669. */
  52670. export class PBRClearCoatConfiguration {
  52671. /**
  52672. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  52673. * The default fits with a polyurethane material.
  52674. */
  52675. private static readonly _DefaultIndexOfRefraction;
  52676. private _isEnabled;
  52677. /**
  52678. * Defines if the clear coat is enabled in the material.
  52679. */
  52680. isEnabled: boolean;
  52681. /**
  52682. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  52683. */
  52684. intensity: number;
  52685. /**
  52686. * Defines the clear coat layer roughness.
  52687. */
  52688. roughness: number;
  52689. private _indexOfRefraction;
  52690. /**
  52691. * Defines the index of refraction of the clear coat.
  52692. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  52693. * The default fits with a polyurethane material.
  52694. * Changing the default value is more performance intensive.
  52695. */
  52696. indexOfRefraction: number;
  52697. private _texture;
  52698. /**
  52699. * Stores the clear coat values in a texture.
  52700. */
  52701. texture: Nullable<BaseTexture>;
  52702. private _bumpTexture;
  52703. /**
  52704. * Define the clear coat specific bump texture.
  52705. */
  52706. bumpTexture: Nullable<BaseTexture>;
  52707. private _isTintEnabled;
  52708. /**
  52709. * Defines if the clear coat tint is enabled in the material.
  52710. */
  52711. isTintEnabled: boolean;
  52712. /**
  52713. * Defines the clear coat tint of the material.
  52714. * This is only use if tint is enabled
  52715. */
  52716. tintColor: Color3;
  52717. /**
  52718. * Defines the distance at which the tint color should be found in the
  52719. * clear coat media.
  52720. * This is only use if tint is enabled
  52721. */
  52722. tintColorAtDistance: number;
  52723. /**
  52724. * Defines the clear coat layer thickness.
  52725. * This is only use if tint is enabled
  52726. */
  52727. tintThickness: number;
  52728. private _tintTexture;
  52729. /**
  52730. * Stores the clear tint values in a texture.
  52731. * rgb is tint
  52732. * a is a thickness factor
  52733. */
  52734. tintTexture: Nullable<BaseTexture>;
  52735. /** @hidden */
  52736. private _internalMarkAllSubMeshesAsTexturesDirty;
  52737. /** @hidden */
  52738. _markAllSubMeshesAsTexturesDirty(): void;
  52739. /**
  52740. * Instantiate a new istance of clear coat configuration.
  52741. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  52742. */
  52743. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  52744. /**
  52745. * Gets wehter the submesh is ready to be used or not.
  52746. * @param defines the list of "defines" to update.
  52747. * @param scene defines the scene the material belongs to.
  52748. * @param engine defines the engine the material belongs to.
  52749. * @param disableBumpMap defines wether the material disables bump or not.
  52750. * @returns - boolean indicating that the submesh is ready or not.
  52751. */
  52752. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  52753. /**
  52754. * Checks to see if a texture is used in the material.
  52755. * @param defines the list of "defines" to update.
  52756. * @param scene defines the scene to the material belongs to.
  52757. */
  52758. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  52759. /**
  52760. * Binds the material data.
  52761. * @param uniformBuffer defines the Uniform buffer to fill in.
  52762. * @param scene defines the scene the material belongs to.
  52763. * @param engine defines the engine the material belongs to.
  52764. * @param disableBumpMap defines wether the material disables bump or not.
  52765. * @param isFrozen defines wether the material is frozen or not.
  52766. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  52767. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  52768. */
  52769. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  52770. /**
  52771. * Checks to see if a texture is used in the material.
  52772. * @param texture - Base texture to use.
  52773. * @returns - Boolean specifying if a texture is used in the material.
  52774. */
  52775. hasTexture(texture: BaseTexture): boolean;
  52776. /**
  52777. * Returns an array of the actively used textures.
  52778. * @param activeTextures Array of BaseTextures
  52779. */
  52780. getActiveTextures(activeTextures: BaseTexture[]): void;
  52781. /**
  52782. * Returns the animatable textures.
  52783. * @param animatables Array of animatable textures.
  52784. */
  52785. getAnimatables(animatables: IAnimatable[]): void;
  52786. /**
  52787. * Disposes the resources of the material.
  52788. * @param forceDisposeTextures - Forces the disposal of all textures.
  52789. */
  52790. dispose(forceDisposeTextures?: boolean): void;
  52791. /**
  52792. * Get the current class name of the texture useful for serialization or dynamic coding.
  52793. * @returns "PBRClearCoatConfiguration"
  52794. */
  52795. getClassName(): string;
  52796. /**
  52797. * Add fallbacks to the effect fallbacks list.
  52798. * @param defines defines the Base texture to use.
  52799. * @param fallbacks defines the current fallback list.
  52800. * @param currentRank defines the current fallback rank.
  52801. * @returns the new fallback rank.
  52802. */
  52803. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  52804. /**
  52805. * Add the required uniforms to the current list.
  52806. * @param uniforms defines the current uniform list.
  52807. */
  52808. static AddUniforms(uniforms: string[]): void;
  52809. /**
  52810. * Add the required samplers to the current list.
  52811. * @param samplers defines the current sampler list.
  52812. */
  52813. static AddSamplers(samplers: string[]): void;
  52814. /**
  52815. * Add the required uniforms to the current buffer.
  52816. * @param uniformBuffer defines the current uniform buffer.
  52817. */
  52818. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  52819. /**
  52820. * Makes a duplicate of the current configuration into another one.
  52821. * @param clearCoatConfiguration define the config where to copy the info
  52822. */
  52823. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  52824. /**
  52825. * Serializes this clear coat configuration.
  52826. * @returns - An object with the serialized config.
  52827. */
  52828. serialize(): any;
  52829. /**
  52830. * Parses a anisotropy Configuration from a serialized object.
  52831. * @param source - Serialized object.
  52832. * @param scene Defines the scene we are parsing for
  52833. * @param rootUrl Defines the rootUrl to load from
  52834. */
  52835. parse(source: any, scene: Scene, rootUrl: string): void;
  52836. }
  52837. }
  52838. declare module "babylonjs/Materials/PBR/pbrAnisotropicConfiguration" {
  52839. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  52840. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52841. import { Vector2 } from "babylonjs/Maths/math.vector";
  52842. import { Scene } from "babylonjs/scene";
  52843. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52844. import { Nullable } from "babylonjs/types";
  52845. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  52846. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  52847. /**
  52848. * @hidden
  52849. */
  52850. export interface IMaterialAnisotropicDefines {
  52851. ANISOTROPIC: boolean;
  52852. ANISOTROPIC_TEXTURE: boolean;
  52853. ANISOTROPIC_TEXTUREDIRECTUV: number;
  52854. MAINUV1: boolean;
  52855. _areTexturesDirty: boolean;
  52856. _needUVs: boolean;
  52857. }
  52858. /**
  52859. * Define the code related to the anisotropic parameters of the pbr material.
  52860. */
  52861. export class PBRAnisotropicConfiguration {
  52862. private _isEnabled;
  52863. /**
  52864. * Defines if the anisotropy is enabled in the material.
  52865. */
  52866. isEnabled: boolean;
  52867. /**
  52868. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  52869. */
  52870. intensity: number;
  52871. /**
  52872. * Defines if the effect is along the tangents, bitangents or in between.
  52873. * By default, the effect is "strectching" the highlights along the tangents.
  52874. */
  52875. direction: Vector2;
  52876. private _texture;
  52877. /**
  52878. * Stores the anisotropy values in a texture.
  52879. * rg is direction (like normal from -1 to 1)
  52880. * b is a intensity
  52881. */
  52882. texture: Nullable<BaseTexture>;
  52883. /** @hidden */
  52884. private _internalMarkAllSubMeshesAsTexturesDirty;
  52885. /** @hidden */
  52886. _markAllSubMeshesAsTexturesDirty(): void;
  52887. /**
  52888. * Instantiate a new istance of anisotropy configuration.
  52889. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  52890. */
  52891. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  52892. /**
  52893. * Specifies that the submesh is ready to be used.
  52894. * @param defines the list of "defines" to update.
  52895. * @param scene defines the scene the material belongs to.
  52896. * @returns - boolean indicating that the submesh is ready or not.
  52897. */
  52898. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  52899. /**
  52900. * Checks to see if a texture is used in the material.
  52901. * @param defines the list of "defines" to update.
  52902. * @param mesh the mesh we are preparing the defines for.
  52903. * @param scene defines the scene the material belongs to.
  52904. */
  52905. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  52906. /**
  52907. * Binds the material data.
  52908. * @param uniformBuffer defines the Uniform buffer to fill in.
  52909. * @param scene defines the scene the material belongs to.
  52910. * @param isFrozen defines wether the material is frozen or not.
  52911. */
  52912. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  52913. /**
  52914. * Checks to see if a texture is used in the material.
  52915. * @param texture - Base texture to use.
  52916. * @returns - Boolean specifying if a texture is used in the material.
  52917. */
  52918. hasTexture(texture: BaseTexture): boolean;
  52919. /**
  52920. * Returns an array of the actively used textures.
  52921. * @param activeTextures Array of BaseTextures
  52922. */
  52923. getActiveTextures(activeTextures: BaseTexture[]): void;
  52924. /**
  52925. * Returns the animatable textures.
  52926. * @param animatables Array of animatable textures.
  52927. */
  52928. getAnimatables(animatables: IAnimatable[]): void;
  52929. /**
  52930. * Disposes the resources of the material.
  52931. * @param forceDisposeTextures - Forces the disposal of all textures.
  52932. */
  52933. dispose(forceDisposeTextures?: boolean): void;
  52934. /**
  52935. * Get the current class name of the texture useful for serialization or dynamic coding.
  52936. * @returns "PBRAnisotropicConfiguration"
  52937. */
  52938. getClassName(): string;
  52939. /**
  52940. * Add fallbacks to the effect fallbacks list.
  52941. * @param defines defines the Base texture to use.
  52942. * @param fallbacks defines the current fallback list.
  52943. * @param currentRank defines the current fallback rank.
  52944. * @returns the new fallback rank.
  52945. */
  52946. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  52947. /**
  52948. * Add the required uniforms to the current list.
  52949. * @param uniforms defines the current uniform list.
  52950. */
  52951. static AddUniforms(uniforms: string[]): void;
  52952. /**
  52953. * Add the required uniforms to the current buffer.
  52954. * @param uniformBuffer defines the current uniform buffer.
  52955. */
  52956. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  52957. /**
  52958. * Add the required samplers to the current list.
  52959. * @param samplers defines the current sampler list.
  52960. */
  52961. static AddSamplers(samplers: string[]): void;
  52962. /**
  52963. * Makes a duplicate of the current configuration into another one.
  52964. * @param anisotropicConfiguration define the config where to copy the info
  52965. */
  52966. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  52967. /**
  52968. * Serializes this anisotropy configuration.
  52969. * @returns - An object with the serialized config.
  52970. */
  52971. serialize(): any;
  52972. /**
  52973. * Parses a anisotropy Configuration from a serialized object.
  52974. * @param source - Serialized object.
  52975. * @param scene Defines the scene we are parsing for
  52976. * @param rootUrl Defines the rootUrl to load from
  52977. */
  52978. parse(source: any, scene: Scene, rootUrl: string): void;
  52979. }
  52980. }
  52981. declare module "babylonjs/Materials/PBR/pbrBRDFConfiguration" {
  52982. import { Scene } from "babylonjs/scene";
  52983. /**
  52984. * @hidden
  52985. */
  52986. export interface IMaterialBRDFDefines {
  52987. BRDF_V_HEIGHT_CORRELATED: boolean;
  52988. MS_BRDF_ENERGY_CONSERVATION: boolean;
  52989. SPHERICAL_HARMONICS: boolean;
  52990. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  52991. /** @hidden */
  52992. _areMiscDirty: boolean;
  52993. }
  52994. /**
  52995. * Define the code related to the BRDF parameters of the pbr material.
  52996. */
  52997. export class PBRBRDFConfiguration {
  52998. /**
  52999. * Default value used for the energy conservation.
  53000. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  53001. */
  53002. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  53003. /**
  53004. * Default value used for the Smith Visibility Height Correlated mode.
  53005. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  53006. */
  53007. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  53008. /**
  53009. * Default value used for the IBL diffuse part.
  53010. * This can help switching back to the polynomials mode globally which is a tiny bit
  53011. * less GPU intensive at the drawback of a lower quality.
  53012. */
  53013. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  53014. /**
  53015. * Default value used for activating energy conservation for the specular workflow.
  53016. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  53017. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  53018. */
  53019. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  53020. private _useEnergyConservation;
  53021. /**
  53022. * Defines if the material uses energy conservation.
  53023. */
  53024. useEnergyConservation: boolean;
  53025. private _useSmithVisibilityHeightCorrelated;
  53026. /**
  53027. * LEGACY Mode set to false
  53028. * Defines if the material uses height smith correlated visibility term.
  53029. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  53030. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  53031. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  53032. * Not relying on height correlated will also disable energy conservation.
  53033. */
  53034. useSmithVisibilityHeightCorrelated: boolean;
  53035. private _useSphericalHarmonics;
  53036. /**
  53037. * LEGACY Mode set to false
  53038. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  53039. * diffuse part of the IBL.
  53040. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  53041. * to the ground truth.
  53042. */
  53043. useSphericalHarmonics: boolean;
  53044. private _useSpecularGlossinessInputEnergyConservation;
  53045. /**
  53046. * Defines if the material uses energy conservation, when the specular workflow is active.
  53047. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  53048. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  53049. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  53050. */
  53051. useSpecularGlossinessInputEnergyConservation: boolean;
  53052. /** @hidden */
  53053. private _internalMarkAllSubMeshesAsMiscDirty;
  53054. /** @hidden */
  53055. _markAllSubMeshesAsMiscDirty(): void;
  53056. /**
  53057. * Instantiate a new istance of clear coat configuration.
  53058. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  53059. */
  53060. constructor(markAllSubMeshesAsMiscDirty: () => void);
  53061. /**
  53062. * Checks to see if a texture is used in the material.
  53063. * @param defines the list of "defines" to update.
  53064. */
  53065. prepareDefines(defines: IMaterialBRDFDefines): void;
  53066. /**
  53067. * Get the current class name of the texture useful for serialization or dynamic coding.
  53068. * @returns "PBRClearCoatConfiguration"
  53069. */
  53070. getClassName(): string;
  53071. /**
  53072. * Makes a duplicate of the current configuration into another one.
  53073. * @param brdfConfiguration define the config where to copy the info
  53074. */
  53075. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  53076. /**
  53077. * Serializes this BRDF configuration.
  53078. * @returns - An object with the serialized config.
  53079. */
  53080. serialize(): any;
  53081. /**
  53082. * Parses a anisotropy Configuration from a serialized object.
  53083. * @param source - Serialized object.
  53084. * @param scene Defines the scene we are parsing for
  53085. * @param rootUrl Defines the rootUrl to load from
  53086. */
  53087. parse(source: any, scene: Scene, rootUrl: string): void;
  53088. }
  53089. }
  53090. declare module "babylonjs/Materials/PBR/pbrSheenConfiguration" {
  53091. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  53092. import { Color3 } from "babylonjs/Maths/math.color";
  53093. import { Scene } from "babylonjs/scene";
  53094. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  53095. import { Nullable } from "babylonjs/types";
  53096. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  53097. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  53098. /**
  53099. * @hidden
  53100. */
  53101. export interface IMaterialSheenDefines {
  53102. SHEEN: boolean;
  53103. SHEEN_TEXTURE: boolean;
  53104. SHEEN_TEXTUREDIRECTUV: number;
  53105. SHEEN_LINKWITHALBEDO: boolean;
  53106. SHEEN_ROUGHNESS: boolean;
  53107. SHEEN_ALBEDOSCALING: boolean;
  53108. /** @hidden */
  53109. _areTexturesDirty: boolean;
  53110. }
  53111. /**
  53112. * Define the code related to the Sheen parameters of the pbr material.
  53113. */
  53114. export class PBRSheenConfiguration {
  53115. private _isEnabled;
  53116. /**
  53117. * Defines if the material uses sheen.
  53118. */
  53119. isEnabled: boolean;
  53120. private _linkSheenWithAlbedo;
  53121. /**
  53122. * Defines if the sheen is linked to the sheen color.
  53123. */
  53124. linkSheenWithAlbedo: boolean;
  53125. /**
  53126. * Defines the sheen intensity.
  53127. */
  53128. intensity: number;
  53129. /**
  53130. * Defines the sheen color.
  53131. */
  53132. color: Color3;
  53133. private _texture;
  53134. /**
  53135. * Stores the sheen tint values in a texture.
  53136. * rgb is tint
  53137. * a is a intensity
  53138. */
  53139. texture: Nullable<BaseTexture>;
  53140. private _roughness;
  53141. /**
  53142. * Defines the sheen roughness.
  53143. * It is not taken into account if linkSheenWithAlbedo is true.
  53144. * To stay backward compatible, material roughness is used instead if sheen roughness = null
  53145. */
  53146. roughness: Nullable<number>;
  53147. private _albedoScaling;
  53148. /**
  53149. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  53150. * It allows the strength of the sheen effect to not depend on the base color of the material,
  53151. * making it easier to setup and tweak the effect
  53152. */
  53153. albedoScaling: boolean;
  53154. /** @hidden */
  53155. private _internalMarkAllSubMeshesAsTexturesDirty;
  53156. /** @hidden */
  53157. _markAllSubMeshesAsTexturesDirty(): void;
  53158. /**
  53159. * Instantiate a new istance of clear coat configuration.
  53160. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  53161. */
  53162. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  53163. /**
  53164. * Specifies that the submesh is ready to be used.
  53165. * @param defines the list of "defines" to update.
  53166. * @param scene defines the scene the material belongs to.
  53167. * @returns - boolean indicating that the submesh is ready or not.
  53168. */
  53169. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  53170. /**
  53171. * Checks to see if a texture is used in the material.
  53172. * @param defines the list of "defines" to update.
  53173. * @param scene defines the scene the material belongs to.
  53174. */
  53175. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  53176. /**
  53177. * Binds the material data.
  53178. * @param uniformBuffer defines the Uniform buffer to fill in.
  53179. * @param scene defines the scene the material belongs to.
  53180. * @param isFrozen defines wether the material is frozen or not.
  53181. */
  53182. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  53183. /**
  53184. * Checks to see if a texture is used in the material.
  53185. * @param texture - Base texture to use.
  53186. * @returns - Boolean specifying if a texture is used in the material.
  53187. */
  53188. hasTexture(texture: BaseTexture): boolean;
  53189. /**
  53190. * Returns an array of the actively used textures.
  53191. * @param activeTextures Array of BaseTextures
  53192. */
  53193. getActiveTextures(activeTextures: BaseTexture[]): void;
  53194. /**
  53195. * Returns the animatable textures.
  53196. * @param animatables Array of animatable textures.
  53197. */
  53198. getAnimatables(animatables: IAnimatable[]): void;
  53199. /**
  53200. * Disposes the resources of the material.
  53201. * @param forceDisposeTextures - Forces the disposal of all textures.
  53202. */
  53203. dispose(forceDisposeTextures?: boolean): void;
  53204. /**
  53205. * Get the current class name of the texture useful for serialization or dynamic coding.
  53206. * @returns "PBRSheenConfiguration"
  53207. */
  53208. getClassName(): string;
  53209. /**
  53210. * Add fallbacks to the effect fallbacks list.
  53211. * @param defines defines the Base texture to use.
  53212. * @param fallbacks defines the current fallback list.
  53213. * @param currentRank defines the current fallback rank.
  53214. * @returns the new fallback rank.
  53215. */
  53216. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  53217. /**
  53218. * Add the required uniforms to the current list.
  53219. * @param uniforms defines the current uniform list.
  53220. */
  53221. static AddUniforms(uniforms: string[]): void;
  53222. /**
  53223. * Add the required uniforms to the current buffer.
  53224. * @param uniformBuffer defines the current uniform buffer.
  53225. */
  53226. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  53227. /**
  53228. * Add the required samplers to the current list.
  53229. * @param samplers defines the current sampler list.
  53230. */
  53231. static AddSamplers(samplers: string[]): void;
  53232. /**
  53233. * Makes a duplicate of the current configuration into another one.
  53234. * @param sheenConfiguration define the config where to copy the info
  53235. */
  53236. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  53237. /**
  53238. * Serializes this BRDF configuration.
  53239. * @returns - An object with the serialized config.
  53240. */
  53241. serialize(): any;
  53242. /**
  53243. * Parses a anisotropy Configuration from a serialized object.
  53244. * @param source - Serialized object.
  53245. * @param scene Defines the scene we are parsing for
  53246. * @param rootUrl Defines the rootUrl to load from
  53247. */
  53248. parse(source: any, scene: Scene, rootUrl: string): void;
  53249. }
  53250. }
  53251. declare module "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration" {
  53252. import { Nullable } from "babylonjs/types";
  53253. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  53254. import { Color3 } from "babylonjs/Maths/math.color";
  53255. import { SmartArray } from "babylonjs/Misc/smartArray";
  53256. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  53257. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  53258. import { Effect } from "babylonjs/Materials/effect";
  53259. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  53260. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  53261. import { Engine } from "babylonjs/Engines/engine";
  53262. import { Scene } from "babylonjs/scene";
  53263. /**
  53264. * @hidden
  53265. */
  53266. export interface IMaterialSubSurfaceDefines {
  53267. SUBSURFACE: boolean;
  53268. SS_REFRACTION: boolean;
  53269. SS_TRANSLUCENCY: boolean;
  53270. SS_SCATERRING: boolean;
  53271. SS_THICKNESSANDMASK_TEXTURE: boolean;
  53272. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  53273. SS_REFRACTIONMAP_3D: boolean;
  53274. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  53275. SS_LODINREFRACTIONALPHA: boolean;
  53276. SS_GAMMAREFRACTION: boolean;
  53277. SS_RGBDREFRACTION: boolean;
  53278. SS_LINEARSPECULARREFRACTION: boolean;
  53279. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  53280. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  53281. /** @hidden */
  53282. _areTexturesDirty: boolean;
  53283. }
  53284. /**
  53285. * Define the code related to the sub surface parameters of the pbr material.
  53286. */
  53287. export class PBRSubSurfaceConfiguration {
  53288. private _isRefractionEnabled;
  53289. /**
  53290. * Defines if the refraction is enabled in the material.
  53291. */
  53292. isRefractionEnabled: boolean;
  53293. private _isTranslucencyEnabled;
  53294. /**
  53295. * Defines if the translucency is enabled in the material.
  53296. */
  53297. isTranslucencyEnabled: boolean;
  53298. private _isScatteringEnabled;
  53299. /**
  53300. * Defines the refraction intensity of the material.
  53301. * The refraction when enabled replaces the Diffuse part of the material.
  53302. * The intensity helps transitionning between diffuse and refraction.
  53303. */
  53304. refractionIntensity: number;
  53305. /**
  53306. * Defines the translucency intensity of the material.
  53307. * When translucency has been enabled, this defines how much of the "translucency"
  53308. * is addded to the diffuse part of the material.
  53309. */
  53310. translucencyIntensity: number;
  53311. /**
  53312. * Defines the scattering intensity of the material.
  53313. * When scattering has been enabled, this defines how much of the "scattered light"
  53314. * is addded to the diffuse part of the material.
  53315. */
  53316. scatteringIntensity: number;
  53317. private _thicknessTexture;
  53318. /**
  53319. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  53320. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  53321. * 0 would mean minimumThickness
  53322. * 1 would mean maximumThickness
  53323. * The other channels might be use as a mask to vary the different effects intensity.
  53324. */
  53325. thicknessTexture: Nullable<BaseTexture>;
  53326. private _refractionTexture;
  53327. /**
  53328. * Defines the texture to use for refraction.
  53329. */
  53330. refractionTexture: Nullable<BaseTexture>;
  53331. private _indexOfRefraction;
  53332. /**
  53333. * Defines the index of refraction used in the material.
  53334. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  53335. */
  53336. indexOfRefraction: number;
  53337. private _invertRefractionY;
  53338. /**
  53339. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  53340. */
  53341. invertRefractionY: boolean;
  53342. private _linkRefractionWithTransparency;
  53343. /**
  53344. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  53345. * Materials half opaque for instance using refraction could benefit from this control.
  53346. */
  53347. linkRefractionWithTransparency: boolean;
  53348. /**
  53349. * Defines the minimum thickness stored in the thickness map.
  53350. * If no thickness map is defined, this value will be used to simulate thickness.
  53351. */
  53352. minimumThickness: number;
  53353. /**
  53354. * Defines the maximum thickness stored in the thickness map.
  53355. */
  53356. maximumThickness: number;
  53357. /**
  53358. * Defines the volume tint of the material.
  53359. * This is used for both translucency and scattering.
  53360. */
  53361. tintColor: Color3;
  53362. /**
  53363. * Defines the distance at which the tint color should be found in the media.
  53364. * This is used for refraction only.
  53365. */
  53366. tintColorAtDistance: number;
  53367. /**
  53368. * Defines how far each channel transmit through the media.
  53369. * It is defined as a color to simplify it selection.
  53370. */
  53371. diffusionDistance: Color3;
  53372. private _useMaskFromThicknessTexture;
  53373. /**
  53374. * Stores the intensity of the different subsurface effects in the thickness texture.
  53375. * * the green channel is the translucency intensity.
  53376. * * the blue channel is the scattering intensity.
  53377. * * the alpha channel is the refraction intensity.
  53378. */
  53379. useMaskFromThicknessTexture: boolean;
  53380. /** @hidden */
  53381. private _internalMarkAllSubMeshesAsTexturesDirty;
  53382. /** @hidden */
  53383. _markAllSubMeshesAsTexturesDirty(): void;
  53384. /**
  53385. * Instantiate a new istance of sub surface configuration.
  53386. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  53387. */
  53388. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  53389. /**
  53390. * Gets wehter the submesh is ready to be used or not.
  53391. * @param defines the list of "defines" to update.
  53392. * @param scene defines the scene the material belongs to.
  53393. * @returns - boolean indicating that the submesh is ready or not.
  53394. */
  53395. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  53396. /**
  53397. * Checks to see if a texture is used in the material.
  53398. * @param defines the list of "defines" to update.
  53399. * @param scene defines the scene to the material belongs to.
  53400. */
  53401. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  53402. /**
  53403. * Binds the material data.
  53404. * @param uniformBuffer defines the Uniform buffer to fill in.
  53405. * @param scene defines the scene the material belongs to.
  53406. * @param engine defines the engine the material belongs to.
  53407. * @param isFrozen defines wether the material is frozen or not.
  53408. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  53409. */
  53410. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  53411. /**
  53412. * Unbinds the material from the mesh.
  53413. * @param activeEffect defines the effect that should be unbound from.
  53414. * @returns true if unbound, otherwise false
  53415. */
  53416. unbind(activeEffect: Effect): boolean;
  53417. /**
  53418. * Returns the texture used for refraction or null if none is used.
  53419. * @param scene defines the scene the material belongs to.
  53420. * @returns - Refraction texture if present. If no refraction texture and refraction
  53421. * is linked with transparency, returns environment texture. Otherwise, returns null.
  53422. */
  53423. private _getRefractionTexture;
  53424. /**
  53425. * Returns true if alpha blending should be disabled.
  53426. */
  53427. get disableAlphaBlending(): boolean;
  53428. /**
  53429. * Fills the list of render target textures.
  53430. * @param renderTargets the list of render targets to update
  53431. */
  53432. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  53433. /**
  53434. * Checks to see if a texture is used in the material.
  53435. * @param texture - Base texture to use.
  53436. * @returns - Boolean specifying if a texture is used in the material.
  53437. */
  53438. hasTexture(texture: BaseTexture): boolean;
  53439. /**
  53440. * Gets a boolean indicating that current material needs to register RTT
  53441. * @returns true if this uses a render target otherwise false.
  53442. */
  53443. hasRenderTargetTextures(): boolean;
  53444. /**
  53445. * Returns an array of the actively used textures.
  53446. * @param activeTextures Array of BaseTextures
  53447. */
  53448. getActiveTextures(activeTextures: BaseTexture[]): void;
  53449. /**
  53450. * Returns the animatable textures.
  53451. * @param animatables Array of animatable textures.
  53452. */
  53453. getAnimatables(animatables: IAnimatable[]): void;
  53454. /**
  53455. * Disposes the resources of the material.
  53456. * @param forceDisposeTextures - Forces the disposal of all textures.
  53457. */
  53458. dispose(forceDisposeTextures?: boolean): void;
  53459. /**
  53460. * Get the current class name of the texture useful for serialization or dynamic coding.
  53461. * @returns "PBRSubSurfaceConfiguration"
  53462. */
  53463. getClassName(): string;
  53464. /**
  53465. * Add fallbacks to the effect fallbacks list.
  53466. * @param defines defines the Base texture to use.
  53467. * @param fallbacks defines the current fallback list.
  53468. * @param currentRank defines the current fallback rank.
  53469. * @returns the new fallback rank.
  53470. */
  53471. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  53472. /**
  53473. * Add the required uniforms to the current list.
  53474. * @param uniforms defines the current uniform list.
  53475. */
  53476. static AddUniforms(uniforms: string[]): void;
  53477. /**
  53478. * Add the required samplers to the current list.
  53479. * @param samplers defines the current sampler list.
  53480. */
  53481. static AddSamplers(samplers: string[]): void;
  53482. /**
  53483. * Add the required uniforms to the current buffer.
  53484. * @param uniformBuffer defines the current uniform buffer.
  53485. */
  53486. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  53487. /**
  53488. * Makes a duplicate of the current configuration into another one.
  53489. * @param configuration define the config where to copy the info
  53490. */
  53491. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  53492. /**
  53493. * Serializes this Sub Surface configuration.
  53494. * @returns - An object with the serialized config.
  53495. */
  53496. serialize(): any;
  53497. /**
  53498. * Parses a anisotropy Configuration from a serialized object.
  53499. * @param source - Serialized object.
  53500. * @param scene Defines the scene we are parsing for
  53501. * @param rootUrl Defines the rootUrl to load from
  53502. */
  53503. parse(source: any, scene: Scene, rootUrl: string): void;
  53504. }
  53505. }
  53506. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration" {
  53507. /** @hidden */
  53508. export var pbrFragmentDeclaration: {
  53509. name: string;
  53510. shader: string;
  53511. };
  53512. }
  53513. declare module "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration" {
  53514. /** @hidden */
  53515. export var pbrUboDeclaration: {
  53516. name: string;
  53517. shader: string;
  53518. };
  53519. }
  53520. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration" {
  53521. /** @hidden */
  53522. export var pbrFragmentExtraDeclaration: {
  53523. name: string;
  53524. shader: string;
  53525. };
  53526. }
  53527. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration" {
  53528. /** @hidden */
  53529. export var pbrFragmentSamplersDeclaration: {
  53530. name: string;
  53531. shader: string;
  53532. };
  53533. }
  53534. declare module "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions" {
  53535. /** @hidden */
  53536. export var pbrHelperFunctions: {
  53537. name: string;
  53538. shader: string;
  53539. };
  53540. }
  53541. declare module "babylonjs/Shaders/ShadersInclude/harmonicsFunctions" {
  53542. /** @hidden */
  53543. export var harmonicsFunctions: {
  53544. name: string;
  53545. shader: string;
  53546. };
  53547. }
  53548. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions" {
  53549. /** @hidden */
  53550. export var pbrDirectLightingSetupFunctions: {
  53551. name: string;
  53552. shader: string;
  53553. };
  53554. }
  53555. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions" {
  53556. /** @hidden */
  53557. export var pbrDirectLightingFalloffFunctions: {
  53558. name: string;
  53559. shader: string;
  53560. };
  53561. }
  53562. declare module "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions" {
  53563. /** @hidden */
  53564. export var pbrBRDFFunctions: {
  53565. name: string;
  53566. shader: string;
  53567. };
  53568. }
  53569. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions" {
  53570. /** @hidden */
  53571. export var pbrDirectLightingFunctions: {
  53572. name: string;
  53573. shader: string;
  53574. };
  53575. }
  53576. declare module "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions" {
  53577. /** @hidden */
  53578. export var pbrIBLFunctions: {
  53579. name: string;
  53580. shader: string;
  53581. };
  53582. }
  53583. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockAlbedoOpacity" {
  53584. /** @hidden */
  53585. export var pbrBlockAlbedoOpacity: {
  53586. name: string;
  53587. shader: string;
  53588. };
  53589. }
  53590. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockReflectivity" {
  53591. /** @hidden */
  53592. export var pbrBlockReflectivity: {
  53593. name: string;
  53594. shader: string;
  53595. };
  53596. }
  53597. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockAmbientOcclusion" {
  53598. /** @hidden */
  53599. export var pbrBlockAmbientOcclusion: {
  53600. name: string;
  53601. shader: string;
  53602. };
  53603. }
  53604. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockAlphaFresnel" {
  53605. /** @hidden */
  53606. export var pbrBlockAlphaFresnel: {
  53607. name: string;
  53608. shader: string;
  53609. };
  53610. }
  53611. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockAnisotropic" {
  53612. /** @hidden */
  53613. export var pbrBlockAnisotropic: {
  53614. name: string;
  53615. shader: string;
  53616. };
  53617. }
  53618. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockReflection" {
  53619. /** @hidden */
  53620. export var pbrBlockReflection: {
  53621. name: string;
  53622. shader: string;
  53623. };
  53624. }
  53625. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockSheen" {
  53626. /** @hidden */
  53627. export var pbrBlockSheen: {
  53628. name: string;
  53629. shader: string;
  53630. };
  53631. }
  53632. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockClearcoat" {
  53633. /** @hidden */
  53634. export var pbrBlockClearcoat: {
  53635. name: string;
  53636. shader: string;
  53637. };
  53638. }
  53639. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockSubSurface" {
  53640. /** @hidden */
  53641. export var pbrBlockSubSurface: {
  53642. name: string;
  53643. shader: string;
  53644. };
  53645. }
  53646. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockNormalGeometric" {
  53647. /** @hidden */
  53648. export var pbrBlockNormalGeometric: {
  53649. name: string;
  53650. shader: string;
  53651. };
  53652. }
  53653. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockNormalFinal" {
  53654. /** @hidden */
  53655. export var pbrBlockNormalFinal: {
  53656. name: string;
  53657. shader: string;
  53658. };
  53659. }
  53660. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockGeometryInfo" {
  53661. /** @hidden */
  53662. export var pbrBlockGeometryInfo: {
  53663. name: string;
  53664. shader: string;
  53665. };
  53666. }
  53667. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockReflectance0" {
  53668. /** @hidden */
  53669. export var pbrBlockReflectance0: {
  53670. name: string;
  53671. shader: string;
  53672. };
  53673. }
  53674. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockReflectance" {
  53675. /** @hidden */
  53676. export var pbrBlockReflectance: {
  53677. name: string;
  53678. shader: string;
  53679. };
  53680. }
  53681. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockDirectLighting" {
  53682. /** @hidden */
  53683. export var pbrBlockDirectLighting: {
  53684. name: string;
  53685. shader: string;
  53686. };
  53687. }
  53688. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockFinalLitComponents" {
  53689. /** @hidden */
  53690. export var pbrBlockFinalLitComponents: {
  53691. name: string;
  53692. shader: string;
  53693. };
  53694. }
  53695. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockFinalUnlitComponents" {
  53696. /** @hidden */
  53697. export var pbrBlockFinalUnlitComponents: {
  53698. name: string;
  53699. shader: string;
  53700. };
  53701. }
  53702. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockFinalColorComposition" {
  53703. /** @hidden */
  53704. export var pbrBlockFinalColorComposition: {
  53705. name: string;
  53706. shader: string;
  53707. };
  53708. }
  53709. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockImageProcessing" {
  53710. /** @hidden */
  53711. export var pbrBlockImageProcessing: {
  53712. name: string;
  53713. shader: string;
  53714. };
  53715. }
  53716. declare module "babylonjs/Shaders/ShadersInclude/pbrDebug" {
  53717. /** @hidden */
  53718. export var pbrDebug: {
  53719. name: string;
  53720. shader: string;
  53721. };
  53722. }
  53723. declare module "babylonjs/Shaders/pbr.fragment" {
  53724. import "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration";
  53725. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  53726. import "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration";
  53727. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  53728. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  53729. import "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration";
  53730. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  53731. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  53732. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  53733. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  53734. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  53735. import "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions";
  53736. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  53737. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  53738. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  53739. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions";
  53740. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions";
  53741. import "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions";
  53742. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions";
  53743. import "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions";
  53744. import "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions";
  53745. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  53746. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  53747. import "babylonjs/Shaders/ShadersInclude/pbrBlockAlbedoOpacity";
  53748. import "babylonjs/Shaders/ShadersInclude/pbrBlockReflectivity";
  53749. import "babylonjs/Shaders/ShadersInclude/pbrBlockAmbientOcclusion";
  53750. import "babylonjs/Shaders/ShadersInclude/pbrBlockAlphaFresnel";
  53751. import "babylonjs/Shaders/ShadersInclude/pbrBlockAnisotropic";
  53752. import "babylonjs/Shaders/ShadersInclude/pbrBlockReflection";
  53753. import "babylonjs/Shaders/ShadersInclude/pbrBlockSheen";
  53754. import "babylonjs/Shaders/ShadersInclude/pbrBlockClearcoat";
  53755. import "babylonjs/Shaders/ShadersInclude/pbrBlockSubSurface";
  53756. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  53757. import "babylonjs/Shaders/ShadersInclude/pbrBlockNormalGeometric";
  53758. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  53759. import "babylonjs/Shaders/ShadersInclude/pbrBlockNormalFinal";
  53760. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  53761. import "babylonjs/Shaders/ShadersInclude/pbrBlockGeometryInfo";
  53762. import "babylonjs/Shaders/ShadersInclude/pbrBlockReflectance0";
  53763. import "babylonjs/Shaders/ShadersInclude/pbrBlockReflectance";
  53764. import "babylonjs/Shaders/ShadersInclude/pbrBlockDirectLighting";
  53765. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  53766. import "babylonjs/Shaders/ShadersInclude/pbrBlockFinalLitComponents";
  53767. import "babylonjs/Shaders/ShadersInclude/pbrBlockFinalUnlitComponents";
  53768. import "babylonjs/Shaders/ShadersInclude/pbrBlockFinalColorComposition";
  53769. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  53770. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  53771. import "babylonjs/Shaders/ShadersInclude/pbrBlockImageProcessing";
  53772. import "babylonjs/Shaders/ShadersInclude/pbrDebug";
  53773. /** @hidden */
  53774. export var pbrPixelShader: {
  53775. name: string;
  53776. shader: string;
  53777. };
  53778. }
  53779. declare module "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration" {
  53780. /** @hidden */
  53781. export var pbrVertexDeclaration: {
  53782. name: string;
  53783. shader: string;
  53784. };
  53785. }
  53786. declare module "babylonjs/Shaders/pbr.vertex" {
  53787. import "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration";
  53788. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  53789. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  53790. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  53791. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  53792. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  53793. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  53794. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  53795. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  53796. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  53797. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  53798. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  53799. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  53800. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  53801. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  53802. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  53803. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  53804. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  53805. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  53806. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  53807. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  53808. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  53809. /** @hidden */
  53810. export var pbrVertexShader: {
  53811. name: string;
  53812. shader: string;
  53813. };
  53814. }
  53815. declare module "babylonjs/Materials/PBR/pbrBaseMaterial" {
  53816. import { Nullable } from "babylonjs/types";
  53817. import { Scene } from "babylonjs/scene";
  53818. import { Matrix } from "babylonjs/Maths/math.vector";
  53819. import { SubMesh } from "babylonjs/Meshes/subMesh";
  53820. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53821. import { Mesh } from "babylonjs/Meshes/mesh";
  53822. import { IMaterialClearCoatDefines, PBRClearCoatConfiguration } from "babylonjs/Materials/PBR/pbrClearCoatConfiguration";
  53823. import { IMaterialAnisotropicDefines, PBRAnisotropicConfiguration } from "babylonjs/Materials/PBR/pbrAnisotropicConfiguration";
  53824. import { IMaterialBRDFDefines, PBRBRDFConfiguration } from "babylonjs/Materials/PBR/pbrBRDFConfiguration";
  53825. import { IMaterialSheenDefines, PBRSheenConfiguration } from "babylonjs/Materials/PBR/pbrSheenConfiguration";
  53826. import { IMaterialSubSurfaceDefines, PBRSubSurfaceConfiguration } from "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration";
  53827. import { Color3 } from "babylonjs/Maths/math.color";
  53828. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  53829. import { Material, IMaterialCompilationOptions } from "babylonjs/Materials/material";
  53830. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  53831. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  53832. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  53833. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  53834. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  53835. import "babylonjs/Shaders/pbr.fragment";
  53836. import "babylonjs/Shaders/pbr.vertex";
  53837. /**
  53838. * Manages the defines for the PBR Material.
  53839. * @hidden
  53840. */
  53841. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  53842. PBR: boolean;
  53843. MAINUV1: boolean;
  53844. MAINUV2: boolean;
  53845. UV1: boolean;
  53846. UV2: boolean;
  53847. ALBEDO: boolean;
  53848. GAMMAALBEDO: boolean;
  53849. ALBEDODIRECTUV: number;
  53850. VERTEXCOLOR: boolean;
  53851. AMBIENT: boolean;
  53852. AMBIENTDIRECTUV: number;
  53853. AMBIENTINGRAYSCALE: boolean;
  53854. OPACITY: boolean;
  53855. VERTEXALPHA: boolean;
  53856. OPACITYDIRECTUV: number;
  53857. OPACITYRGB: boolean;
  53858. ALPHATEST: boolean;
  53859. DEPTHPREPASS: boolean;
  53860. ALPHABLEND: boolean;
  53861. ALPHAFROMALBEDO: boolean;
  53862. ALPHATESTVALUE: string;
  53863. SPECULAROVERALPHA: boolean;
  53864. RADIANCEOVERALPHA: boolean;
  53865. ALPHAFRESNEL: boolean;
  53866. LINEARALPHAFRESNEL: boolean;
  53867. PREMULTIPLYALPHA: boolean;
  53868. EMISSIVE: boolean;
  53869. EMISSIVEDIRECTUV: number;
  53870. REFLECTIVITY: boolean;
  53871. REFLECTIVITYDIRECTUV: number;
  53872. SPECULARTERM: boolean;
  53873. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  53874. MICROSURFACEAUTOMATIC: boolean;
  53875. LODBASEDMICROSFURACE: boolean;
  53876. MICROSURFACEMAP: boolean;
  53877. MICROSURFACEMAPDIRECTUV: number;
  53878. METALLICWORKFLOW: boolean;
  53879. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  53880. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  53881. METALLNESSSTOREINMETALMAPBLUE: boolean;
  53882. AOSTOREINMETALMAPRED: boolean;
  53883. METALLICF0FACTORFROMMETALLICMAP: boolean;
  53884. ENVIRONMENTBRDF: boolean;
  53885. ENVIRONMENTBRDF_RGBD: boolean;
  53886. NORMAL: boolean;
  53887. TANGENT: boolean;
  53888. BUMP: boolean;
  53889. BUMPDIRECTUV: number;
  53890. OBJECTSPACE_NORMALMAP: boolean;
  53891. PARALLAX: boolean;
  53892. PARALLAXOCCLUSION: boolean;
  53893. NORMALXYSCALE: boolean;
  53894. LIGHTMAP: boolean;
  53895. LIGHTMAPDIRECTUV: number;
  53896. USELIGHTMAPASSHADOWMAP: boolean;
  53897. GAMMALIGHTMAP: boolean;
  53898. RGBDLIGHTMAP: boolean;
  53899. REFLECTION: boolean;
  53900. REFLECTIONMAP_3D: boolean;
  53901. REFLECTIONMAP_SPHERICAL: boolean;
  53902. REFLECTIONMAP_PLANAR: boolean;
  53903. REFLECTIONMAP_CUBIC: boolean;
  53904. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  53905. REFLECTIONMAP_PROJECTION: boolean;
  53906. REFLECTIONMAP_SKYBOX: boolean;
  53907. REFLECTIONMAP_EXPLICIT: boolean;
  53908. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  53909. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  53910. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  53911. INVERTCUBICMAP: boolean;
  53912. USESPHERICALFROMREFLECTIONMAP: boolean;
  53913. USEIRRADIANCEMAP: boolean;
  53914. SPHERICAL_HARMONICS: boolean;
  53915. USESPHERICALINVERTEX: boolean;
  53916. REFLECTIONMAP_OPPOSITEZ: boolean;
  53917. LODINREFLECTIONALPHA: boolean;
  53918. GAMMAREFLECTION: boolean;
  53919. RGBDREFLECTION: boolean;
  53920. LINEARSPECULARREFLECTION: boolean;
  53921. RADIANCEOCCLUSION: boolean;
  53922. HORIZONOCCLUSION: boolean;
  53923. INSTANCES: boolean;
  53924. NUM_BONE_INFLUENCERS: number;
  53925. BonesPerMesh: number;
  53926. BONETEXTURE: boolean;
  53927. NONUNIFORMSCALING: boolean;
  53928. MORPHTARGETS: boolean;
  53929. MORPHTARGETS_NORMAL: boolean;
  53930. MORPHTARGETS_TANGENT: boolean;
  53931. MORPHTARGETS_UV: boolean;
  53932. NUM_MORPH_INFLUENCERS: number;
  53933. IMAGEPROCESSING: boolean;
  53934. VIGNETTE: boolean;
  53935. VIGNETTEBLENDMODEMULTIPLY: boolean;
  53936. VIGNETTEBLENDMODEOPAQUE: boolean;
  53937. TONEMAPPING: boolean;
  53938. TONEMAPPING_ACES: boolean;
  53939. CONTRAST: boolean;
  53940. COLORCURVES: boolean;
  53941. COLORGRADING: boolean;
  53942. COLORGRADING3D: boolean;
  53943. SAMPLER3DGREENDEPTH: boolean;
  53944. SAMPLER3DBGRMAP: boolean;
  53945. IMAGEPROCESSINGPOSTPROCESS: boolean;
  53946. EXPOSURE: boolean;
  53947. MULTIVIEW: boolean;
  53948. USEPHYSICALLIGHTFALLOFF: boolean;
  53949. USEGLTFLIGHTFALLOFF: boolean;
  53950. TWOSIDEDLIGHTING: boolean;
  53951. SHADOWFLOAT: boolean;
  53952. CLIPPLANE: boolean;
  53953. CLIPPLANE2: boolean;
  53954. CLIPPLANE3: boolean;
  53955. CLIPPLANE4: boolean;
  53956. CLIPPLANE5: boolean;
  53957. CLIPPLANE6: boolean;
  53958. POINTSIZE: boolean;
  53959. FOG: boolean;
  53960. LOGARITHMICDEPTH: boolean;
  53961. FORCENORMALFORWARD: boolean;
  53962. SPECULARAA: boolean;
  53963. CLEARCOAT: boolean;
  53964. CLEARCOAT_DEFAULTIOR: boolean;
  53965. CLEARCOAT_TEXTURE: boolean;
  53966. CLEARCOAT_TEXTUREDIRECTUV: number;
  53967. CLEARCOAT_BUMP: boolean;
  53968. CLEARCOAT_BUMPDIRECTUV: number;
  53969. CLEARCOAT_TINT: boolean;
  53970. CLEARCOAT_TINT_TEXTURE: boolean;
  53971. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  53972. ANISOTROPIC: boolean;
  53973. ANISOTROPIC_TEXTURE: boolean;
  53974. ANISOTROPIC_TEXTUREDIRECTUV: number;
  53975. BRDF_V_HEIGHT_CORRELATED: boolean;
  53976. MS_BRDF_ENERGY_CONSERVATION: boolean;
  53977. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  53978. SHEEN: boolean;
  53979. SHEEN_TEXTURE: boolean;
  53980. SHEEN_TEXTUREDIRECTUV: number;
  53981. SHEEN_LINKWITHALBEDO: boolean;
  53982. SHEEN_ROUGHNESS: boolean;
  53983. SHEEN_ALBEDOSCALING: boolean;
  53984. SUBSURFACE: boolean;
  53985. SS_REFRACTION: boolean;
  53986. SS_TRANSLUCENCY: boolean;
  53987. SS_SCATERRING: boolean;
  53988. SS_THICKNESSANDMASK_TEXTURE: boolean;
  53989. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  53990. SS_REFRACTIONMAP_3D: boolean;
  53991. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  53992. SS_LODINREFRACTIONALPHA: boolean;
  53993. SS_GAMMAREFRACTION: boolean;
  53994. SS_RGBDREFRACTION: boolean;
  53995. SS_LINEARSPECULARREFRACTION: boolean;
  53996. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  53997. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  53998. UNLIT: boolean;
  53999. DEBUGMODE: number;
  54000. /**
  54001. * Initializes the PBR Material defines.
  54002. */
  54003. constructor();
  54004. /**
  54005. * Resets the PBR Material defines.
  54006. */
  54007. reset(): void;
  54008. }
  54009. /**
  54010. * The Physically based material base class of BJS.
  54011. *
  54012. * This offers the main features of a standard PBR material.
  54013. * For more information, please refer to the documentation :
  54014. * https://doc.babylonjs.com/how_to/physically_based_rendering
  54015. */
  54016. export abstract class PBRBaseMaterial extends PushMaterial {
  54017. /**
  54018. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  54019. */
  54020. static readonly PBRMATERIAL_OPAQUE: number;
  54021. /**
  54022. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  54023. */
  54024. static readonly PBRMATERIAL_ALPHATEST: number;
  54025. /**
  54026. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  54027. */
  54028. static readonly PBRMATERIAL_ALPHABLEND: number;
  54029. /**
  54030. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  54031. * They are also discarded below the alpha cutoff threshold to improve performances.
  54032. */
  54033. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  54034. /**
  54035. * Defines the default value of how much AO map is occluding the analytical lights
  54036. * (point spot...).
  54037. */
  54038. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  54039. /**
  54040. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  54041. */
  54042. static readonly LIGHTFALLOFF_PHYSICAL: number;
  54043. /**
  54044. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  54045. * to enhance interoperability with other engines.
  54046. */
  54047. static readonly LIGHTFALLOFF_GLTF: number;
  54048. /**
  54049. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  54050. * to enhance interoperability with other materials.
  54051. */
  54052. static readonly LIGHTFALLOFF_STANDARD: number;
  54053. /**
  54054. * Intensity of the direct lights e.g. the four lights available in your scene.
  54055. * This impacts both the direct diffuse and specular highlights.
  54056. */
  54057. protected _directIntensity: number;
  54058. /**
  54059. * Intensity of the emissive part of the material.
  54060. * This helps controlling the emissive effect without modifying the emissive color.
  54061. */
  54062. protected _emissiveIntensity: number;
  54063. /**
  54064. * Intensity of the environment e.g. how much the environment will light the object
  54065. * either through harmonics for rough material or through the refelction for shiny ones.
  54066. */
  54067. protected _environmentIntensity: number;
  54068. /**
  54069. * This is a special control allowing the reduction of the specular highlights coming from the
  54070. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  54071. */
  54072. protected _specularIntensity: number;
  54073. /**
  54074. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  54075. */
  54076. private _lightingInfos;
  54077. /**
  54078. * Debug Control allowing disabling the bump map on this material.
  54079. */
  54080. protected _disableBumpMap: boolean;
  54081. /**
  54082. * AKA Diffuse Texture in standard nomenclature.
  54083. */
  54084. protected _albedoTexture: Nullable<BaseTexture>;
  54085. /**
  54086. * AKA Occlusion Texture in other nomenclature.
  54087. */
  54088. protected _ambientTexture: Nullable<BaseTexture>;
  54089. /**
  54090. * AKA Occlusion Texture Intensity in other nomenclature.
  54091. */
  54092. protected _ambientTextureStrength: number;
  54093. /**
  54094. * Defines how much the AO map is occluding the analytical lights (point spot...).
  54095. * 1 means it completely occludes it
  54096. * 0 mean it has no impact
  54097. */
  54098. protected _ambientTextureImpactOnAnalyticalLights: number;
  54099. /**
  54100. * Stores the alpha values in a texture.
  54101. */
  54102. protected _opacityTexture: Nullable<BaseTexture>;
  54103. /**
  54104. * Stores the reflection values in a texture.
  54105. */
  54106. protected _reflectionTexture: Nullable<BaseTexture>;
  54107. /**
  54108. * Stores the emissive values in a texture.
  54109. */
  54110. protected _emissiveTexture: Nullable<BaseTexture>;
  54111. /**
  54112. * AKA Specular texture in other nomenclature.
  54113. */
  54114. protected _reflectivityTexture: Nullable<BaseTexture>;
  54115. /**
  54116. * Used to switch from specular/glossiness to metallic/roughness workflow.
  54117. */
  54118. protected _metallicTexture: Nullable<BaseTexture>;
  54119. /**
  54120. * Specifies the metallic scalar of the metallic/roughness workflow.
  54121. * Can also be used to scale the metalness values of the metallic texture.
  54122. */
  54123. protected _metallic: Nullable<number>;
  54124. /**
  54125. * Specifies the roughness scalar of the metallic/roughness workflow.
  54126. * Can also be used to scale the roughness values of the metallic texture.
  54127. */
  54128. protected _roughness: Nullable<number>;
  54129. /**
  54130. * Specifies the an F0 factor to help configuring the material F0.
  54131. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  54132. * to 0.5 the previously hard coded value stays the same.
  54133. * Can also be used to scale the F0 values of the metallic texture.
  54134. */
  54135. protected _metallicF0Factor: number;
  54136. /**
  54137. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  54138. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  54139. * your expectation as it multiplies with the texture data.
  54140. */
  54141. protected _useMetallicF0FactorFromMetallicTexture: boolean;
  54142. /**
  54143. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  54144. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  54145. */
  54146. protected _microSurfaceTexture: Nullable<BaseTexture>;
  54147. /**
  54148. * Stores surface normal data used to displace a mesh in a texture.
  54149. */
  54150. protected _bumpTexture: Nullable<BaseTexture>;
  54151. /**
  54152. * Stores the pre-calculated light information of a mesh in a texture.
  54153. */
  54154. protected _lightmapTexture: Nullable<BaseTexture>;
  54155. /**
  54156. * The color of a material in ambient lighting.
  54157. */
  54158. protected _ambientColor: Color3;
  54159. /**
  54160. * AKA Diffuse Color in other nomenclature.
  54161. */
  54162. protected _albedoColor: Color3;
  54163. /**
  54164. * AKA Specular Color in other nomenclature.
  54165. */
  54166. protected _reflectivityColor: Color3;
  54167. /**
  54168. * The color applied when light is reflected from a material.
  54169. */
  54170. protected _reflectionColor: Color3;
  54171. /**
  54172. * The color applied when light is emitted from a material.
  54173. */
  54174. protected _emissiveColor: Color3;
  54175. /**
  54176. * AKA Glossiness in other nomenclature.
  54177. */
  54178. protected _microSurface: number;
  54179. /**
  54180. * Specifies that the material will use the light map as a show map.
  54181. */
  54182. protected _useLightmapAsShadowmap: boolean;
  54183. /**
  54184. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  54185. * makes the reflect vector face the model (under horizon).
  54186. */
  54187. protected _useHorizonOcclusion: boolean;
  54188. /**
  54189. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  54190. * too much the area relying on ambient texture to define their ambient occlusion.
  54191. */
  54192. protected _useRadianceOcclusion: boolean;
  54193. /**
  54194. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  54195. */
  54196. protected _useAlphaFromAlbedoTexture: boolean;
  54197. /**
  54198. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  54199. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  54200. */
  54201. protected _useSpecularOverAlpha: boolean;
  54202. /**
  54203. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  54204. */
  54205. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  54206. /**
  54207. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  54208. */
  54209. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  54210. /**
  54211. * Specifies if the metallic texture contains the roughness information in its green channel.
  54212. */
  54213. protected _useRoughnessFromMetallicTextureGreen: boolean;
  54214. /**
  54215. * Specifies if the metallic texture contains the metallness information in its blue channel.
  54216. */
  54217. protected _useMetallnessFromMetallicTextureBlue: boolean;
  54218. /**
  54219. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  54220. */
  54221. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  54222. /**
  54223. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  54224. */
  54225. protected _useAmbientInGrayScale: boolean;
  54226. /**
  54227. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  54228. * The material will try to infer what glossiness each pixel should be.
  54229. */
  54230. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  54231. /**
  54232. * Defines the falloff type used in this material.
  54233. * It by default is Physical.
  54234. */
  54235. protected _lightFalloff: number;
  54236. /**
  54237. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  54238. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  54239. */
  54240. protected _useRadianceOverAlpha: boolean;
  54241. /**
  54242. * Allows using an object space normal map (instead of tangent space).
  54243. */
  54244. protected _useObjectSpaceNormalMap: boolean;
  54245. /**
  54246. * Allows using the bump map in parallax mode.
  54247. */
  54248. protected _useParallax: boolean;
  54249. /**
  54250. * Allows using the bump map in parallax occlusion mode.
  54251. */
  54252. protected _useParallaxOcclusion: boolean;
  54253. /**
  54254. * Controls the scale bias of the parallax mode.
  54255. */
  54256. protected _parallaxScaleBias: number;
  54257. /**
  54258. * If sets to true, disables all the lights affecting the material.
  54259. */
  54260. protected _disableLighting: boolean;
  54261. /**
  54262. * Number of Simultaneous lights allowed on the material.
  54263. */
  54264. protected _maxSimultaneousLights: number;
  54265. /**
  54266. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  54267. */
  54268. protected _invertNormalMapX: boolean;
  54269. /**
  54270. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  54271. */
  54272. protected _invertNormalMapY: boolean;
  54273. /**
  54274. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  54275. */
  54276. protected _twoSidedLighting: boolean;
  54277. /**
  54278. * Defines the alpha limits in alpha test mode.
  54279. */
  54280. protected _alphaCutOff: number;
  54281. /**
  54282. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  54283. */
  54284. protected _forceAlphaTest: boolean;
  54285. /**
  54286. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  54287. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  54288. */
  54289. protected _useAlphaFresnel: boolean;
  54290. /**
  54291. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  54292. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  54293. */
  54294. protected _useLinearAlphaFresnel: boolean;
  54295. /**
  54296. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  54297. * from cos thetav and roughness:
  54298. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  54299. */
  54300. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  54301. /**
  54302. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  54303. */
  54304. protected _forceIrradianceInFragment: boolean;
  54305. /**
  54306. * Force normal to face away from face.
  54307. */
  54308. protected _forceNormalForward: boolean;
  54309. /**
  54310. * Enables specular anti aliasing in the PBR shader.
  54311. * It will both interacts on the Geometry for analytical and IBL lighting.
  54312. * It also prefilter the roughness map based on the bump values.
  54313. */
  54314. protected _enableSpecularAntiAliasing: boolean;
  54315. /**
  54316. * Default configuration related to image processing available in the PBR Material.
  54317. */
  54318. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  54319. /**
  54320. * Keep track of the image processing observer to allow dispose and replace.
  54321. */
  54322. private _imageProcessingObserver;
  54323. /**
  54324. * Attaches a new image processing configuration to the PBR Material.
  54325. * @param configuration
  54326. */
  54327. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  54328. /**
  54329. * Stores the available render targets.
  54330. */
  54331. private _renderTargets;
  54332. /**
  54333. * Sets the global ambient color for the material used in lighting calculations.
  54334. */
  54335. private _globalAmbientColor;
  54336. /**
  54337. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  54338. */
  54339. private _useLogarithmicDepth;
  54340. /**
  54341. * If set to true, no lighting calculations will be applied.
  54342. */
  54343. private _unlit;
  54344. private _debugMode;
  54345. /**
  54346. * @hidden
  54347. * This is reserved for the inspector.
  54348. * Defines the material debug mode.
  54349. * It helps seeing only some components of the material while troubleshooting.
  54350. */
  54351. debugMode: number;
  54352. /**
  54353. * @hidden
  54354. * This is reserved for the inspector.
  54355. * Specify from where on screen the debug mode should start.
  54356. * The value goes from -1 (full screen) to 1 (not visible)
  54357. * It helps with side by side comparison against the final render
  54358. * This defaults to -1
  54359. */
  54360. private debugLimit;
  54361. /**
  54362. * @hidden
  54363. * This is reserved for the inspector.
  54364. * As the default viewing range might not be enough (if the ambient is really small for instance)
  54365. * You can use the factor to better multiply the final value.
  54366. */
  54367. private debugFactor;
  54368. /**
  54369. * Defines the clear coat layer parameters for the material.
  54370. */
  54371. readonly clearCoat: PBRClearCoatConfiguration;
  54372. /**
  54373. * Defines the anisotropic parameters for the material.
  54374. */
  54375. readonly anisotropy: PBRAnisotropicConfiguration;
  54376. /**
  54377. * Defines the BRDF parameters for the material.
  54378. */
  54379. readonly brdf: PBRBRDFConfiguration;
  54380. /**
  54381. * Defines the Sheen parameters for the material.
  54382. */
  54383. readonly sheen: PBRSheenConfiguration;
  54384. /**
  54385. * Defines the SubSurface parameters for the material.
  54386. */
  54387. readonly subSurface: PBRSubSurfaceConfiguration;
  54388. protected _rebuildInParallel: boolean;
  54389. /**
  54390. * Instantiates a new PBRMaterial instance.
  54391. *
  54392. * @param name The material name
  54393. * @param scene The scene the material will be use in.
  54394. */
  54395. constructor(name: string, scene: Scene);
  54396. /**
  54397. * Gets a boolean indicating that current material needs to register RTT
  54398. */
  54399. get hasRenderTargetTextures(): boolean;
  54400. /**
  54401. * Gets the name of the material class.
  54402. */
  54403. getClassName(): string;
  54404. /**
  54405. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  54406. */
  54407. get useLogarithmicDepth(): boolean;
  54408. /**
  54409. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  54410. */
  54411. set useLogarithmicDepth(value: boolean);
  54412. /**
  54413. * Returns true if alpha blending should be disabled.
  54414. */
  54415. protected get _disableAlphaBlending(): boolean;
  54416. /**
  54417. * Specifies whether or not this material should be rendered in alpha blend mode.
  54418. */
  54419. needAlphaBlending(): boolean;
  54420. /**
  54421. * Specifies whether or not this material should be rendered in alpha test mode.
  54422. */
  54423. needAlphaTesting(): boolean;
  54424. /**
  54425. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  54426. */
  54427. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  54428. /**
  54429. * Gets the texture used for the alpha test.
  54430. */
  54431. getAlphaTestTexture(): Nullable<BaseTexture>;
  54432. /**
  54433. * Specifies that the submesh is ready to be used.
  54434. * @param mesh - BJS mesh.
  54435. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  54436. * @param useInstances - Specifies that instances should be used.
  54437. * @returns - boolean indicating that the submesh is ready or not.
  54438. */
  54439. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  54440. /**
  54441. * Specifies if the material uses metallic roughness workflow.
  54442. * @returns boolean specifiying if the material uses metallic roughness workflow.
  54443. */
  54444. isMetallicWorkflow(): boolean;
  54445. private _prepareEffect;
  54446. private _prepareDefines;
  54447. /**
  54448. * Force shader compilation
  54449. */
  54450. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  54451. /**
  54452. * Initializes the uniform buffer layout for the shader.
  54453. */
  54454. buildUniformLayout(): void;
  54455. /**
  54456. * Unbinds the material from the mesh
  54457. */
  54458. unbind(): void;
  54459. /**
  54460. * Binds the submesh data.
  54461. * @param world - The world matrix.
  54462. * @param mesh - The BJS mesh.
  54463. * @param subMesh - A submesh of the BJS mesh.
  54464. */
  54465. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  54466. /**
  54467. * Returns the animatable textures.
  54468. * @returns - Array of animatable textures.
  54469. */
  54470. getAnimatables(): IAnimatable[];
  54471. /**
  54472. * Returns the texture used for reflections.
  54473. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  54474. */
  54475. private _getReflectionTexture;
  54476. /**
  54477. * Returns an array of the actively used textures.
  54478. * @returns - Array of BaseTextures
  54479. */
  54480. getActiveTextures(): BaseTexture[];
  54481. /**
  54482. * Checks to see if a texture is used in the material.
  54483. * @param texture - Base texture to use.
  54484. * @returns - Boolean specifying if a texture is used in the material.
  54485. */
  54486. hasTexture(texture: BaseTexture): boolean;
  54487. /**
  54488. * Disposes the resources of the material.
  54489. * @param forceDisposeEffect - Forces the disposal of effects.
  54490. * @param forceDisposeTextures - Forces the disposal of all textures.
  54491. */
  54492. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  54493. }
  54494. }
  54495. declare module "babylonjs/Materials/PBR/pbrMaterial" {
  54496. import { Nullable } from "babylonjs/types";
  54497. import { Scene } from "babylonjs/scene";
  54498. import { Color3 } from "babylonjs/Maths/math.color";
  54499. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  54500. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  54501. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54502. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  54503. /**
  54504. * The Physically based material of BJS.
  54505. *
  54506. * This offers the main features of a standard PBR material.
  54507. * For more information, please refer to the documentation :
  54508. * https://doc.babylonjs.com/how_to/physically_based_rendering
  54509. */
  54510. export class PBRMaterial extends PBRBaseMaterial {
  54511. /**
  54512. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  54513. */
  54514. static readonly PBRMATERIAL_OPAQUE: number;
  54515. /**
  54516. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  54517. */
  54518. static readonly PBRMATERIAL_ALPHATEST: number;
  54519. /**
  54520. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  54521. */
  54522. static readonly PBRMATERIAL_ALPHABLEND: number;
  54523. /**
  54524. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  54525. * They are also discarded below the alpha cutoff threshold to improve performances.
  54526. */
  54527. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  54528. /**
  54529. * Defines the default value of how much AO map is occluding the analytical lights
  54530. * (point spot...).
  54531. */
  54532. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  54533. /**
  54534. * Intensity of the direct lights e.g. the four lights available in your scene.
  54535. * This impacts both the direct diffuse and specular highlights.
  54536. */
  54537. directIntensity: number;
  54538. /**
  54539. * Intensity of the emissive part of the material.
  54540. * This helps controlling the emissive effect without modifying the emissive color.
  54541. */
  54542. emissiveIntensity: number;
  54543. /**
  54544. * Intensity of the environment e.g. how much the environment will light the object
  54545. * either through harmonics for rough material or through the refelction for shiny ones.
  54546. */
  54547. environmentIntensity: number;
  54548. /**
  54549. * This is a special control allowing the reduction of the specular highlights coming from the
  54550. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  54551. */
  54552. specularIntensity: number;
  54553. /**
  54554. * Debug Control allowing disabling the bump map on this material.
  54555. */
  54556. disableBumpMap: boolean;
  54557. /**
  54558. * AKA Diffuse Texture in standard nomenclature.
  54559. */
  54560. albedoTexture: BaseTexture;
  54561. /**
  54562. * AKA Occlusion Texture in other nomenclature.
  54563. */
  54564. ambientTexture: BaseTexture;
  54565. /**
  54566. * AKA Occlusion Texture Intensity in other nomenclature.
  54567. */
  54568. ambientTextureStrength: number;
  54569. /**
  54570. * Defines how much the AO map is occluding the analytical lights (point spot...).
  54571. * 1 means it completely occludes it
  54572. * 0 mean it has no impact
  54573. */
  54574. ambientTextureImpactOnAnalyticalLights: number;
  54575. /**
  54576. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  54577. */
  54578. opacityTexture: BaseTexture;
  54579. /**
  54580. * Stores the reflection values in a texture.
  54581. */
  54582. reflectionTexture: Nullable<BaseTexture>;
  54583. /**
  54584. * Stores the emissive values in a texture.
  54585. */
  54586. emissiveTexture: BaseTexture;
  54587. /**
  54588. * AKA Specular texture in other nomenclature.
  54589. */
  54590. reflectivityTexture: BaseTexture;
  54591. /**
  54592. * Used to switch from specular/glossiness to metallic/roughness workflow.
  54593. */
  54594. metallicTexture: BaseTexture;
  54595. /**
  54596. * Specifies the metallic scalar of the metallic/roughness workflow.
  54597. * Can also be used to scale the metalness values of the metallic texture.
  54598. */
  54599. metallic: Nullable<number>;
  54600. /**
  54601. * Specifies the roughness scalar of the metallic/roughness workflow.
  54602. * Can also be used to scale the roughness values of the metallic texture.
  54603. */
  54604. roughness: Nullable<number>;
  54605. /**
  54606. * Specifies the an F0 factor to help configuring the material F0.
  54607. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  54608. * to 0.5 the previously hard coded value stays the same.
  54609. * Can also be used to scale the F0 values of the metallic texture.
  54610. */
  54611. metallicF0Factor: number;
  54612. /**
  54613. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  54614. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  54615. * your expectation as it multiplies with the texture data.
  54616. */
  54617. useMetallicF0FactorFromMetallicTexture: boolean;
  54618. /**
  54619. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  54620. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  54621. */
  54622. microSurfaceTexture: BaseTexture;
  54623. /**
  54624. * Stores surface normal data used to displace a mesh in a texture.
  54625. */
  54626. bumpTexture: BaseTexture;
  54627. /**
  54628. * Stores the pre-calculated light information of a mesh in a texture.
  54629. */
  54630. lightmapTexture: BaseTexture;
  54631. /**
  54632. * Stores the refracted light information in a texture.
  54633. */
  54634. get refractionTexture(): Nullable<BaseTexture>;
  54635. set refractionTexture(value: Nullable<BaseTexture>);
  54636. /**
  54637. * The color of a material in ambient lighting.
  54638. */
  54639. ambientColor: Color3;
  54640. /**
  54641. * AKA Diffuse Color in other nomenclature.
  54642. */
  54643. albedoColor: Color3;
  54644. /**
  54645. * AKA Specular Color in other nomenclature.
  54646. */
  54647. reflectivityColor: Color3;
  54648. /**
  54649. * The color reflected from the material.
  54650. */
  54651. reflectionColor: Color3;
  54652. /**
  54653. * The color emitted from the material.
  54654. */
  54655. emissiveColor: Color3;
  54656. /**
  54657. * AKA Glossiness in other nomenclature.
  54658. */
  54659. microSurface: number;
  54660. /**
  54661. * source material index of refraction (IOR)' / 'destination material IOR.
  54662. */
  54663. get indexOfRefraction(): number;
  54664. set indexOfRefraction(value: number);
  54665. /**
  54666. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  54667. */
  54668. get invertRefractionY(): boolean;
  54669. set invertRefractionY(value: boolean);
  54670. /**
  54671. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  54672. * Materials half opaque for instance using refraction could benefit from this control.
  54673. */
  54674. get linkRefractionWithTransparency(): boolean;
  54675. set linkRefractionWithTransparency(value: boolean);
  54676. /**
  54677. * If true, the light map contains occlusion information instead of lighting info.
  54678. */
  54679. useLightmapAsShadowmap: boolean;
  54680. /**
  54681. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  54682. */
  54683. useAlphaFromAlbedoTexture: boolean;
  54684. /**
  54685. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  54686. */
  54687. forceAlphaTest: boolean;
  54688. /**
  54689. * Defines the alpha limits in alpha test mode.
  54690. */
  54691. alphaCutOff: number;
  54692. /**
  54693. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  54694. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  54695. */
  54696. useSpecularOverAlpha: boolean;
  54697. /**
  54698. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  54699. */
  54700. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  54701. /**
  54702. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  54703. */
  54704. useRoughnessFromMetallicTextureAlpha: boolean;
  54705. /**
  54706. * Specifies if the metallic texture contains the roughness information in its green channel.
  54707. */
  54708. useRoughnessFromMetallicTextureGreen: boolean;
  54709. /**
  54710. * Specifies if the metallic texture contains the metallness information in its blue channel.
  54711. */
  54712. useMetallnessFromMetallicTextureBlue: boolean;
  54713. /**
  54714. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  54715. */
  54716. useAmbientOcclusionFromMetallicTextureRed: boolean;
  54717. /**
  54718. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  54719. */
  54720. useAmbientInGrayScale: boolean;
  54721. /**
  54722. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  54723. * The material will try to infer what glossiness each pixel should be.
  54724. */
  54725. useAutoMicroSurfaceFromReflectivityMap: boolean;
  54726. /**
  54727. * BJS is using an harcoded light falloff based on a manually sets up range.
  54728. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  54729. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  54730. */
  54731. get usePhysicalLightFalloff(): boolean;
  54732. /**
  54733. * BJS is using an harcoded light falloff based on a manually sets up range.
  54734. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  54735. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  54736. */
  54737. set usePhysicalLightFalloff(value: boolean);
  54738. /**
  54739. * In order to support the falloff compatibility with gltf, a special mode has been added
  54740. * to reproduce the gltf light falloff.
  54741. */
  54742. get useGLTFLightFalloff(): boolean;
  54743. /**
  54744. * In order to support the falloff compatibility with gltf, a special mode has been added
  54745. * to reproduce the gltf light falloff.
  54746. */
  54747. set useGLTFLightFalloff(value: boolean);
  54748. /**
  54749. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  54750. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  54751. */
  54752. useRadianceOverAlpha: boolean;
  54753. /**
  54754. * Allows using an object space normal map (instead of tangent space).
  54755. */
  54756. useObjectSpaceNormalMap: boolean;
  54757. /**
  54758. * Allows using the bump map in parallax mode.
  54759. */
  54760. useParallax: boolean;
  54761. /**
  54762. * Allows using the bump map in parallax occlusion mode.
  54763. */
  54764. useParallaxOcclusion: boolean;
  54765. /**
  54766. * Controls the scale bias of the parallax mode.
  54767. */
  54768. parallaxScaleBias: number;
  54769. /**
  54770. * If sets to true, disables all the lights affecting the material.
  54771. */
  54772. disableLighting: boolean;
  54773. /**
  54774. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  54775. */
  54776. forceIrradianceInFragment: boolean;
  54777. /**
  54778. * Number of Simultaneous lights allowed on the material.
  54779. */
  54780. maxSimultaneousLights: number;
  54781. /**
  54782. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  54783. */
  54784. invertNormalMapX: boolean;
  54785. /**
  54786. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  54787. */
  54788. invertNormalMapY: boolean;
  54789. /**
  54790. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  54791. */
  54792. twoSidedLighting: boolean;
  54793. /**
  54794. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  54795. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  54796. */
  54797. useAlphaFresnel: boolean;
  54798. /**
  54799. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  54800. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  54801. */
  54802. useLinearAlphaFresnel: boolean;
  54803. /**
  54804. * Let user defines the brdf lookup texture used for IBL.
  54805. * A default 8bit version is embedded but you could point at :
  54806. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  54807. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  54808. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  54809. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  54810. */
  54811. environmentBRDFTexture: Nullable<BaseTexture>;
  54812. /**
  54813. * Force normal to face away from face.
  54814. */
  54815. forceNormalForward: boolean;
  54816. /**
  54817. * Enables specular anti aliasing in the PBR shader.
  54818. * It will both interacts on the Geometry for analytical and IBL lighting.
  54819. * It also prefilter the roughness map based on the bump values.
  54820. */
  54821. enableSpecularAntiAliasing: boolean;
  54822. /**
  54823. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  54824. * makes the reflect vector face the model (under horizon).
  54825. */
  54826. useHorizonOcclusion: boolean;
  54827. /**
  54828. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  54829. * too much the area relying on ambient texture to define their ambient occlusion.
  54830. */
  54831. useRadianceOcclusion: boolean;
  54832. /**
  54833. * If set to true, no lighting calculations will be applied.
  54834. */
  54835. unlit: boolean;
  54836. /**
  54837. * Gets the image processing configuration used either in this material.
  54838. */
  54839. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  54840. /**
  54841. * Sets the Default image processing configuration used either in the this material.
  54842. *
  54843. * If sets to null, the scene one is in use.
  54844. */
  54845. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  54846. /**
  54847. * Gets wether the color curves effect is enabled.
  54848. */
  54849. get cameraColorCurvesEnabled(): boolean;
  54850. /**
  54851. * Sets wether the color curves effect is enabled.
  54852. */
  54853. set cameraColorCurvesEnabled(value: boolean);
  54854. /**
  54855. * Gets wether the color grading effect is enabled.
  54856. */
  54857. get cameraColorGradingEnabled(): boolean;
  54858. /**
  54859. * Gets wether the color grading effect is enabled.
  54860. */
  54861. set cameraColorGradingEnabled(value: boolean);
  54862. /**
  54863. * Gets wether tonemapping is enabled or not.
  54864. */
  54865. get cameraToneMappingEnabled(): boolean;
  54866. /**
  54867. * Sets wether tonemapping is enabled or not
  54868. */
  54869. set cameraToneMappingEnabled(value: boolean);
  54870. /**
  54871. * The camera exposure used on this material.
  54872. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  54873. * This corresponds to a photographic exposure.
  54874. */
  54875. get cameraExposure(): number;
  54876. /**
  54877. * The camera exposure used on this material.
  54878. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  54879. * This corresponds to a photographic exposure.
  54880. */
  54881. set cameraExposure(value: number);
  54882. /**
  54883. * Gets The camera contrast used on this material.
  54884. */
  54885. get cameraContrast(): number;
  54886. /**
  54887. * Sets The camera contrast used on this material.
  54888. */
  54889. set cameraContrast(value: number);
  54890. /**
  54891. * Gets the Color Grading 2D Lookup Texture.
  54892. */
  54893. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  54894. /**
  54895. * Sets the Color Grading 2D Lookup Texture.
  54896. */
  54897. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  54898. /**
  54899. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  54900. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  54901. * 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;
  54902. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  54903. */
  54904. get cameraColorCurves(): Nullable<ColorCurves>;
  54905. /**
  54906. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  54907. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  54908. * 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;
  54909. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  54910. */
  54911. set cameraColorCurves(value: Nullable<ColorCurves>);
  54912. /**
  54913. * Instantiates a new PBRMaterial instance.
  54914. *
  54915. * @param name The material name
  54916. * @param scene The scene the material will be use in.
  54917. */
  54918. constructor(name: string, scene: Scene);
  54919. /**
  54920. * Returns the name of this material class.
  54921. */
  54922. getClassName(): string;
  54923. /**
  54924. * Makes a duplicate of the current material.
  54925. * @param name - name to use for the new material.
  54926. */
  54927. clone(name: string): PBRMaterial;
  54928. /**
  54929. * Serializes this PBR Material.
  54930. * @returns - An object with the serialized material.
  54931. */
  54932. serialize(): any;
  54933. /**
  54934. * Parses a PBR Material from a serialized object.
  54935. * @param source - Serialized object.
  54936. * @param scene - BJS scene instance.
  54937. * @param rootUrl - url for the scene object
  54938. * @returns - PBRMaterial
  54939. */
  54940. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  54941. }
  54942. }
  54943. declare module "babylonjs/Misc/dds" {
  54944. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  54945. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54946. import { Nullable } from "babylonjs/types";
  54947. import { Scene } from "babylonjs/scene";
  54948. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  54949. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  54950. /**
  54951. * Direct draw surface info
  54952. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  54953. */
  54954. export interface DDSInfo {
  54955. /**
  54956. * Width of the texture
  54957. */
  54958. width: number;
  54959. /**
  54960. * Width of the texture
  54961. */
  54962. height: number;
  54963. /**
  54964. * Number of Mipmaps for the texture
  54965. * @see https://en.wikipedia.org/wiki/Mipmap
  54966. */
  54967. mipmapCount: number;
  54968. /**
  54969. * If the textures format is a known fourCC format
  54970. * @see https://www.fourcc.org/
  54971. */
  54972. isFourCC: boolean;
  54973. /**
  54974. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  54975. */
  54976. isRGB: boolean;
  54977. /**
  54978. * If the texture is a lumincance format
  54979. */
  54980. isLuminance: boolean;
  54981. /**
  54982. * If this is a cube texture
  54983. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  54984. */
  54985. isCube: boolean;
  54986. /**
  54987. * If the texture is a compressed format eg. FOURCC_DXT1
  54988. */
  54989. isCompressed: boolean;
  54990. /**
  54991. * The dxgiFormat of the texture
  54992. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  54993. */
  54994. dxgiFormat: number;
  54995. /**
  54996. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  54997. */
  54998. textureType: number;
  54999. /**
  55000. * Sphericle polynomial created for the dds texture
  55001. */
  55002. sphericalPolynomial?: SphericalPolynomial;
  55003. }
  55004. /**
  55005. * Class used to provide DDS decompression tools
  55006. */
  55007. export class DDSTools {
  55008. /**
  55009. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  55010. */
  55011. static StoreLODInAlphaChannel: boolean;
  55012. /**
  55013. * Gets DDS information from an array buffer
  55014. * @param data defines the array buffer view to read data from
  55015. * @returns the DDS information
  55016. */
  55017. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  55018. private static _FloatView;
  55019. private static _Int32View;
  55020. private static _ToHalfFloat;
  55021. private static _FromHalfFloat;
  55022. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  55023. private static _GetHalfFloatRGBAArrayBuffer;
  55024. private static _GetFloatRGBAArrayBuffer;
  55025. private static _GetFloatAsUIntRGBAArrayBuffer;
  55026. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  55027. private static _GetRGBAArrayBuffer;
  55028. private static _ExtractLongWordOrder;
  55029. private static _GetRGBArrayBuffer;
  55030. private static _GetLuminanceArrayBuffer;
  55031. /**
  55032. * Uploads DDS Levels to a Babylon Texture
  55033. * @hidden
  55034. */
  55035. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  55036. }
  55037. module "babylonjs/Engines/thinEngine" {
  55038. interface ThinEngine {
  55039. /**
  55040. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  55041. * @param rootUrl defines the url where the file to load is located
  55042. * @param scene defines the current scene
  55043. * @param lodScale defines scale to apply to the mip map selection
  55044. * @param lodOffset defines offset to apply to the mip map selection
  55045. * @param onLoad defines an optional callback raised when the texture is loaded
  55046. * @param onError defines an optional callback raised if there is an issue to load the texture
  55047. * @param format defines the format of the data
  55048. * @param forcedExtension defines the extension to use to pick the right loader
  55049. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  55050. * @returns the cube texture as an InternalTexture
  55051. */
  55052. 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;
  55053. }
  55054. }
  55055. }
  55056. declare module "babylonjs/Materials/Textures/Loaders/ddsTextureLoader" {
  55057. import { Nullable } from "babylonjs/types";
  55058. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  55059. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  55060. /**
  55061. * Implementation of the DDS Texture Loader.
  55062. * @hidden
  55063. */
  55064. export class _DDSTextureLoader implements IInternalTextureLoader {
  55065. /**
  55066. * Defines wether the loader supports cascade loading the different faces.
  55067. */
  55068. readonly supportCascades: boolean;
  55069. /**
  55070. * This returns if the loader support the current file information.
  55071. * @param extension defines the file extension of the file being loaded
  55072. * @returns true if the loader can load the specified file
  55073. */
  55074. canLoad(extension: string): boolean;
  55075. /**
  55076. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  55077. * @param data contains the texture data
  55078. * @param texture defines the BabylonJS internal texture
  55079. * @param createPolynomials will be true if polynomials have been requested
  55080. * @param onLoad defines the callback to trigger once the texture is ready
  55081. * @param onError defines the callback to trigger in case of error
  55082. */
  55083. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  55084. /**
  55085. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  55086. * @param data contains the texture data
  55087. * @param texture defines the BabylonJS internal texture
  55088. * @param callback defines the method to call once ready to upload
  55089. */
  55090. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  55091. }
  55092. }
  55093. declare module "babylonjs/Materials/Textures/Loaders/envTextureLoader" {
  55094. import { Nullable } from "babylonjs/types";
  55095. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  55096. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  55097. /**
  55098. * Implementation of the ENV Texture Loader.
  55099. * @hidden
  55100. */
  55101. export class _ENVTextureLoader implements IInternalTextureLoader {
  55102. /**
  55103. * Defines wether the loader supports cascade loading the different faces.
  55104. */
  55105. readonly supportCascades: boolean;
  55106. /**
  55107. * This returns if the loader support the current file information.
  55108. * @param extension defines the file extension of the file being loaded
  55109. * @returns true if the loader can load the specified file
  55110. */
  55111. canLoad(extension: string): boolean;
  55112. /**
  55113. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  55114. * @param data contains the texture data
  55115. * @param texture defines the BabylonJS internal texture
  55116. * @param createPolynomials will be true if polynomials have been requested
  55117. * @param onLoad defines the callback to trigger once the texture is ready
  55118. * @param onError defines the callback to trigger in case of error
  55119. */
  55120. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  55121. /**
  55122. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  55123. * @param data contains the texture data
  55124. * @param texture defines the BabylonJS internal texture
  55125. * @param callback defines the method to call once ready to upload
  55126. */
  55127. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  55128. }
  55129. }
  55130. declare module "babylonjs/Misc/khronosTextureContainer" {
  55131. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  55132. /**
  55133. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  55134. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  55135. */
  55136. export class KhronosTextureContainer {
  55137. /** contents of the KTX container file */
  55138. data: ArrayBufferView;
  55139. private static HEADER_LEN;
  55140. private static COMPRESSED_2D;
  55141. private static COMPRESSED_3D;
  55142. private static TEX_2D;
  55143. private static TEX_3D;
  55144. /**
  55145. * Gets the openGL type
  55146. */
  55147. glType: number;
  55148. /**
  55149. * Gets the openGL type size
  55150. */
  55151. glTypeSize: number;
  55152. /**
  55153. * Gets the openGL format
  55154. */
  55155. glFormat: number;
  55156. /**
  55157. * Gets the openGL internal format
  55158. */
  55159. glInternalFormat: number;
  55160. /**
  55161. * Gets the base internal format
  55162. */
  55163. glBaseInternalFormat: number;
  55164. /**
  55165. * Gets image width in pixel
  55166. */
  55167. pixelWidth: number;
  55168. /**
  55169. * Gets image height in pixel
  55170. */
  55171. pixelHeight: number;
  55172. /**
  55173. * Gets image depth in pixels
  55174. */
  55175. pixelDepth: number;
  55176. /**
  55177. * Gets the number of array elements
  55178. */
  55179. numberOfArrayElements: number;
  55180. /**
  55181. * Gets the number of faces
  55182. */
  55183. numberOfFaces: number;
  55184. /**
  55185. * Gets the number of mipmap levels
  55186. */
  55187. numberOfMipmapLevels: number;
  55188. /**
  55189. * Gets the bytes of key value data
  55190. */
  55191. bytesOfKeyValueData: number;
  55192. /**
  55193. * Gets the load type
  55194. */
  55195. loadType: number;
  55196. /**
  55197. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  55198. */
  55199. isInvalid: boolean;
  55200. /**
  55201. * Creates a new KhronosTextureContainer
  55202. * @param data contents of the KTX container file
  55203. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  55204. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  55205. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  55206. */
  55207. constructor(
  55208. /** contents of the KTX container file */
  55209. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  55210. /**
  55211. * Uploads KTX content to a Babylon Texture.
  55212. * It is assumed that the texture has already been created & is currently bound
  55213. * @hidden
  55214. */
  55215. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  55216. private _upload2DCompressedLevels;
  55217. /**
  55218. * Checks if the given data starts with a KTX file identifier.
  55219. * @param data the data to check
  55220. * @returns true if the data is a KTX file or false otherwise
  55221. */
  55222. static IsValid(data: ArrayBufferView): boolean;
  55223. }
  55224. }
  55225. declare module "babylonjs/Misc/khronosTextureContainer2" {
  55226. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  55227. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  55228. /**
  55229. * Class for loading KTX2 files
  55230. * !!! Experimental Extension Subject to Changes !!!
  55231. * @hidden
  55232. */
  55233. export class KhronosTextureContainer2 {
  55234. private static _ModulePromise;
  55235. private static _TranscodeFormat;
  55236. constructor(engine: ThinEngine);
  55237. uploadAsync(data: ArrayBufferView, internalTexture: InternalTexture): Promise<void>;
  55238. private _determineTranscodeFormat;
  55239. /**
  55240. * Checks if the given data starts with a KTX2 file identifier.
  55241. * @param data the data to check
  55242. * @returns true if the data is a KTX2 file or false otherwise
  55243. */
  55244. static IsValid(data: ArrayBufferView): boolean;
  55245. }
  55246. }
  55247. declare module "babylonjs/Materials/Textures/Loaders/ktxTextureLoader" {
  55248. import { Nullable } from "babylonjs/types";
  55249. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  55250. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  55251. /**
  55252. * Implementation of the KTX Texture Loader.
  55253. * @hidden
  55254. */
  55255. export class _KTXTextureLoader implements IInternalTextureLoader {
  55256. /**
  55257. * Defines wether the loader supports cascade loading the different faces.
  55258. */
  55259. readonly supportCascades: boolean;
  55260. /**
  55261. * This returns if the loader support the current file information.
  55262. * @param extension defines the file extension of the file being loaded
  55263. * @returns true if the loader can load the specified file
  55264. */
  55265. canLoad(extension: string): boolean;
  55266. /**
  55267. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  55268. * @param data contains the texture data
  55269. * @param texture defines the BabylonJS internal texture
  55270. * @param createPolynomials will be true if polynomials have been requested
  55271. * @param onLoad defines the callback to trigger once the texture is ready
  55272. * @param onError defines the callback to trigger in case of error
  55273. */
  55274. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  55275. /**
  55276. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  55277. * @param data contains the texture data
  55278. * @param texture defines the BabylonJS internal texture
  55279. * @param callback defines the method to call once ready to upload
  55280. */
  55281. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  55282. }
  55283. }
  55284. declare module "babylonjs/Helpers/sceneHelpers" {
  55285. import { Nullable } from "babylonjs/types";
  55286. import { Mesh } from "babylonjs/Meshes/mesh";
  55287. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  55288. import { IEnvironmentHelperOptions, EnvironmentHelper } from "babylonjs/Helpers/environmentHelper";
  55289. import { VRExperienceHelperOptions, VRExperienceHelper } from "babylonjs/Cameras/VR/vrExperienceHelper";
  55290. import "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  55291. import "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  55292. import "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  55293. import "babylonjs/Meshes/Builders/boxBuilder";
  55294. import { WebXRDefaultExperience, WebXRDefaultExperienceOptions } from "babylonjs/XR/webXRDefaultExperience";
  55295. /** @hidden */
  55296. export var _forceSceneHelpersToBundle: boolean;
  55297. module "babylonjs/scene" {
  55298. interface Scene {
  55299. /**
  55300. * Creates a default light for the scene.
  55301. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  55302. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  55303. */
  55304. createDefaultLight(replace?: boolean): void;
  55305. /**
  55306. * Creates a default camera for the scene.
  55307. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  55308. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  55309. * @param replace has default false, when true replaces the active camera in the scene
  55310. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  55311. */
  55312. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  55313. /**
  55314. * Creates a default camera and a default light.
  55315. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  55316. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  55317. * @param replace has the default false, when true replaces the active camera/light in the scene
  55318. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  55319. */
  55320. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  55321. /**
  55322. * Creates a new sky box
  55323. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  55324. * @param environmentTexture defines the texture to use as environment texture
  55325. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  55326. * @param scale defines the overall scale of the skybox
  55327. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  55328. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  55329. * @returns a new mesh holding the sky box
  55330. */
  55331. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  55332. /**
  55333. * Creates a new environment
  55334. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  55335. * @param options defines the options you can use to configure the environment
  55336. * @returns the new EnvironmentHelper
  55337. */
  55338. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  55339. /**
  55340. * Creates a new VREXperienceHelper
  55341. * @see http://doc.babylonjs.com/how_to/webvr_helper
  55342. * @param webVROptions defines the options used to create the new VREXperienceHelper
  55343. * @returns a new VREXperienceHelper
  55344. */
  55345. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  55346. /**
  55347. * Creates a new WebXRDefaultExperience
  55348. * @see http://doc.babylonjs.com/how_to/webxr
  55349. * @param options experience options
  55350. * @returns a promise for a new WebXRDefaultExperience
  55351. */
  55352. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  55353. }
  55354. }
  55355. }
  55356. declare module "babylonjs/Helpers/videoDome" {
  55357. import { Scene } from "babylonjs/scene";
  55358. import { TransformNode } from "babylonjs/Meshes/transformNode";
  55359. import { Mesh } from "babylonjs/Meshes/mesh";
  55360. import { VideoTexture } from "babylonjs/Materials/Textures/videoTexture";
  55361. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  55362. import "babylonjs/Meshes/Builders/sphereBuilder";
  55363. /**
  55364. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  55365. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  55366. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  55367. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  55368. */
  55369. export class VideoDome extends TransformNode {
  55370. /**
  55371. * Define the video source as a Monoscopic panoramic 360 video.
  55372. */
  55373. static readonly MODE_MONOSCOPIC: number;
  55374. /**
  55375. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  55376. */
  55377. static readonly MODE_TOPBOTTOM: number;
  55378. /**
  55379. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  55380. */
  55381. static readonly MODE_SIDEBYSIDE: number;
  55382. private _halfDome;
  55383. private _useDirectMapping;
  55384. /**
  55385. * The video texture being displayed on the sphere
  55386. */
  55387. protected _videoTexture: VideoTexture;
  55388. /**
  55389. * Gets the video texture being displayed on the sphere
  55390. */
  55391. get videoTexture(): VideoTexture;
  55392. /**
  55393. * The skybox material
  55394. */
  55395. protected _material: BackgroundMaterial;
  55396. /**
  55397. * The surface used for the skybox
  55398. */
  55399. protected _mesh: Mesh;
  55400. /**
  55401. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  55402. */
  55403. private _halfDomeMask;
  55404. /**
  55405. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  55406. * Also see the options.resolution property.
  55407. */
  55408. get fovMultiplier(): number;
  55409. set fovMultiplier(value: number);
  55410. private _videoMode;
  55411. /**
  55412. * Gets or set the current video mode for the video. It can be:
  55413. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  55414. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  55415. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  55416. */
  55417. get videoMode(): number;
  55418. set videoMode(value: number);
  55419. /**
  55420. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  55421. *
  55422. */
  55423. get halfDome(): boolean;
  55424. /**
  55425. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  55426. */
  55427. set halfDome(enabled: boolean);
  55428. /**
  55429. * Oberserver used in Stereoscopic VR Mode.
  55430. */
  55431. private _onBeforeCameraRenderObserver;
  55432. /**
  55433. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  55434. * @param name Element's name, child elements will append suffixes for their own names.
  55435. * @param urlsOrVideo defines the url(s) or the video element to use
  55436. * @param options An object containing optional or exposed sub element properties
  55437. */
  55438. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  55439. resolution?: number;
  55440. clickToPlay?: boolean;
  55441. autoPlay?: boolean;
  55442. loop?: boolean;
  55443. size?: number;
  55444. poster?: string;
  55445. faceForward?: boolean;
  55446. useDirectMapping?: boolean;
  55447. halfDomeMode?: boolean;
  55448. }, scene: Scene);
  55449. private _changeVideoMode;
  55450. /**
  55451. * Releases resources associated with this node.
  55452. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  55453. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  55454. */
  55455. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  55456. }
  55457. }
  55458. declare module "babylonjs/Helpers/index" {
  55459. export * from "babylonjs/Helpers/environmentHelper";
  55460. export * from "babylonjs/Helpers/photoDome";
  55461. export * from "babylonjs/Helpers/sceneHelpers";
  55462. export * from "babylonjs/Helpers/videoDome";
  55463. }
  55464. declare module "babylonjs/Instrumentation/engineInstrumentation" {
  55465. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  55466. import { IDisposable } from "babylonjs/scene";
  55467. import { Engine } from "babylonjs/Engines/engine";
  55468. /**
  55469. * This class can be used to get instrumentation data from a Babylon engine
  55470. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  55471. */
  55472. export class EngineInstrumentation implements IDisposable {
  55473. /**
  55474. * Define the instrumented engine.
  55475. */
  55476. engine: Engine;
  55477. private _captureGPUFrameTime;
  55478. private _gpuFrameTimeToken;
  55479. private _gpuFrameTime;
  55480. private _captureShaderCompilationTime;
  55481. private _shaderCompilationTime;
  55482. private _onBeginFrameObserver;
  55483. private _onEndFrameObserver;
  55484. private _onBeforeShaderCompilationObserver;
  55485. private _onAfterShaderCompilationObserver;
  55486. /**
  55487. * Gets the perf counter used for GPU frame time
  55488. */
  55489. get gpuFrameTimeCounter(): PerfCounter;
  55490. /**
  55491. * Gets the GPU frame time capture status
  55492. */
  55493. get captureGPUFrameTime(): boolean;
  55494. /**
  55495. * Enable or disable the GPU frame time capture
  55496. */
  55497. set captureGPUFrameTime(value: boolean);
  55498. /**
  55499. * Gets the perf counter used for shader compilation time
  55500. */
  55501. get shaderCompilationTimeCounter(): PerfCounter;
  55502. /**
  55503. * Gets the shader compilation time capture status
  55504. */
  55505. get captureShaderCompilationTime(): boolean;
  55506. /**
  55507. * Enable or disable the shader compilation time capture
  55508. */
  55509. set captureShaderCompilationTime(value: boolean);
  55510. /**
  55511. * Instantiates a new engine instrumentation.
  55512. * This class can be used to get instrumentation data from a Babylon engine
  55513. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  55514. * @param engine Defines the engine to instrument
  55515. */
  55516. constructor(
  55517. /**
  55518. * Define the instrumented engine.
  55519. */
  55520. engine: Engine);
  55521. /**
  55522. * Dispose and release associated resources.
  55523. */
  55524. dispose(): void;
  55525. }
  55526. }
  55527. declare module "babylonjs/Instrumentation/sceneInstrumentation" {
  55528. import { Scene, IDisposable } from "babylonjs/scene";
  55529. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  55530. /**
  55531. * This class can be used to get instrumentation data from a Babylon engine
  55532. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  55533. */
  55534. export class SceneInstrumentation implements IDisposable {
  55535. /**
  55536. * Defines the scene to instrument
  55537. */
  55538. scene: Scene;
  55539. private _captureActiveMeshesEvaluationTime;
  55540. private _activeMeshesEvaluationTime;
  55541. private _captureRenderTargetsRenderTime;
  55542. private _renderTargetsRenderTime;
  55543. private _captureFrameTime;
  55544. private _frameTime;
  55545. private _captureRenderTime;
  55546. private _renderTime;
  55547. private _captureInterFrameTime;
  55548. private _interFrameTime;
  55549. private _captureParticlesRenderTime;
  55550. private _particlesRenderTime;
  55551. private _captureSpritesRenderTime;
  55552. private _spritesRenderTime;
  55553. private _capturePhysicsTime;
  55554. private _physicsTime;
  55555. private _captureAnimationsTime;
  55556. private _animationsTime;
  55557. private _captureCameraRenderTime;
  55558. private _cameraRenderTime;
  55559. private _onBeforeActiveMeshesEvaluationObserver;
  55560. private _onAfterActiveMeshesEvaluationObserver;
  55561. private _onBeforeRenderTargetsRenderObserver;
  55562. private _onAfterRenderTargetsRenderObserver;
  55563. private _onAfterRenderObserver;
  55564. private _onBeforeDrawPhaseObserver;
  55565. private _onAfterDrawPhaseObserver;
  55566. private _onBeforeAnimationsObserver;
  55567. private _onBeforeParticlesRenderingObserver;
  55568. private _onAfterParticlesRenderingObserver;
  55569. private _onBeforeSpritesRenderingObserver;
  55570. private _onAfterSpritesRenderingObserver;
  55571. private _onBeforePhysicsObserver;
  55572. private _onAfterPhysicsObserver;
  55573. private _onAfterAnimationsObserver;
  55574. private _onBeforeCameraRenderObserver;
  55575. private _onAfterCameraRenderObserver;
  55576. /**
  55577. * Gets the perf counter used for active meshes evaluation time
  55578. */
  55579. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  55580. /**
  55581. * Gets the active meshes evaluation time capture status
  55582. */
  55583. get captureActiveMeshesEvaluationTime(): boolean;
  55584. /**
  55585. * Enable or disable the active meshes evaluation time capture
  55586. */
  55587. set captureActiveMeshesEvaluationTime(value: boolean);
  55588. /**
  55589. * Gets the perf counter used for render targets render time
  55590. */
  55591. get renderTargetsRenderTimeCounter(): PerfCounter;
  55592. /**
  55593. * Gets the render targets render time capture status
  55594. */
  55595. get captureRenderTargetsRenderTime(): boolean;
  55596. /**
  55597. * Enable or disable the render targets render time capture
  55598. */
  55599. set captureRenderTargetsRenderTime(value: boolean);
  55600. /**
  55601. * Gets the perf counter used for particles render time
  55602. */
  55603. get particlesRenderTimeCounter(): PerfCounter;
  55604. /**
  55605. * Gets the particles render time capture status
  55606. */
  55607. get captureParticlesRenderTime(): boolean;
  55608. /**
  55609. * Enable or disable the particles render time capture
  55610. */
  55611. set captureParticlesRenderTime(value: boolean);
  55612. /**
  55613. * Gets the perf counter used for sprites render time
  55614. */
  55615. get spritesRenderTimeCounter(): PerfCounter;
  55616. /**
  55617. * Gets the sprites render time capture status
  55618. */
  55619. get captureSpritesRenderTime(): boolean;
  55620. /**
  55621. * Enable or disable the sprites render time capture
  55622. */
  55623. set captureSpritesRenderTime(value: boolean);
  55624. /**
  55625. * Gets the perf counter used for physics time
  55626. */
  55627. get physicsTimeCounter(): PerfCounter;
  55628. /**
  55629. * Gets the physics time capture status
  55630. */
  55631. get capturePhysicsTime(): boolean;
  55632. /**
  55633. * Enable or disable the physics time capture
  55634. */
  55635. set capturePhysicsTime(value: boolean);
  55636. /**
  55637. * Gets the perf counter used for animations time
  55638. */
  55639. get animationsTimeCounter(): PerfCounter;
  55640. /**
  55641. * Gets the animations time capture status
  55642. */
  55643. get captureAnimationsTime(): boolean;
  55644. /**
  55645. * Enable or disable the animations time capture
  55646. */
  55647. set captureAnimationsTime(value: boolean);
  55648. /**
  55649. * Gets the perf counter used for frame time capture
  55650. */
  55651. get frameTimeCounter(): PerfCounter;
  55652. /**
  55653. * Gets the frame time capture status
  55654. */
  55655. get captureFrameTime(): boolean;
  55656. /**
  55657. * Enable or disable the frame time capture
  55658. */
  55659. set captureFrameTime(value: boolean);
  55660. /**
  55661. * Gets the perf counter used for inter-frames time capture
  55662. */
  55663. get interFrameTimeCounter(): PerfCounter;
  55664. /**
  55665. * Gets the inter-frames time capture status
  55666. */
  55667. get captureInterFrameTime(): boolean;
  55668. /**
  55669. * Enable or disable the inter-frames time capture
  55670. */
  55671. set captureInterFrameTime(value: boolean);
  55672. /**
  55673. * Gets the perf counter used for render time capture
  55674. */
  55675. get renderTimeCounter(): PerfCounter;
  55676. /**
  55677. * Gets the render time capture status
  55678. */
  55679. get captureRenderTime(): boolean;
  55680. /**
  55681. * Enable or disable the render time capture
  55682. */
  55683. set captureRenderTime(value: boolean);
  55684. /**
  55685. * Gets the perf counter used for camera render time capture
  55686. */
  55687. get cameraRenderTimeCounter(): PerfCounter;
  55688. /**
  55689. * Gets the camera render time capture status
  55690. */
  55691. get captureCameraRenderTime(): boolean;
  55692. /**
  55693. * Enable or disable the camera render time capture
  55694. */
  55695. set captureCameraRenderTime(value: boolean);
  55696. /**
  55697. * Gets the perf counter used for draw calls
  55698. */
  55699. get drawCallsCounter(): PerfCounter;
  55700. /**
  55701. * Instantiates a new scene instrumentation.
  55702. * This class can be used to get instrumentation data from a Babylon engine
  55703. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  55704. * @param scene Defines the scene to instrument
  55705. */
  55706. constructor(
  55707. /**
  55708. * Defines the scene to instrument
  55709. */
  55710. scene: Scene);
  55711. /**
  55712. * Dispose and release associated resources.
  55713. */
  55714. dispose(): void;
  55715. }
  55716. }
  55717. declare module "babylonjs/Instrumentation/index" {
  55718. export * from "babylonjs/Instrumentation/engineInstrumentation";
  55719. export * from "babylonjs/Instrumentation/sceneInstrumentation";
  55720. export * from "babylonjs/Instrumentation/timeToken";
  55721. }
  55722. declare module "babylonjs/Shaders/glowMapGeneration.fragment" {
  55723. /** @hidden */
  55724. export var glowMapGenerationPixelShader: {
  55725. name: string;
  55726. shader: string;
  55727. };
  55728. }
  55729. declare module "babylonjs/Shaders/glowMapGeneration.vertex" {
  55730. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  55731. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  55732. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  55733. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  55734. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  55735. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  55736. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  55737. /** @hidden */
  55738. export var glowMapGenerationVertexShader: {
  55739. name: string;
  55740. shader: string;
  55741. };
  55742. }
  55743. declare module "babylonjs/Layers/effectLayer" {
  55744. import { Observable } from "babylonjs/Misc/observable";
  55745. import { Nullable } from "babylonjs/types";
  55746. import { Camera } from "babylonjs/Cameras/camera";
  55747. import { Scene } from "babylonjs/scene";
  55748. import { ISize } from "babylonjs/Maths/math.size";
  55749. import { Color4 } from "babylonjs/Maths/math.color";
  55750. import { Engine } from "babylonjs/Engines/engine";
  55751. import { SubMesh } from "babylonjs/Meshes/subMesh";
  55752. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55753. import { Mesh } from "babylonjs/Meshes/mesh";
  55754. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  55755. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  55756. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  55757. import { Effect } from "babylonjs/Materials/effect";
  55758. import { Material } from "babylonjs/Materials/material";
  55759. import "babylonjs/Shaders/glowMapGeneration.fragment";
  55760. import "babylonjs/Shaders/glowMapGeneration.vertex";
  55761. /**
  55762. * Effect layer options. This helps customizing the behaviour
  55763. * of the effect layer.
  55764. */
  55765. export interface IEffectLayerOptions {
  55766. /**
  55767. * Multiplication factor apply to the canvas size to compute the render target size
  55768. * used to generated the objects (the smaller the faster).
  55769. */
  55770. mainTextureRatio: number;
  55771. /**
  55772. * Enforces a fixed size texture to ensure effect stability across devices.
  55773. */
  55774. mainTextureFixedSize?: number;
  55775. /**
  55776. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  55777. */
  55778. alphaBlendingMode: number;
  55779. /**
  55780. * The camera attached to the layer.
  55781. */
  55782. camera: Nullable<Camera>;
  55783. /**
  55784. * The rendering group to draw the layer in.
  55785. */
  55786. renderingGroupId: number;
  55787. }
  55788. /**
  55789. * The effect layer Helps adding post process effect blended with the main pass.
  55790. *
  55791. * This can be for instance use to generate glow or higlight effects on the scene.
  55792. *
  55793. * The effect layer class can not be used directly and is intented to inherited from to be
  55794. * customized per effects.
  55795. */
  55796. export abstract class EffectLayer {
  55797. private _vertexBuffers;
  55798. private _indexBuffer;
  55799. private _cachedDefines;
  55800. private _effectLayerMapGenerationEffect;
  55801. private _effectLayerOptions;
  55802. private _mergeEffect;
  55803. protected _scene: Scene;
  55804. protected _engine: Engine;
  55805. protected _maxSize: number;
  55806. protected _mainTextureDesiredSize: ISize;
  55807. protected _mainTexture: RenderTargetTexture;
  55808. protected _shouldRender: boolean;
  55809. protected _postProcesses: PostProcess[];
  55810. protected _textures: BaseTexture[];
  55811. protected _emissiveTextureAndColor: {
  55812. texture: Nullable<BaseTexture>;
  55813. color: Color4;
  55814. };
  55815. /**
  55816. * The name of the layer
  55817. */
  55818. name: string;
  55819. /**
  55820. * The clear color of the texture used to generate the glow map.
  55821. */
  55822. neutralColor: Color4;
  55823. /**
  55824. * Specifies whether the highlight layer is enabled or not.
  55825. */
  55826. isEnabled: boolean;
  55827. /**
  55828. * Gets the camera attached to the layer.
  55829. */
  55830. get camera(): Nullable<Camera>;
  55831. /**
  55832. * Gets the rendering group id the layer should render in.
  55833. */
  55834. get renderingGroupId(): number;
  55835. set renderingGroupId(renderingGroupId: number);
  55836. /**
  55837. * An event triggered when the effect layer has been disposed.
  55838. */
  55839. onDisposeObservable: Observable<EffectLayer>;
  55840. /**
  55841. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  55842. */
  55843. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  55844. /**
  55845. * An event triggered when the generated texture is being merged in the scene.
  55846. */
  55847. onBeforeComposeObservable: Observable<EffectLayer>;
  55848. /**
  55849. * An event triggered when the mesh is rendered into the effect render target.
  55850. */
  55851. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  55852. /**
  55853. * An event triggered after the mesh has been rendered into the effect render target.
  55854. */
  55855. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  55856. /**
  55857. * An event triggered when the generated texture has been merged in the scene.
  55858. */
  55859. onAfterComposeObservable: Observable<EffectLayer>;
  55860. /**
  55861. * An event triggered when the efffect layer changes its size.
  55862. */
  55863. onSizeChangedObservable: Observable<EffectLayer>;
  55864. /** @hidden */
  55865. static _SceneComponentInitialization: (scene: Scene) => void;
  55866. /**
  55867. * Instantiates a new effect Layer and references it in the scene.
  55868. * @param name The name of the layer
  55869. * @param scene The scene to use the layer in
  55870. */
  55871. constructor(
  55872. /** The Friendly of the effect in the scene */
  55873. name: string, scene: Scene);
  55874. /**
  55875. * Get the effect name of the layer.
  55876. * @return The effect name
  55877. */
  55878. abstract getEffectName(): string;
  55879. /**
  55880. * Checks for the readiness of the element composing the layer.
  55881. * @param subMesh the mesh to check for
  55882. * @param useInstances specify whether or not to use instances to render the mesh
  55883. * @return true if ready otherwise, false
  55884. */
  55885. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  55886. /**
  55887. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  55888. * @returns true if the effect requires stencil during the main canvas render pass.
  55889. */
  55890. abstract needStencil(): boolean;
  55891. /**
  55892. * Create the merge effect. This is the shader use to blit the information back
  55893. * to the main canvas at the end of the scene rendering.
  55894. * @returns The effect containing the shader used to merge the effect on the main canvas
  55895. */
  55896. protected abstract _createMergeEffect(): Effect;
  55897. /**
  55898. * Creates the render target textures and post processes used in the effect layer.
  55899. */
  55900. protected abstract _createTextureAndPostProcesses(): void;
  55901. /**
  55902. * Implementation specific of rendering the generating effect on the main canvas.
  55903. * @param effect The effect used to render through
  55904. */
  55905. protected abstract _internalRender(effect: Effect): void;
  55906. /**
  55907. * Sets the required values for both the emissive texture and and the main color.
  55908. */
  55909. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  55910. /**
  55911. * Free any resources and references associated to a mesh.
  55912. * Internal use
  55913. * @param mesh The mesh to free.
  55914. */
  55915. abstract _disposeMesh(mesh: Mesh): void;
  55916. /**
  55917. * Serializes this layer (Glow or Highlight for example)
  55918. * @returns a serialized layer object
  55919. */
  55920. abstract serialize?(): any;
  55921. /**
  55922. * Initializes the effect layer with the required options.
  55923. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  55924. */
  55925. protected _init(options: Partial<IEffectLayerOptions>): void;
  55926. /**
  55927. * Generates the index buffer of the full screen quad blending to the main canvas.
  55928. */
  55929. private _generateIndexBuffer;
  55930. /**
  55931. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  55932. */
  55933. private _generateVertexBuffer;
  55934. /**
  55935. * Sets the main texture desired size which is the closest power of two
  55936. * of the engine canvas size.
  55937. */
  55938. private _setMainTextureSize;
  55939. /**
  55940. * Creates the main texture for the effect layer.
  55941. */
  55942. protected _createMainTexture(): void;
  55943. /**
  55944. * Adds specific effects defines.
  55945. * @param defines The defines to add specifics to.
  55946. */
  55947. protected _addCustomEffectDefines(defines: string[]): void;
  55948. /**
  55949. * Checks for the readiness of the element composing the layer.
  55950. * @param subMesh the mesh to check for
  55951. * @param useInstances specify whether or not to use instances to render the mesh
  55952. * @param emissiveTexture the associated emissive texture used to generate the glow
  55953. * @return true if ready otherwise, false
  55954. */
  55955. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  55956. /**
  55957. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  55958. */
  55959. render(): void;
  55960. /**
  55961. * Determine if a given mesh will be used in the current effect.
  55962. * @param mesh mesh to test
  55963. * @returns true if the mesh will be used
  55964. */
  55965. hasMesh(mesh: AbstractMesh): boolean;
  55966. /**
  55967. * Returns true if the layer contains information to display, otherwise false.
  55968. * @returns true if the glow layer should be rendered
  55969. */
  55970. shouldRender(): boolean;
  55971. /**
  55972. * Returns true if the mesh should render, otherwise false.
  55973. * @param mesh The mesh to render
  55974. * @returns true if it should render otherwise false
  55975. */
  55976. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  55977. /**
  55978. * Returns true if the mesh can be rendered, otherwise false.
  55979. * @param mesh The mesh to render
  55980. * @param material The material used on the mesh
  55981. * @returns true if it can be rendered otherwise false
  55982. */
  55983. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  55984. /**
  55985. * Returns true if the mesh should render, otherwise false.
  55986. * @param mesh The mesh to render
  55987. * @returns true if it should render otherwise false
  55988. */
  55989. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  55990. /**
  55991. * Renders the submesh passed in parameter to the generation map.
  55992. */
  55993. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  55994. /**
  55995. * Defines whether the current material of the mesh should be use to render the effect.
  55996. * @param mesh defines the current mesh to render
  55997. */
  55998. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  55999. /**
  56000. * Rebuild the required buffers.
  56001. * @hidden Internal use only.
  56002. */
  56003. _rebuild(): void;
  56004. /**
  56005. * Dispose only the render target textures and post process.
  56006. */
  56007. private _disposeTextureAndPostProcesses;
  56008. /**
  56009. * Dispose the highlight layer and free resources.
  56010. */
  56011. dispose(): void;
  56012. /**
  56013. * Gets the class name of the effect layer
  56014. * @returns the string with the class name of the effect layer
  56015. */
  56016. getClassName(): string;
  56017. /**
  56018. * Creates an effect layer from parsed effect layer data
  56019. * @param parsedEffectLayer defines effect layer data
  56020. * @param scene defines the current scene
  56021. * @param rootUrl defines the root URL containing the effect layer information
  56022. * @returns a parsed effect Layer
  56023. */
  56024. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  56025. }
  56026. }
  56027. declare module "babylonjs/Layers/effectLayerSceneComponent" {
  56028. import { Scene } from "babylonjs/scene";
  56029. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  56030. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  56031. import { AbstractScene } from "babylonjs/abstractScene";
  56032. module "babylonjs/abstractScene" {
  56033. interface AbstractScene {
  56034. /**
  56035. * The list of effect layers (highlights/glow) added to the scene
  56036. * @see http://doc.babylonjs.com/how_to/highlight_layer
  56037. * @see http://doc.babylonjs.com/how_to/glow_layer
  56038. */
  56039. effectLayers: Array<EffectLayer>;
  56040. /**
  56041. * Removes the given effect layer from this scene.
  56042. * @param toRemove defines the effect layer to remove
  56043. * @returns the index of the removed effect layer
  56044. */
  56045. removeEffectLayer(toRemove: EffectLayer): number;
  56046. /**
  56047. * Adds the given effect layer to this scene
  56048. * @param newEffectLayer defines the effect layer to add
  56049. */
  56050. addEffectLayer(newEffectLayer: EffectLayer): void;
  56051. }
  56052. }
  56053. /**
  56054. * Defines the layer scene component responsible to manage any effect layers
  56055. * in a given scene.
  56056. */
  56057. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  56058. /**
  56059. * The component name helpfull to identify the component in the list of scene components.
  56060. */
  56061. readonly name: string;
  56062. /**
  56063. * The scene the component belongs to.
  56064. */
  56065. scene: Scene;
  56066. private _engine;
  56067. private _renderEffects;
  56068. private _needStencil;
  56069. private _previousStencilState;
  56070. /**
  56071. * Creates a new instance of the component for the given scene
  56072. * @param scene Defines the scene to register the component in
  56073. */
  56074. constructor(scene: Scene);
  56075. /**
  56076. * Registers the component in a given scene
  56077. */
  56078. register(): void;
  56079. /**
  56080. * Rebuilds the elements related to this component in case of
  56081. * context lost for instance.
  56082. */
  56083. rebuild(): void;
  56084. /**
  56085. * Serializes the component data to the specified json object
  56086. * @param serializationObject The object to serialize to
  56087. */
  56088. serialize(serializationObject: any): void;
  56089. /**
  56090. * Adds all the elements from the container to the scene
  56091. * @param container the container holding the elements
  56092. */
  56093. addFromContainer(container: AbstractScene): void;
  56094. /**
  56095. * Removes all the elements in the container from the scene
  56096. * @param container contains the elements to remove
  56097. * @param dispose if the removed element should be disposed (default: false)
  56098. */
  56099. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  56100. /**
  56101. * Disposes the component and the associated ressources.
  56102. */
  56103. dispose(): void;
  56104. private _isReadyForMesh;
  56105. private _renderMainTexture;
  56106. private _setStencil;
  56107. private _setStencilBack;
  56108. private _draw;
  56109. private _drawCamera;
  56110. private _drawRenderingGroup;
  56111. }
  56112. }
  56113. declare module "babylonjs/Shaders/glowMapMerge.fragment" {
  56114. /** @hidden */
  56115. export var glowMapMergePixelShader: {
  56116. name: string;
  56117. shader: string;
  56118. };
  56119. }
  56120. declare module "babylonjs/Shaders/glowMapMerge.vertex" {
  56121. /** @hidden */
  56122. export var glowMapMergeVertexShader: {
  56123. name: string;
  56124. shader: string;
  56125. };
  56126. }
  56127. declare module "babylonjs/Layers/glowLayer" {
  56128. import { Nullable } from "babylonjs/types";
  56129. import { Camera } from "babylonjs/Cameras/camera";
  56130. import { Scene } from "babylonjs/scene";
  56131. import { SubMesh } from "babylonjs/Meshes/subMesh";
  56132. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56133. import { Mesh } from "babylonjs/Meshes/mesh";
  56134. import { Texture } from "babylonjs/Materials/Textures/texture";
  56135. import { Effect } from "babylonjs/Materials/effect";
  56136. import { Material } from "babylonjs/Materials/material";
  56137. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  56138. import { Color4 } from "babylonjs/Maths/math.color";
  56139. import "babylonjs/Shaders/glowMapMerge.fragment";
  56140. import "babylonjs/Shaders/glowMapMerge.vertex";
  56141. import "babylonjs/Layers/effectLayerSceneComponent";
  56142. module "babylonjs/abstractScene" {
  56143. interface AbstractScene {
  56144. /**
  56145. * Return a the first highlight layer of the scene with a given name.
  56146. * @param name The name of the highlight layer to look for.
  56147. * @return The highlight layer if found otherwise null.
  56148. */
  56149. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  56150. }
  56151. }
  56152. /**
  56153. * Glow layer options. This helps customizing the behaviour
  56154. * of the glow layer.
  56155. */
  56156. export interface IGlowLayerOptions {
  56157. /**
  56158. * Multiplication factor apply to the canvas size to compute the render target size
  56159. * used to generated the glowing objects (the smaller the faster).
  56160. */
  56161. mainTextureRatio: number;
  56162. /**
  56163. * Enforces a fixed size texture to ensure resize independant blur.
  56164. */
  56165. mainTextureFixedSize?: number;
  56166. /**
  56167. * How big is the kernel of the blur texture.
  56168. */
  56169. blurKernelSize: number;
  56170. /**
  56171. * The camera attached to the layer.
  56172. */
  56173. camera: Nullable<Camera>;
  56174. /**
  56175. * Enable MSAA by chosing the number of samples.
  56176. */
  56177. mainTextureSamples?: number;
  56178. /**
  56179. * The rendering group to draw the layer in.
  56180. */
  56181. renderingGroupId: number;
  56182. }
  56183. /**
  56184. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  56185. *
  56186. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  56187. *
  56188. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  56189. */
  56190. export class GlowLayer extends EffectLayer {
  56191. /**
  56192. * Effect Name of the layer.
  56193. */
  56194. static readonly EffectName: string;
  56195. /**
  56196. * The default blur kernel size used for the glow.
  56197. */
  56198. static DefaultBlurKernelSize: number;
  56199. /**
  56200. * The default texture size ratio used for the glow.
  56201. */
  56202. static DefaultTextureRatio: number;
  56203. /**
  56204. * Sets the kernel size of the blur.
  56205. */
  56206. set blurKernelSize(value: number);
  56207. /**
  56208. * Gets the kernel size of the blur.
  56209. */
  56210. get blurKernelSize(): number;
  56211. /**
  56212. * Sets the glow intensity.
  56213. */
  56214. set intensity(value: number);
  56215. /**
  56216. * Gets the glow intensity.
  56217. */
  56218. get intensity(): number;
  56219. private _options;
  56220. private _intensity;
  56221. private _horizontalBlurPostprocess1;
  56222. private _verticalBlurPostprocess1;
  56223. private _horizontalBlurPostprocess2;
  56224. private _verticalBlurPostprocess2;
  56225. private _blurTexture1;
  56226. private _blurTexture2;
  56227. private _postProcesses1;
  56228. private _postProcesses2;
  56229. private _includedOnlyMeshes;
  56230. private _excludedMeshes;
  56231. private _meshesUsingTheirOwnMaterials;
  56232. /**
  56233. * Callback used to let the user override the color selection on a per mesh basis
  56234. */
  56235. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  56236. /**
  56237. * Callback used to let the user override the texture selection on a per mesh basis
  56238. */
  56239. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  56240. /**
  56241. * Instantiates a new glow Layer and references it to the scene.
  56242. * @param name The name of the layer
  56243. * @param scene The scene to use the layer in
  56244. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  56245. */
  56246. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  56247. /**
  56248. * Get the effect name of the layer.
  56249. * @return The effect name
  56250. */
  56251. getEffectName(): string;
  56252. /**
  56253. * Create the merge effect. This is the shader use to blit the information back
  56254. * to the main canvas at the end of the scene rendering.
  56255. */
  56256. protected _createMergeEffect(): Effect;
  56257. /**
  56258. * Creates the render target textures and post processes used in the glow layer.
  56259. */
  56260. protected _createTextureAndPostProcesses(): void;
  56261. /**
  56262. * Checks for the readiness of the element composing the layer.
  56263. * @param subMesh the mesh to check for
  56264. * @param useInstances specify wether or not to use instances to render the mesh
  56265. * @param emissiveTexture the associated emissive texture used to generate the glow
  56266. * @return true if ready otherwise, false
  56267. */
  56268. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  56269. /**
  56270. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  56271. */
  56272. needStencil(): boolean;
  56273. /**
  56274. * Returns true if the mesh can be rendered, otherwise false.
  56275. * @param mesh The mesh to render
  56276. * @param material The material used on the mesh
  56277. * @returns true if it can be rendered otherwise false
  56278. */
  56279. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  56280. /**
  56281. * Implementation specific of rendering the generating effect on the main canvas.
  56282. * @param effect The effect used to render through
  56283. */
  56284. protected _internalRender(effect: Effect): void;
  56285. /**
  56286. * Sets the required values for both the emissive texture and and the main color.
  56287. */
  56288. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  56289. /**
  56290. * Returns true if the mesh should render, otherwise false.
  56291. * @param mesh The mesh to render
  56292. * @returns true if it should render otherwise false
  56293. */
  56294. protected _shouldRenderMesh(mesh: Mesh): boolean;
  56295. /**
  56296. * Adds specific effects defines.
  56297. * @param defines The defines to add specifics to.
  56298. */
  56299. protected _addCustomEffectDefines(defines: string[]): void;
  56300. /**
  56301. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  56302. * @param mesh The mesh to exclude from the glow layer
  56303. */
  56304. addExcludedMesh(mesh: Mesh): void;
  56305. /**
  56306. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  56307. * @param mesh The mesh to remove
  56308. */
  56309. removeExcludedMesh(mesh: Mesh): void;
  56310. /**
  56311. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  56312. * @param mesh The mesh to include in the glow layer
  56313. */
  56314. addIncludedOnlyMesh(mesh: Mesh): void;
  56315. /**
  56316. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  56317. * @param mesh The mesh to remove
  56318. */
  56319. removeIncludedOnlyMesh(mesh: Mesh): void;
  56320. /**
  56321. * Determine if a given mesh will be used in the glow layer
  56322. * @param mesh The mesh to test
  56323. * @returns true if the mesh will be highlighted by the current glow layer
  56324. */
  56325. hasMesh(mesh: AbstractMesh): boolean;
  56326. /**
  56327. * Defines whether the current material of the mesh should be use to render the effect.
  56328. * @param mesh defines the current mesh to render
  56329. */
  56330. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  56331. /**
  56332. * Add a mesh to be rendered through its own material and not with emissive only.
  56333. * @param mesh The mesh for which we need to use its material
  56334. */
  56335. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  56336. /**
  56337. * Remove a mesh from being rendered through its own material and not with emissive only.
  56338. * @param mesh The mesh for which we need to not use its material
  56339. */
  56340. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  56341. /**
  56342. * Free any resources and references associated to a mesh.
  56343. * Internal use
  56344. * @param mesh The mesh to free.
  56345. * @hidden
  56346. */
  56347. _disposeMesh(mesh: Mesh): void;
  56348. /**
  56349. * Gets the class name of the effect layer
  56350. * @returns the string with the class name of the effect layer
  56351. */
  56352. getClassName(): string;
  56353. /**
  56354. * Serializes this glow layer
  56355. * @returns a serialized glow layer object
  56356. */
  56357. serialize(): any;
  56358. /**
  56359. * Creates a Glow Layer from parsed glow layer data
  56360. * @param parsedGlowLayer defines glow layer data
  56361. * @param scene defines the current scene
  56362. * @param rootUrl defines the root URL containing the glow layer information
  56363. * @returns a parsed Glow Layer
  56364. */
  56365. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  56366. }
  56367. }
  56368. declare module "babylonjs/Shaders/glowBlurPostProcess.fragment" {
  56369. /** @hidden */
  56370. export var glowBlurPostProcessPixelShader: {
  56371. name: string;
  56372. shader: string;
  56373. };
  56374. }
  56375. declare module "babylonjs/Layers/highlightLayer" {
  56376. import { Observable } from "babylonjs/Misc/observable";
  56377. import { Nullable } from "babylonjs/types";
  56378. import { Camera } from "babylonjs/Cameras/camera";
  56379. import { Scene } from "babylonjs/scene";
  56380. import { SubMesh } from "babylonjs/Meshes/subMesh";
  56381. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56382. import { Mesh } from "babylonjs/Meshes/mesh";
  56383. import { Effect } from "babylonjs/Materials/effect";
  56384. import { Material } from "babylonjs/Materials/material";
  56385. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  56386. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  56387. import "babylonjs/Shaders/glowMapMerge.fragment";
  56388. import "babylonjs/Shaders/glowMapMerge.vertex";
  56389. import "babylonjs/Shaders/glowBlurPostProcess.fragment";
  56390. module "babylonjs/abstractScene" {
  56391. interface AbstractScene {
  56392. /**
  56393. * Return a the first highlight layer of the scene with a given name.
  56394. * @param name The name of the highlight layer to look for.
  56395. * @return The highlight layer if found otherwise null.
  56396. */
  56397. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  56398. }
  56399. }
  56400. /**
  56401. * Highlight layer options. This helps customizing the behaviour
  56402. * of the highlight layer.
  56403. */
  56404. export interface IHighlightLayerOptions {
  56405. /**
  56406. * Multiplication factor apply to the canvas size to compute the render target size
  56407. * used to generated the glowing objects (the smaller the faster).
  56408. */
  56409. mainTextureRatio: number;
  56410. /**
  56411. * Enforces a fixed size texture to ensure resize independant blur.
  56412. */
  56413. mainTextureFixedSize?: number;
  56414. /**
  56415. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  56416. * of the picture to blur (the smaller the faster).
  56417. */
  56418. blurTextureSizeRatio: number;
  56419. /**
  56420. * How big in texel of the blur texture is the vertical blur.
  56421. */
  56422. blurVerticalSize: number;
  56423. /**
  56424. * How big in texel of the blur texture is the horizontal blur.
  56425. */
  56426. blurHorizontalSize: number;
  56427. /**
  56428. * Alpha blending mode used to apply the blur. Default is combine.
  56429. */
  56430. alphaBlendingMode: number;
  56431. /**
  56432. * The camera attached to the layer.
  56433. */
  56434. camera: Nullable<Camera>;
  56435. /**
  56436. * Should we display highlight as a solid stroke?
  56437. */
  56438. isStroke?: boolean;
  56439. /**
  56440. * The rendering group to draw the layer in.
  56441. */
  56442. renderingGroupId: number;
  56443. }
  56444. /**
  56445. * The highlight layer Helps adding a glow effect around a mesh.
  56446. *
  56447. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  56448. * glowy meshes to your scene.
  56449. *
  56450. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  56451. */
  56452. export class HighlightLayer extends EffectLayer {
  56453. name: string;
  56454. /**
  56455. * Effect Name of the highlight layer.
  56456. */
  56457. static readonly EffectName: string;
  56458. /**
  56459. * The neutral color used during the preparation of the glow effect.
  56460. * This is black by default as the blend operation is a blend operation.
  56461. */
  56462. static NeutralColor: Color4;
  56463. /**
  56464. * Stencil value used for glowing meshes.
  56465. */
  56466. static GlowingMeshStencilReference: number;
  56467. /**
  56468. * Stencil value used for the other meshes in the scene.
  56469. */
  56470. static NormalMeshStencilReference: number;
  56471. /**
  56472. * Specifies whether or not the inner glow is ACTIVE in the layer.
  56473. */
  56474. innerGlow: boolean;
  56475. /**
  56476. * Specifies whether or not the outer glow is ACTIVE in the layer.
  56477. */
  56478. outerGlow: boolean;
  56479. /**
  56480. * Specifies the horizontal size of the blur.
  56481. */
  56482. set blurHorizontalSize(value: number);
  56483. /**
  56484. * Specifies the vertical size of the blur.
  56485. */
  56486. set blurVerticalSize(value: number);
  56487. /**
  56488. * Gets the horizontal size of the blur.
  56489. */
  56490. get blurHorizontalSize(): number;
  56491. /**
  56492. * Gets the vertical size of the blur.
  56493. */
  56494. get blurVerticalSize(): number;
  56495. /**
  56496. * An event triggered when the highlight layer is being blurred.
  56497. */
  56498. onBeforeBlurObservable: Observable<HighlightLayer>;
  56499. /**
  56500. * An event triggered when the highlight layer has been blurred.
  56501. */
  56502. onAfterBlurObservable: Observable<HighlightLayer>;
  56503. private _instanceGlowingMeshStencilReference;
  56504. private _options;
  56505. private _downSamplePostprocess;
  56506. private _horizontalBlurPostprocess;
  56507. private _verticalBlurPostprocess;
  56508. private _blurTexture;
  56509. private _meshes;
  56510. private _excludedMeshes;
  56511. /**
  56512. * Instantiates a new highlight Layer and references it to the scene..
  56513. * @param name The name of the layer
  56514. * @param scene The scene to use the layer in
  56515. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  56516. */
  56517. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  56518. /**
  56519. * Get the effect name of the layer.
  56520. * @return The effect name
  56521. */
  56522. getEffectName(): string;
  56523. /**
  56524. * Create the merge effect. This is the shader use to blit the information back
  56525. * to the main canvas at the end of the scene rendering.
  56526. */
  56527. protected _createMergeEffect(): Effect;
  56528. /**
  56529. * Creates the render target textures and post processes used in the highlight layer.
  56530. */
  56531. protected _createTextureAndPostProcesses(): void;
  56532. /**
  56533. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  56534. */
  56535. needStencil(): boolean;
  56536. /**
  56537. * Checks for the readiness of the element composing the layer.
  56538. * @param subMesh the mesh to check for
  56539. * @param useInstances specify wether or not to use instances to render the mesh
  56540. * @param emissiveTexture the associated emissive texture used to generate the glow
  56541. * @return true if ready otherwise, false
  56542. */
  56543. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  56544. /**
  56545. * Implementation specific of rendering the generating effect on the main canvas.
  56546. * @param effect The effect used to render through
  56547. */
  56548. protected _internalRender(effect: Effect): void;
  56549. /**
  56550. * Returns true if the layer contains information to display, otherwise false.
  56551. */
  56552. shouldRender(): boolean;
  56553. /**
  56554. * Returns true if the mesh should render, otherwise false.
  56555. * @param mesh The mesh to render
  56556. * @returns true if it should render otherwise false
  56557. */
  56558. protected _shouldRenderMesh(mesh: Mesh): boolean;
  56559. /**
  56560. * Adds specific effects defines.
  56561. * @param defines The defines to add specifics to.
  56562. */
  56563. protected _addCustomEffectDefines(defines: string[]): void;
  56564. /**
  56565. * Sets the required values for both the emissive texture and and the main color.
  56566. */
  56567. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  56568. /**
  56569. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  56570. * @param mesh The mesh to exclude from the highlight layer
  56571. */
  56572. addExcludedMesh(mesh: Mesh): void;
  56573. /**
  56574. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  56575. * @param mesh The mesh to highlight
  56576. */
  56577. removeExcludedMesh(mesh: Mesh): void;
  56578. /**
  56579. * Determine if a given mesh will be highlighted by the current HighlightLayer
  56580. * @param mesh mesh to test
  56581. * @returns true if the mesh will be highlighted by the current HighlightLayer
  56582. */
  56583. hasMesh(mesh: AbstractMesh): boolean;
  56584. /**
  56585. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  56586. * @param mesh The mesh to highlight
  56587. * @param color The color of the highlight
  56588. * @param glowEmissiveOnly Extract the glow from the emissive texture
  56589. */
  56590. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  56591. /**
  56592. * Remove a mesh from the highlight layer in order to make it stop glowing.
  56593. * @param mesh The mesh to highlight
  56594. */
  56595. removeMesh(mesh: Mesh): void;
  56596. /**
  56597. * Remove all the meshes currently referenced in the highlight layer
  56598. */
  56599. removeAllMeshes(): void;
  56600. /**
  56601. * Force the stencil to the normal expected value for none glowing parts
  56602. */
  56603. private _defaultStencilReference;
  56604. /**
  56605. * Free any resources and references associated to a mesh.
  56606. * Internal use
  56607. * @param mesh The mesh to free.
  56608. * @hidden
  56609. */
  56610. _disposeMesh(mesh: Mesh): void;
  56611. /**
  56612. * Dispose the highlight layer and free resources.
  56613. */
  56614. dispose(): void;
  56615. /**
  56616. * Gets the class name of the effect layer
  56617. * @returns the string with the class name of the effect layer
  56618. */
  56619. getClassName(): string;
  56620. /**
  56621. * Serializes this Highlight layer
  56622. * @returns a serialized Highlight layer object
  56623. */
  56624. serialize(): any;
  56625. /**
  56626. * Creates a Highlight layer from parsed Highlight layer data
  56627. * @param parsedHightlightLayer defines the Highlight layer data
  56628. * @param scene defines the current scene
  56629. * @param rootUrl defines the root URL containing the Highlight layer information
  56630. * @returns a parsed Highlight layer
  56631. */
  56632. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  56633. }
  56634. }
  56635. declare module "babylonjs/Layers/layerSceneComponent" {
  56636. import { Scene } from "babylonjs/scene";
  56637. import { ISceneComponent } from "babylonjs/sceneComponent";
  56638. import { Layer } from "babylonjs/Layers/layer";
  56639. import { AbstractScene } from "babylonjs/abstractScene";
  56640. module "babylonjs/abstractScene" {
  56641. interface AbstractScene {
  56642. /**
  56643. * The list of layers (background and foreground) of the scene
  56644. */
  56645. layers: Array<Layer>;
  56646. }
  56647. }
  56648. /**
  56649. * Defines the layer scene component responsible to manage any layers
  56650. * in a given scene.
  56651. */
  56652. export class LayerSceneComponent implements ISceneComponent {
  56653. /**
  56654. * The component name helpfull to identify the component in the list of scene components.
  56655. */
  56656. readonly name: string;
  56657. /**
  56658. * The scene the component belongs to.
  56659. */
  56660. scene: Scene;
  56661. private _engine;
  56662. /**
  56663. * Creates a new instance of the component for the given scene
  56664. * @param scene Defines the scene to register the component in
  56665. */
  56666. constructor(scene: Scene);
  56667. /**
  56668. * Registers the component in a given scene
  56669. */
  56670. register(): void;
  56671. /**
  56672. * Rebuilds the elements related to this component in case of
  56673. * context lost for instance.
  56674. */
  56675. rebuild(): void;
  56676. /**
  56677. * Disposes the component and the associated ressources.
  56678. */
  56679. dispose(): void;
  56680. private _draw;
  56681. private _drawCameraPredicate;
  56682. private _drawCameraBackground;
  56683. private _drawCameraForeground;
  56684. private _drawRenderTargetPredicate;
  56685. private _drawRenderTargetBackground;
  56686. private _drawRenderTargetForeground;
  56687. /**
  56688. * Adds all the elements from the container to the scene
  56689. * @param container the container holding the elements
  56690. */
  56691. addFromContainer(container: AbstractScene): void;
  56692. /**
  56693. * Removes all the elements in the container from the scene
  56694. * @param container contains the elements to remove
  56695. * @param dispose if the removed element should be disposed (default: false)
  56696. */
  56697. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  56698. }
  56699. }
  56700. declare module "babylonjs/Shaders/layer.fragment" {
  56701. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  56702. /** @hidden */
  56703. export var layerPixelShader: {
  56704. name: string;
  56705. shader: string;
  56706. };
  56707. }
  56708. declare module "babylonjs/Shaders/layer.vertex" {
  56709. /** @hidden */
  56710. export var layerVertexShader: {
  56711. name: string;
  56712. shader: string;
  56713. };
  56714. }
  56715. declare module "babylonjs/Layers/layer" {
  56716. import { Observable } from "babylonjs/Misc/observable";
  56717. import { Nullable } from "babylonjs/types";
  56718. import { Scene } from "babylonjs/scene";
  56719. import { Vector2 } from "babylonjs/Maths/math.vector";
  56720. import { Color4 } from "babylonjs/Maths/math.color";
  56721. import { Texture } from "babylonjs/Materials/Textures/texture";
  56722. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  56723. import "babylonjs/Shaders/layer.fragment";
  56724. import "babylonjs/Shaders/layer.vertex";
  56725. /**
  56726. * This represents a full screen 2d layer.
  56727. * This can be useful to display a picture in the background of your scene for instance.
  56728. * @see https://www.babylonjs-playground.com/#08A2BS#1
  56729. */
  56730. export class Layer {
  56731. /**
  56732. * Define the name of the layer.
  56733. */
  56734. name: string;
  56735. /**
  56736. * Define the texture the layer should display.
  56737. */
  56738. texture: Nullable<Texture>;
  56739. /**
  56740. * Is the layer in background or foreground.
  56741. */
  56742. isBackground: boolean;
  56743. /**
  56744. * Define the color of the layer (instead of texture).
  56745. */
  56746. color: Color4;
  56747. /**
  56748. * Define the scale of the layer in order to zoom in out of the texture.
  56749. */
  56750. scale: Vector2;
  56751. /**
  56752. * Define an offset for the layer in order to shift the texture.
  56753. */
  56754. offset: Vector2;
  56755. /**
  56756. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  56757. */
  56758. alphaBlendingMode: number;
  56759. /**
  56760. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  56761. * Alpha test will not mix with the background color in case of transparency.
  56762. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  56763. */
  56764. alphaTest: boolean;
  56765. /**
  56766. * Define a mask to restrict the layer to only some of the scene cameras.
  56767. */
  56768. layerMask: number;
  56769. /**
  56770. * Define the list of render target the layer is visible into.
  56771. */
  56772. renderTargetTextures: RenderTargetTexture[];
  56773. /**
  56774. * Define if the layer is only used in renderTarget or if it also
  56775. * renders in the main frame buffer of the canvas.
  56776. */
  56777. renderOnlyInRenderTargetTextures: boolean;
  56778. private _scene;
  56779. private _vertexBuffers;
  56780. private _indexBuffer;
  56781. private _effect;
  56782. private _previousDefines;
  56783. /**
  56784. * An event triggered when the layer is disposed.
  56785. */
  56786. onDisposeObservable: Observable<Layer>;
  56787. private _onDisposeObserver;
  56788. /**
  56789. * Back compatibility with callback before the onDisposeObservable existed.
  56790. * The set callback will be triggered when the layer has been disposed.
  56791. */
  56792. set onDispose(callback: () => void);
  56793. /**
  56794. * An event triggered before rendering the scene
  56795. */
  56796. onBeforeRenderObservable: Observable<Layer>;
  56797. private _onBeforeRenderObserver;
  56798. /**
  56799. * Back compatibility with callback before the onBeforeRenderObservable existed.
  56800. * The set callback will be triggered just before rendering the layer.
  56801. */
  56802. set onBeforeRender(callback: () => void);
  56803. /**
  56804. * An event triggered after rendering the scene
  56805. */
  56806. onAfterRenderObservable: Observable<Layer>;
  56807. private _onAfterRenderObserver;
  56808. /**
  56809. * Back compatibility with callback before the onAfterRenderObservable existed.
  56810. * The set callback will be triggered just after rendering the layer.
  56811. */
  56812. set onAfterRender(callback: () => void);
  56813. /**
  56814. * Instantiates a new layer.
  56815. * This represents a full screen 2d layer.
  56816. * This can be useful to display a picture in the background of your scene for instance.
  56817. * @see https://www.babylonjs-playground.com/#08A2BS#1
  56818. * @param name Define the name of the layer in the scene
  56819. * @param imgUrl Define the url of the texture to display in the layer
  56820. * @param scene Define the scene the layer belongs to
  56821. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  56822. * @param color Defines a color for the layer
  56823. */
  56824. constructor(
  56825. /**
  56826. * Define the name of the layer.
  56827. */
  56828. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  56829. private _createIndexBuffer;
  56830. /** @hidden */
  56831. _rebuild(): void;
  56832. /**
  56833. * Renders the layer in the scene.
  56834. */
  56835. render(): void;
  56836. /**
  56837. * Disposes and releases the associated ressources.
  56838. */
  56839. dispose(): void;
  56840. }
  56841. }
  56842. declare module "babylonjs/Layers/index" {
  56843. export * from "babylonjs/Layers/effectLayer";
  56844. export * from "babylonjs/Layers/effectLayerSceneComponent";
  56845. export * from "babylonjs/Layers/glowLayer";
  56846. export * from "babylonjs/Layers/highlightLayer";
  56847. export * from "babylonjs/Layers/layer";
  56848. export * from "babylonjs/Layers/layerSceneComponent";
  56849. }
  56850. declare module "babylonjs/Shaders/lensFlare.fragment" {
  56851. /** @hidden */
  56852. export var lensFlarePixelShader: {
  56853. name: string;
  56854. shader: string;
  56855. };
  56856. }
  56857. declare module "babylonjs/Shaders/lensFlare.vertex" {
  56858. /** @hidden */
  56859. export var lensFlareVertexShader: {
  56860. name: string;
  56861. shader: string;
  56862. };
  56863. }
  56864. declare module "babylonjs/LensFlares/lensFlareSystem" {
  56865. import { Scene } from "babylonjs/scene";
  56866. import { Vector3 } from "babylonjs/Maths/math.vector";
  56867. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56868. import { LensFlare } from "babylonjs/LensFlares/lensFlare";
  56869. import "babylonjs/Shaders/lensFlare.fragment";
  56870. import "babylonjs/Shaders/lensFlare.vertex";
  56871. import { Viewport } from "babylonjs/Maths/math.viewport";
  56872. /**
  56873. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  56874. * It is usually composed of several `lensFlare`.
  56875. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  56876. */
  56877. export class LensFlareSystem {
  56878. /**
  56879. * Define the name of the lens flare system
  56880. */
  56881. name: string;
  56882. /**
  56883. * List of lens flares used in this system.
  56884. */
  56885. lensFlares: LensFlare[];
  56886. /**
  56887. * Define a limit from the border the lens flare can be visible.
  56888. */
  56889. borderLimit: number;
  56890. /**
  56891. * Define a viewport border we do not want to see the lens flare in.
  56892. */
  56893. viewportBorder: number;
  56894. /**
  56895. * Define a predicate which could limit the list of meshes able to occlude the effect.
  56896. */
  56897. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  56898. /**
  56899. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  56900. */
  56901. layerMask: number;
  56902. /**
  56903. * Define the id of the lens flare system in the scene.
  56904. * (equal to name by default)
  56905. */
  56906. id: string;
  56907. private _scene;
  56908. private _emitter;
  56909. private _vertexBuffers;
  56910. private _indexBuffer;
  56911. private _effect;
  56912. private _positionX;
  56913. private _positionY;
  56914. private _isEnabled;
  56915. /** @hidden */
  56916. static _SceneComponentInitialization: (scene: Scene) => void;
  56917. /**
  56918. * Instantiates a lens flare system.
  56919. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  56920. * It is usually composed of several `lensFlare`.
  56921. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  56922. * @param name Define the name of the lens flare system in the scene
  56923. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  56924. * @param scene Define the scene the lens flare system belongs to
  56925. */
  56926. constructor(
  56927. /**
  56928. * Define the name of the lens flare system
  56929. */
  56930. name: string, emitter: any, scene: Scene);
  56931. /**
  56932. * Define if the lens flare system is enabled.
  56933. */
  56934. get isEnabled(): boolean;
  56935. set isEnabled(value: boolean);
  56936. /**
  56937. * Get the scene the effects belongs to.
  56938. * @returns the scene holding the lens flare system
  56939. */
  56940. getScene(): Scene;
  56941. /**
  56942. * Get the emitter of the lens flare system.
  56943. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  56944. * @returns the emitter of the lens flare system
  56945. */
  56946. getEmitter(): any;
  56947. /**
  56948. * Set the emitter of the lens flare system.
  56949. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  56950. * @param newEmitter Define the new emitter of the system
  56951. */
  56952. setEmitter(newEmitter: any): void;
  56953. /**
  56954. * Get the lens flare system emitter position.
  56955. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  56956. * @returns the position
  56957. */
  56958. getEmitterPosition(): Vector3;
  56959. /**
  56960. * @hidden
  56961. */
  56962. computeEffectivePosition(globalViewport: Viewport): boolean;
  56963. /** @hidden */
  56964. _isVisible(): boolean;
  56965. /**
  56966. * @hidden
  56967. */
  56968. render(): boolean;
  56969. /**
  56970. * Dispose and release the lens flare with its associated resources.
  56971. */
  56972. dispose(): void;
  56973. /**
  56974. * Parse a lens flare system from a JSON repressentation
  56975. * @param parsedLensFlareSystem Define the JSON to parse
  56976. * @param scene Define the scene the parsed system should be instantiated in
  56977. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  56978. * @returns the parsed system
  56979. */
  56980. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  56981. /**
  56982. * Serialize the current Lens Flare System into a JSON representation.
  56983. * @returns the serialized JSON
  56984. */
  56985. serialize(): any;
  56986. }
  56987. }
  56988. declare module "babylonjs/LensFlares/lensFlare" {
  56989. import { Nullable } from "babylonjs/types";
  56990. import { Color3 } from "babylonjs/Maths/math.color";
  56991. import { Texture } from "babylonjs/Materials/Textures/texture";
  56992. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  56993. /**
  56994. * This represents one of the lens effect in a `lensFlareSystem`.
  56995. * It controls one of the indiviual texture used in the effect.
  56996. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  56997. */
  56998. export class LensFlare {
  56999. /**
  57000. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  57001. */
  57002. size: number;
  57003. /**
  57004. * 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.
  57005. */
  57006. position: number;
  57007. /**
  57008. * Define the lens color.
  57009. */
  57010. color: Color3;
  57011. /**
  57012. * Define the lens texture.
  57013. */
  57014. texture: Nullable<Texture>;
  57015. /**
  57016. * Define the alpha mode to render this particular lens.
  57017. */
  57018. alphaMode: number;
  57019. private _system;
  57020. /**
  57021. * Creates a new Lens Flare.
  57022. * This represents one of the lens effect in a `lensFlareSystem`.
  57023. * It controls one of the indiviual texture used in the effect.
  57024. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  57025. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  57026. * @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.
  57027. * @param color Define the lens color
  57028. * @param imgUrl Define the lens texture url
  57029. * @param system Define the `lensFlareSystem` this flare is part of
  57030. * @returns The newly created Lens Flare
  57031. */
  57032. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  57033. /**
  57034. * Instantiates a new Lens Flare.
  57035. * This represents one of the lens effect in a `lensFlareSystem`.
  57036. * It controls one of the indiviual texture used in the effect.
  57037. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  57038. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  57039. * @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.
  57040. * @param color Define the lens color
  57041. * @param imgUrl Define the lens texture url
  57042. * @param system Define the `lensFlareSystem` this flare is part of
  57043. */
  57044. constructor(
  57045. /**
  57046. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  57047. */
  57048. size: number,
  57049. /**
  57050. * 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.
  57051. */
  57052. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  57053. /**
  57054. * Dispose and release the lens flare with its associated resources.
  57055. */
  57056. dispose(): void;
  57057. }
  57058. }
  57059. declare module "babylonjs/LensFlares/lensFlareSystemSceneComponent" {
  57060. import { Nullable } from "babylonjs/types";
  57061. import { Scene } from "babylonjs/scene";
  57062. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  57063. import { AbstractScene } from "babylonjs/abstractScene";
  57064. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  57065. module "babylonjs/abstractScene" {
  57066. interface AbstractScene {
  57067. /**
  57068. * The list of lens flare system added to the scene
  57069. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  57070. */
  57071. lensFlareSystems: Array<LensFlareSystem>;
  57072. /**
  57073. * Removes the given lens flare system from this scene.
  57074. * @param toRemove The lens flare system to remove
  57075. * @returns The index of the removed lens flare system
  57076. */
  57077. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  57078. /**
  57079. * Adds the given lens flare system to this scene
  57080. * @param newLensFlareSystem The lens flare system to add
  57081. */
  57082. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  57083. /**
  57084. * Gets a lens flare system using its name
  57085. * @param name defines the name to look for
  57086. * @returns the lens flare system or null if not found
  57087. */
  57088. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  57089. /**
  57090. * Gets a lens flare system using its id
  57091. * @param id defines the id to look for
  57092. * @returns the lens flare system or null if not found
  57093. */
  57094. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  57095. }
  57096. }
  57097. /**
  57098. * Defines the lens flare scene component responsible to manage any lens flares
  57099. * in a given scene.
  57100. */
  57101. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  57102. /**
  57103. * The component name helpfull to identify the component in the list of scene components.
  57104. */
  57105. readonly name: string;
  57106. /**
  57107. * The scene the component belongs to.
  57108. */
  57109. scene: Scene;
  57110. /**
  57111. * Creates a new instance of the component for the given scene
  57112. * @param scene Defines the scene to register the component in
  57113. */
  57114. constructor(scene: Scene);
  57115. /**
  57116. * Registers the component in a given scene
  57117. */
  57118. register(): void;
  57119. /**
  57120. * Rebuilds the elements related to this component in case of
  57121. * context lost for instance.
  57122. */
  57123. rebuild(): void;
  57124. /**
  57125. * Adds all the elements from the container to the scene
  57126. * @param container the container holding the elements
  57127. */
  57128. addFromContainer(container: AbstractScene): void;
  57129. /**
  57130. * Removes all the elements in the container from the scene
  57131. * @param container contains the elements to remove
  57132. * @param dispose if the removed element should be disposed (default: false)
  57133. */
  57134. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  57135. /**
  57136. * Serializes the component data to the specified json object
  57137. * @param serializationObject The object to serialize to
  57138. */
  57139. serialize(serializationObject: any): void;
  57140. /**
  57141. * Disposes the component and the associated ressources.
  57142. */
  57143. dispose(): void;
  57144. private _draw;
  57145. }
  57146. }
  57147. declare module "babylonjs/LensFlares/index" {
  57148. export * from "babylonjs/LensFlares/lensFlare";
  57149. export * from "babylonjs/LensFlares/lensFlareSystem";
  57150. export * from "babylonjs/LensFlares/lensFlareSystemSceneComponent";
  57151. }
  57152. declare module "babylonjs/Shaders/depth.fragment" {
  57153. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  57154. /** @hidden */
  57155. export var depthPixelShader: {
  57156. name: string;
  57157. shader: string;
  57158. };
  57159. }
  57160. declare module "babylonjs/Shaders/depth.vertex" {
  57161. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  57162. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  57163. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  57164. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  57165. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  57166. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  57167. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  57168. /** @hidden */
  57169. export var depthVertexShader: {
  57170. name: string;
  57171. shader: string;
  57172. };
  57173. }
  57174. declare module "babylonjs/Rendering/depthRenderer" {
  57175. import { Nullable } from "babylonjs/types";
  57176. import { SubMesh } from "babylonjs/Meshes/subMesh";
  57177. import { Scene } from "babylonjs/scene";
  57178. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  57179. import { Camera } from "babylonjs/Cameras/camera";
  57180. import "babylonjs/Shaders/depth.fragment";
  57181. import "babylonjs/Shaders/depth.vertex";
  57182. /**
  57183. * This represents a depth renderer in Babylon.
  57184. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  57185. */
  57186. export class DepthRenderer {
  57187. private _scene;
  57188. private _depthMap;
  57189. private _effect;
  57190. private readonly _storeNonLinearDepth;
  57191. private readonly _clearColor;
  57192. /** Get if the depth renderer is using packed depth or not */
  57193. readonly isPacked: boolean;
  57194. private _cachedDefines;
  57195. private _camera;
  57196. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  57197. enabled: boolean;
  57198. /**
  57199. * Specifiess that the depth renderer will only be used within
  57200. * the camera it is created for.
  57201. * This can help forcing its rendering during the camera processing.
  57202. */
  57203. useOnlyInActiveCamera: boolean;
  57204. /** @hidden */
  57205. static _SceneComponentInitialization: (scene: Scene) => void;
  57206. /**
  57207. * Instantiates a depth renderer
  57208. * @param scene The scene the renderer belongs to
  57209. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  57210. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  57211. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  57212. */
  57213. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  57214. /**
  57215. * Creates the depth rendering effect and checks if the effect is ready.
  57216. * @param subMesh The submesh to be used to render the depth map of
  57217. * @param useInstances If multiple world instances should be used
  57218. * @returns if the depth renderer is ready to render the depth map
  57219. */
  57220. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  57221. /**
  57222. * Gets the texture which the depth map will be written to.
  57223. * @returns The depth map texture
  57224. */
  57225. getDepthMap(): RenderTargetTexture;
  57226. /**
  57227. * Disposes of the depth renderer.
  57228. */
  57229. dispose(): void;
  57230. }
  57231. }
  57232. declare module "babylonjs/Shaders/minmaxRedux.fragment" {
  57233. /** @hidden */
  57234. export var minmaxReduxPixelShader: {
  57235. name: string;
  57236. shader: string;
  57237. };
  57238. }
  57239. declare module "babylonjs/Misc/minMaxReducer" {
  57240. import { Nullable } from "babylonjs/types";
  57241. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  57242. import { Camera } from "babylonjs/Cameras/camera";
  57243. import { Observer } from "babylonjs/Misc/observable";
  57244. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  57245. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  57246. import { Observable } from "babylonjs/Misc/observable";
  57247. import "babylonjs/Shaders/minmaxRedux.fragment";
  57248. /**
  57249. * This class computes a min/max reduction from a texture: it means it computes the minimum
  57250. * and maximum values from all values of the texture.
  57251. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  57252. * The source values are read from the red channel of the texture.
  57253. */
  57254. export class MinMaxReducer {
  57255. /**
  57256. * Observable triggered when the computation has been performed
  57257. */
  57258. onAfterReductionPerformed: Observable<{
  57259. min: number;
  57260. max: number;
  57261. }>;
  57262. protected _camera: Camera;
  57263. protected _sourceTexture: Nullable<RenderTargetTexture>;
  57264. protected _reductionSteps: Nullable<Array<PostProcess>>;
  57265. protected _postProcessManager: PostProcessManager;
  57266. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  57267. protected _forceFullscreenViewport: boolean;
  57268. /**
  57269. * Creates a min/max reducer
  57270. * @param camera The camera to use for the post processes
  57271. */
  57272. constructor(camera: Camera);
  57273. /**
  57274. * Gets the texture used to read the values from.
  57275. */
  57276. get sourceTexture(): Nullable<RenderTargetTexture>;
  57277. /**
  57278. * Sets the source texture to read the values from.
  57279. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  57280. * because in such textures '1' value must not be taken into account to compute the maximum
  57281. * as this value is used to clear the texture.
  57282. * Note that the computation is not activated by calling this function, you must call activate() for that!
  57283. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  57284. * @param depthRedux Indicates if the texture is a depth texture or not
  57285. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  57286. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  57287. */
  57288. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  57289. /**
  57290. * Defines the refresh rate of the computation.
  57291. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  57292. */
  57293. get refreshRate(): number;
  57294. set refreshRate(value: number);
  57295. protected _activated: boolean;
  57296. /**
  57297. * Gets the activation status of the reducer
  57298. */
  57299. get activated(): boolean;
  57300. /**
  57301. * Activates the reduction computation.
  57302. * When activated, the observers registered in onAfterReductionPerformed are
  57303. * called after the compuation is performed
  57304. */
  57305. activate(): void;
  57306. /**
  57307. * Deactivates the reduction computation.
  57308. */
  57309. deactivate(): void;
  57310. /**
  57311. * Disposes the min/max reducer
  57312. * @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.
  57313. */
  57314. dispose(disposeAll?: boolean): void;
  57315. }
  57316. }
  57317. declare module "babylonjs/Misc/depthReducer" {
  57318. import { Nullable } from "babylonjs/types";
  57319. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  57320. import { Camera } from "babylonjs/Cameras/camera";
  57321. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  57322. import { MinMaxReducer } from "babylonjs/Misc/minMaxReducer";
  57323. /**
  57324. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  57325. */
  57326. export class DepthReducer extends MinMaxReducer {
  57327. private _depthRenderer;
  57328. private _depthRendererId;
  57329. /**
  57330. * Gets the depth renderer used for the computation.
  57331. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  57332. */
  57333. get depthRenderer(): Nullable<DepthRenderer>;
  57334. /**
  57335. * Creates a depth reducer
  57336. * @param camera The camera used to render the depth texture
  57337. */
  57338. constructor(camera: Camera);
  57339. /**
  57340. * Sets the depth renderer to use to generate the depth map
  57341. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  57342. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  57343. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  57344. */
  57345. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  57346. /** @hidden */
  57347. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  57348. /**
  57349. * Activates the reduction computation.
  57350. * When activated, the observers registered in onAfterReductionPerformed are
  57351. * called after the compuation is performed
  57352. */
  57353. activate(): void;
  57354. /**
  57355. * Deactivates the reduction computation.
  57356. */
  57357. deactivate(): void;
  57358. /**
  57359. * Disposes the depth reducer
  57360. * @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.
  57361. */
  57362. dispose(disposeAll?: boolean): void;
  57363. }
  57364. }
  57365. declare module "babylonjs/Lights/Shadows/cascadedShadowGenerator" {
  57366. import { Nullable } from "babylonjs/types";
  57367. import { Scene } from "babylonjs/scene";
  57368. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  57369. import { SubMesh } from "babylonjs/Meshes/subMesh";
  57370. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57371. import { Effect } from "babylonjs/Materials/effect";
  57372. import "babylonjs/Shaders/shadowMap.fragment";
  57373. import "babylonjs/Shaders/shadowMap.vertex";
  57374. import "babylonjs/Shaders/depthBoxBlur.fragment";
  57375. import { ShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  57376. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  57377. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  57378. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  57379. /**
  57380. * A CSM implementation allowing casting shadows on large scenes.
  57381. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  57382. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  57383. */
  57384. export class CascadedShadowGenerator extends ShadowGenerator {
  57385. private static readonly frustumCornersNDCSpace;
  57386. /**
  57387. * Name of the CSM class
  57388. */
  57389. static CLASSNAME: string;
  57390. /**
  57391. * Defines the default number of cascades used by the CSM.
  57392. */
  57393. static readonly DEFAULT_CASCADES_COUNT: number;
  57394. /**
  57395. * Defines the minimum number of cascades used by the CSM.
  57396. */
  57397. static readonly MIN_CASCADES_COUNT: number;
  57398. /**
  57399. * Defines the maximum number of cascades used by the CSM.
  57400. */
  57401. static readonly MAX_CASCADES_COUNT: number;
  57402. protected _validateFilter(filter: number): number;
  57403. /**
  57404. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  57405. */
  57406. penumbraDarkness: number;
  57407. private _numCascades;
  57408. /**
  57409. * Gets or set the number of cascades used by the CSM.
  57410. */
  57411. get numCascades(): number;
  57412. set numCascades(value: number);
  57413. /**
  57414. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  57415. * The trade off is that you loose some precision in the shadow rendering when enabling this setting.
  57416. */
  57417. stabilizeCascades: boolean;
  57418. private _freezeShadowCastersBoundingInfo;
  57419. private _freezeShadowCastersBoundingInfoObservable;
  57420. /**
  57421. * Enables or disables the shadow casters bounding info computation.
  57422. * If your shadow casters don't move, you can disable this feature.
  57423. * If it is enabled, the bounding box computation is done every frame.
  57424. */
  57425. get freezeShadowCastersBoundingInfo(): boolean;
  57426. set freezeShadowCastersBoundingInfo(freeze: boolean);
  57427. private _scbiMin;
  57428. private _scbiMax;
  57429. protected _computeShadowCastersBoundingInfo(): void;
  57430. protected _shadowCastersBoundingInfo: BoundingInfo;
  57431. /**
  57432. * Gets or sets the shadow casters bounding info.
  57433. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  57434. * so that the system won't overwrite the bounds you provide
  57435. */
  57436. get shadowCastersBoundingInfo(): BoundingInfo;
  57437. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  57438. protected _breaksAreDirty: boolean;
  57439. protected _minDistance: number;
  57440. protected _maxDistance: number;
  57441. /**
  57442. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  57443. *
  57444. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  57445. * If you don't know these values, simply leave them to their defaults and don't call this function.
  57446. * @param min minimal distance for the breaks (default to 0.)
  57447. * @param max maximal distance for the breaks (default to 1.)
  57448. */
  57449. setMinMaxDistance(min: number, max: number): void;
  57450. /** Gets the minimal distance used in the cascade break computation */
  57451. get minDistance(): number;
  57452. /** Gets the maximal distance used in the cascade break computation */
  57453. get maxDistance(): number;
  57454. /**
  57455. * Gets the class name of that object
  57456. * @returns "CascadedShadowGenerator"
  57457. */
  57458. getClassName(): string;
  57459. private _cascadeMinExtents;
  57460. private _cascadeMaxExtents;
  57461. /**
  57462. * Gets a cascade minimum extents
  57463. * @param cascadeIndex index of the cascade
  57464. * @returns the minimum cascade extents
  57465. */
  57466. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  57467. /**
  57468. * Gets a cascade maximum extents
  57469. * @param cascadeIndex index of the cascade
  57470. * @returns the maximum cascade extents
  57471. */
  57472. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  57473. private _cascades;
  57474. private _currentLayer;
  57475. private _viewSpaceFrustumsZ;
  57476. private _viewMatrices;
  57477. private _projectionMatrices;
  57478. private _transformMatrices;
  57479. private _transformMatricesAsArray;
  57480. private _frustumLengths;
  57481. private _lightSizeUVCorrection;
  57482. private _depthCorrection;
  57483. private _frustumCornersWorldSpace;
  57484. private _frustumCenter;
  57485. private _shadowCameraPos;
  57486. private _shadowMaxZ;
  57487. /**
  57488. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  57489. * It defaults to camera.maxZ
  57490. */
  57491. get shadowMaxZ(): number;
  57492. /**
  57493. * Sets the shadow max z distance.
  57494. */
  57495. set shadowMaxZ(value: number);
  57496. protected _debug: boolean;
  57497. /**
  57498. * Gets or sets the debug flag.
  57499. * When enabled, the cascades are materialized by different colors on the screen.
  57500. */
  57501. get debug(): boolean;
  57502. set debug(dbg: boolean);
  57503. private _depthClamp;
  57504. /**
  57505. * Gets or sets the depth clamping value.
  57506. *
  57507. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  57508. * to account for the shadow casters far away.
  57509. *
  57510. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  57511. */
  57512. get depthClamp(): boolean;
  57513. set depthClamp(value: boolean);
  57514. private _cascadeBlendPercentage;
  57515. /**
  57516. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  57517. * It defaults to 0.1 (10% blending).
  57518. */
  57519. get cascadeBlendPercentage(): number;
  57520. set cascadeBlendPercentage(value: number);
  57521. private _lambda;
  57522. /**
  57523. * Gets or set the lambda parameter.
  57524. * This parameter is used to split the camera frustum and create the cascades.
  57525. * 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.
  57526. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  57527. */
  57528. get lambda(): number;
  57529. set lambda(value: number);
  57530. /**
  57531. * Gets the view matrix corresponding to a given cascade
  57532. * @param cascadeNum cascade to retrieve the view matrix from
  57533. * @returns the cascade view matrix
  57534. */
  57535. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  57536. /**
  57537. * Gets the projection matrix corresponding to a given cascade
  57538. * @param cascadeNum cascade to retrieve the projection matrix from
  57539. * @returns the cascade projection matrix
  57540. */
  57541. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  57542. /**
  57543. * Gets the transformation matrix corresponding to a given cascade
  57544. * @param cascadeNum cascade to retrieve the transformation matrix from
  57545. * @returns the cascade transformation matrix
  57546. */
  57547. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  57548. private _depthRenderer;
  57549. /**
  57550. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  57551. *
  57552. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  57553. *
  57554. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  57555. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  57556. * @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
  57557. */
  57558. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  57559. private _depthReducer;
  57560. private _autoCalcDepthBounds;
  57561. /**
  57562. * Gets or sets the autoCalcDepthBounds property.
  57563. *
  57564. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  57565. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  57566. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  57567. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  57568. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  57569. */
  57570. get autoCalcDepthBounds(): boolean;
  57571. set autoCalcDepthBounds(value: boolean);
  57572. /**
  57573. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  57574. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  57575. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  57576. * for setting the refresh rate on the renderer yourself!
  57577. */
  57578. get autoCalcDepthBoundsRefreshRate(): number;
  57579. set autoCalcDepthBoundsRefreshRate(value: number);
  57580. /**
  57581. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  57582. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  57583. * you change the camera near/far planes!
  57584. */
  57585. splitFrustum(): void;
  57586. private _splitFrustum;
  57587. private _computeMatrices;
  57588. private _computeFrustumInWorldSpace;
  57589. private _computeCascadeFrustum;
  57590. /**
  57591. * Support test.
  57592. */
  57593. static get IsSupported(): boolean;
  57594. /** @hidden */
  57595. static _SceneComponentInitialization: (scene: Scene) => void;
  57596. /**
  57597. * Creates a Cascaded Shadow Generator object.
  57598. * A ShadowGenerator is the required tool to use the shadows.
  57599. * Each directional light casting shadows needs to use its own ShadowGenerator.
  57600. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  57601. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  57602. * @param light The directional light object generating the shadows.
  57603. * @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.
  57604. */
  57605. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  57606. protected _initializeGenerator(): void;
  57607. protected _createTargetRenderTexture(): void;
  57608. protected _initializeShadowMap(): void;
  57609. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  57610. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  57611. /**
  57612. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  57613. * @param defines Defines of the material we want to update
  57614. * @param lightIndex Index of the light in the enabled light list of the material
  57615. */
  57616. prepareDefines(defines: any, lightIndex: number): void;
  57617. /**
  57618. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  57619. * defined in the generator but impacting the effect).
  57620. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  57621. * @param effect The effect we are binfing the information for
  57622. */
  57623. bindShadowLight(lightIndex: string, effect: Effect): void;
  57624. /**
  57625. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  57626. * (eq to view projection * shadow projection matrices)
  57627. * @returns The transform matrix used to create the shadow map
  57628. */
  57629. getTransformMatrix(): Matrix;
  57630. /**
  57631. * Disposes the ShadowGenerator.
  57632. * Returns nothing.
  57633. */
  57634. dispose(): void;
  57635. /**
  57636. * Serializes the shadow generator setup to a json object.
  57637. * @returns The serialized JSON object
  57638. */
  57639. serialize(): any;
  57640. /**
  57641. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  57642. * @param parsedShadowGenerator The JSON object to parse
  57643. * @param scene The scene to create the shadow map for
  57644. * @returns The parsed shadow generator
  57645. */
  57646. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  57647. }
  57648. }
  57649. declare module "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent" {
  57650. import { Scene } from "babylonjs/scene";
  57651. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  57652. import { AbstractScene } from "babylonjs/abstractScene";
  57653. /**
  57654. * Defines the shadow generator component responsible to manage any shadow generators
  57655. * in a given scene.
  57656. */
  57657. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  57658. /**
  57659. * The component name helpfull to identify the component in the list of scene components.
  57660. */
  57661. readonly name: string;
  57662. /**
  57663. * The scene the component belongs to.
  57664. */
  57665. scene: Scene;
  57666. /**
  57667. * Creates a new instance of the component for the given scene
  57668. * @param scene Defines the scene to register the component in
  57669. */
  57670. constructor(scene: Scene);
  57671. /**
  57672. * Registers the component in a given scene
  57673. */
  57674. register(): void;
  57675. /**
  57676. * Rebuilds the elements related to this component in case of
  57677. * context lost for instance.
  57678. */
  57679. rebuild(): void;
  57680. /**
  57681. * Serializes the component data to the specified json object
  57682. * @param serializationObject The object to serialize to
  57683. */
  57684. serialize(serializationObject: any): void;
  57685. /**
  57686. * Adds all the elements from the container to the scene
  57687. * @param container the container holding the elements
  57688. */
  57689. addFromContainer(container: AbstractScene): void;
  57690. /**
  57691. * Removes all the elements in the container from the scene
  57692. * @param container contains the elements to remove
  57693. * @param dispose if the removed element should be disposed (default: false)
  57694. */
  57695. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  57696. /**
  57697. * Rebuilds the elements related to this component in case of
  57698. * context lost for instance.
  57699. */
  57700. dispose(): void;
  57701. private _gatherRenderTargets;
  57702. }
  57703. }
  57704. declare module "babylonjs/Lights/Shadows/index" {
  57705. export * from "babylonjs/Lights/Shadows/shadowGenerator";
  57706. export * from "babylonjs/Lights/Shadows/cascadedShadowGenerator";
  57707. export * from "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent";
  57708. }
  57709. declare module "babylonjs/Lights/pointLight" {
  57710. import { Scene } from "babylonjs/scene";
  57711. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  57712. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57713. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  57714. import { Effect } from "babylonjs/Materials/effect";
  57715. /**
  57716. * A point light is a light defined by an unique point in world space.
  57717. * The light is emitted in every direction from this point.
  57718. * A good example of a point light is a standard light bulb.
  57719. * Documentation: https://doc.babylonjs.com/babylon101/lights
  57720. */
  57721. export class PointLight extends ShadowLight {
  57722. private _shadowAngle;
  57723. /**
  57724. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  57725. * This specifies what angle the shadow will use to be created.
  57726. *
  57727. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  57728. */
  57729. get shadowAngle(): number;
  57730. /**
  57731. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  57732. * This specifies what angle the shadow will use to be created.
  57733. *
  57734. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  57735. */
  57736. set shadowAngle(value: number);
  57737. /**
  57738. * Gets the direction if it has been set.
  57739. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  57740. */
  57741. get direction(): Vector3;
  57742. /**
  57743. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  57744. */
  57745. set direction(value: Vector3);
  57746. /**
  57747. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  57748. * A PointLight emits the light in every direction.
  57749. * It can cast shadows.
  57750. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  57751. * ```javascript
  57752. * var pointLight = new PointLight("pl", camera.position, scene);
  57753. * ```
  57754. * Documentation : https://doc.babylonjs.com/babylon101/lights
  57755. * @param name The light friendly name
  57756. * @param position The position of the point light in the scene
  57757. * @param scene The scene the lights belongs to
  57758. */
  57759. constructor(name: string, position: Vector3, scene: Scene);
  57760. /**
  57761. * Returns the string "PointLight"
  57762. * @returns the class name
  57763. */
  57764. getClassName(): string;
  57765. /**
  57766. * Returns the integer 0.
  57767. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  57768. */
  57769. getTypeID(): number;
  57770. /**
  57771. * Specifies wether or not the shadowmap should be a cube texture.
  57772. * @returns true if the shadowmap needs to be a cube texture.
  57773. */
  57774. needCube(): boolean;
  57775. /**
  57776. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  57777. * @param faceIndex The index of the face we are computed the direction to generate shadow
  57778. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  57779. */
  57780. getShadowDirection(faceIndex?: number): Vector3;
  57781. /**
  57782. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  57783. * - fov = PI / 2
  57784. * - aspect ratio : 1.0
  57785. * - z-near and far equal to the active camera minZ and maxZ.
  57786. * Returns the PointLight.
  57787. */
  57788. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  57789. protected _buildUniformLayout(): void;
  57790. /**
  57791. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  57792. * @param effect The effect to update
  57793. * @param lightIndex The index of the light in the effect to update
  57794. * @returns The point light
  57795. */
  57796. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  57797. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  57798. /**
  57799. * Prepares the list of defines specific to the light type.
  57800. * @param defines the list of defines
  57801. * @param lightIndex defines the index of the light for the effect
  57802. */
  57803. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  57804. }
  57805. }
  57806. declare module "babylonjs/Lights/index" {
  57807. export * from "babylonjs/Lights/light";
  57808. export * from "babylonjs/Lights/shadowLight";
  57809. export * from "babylonjs/Lights/Shadows/index";
  57810. export * from "babylonjs/Lights/directionalLight";
  57811. export * from "babylonjs/Lights/hemisphericLight";
  57812. export * from "babylonjs/Lights/pointLight";
  57813. export * from "babylonjs/Lights/spotLight";
  57814. }
  57815. declare module "babylonjs/Misc/HighDynamicRange/hdr" {
  57816. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  57817. /**
  57818. * Header information of HDR texture files.
  57819. */
  57820. export interface HDRInfo {
  57821. /**
  57822. * The height of the texture in pixels.
  57823. */
  57824. height: number;
  57825. /**
  57826. * The width of the texture in pixels.
  57827. */
  57828. width: number;
  57829. /**
  57830. * The index of the beginning of the data in the binary file.
  57831. */
  57832. dataPosition: number;
  57833. }
  57834. /**
  57835. * This groups tools to convert HDR texture to native colors array.
  57836. */
  57837. export class HDRTools {
  57838. private static Ldexp;
  57839. private static Rgbe2float;
  57840. private static readStringLine;
  57841. /**
  57842. * Reads header information from an RGBE texture stored in a native array.
  57843. * More information on this format are available here:
  57844. * https://en.wikipedia.org/wiki/RGBE_image_format
  57845. *
  57846. * @param uint8array The binary file stored in native array.
  57847. * @return The header information.
  57848. */
  57849. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  57850. /**
  57851. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  57852. * This RGBE texture needs to store the information as a panorama.
  57853. *
  57854. * More information on this format are available here:
  57855. * https://en.wikipedia.org/wiki/RGBE_image_format
  57856. *
  57857. * @param buffer The binary file stored in an array buffer.
  57858. * @param size The expected size of the extracted cubemap.
  57859. * @return The Cube Map information.
  57860. */
  57861. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  57862. /**
  57863. * Returns the pixels data extracted from an RGBE texture.
  57864. * This pixels will be stored left to right up to down in the R G B order in one array.
  57865. *
  57866. * More information on this format are available here:
  57867. * https://en.wikipedia.org/wiki/RGBE_image_format
  57868. *
  57869. * @param uint8array The binary file stored in an array buffer.
  57870. * @param hdrInfo The header information of the file.
  57871. * @return The pixels data in RGB right to left up to down order.
  57872. */
  57873. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  57874. private static RGBE_ReadPixels_RLE;
  57875. }
  57876. }
  57877. declare module "babylonjs/Materials/Textures/hdrCubeTexture" {
  57878. import { Nullable } from "babylonjs/types";
  57879. import { Scene } from "babylonjs/scene";
  57880. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  57881. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  57882. import "babylonjs/Engines/Extensions/engine.rawTexture";
  57883. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  57884. /**
  57885. * This represents a texture coming from an HDR input.
  57886. *
  57887. * The only supported format is currently panorama picture stored in RGBE format.
  57888. * Example of such files can be found on HDRLib: http://hdrlib.com/
  57889. */
  57890. export class HDRCubeTexture extends BaseTexture {
  57891. private static _facesMapping;
  57892. private _generateHarmonics;
  57893. private _noMipmap;
  57894. private _textureMatrix;
  57895. private _size;
  57896. private _onLoad;
  57897. private _onError;
  57898. /**
  57899. * The texture URL.
  57900. */
  57901. url: string;
  57902. /**
  57903. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  57904. */
  57905. coordinatesMode: number;
  57906. protected _isBlocking: boolean;
  57907. /**
  57908. * Sets wether or not the texture is blocking during loading.
  57909. */
  57910. set isBlocking(value: boolean);
  57911. /**
  57912. * Gets wether or not the texture is blocking during loading.
  57913. */
  57914. get isBlocking(): boolean;
  57915. protected _rotationY: number;
  57916. /**
  57917. * Sets texture matrix rotation angle around Y axis in radians.
  57918. */
  57919. set rotationY(value: number);
  57920. /**
  57921. * Gets texture matrix rotation angle around Y axis radians.
  57922. */
  57923. get rotationY(): number;
  57924. /**
  57925. * Gets or sets the center of the bounding box associated with the cube texture
  57926. * It must define where the camera used to render the texture was set
  57927. */
  57928. boundingBoxPosition: Vector3;
  57929. private _boundingBoxSize;
  57930. /**
  57931. * Gets or sets the size of the bounding box associated with the cube texture
  57932. * When defined, the cubemap will switch to local mode
  57933. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  57934. * @example https://www.babylonjs-playground.com/#RNASML
  57935. */
  57936. set boundingBoxSize(value: Vector3);
  57937. get boundingBoxSize(): Vector3;
  57938. /**
  57939. * Instantiates an HDRTexture from the following parameters.
  57940. *
  57941. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  57942. * @param scene The scene the texture will be used in
  57943. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  57944. * @param noMipmap Forces to not generate the mipmap if true
  57945. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  57946. * @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)
  57947. * @param reserved Reserved flag for internal use.
  57948. */
  57949. 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>);
  57950. /**
  57951. * Get the current class name of the texture useful for serialization or dynamic coding.
  57952. * @returns "HDRCubeTexture"
  57953. */
  57954. getClassName(): string;
  57955. /**
  57956. * Occurs when the file is raw .hdr file.
  57957. */
  57958. private loadTexture;
  57959. clone(): HDRCubeTexture;
  57960. delayLoad(): void;
  57961. /**
  57962. * Get the texture reflection matrix used to rotate/transform the reflection.
  57963. * @returns the reflection matrix
  57964. */
  57965. getReflectionTextureMatrix(): Matrix;
  57966. /**
  57967. * Set the texture reflection matrix used to rotate/transform the reflection.
  57968. * @param value Define the reflection matrix to set
  57969. */
  57970. setReflectionTextureMatrix(value: Matrix): void;
  57971. /**
  57972. * Parses a JSON representation of an HDR Texture in order to create the texture
  57973. * @param parsedTexture Define the JSON representation
  57974. * @param scene Define the scene the texture should be created in
  57975. * @param rootUrl Define the root url in case we need to load relative dependencies
  57976. * @returns the newly created texture after parsing
  57977. */
  57978. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  57979. serialize(): any;
  57980. }
  57981. }
  57982. declare module "babylonjs/Physics/physicsEngine" {
  57983. import { Nullable } from "babylonjs/types";
  57984. import { Vector3 } from "babylonjs/Maths/math.vector";
  57985. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  57986. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  57987. import { PhysicsJoint } from "babylonjs/Physics/physicsJoint";
  57988. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  57989. /**
  57990. * Class used to control physics engine
  57991. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  57992. */
  57993. export class PhysicsEngine implements IPhysicsEngine {
  57994. private _physicsPlugin;
  57995. /**
  57996. * Global value used to control the smallest number supported by the simulation
  57997. */
  57998. static Epsilon: number;
  57999. private _impostors;
  58000. private _joints;
  58001. private _subTimeStep;
  58002. /**
  58003. * Gets the gravity vector used by the simulation
  58004. */
  58005. gravity: Vector3;
  58006. /**
  58007. * Factory used to create the default physics plugin.
  58008. * @returns The default physics plugin
  58009. */
  58010. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  58011. /**
  58012. * Creates a new Physics Engine
  58013. * @param gravity defines the gravity vector used by the simulation
  58014. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  58015. */
  58016. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  58017. /**
  58018. * Sets the gravity vector used by the simulation
  58019. * @param gravity defines the gravity vector to use
  58020. */
  58021. setGravity(gravity: Vector3): void;
  58022. /**
  58023. * Set the time step of the physics engine.
  58024. * Default is 1/60.
  58025. * To slow it down, enter 1/600 for example.
  58026. * To speed it up, 1/30
  58027. * @param newTimeStep defines the new timestep to apply to this world.
  58028. */
  58029. setTimeStep(newTimeStep?: number): void;
  58030. /**
  58031. * Get the time step of the physics engine.
  58032. * @returns the current time step
  58033. */
  58034. getTimeStep(): number;
  58035. /**
  58036. * Set the sub time step of the physics engine.
  58037. * Default is 0 meaning there is no sub steps
  58038. * To increase physics resolution precision, set a small value (like 1 ms)
  58039. * @param subTimeStep defines the new sub timestep used for physics resolution.
  58040. */
  58041. setSubTimeStep(subTimeStep?: number): void;
  58042. /**
  58043. * Get the sub time step of the physics engine.
  58044. * @returns the current sub time step
  58045. */
  58046. getSubTimeStep(): number;
  58047. /**
  58048. * Release all resources
  58049. */
  58050. dispose(): void;
  58051. /**
  58052. * Gets the name of the current physics plugin
  58053. * @returns the name of the plugin
  58054. */
  58055. getPhysicsPluginName(): string;
  58056. /**
  58057. * Adding a new impostor for the impostor tracking.
  58058. * This will be done by the impostor itself.
  58059. * @param impostor the impostor to add
  58060. */
  58061. addImpostor(impostor: PhysicsImpostor): void;
  58062. /**
  58063. * Remove an impostor from the engine.
  58064. * This impostor and its mesh will not longer be updated by the physics engine.
  58065. * @param impostor the impostor to remove
  58066. */
  58067. removeImpostor(impostor: PhysicsImpostor): void;
  58068. /**
  58069. * Add a joint to the physics engine
  58070. * @param mainImpostor defines the main impostor to which the joint is added.
  58071. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  58072. * @param joint defines the joint that will connect both impostors.
  58073. */
  58074. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  58075. /**
  58076. * Removes a joint from the simulation
  58077. * @param mainImpostor defines the impostor used with the joint
  58078. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  58079. * @param joint defines the joint to remove
  58080. */
  58081. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  58082. /**
  58083. * Called by the scene. No need to call it.
  58084. * @param delta defines the timespam between frames
  58085. */
  58086. _step(delta: number): void;
  58087. /**
  58088. * Gets the current plugin used to run the simulation
  58089. * @returns current plugin
  58090. */
  58091. getPhysicsPlugin(): IPhysicsEnginePlugin;
  58092. /**
  58093. * Gets the list of physic impostors
  58094. * @returns an array of PhysicsImpostor
  58095. */
  58096. getImpostors(): Array<PhysicsImpostor>;
  58097. /**
  58098. * Gets the impostor for a physics enabled object
  58099. * @param object defines the object impersonated by the impostor
  58100. * @returns the PhysicsImpostor or null if not found
  58101. */
  58102. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  58103. /**
  58104. * Gets the impostor for a physics body object
  58105. * @param body defines physics body used by the impostor
  58106. * @returns the PhysicsImpostor or null if not found
  58107. */
  58108. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  58109. /**
  58110. * Does a raycast in the physics world
  58111. * @param from when should the ray start?
  58112. * @param to when should the ray end?
  58113. * @returns PhysicsRaycastResult
  58114. */
  58115. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  58116. }
  58117. }
  58118. declare module "babylonjs/Physics/Plugins/cannonJSPlugin" {
  58119. import { Nullable } from "babylonjs/types";
  58120. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  58121. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  58122. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  58123. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  58124. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  58125. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  58126. /** @hidden */
  58127. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  58128. private _useDeltaForWorldStep;
  58129. world: any;
  58130. name: string;
  58131. private _physicsMaterials;
  58132. private _fixedTimeStep;
  58133. private _cannonRaycastResult;
  58134. private _raycastResult;
  58135. private _physicsBodysToRemoveAfterStep;
  58136. BJSCANNON: any;
  58137. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  58138. setGravity(gravity: Vector3): void;
  58139. setTimeStep(timeStep: number): void;
  58140. getTimeStep(): number;
  58141. executeStep(delta: number): void;
  58142. private _removeMarkedPhysicsBodiesFromWorld;
  58143. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  58144. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  58145. generatePhysicsBody(impostor: PhysicsImpostor): void;
  58146. private _processChildMeshes;
  58147. removePhysicsBody(impostor: PhysicsImpostor): void;
  58148. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  58149. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  58150. private _addMaterial;
  58151. private _checkWithEpsilon;
  58152. private _createShape;
  58153. private _createHeightmap;
  58154. private _minus90X;
  58155. private _plus90X;
  58156. private _tmpPosition;
  58157. private _tmpDeltaPosition;
  58158. private _tmpUnityRotation;
  58159. private _updatePhysicsBodyTransformation;
  58160. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  58161. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  58162. isSupported(): boolean;
  58163. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  58164. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  58165. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  58166. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  58167. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  58168. getBodyMass(impostor: PhysicsImpostor): number;
  58169. getBodyFriction(impostor: PhysicsImpostor): number;
  58170. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  58171. getBodyRestitution(impostor: PhysicsImpostor): number;
  58172. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  58173. sleepBody(impostor: PhysicsImpostor): void;
  58174. wakeUpBody(impostor: PhysicsImpostor): void;
  58175. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  58176. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  58177. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  58178. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  58179. getRadius(impostor: PhysicsImpostor): number;
  58180. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  58181. dispose(): void;
  58182. private _extendNamespace;
  58183. /**
  58184. * Does a raycast in the physics world
  58185. * @param from when should the ray start?
  58186. * @param to when should the ray end?
  58187. * @returns PhysicsRaycastResult
  58188. */
  58189. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  58190. }
  58191. }
  58192. declare module "babylonjs/Physics/Plugins/oimoJSPlugin" {
  58193. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  58194. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  58195. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  58196. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  58197. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  58198. import { Nullable } from "babylonjs/types";
  58199. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  58200. /** @hidden */
  58201. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  58202. private _useDeltaForWorldStep;
  58203. world: any;
  58204. name: string;
  58205. BJSOIMO: any;
  58206. private _raycastResult;
  58207. private _fixedTimeStep;
  58208. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, oimoInjection?: any);
  58209. setGravity(gravity: Vector3): void;
  58210. setTimeStep(timeStep: number): void;
  58211. getTimeStep(): number;
  58212. private _tmpImpostorsArray;
  58213. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  58214. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  58215. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  58216. generatePhysicsBody(impostor: PhysicsImpostor): void;
  58217. private _tmpPositionVector;
  58218. removePhysicsBody(impostor: PhysicsImpostor): void;
  58219. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  58220. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  58221. isSupported(): boolean;
  58222. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  58223. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  58224. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  58225. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  58226. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  58227. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  58228. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  58229. getBodyMass(impostor: PhysicsImpostor): number;
  58230. getBodyFriction(impostor: PhysicsImpostor): number;
  58231. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  58232. getBodyRestitution(impostor: PhysicsImpostor): number;
  58233. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  58234. sleepBody(impostor: PhysicsImpostor): void;
  58235. wakeUpBody(impostor: PhysicsImpostor): void;
  58236. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  58237. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  58238. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  58239. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  58240. getRadius(impostor: PhysicsImpostor): number;
  58241. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  58242. dispose(): void;
  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/Meshes/Builders/ribbonBuilder" {
  58253. import { Nullable } from "babylonjs/types";
  58254. import { Scene } from "babylonjs/scene";
  58255. import { Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  58256. import { Color4 } from "babylonjs/Maths/math.color";
  58257. import { Mesh } from "babylonjs/Meshes/mesh";
  58258. /**
  58259. * Class containing static functions to help procedurally build meshes
  58260. */
  58261. export class RibbonBuilder {
  58262. /**
  58263. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  58264. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  58265. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  58266. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  58267. * * 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
  58268. * * 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
  58269. * * 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
  58270. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58271. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  58272. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  58273. * * 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
  58274. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  58275. * * 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
  58276. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  58277. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58278. * @param name defines the name of the mesh
  58279. * @param options defines the options used to create the mesh
  58280. * @param scene defines the hosting scene
  58281. * @returns the ribbon mesh
  58282. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  58283. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  58284. */
  58285. static CreateRibbon(name: string, options: {
  58286. pathArray: Vector3[][];
  58287. closeArray?: boolean;
  58288. closePath?: boolean;
  58289. offset?: number;
  58290. updatable?: boolean;
  58291. sideOrientation?: number;
  58292. frontUVs?: Vector4;
  58293. backUVs?: Vector4;
  58294. instance?: Mesh;
  58295. invertUV?: boolean;
  58296. uvs?: Vector2[];
  58297. colors?: Color4[];
  58298. }, scene?: Nullable<Scene>): Mesh;
  58299. }
  58300. }
  58301. declare module "babylonjs/Meshes/Builders/shapeBuilder" {
  58302. import { Nullable } from "babylonjs/types";
  58303. import { Scene } from "babylonjs/scene";
  58304. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  58305. import { Mesh } from "babylonjs/Meshes/mesh";
  58306. /**
  58307. * Class containing static functions to help procedurally build meshes
  58308. */
  58309. export class ShapeBuilder {
  58310. /**
  58311. * 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.
  58312. * * 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.
  58313. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  58314. * * 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.
  58315. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  58316. * * 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
  58317. * * 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
  58318. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  58319. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58320. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  58321. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  58322. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  58323. * @param name defines the name of the mesh
  58324. * @param options defines the options used to create the mesh
  58325. * @param scene defines the hosting scene
  58326. * @returns the extruded shape mesh
  58327. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  58328. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  58329. */
  58330. static ExtrudeShape(name: string, options: {
  58331. shape: Vector3[];
  58332. path: Vector3[];
  58333. scale?: number;
  58334. rotation?: number;
  58335. cap?: number;
  58336. updatable?: boolean;
  58337. sideOrientation?: number;
  58338. frontUVs?: Vector4;
  58339. backUVs?: Vector4;
  58340. instance?: Mesh;
  58341. invertUV?: boolean;
  58342. }, scene?: Nullable<Scene>): Mesh;
  58343. /**
  58344. * Creates an custom extruded shape mesh.
  58345. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  58346. * * 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.
  58347. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  58348. * * 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
  58349. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  58350. * * 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
  58351. * * It must returns a float value that will be the scale value applied to the shape on each path point
  58352. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  58353. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  58354. * * 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
  58355. * * 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
  58356. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  58357. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58358. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  58359. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  58360. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58361. * @param name defines the name of the mesh
  58362. * @param options defines the options used to create the mesh
  58363. * @param scene defines the hosting scene
  58364. * @returns the custom extruded shape mesh
  58365. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  58366. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  58367. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  58368. */
  58369. static ExtrudeShapeCustom(name: string, options: {
  58370. shape: Vector3[];
  58371. path: Vector3[];
  58372. scaleFunction?: any;
  58373. rotationFunction?: any;
  58374. ribbonCloseArray?: boolean;
  58375. ribbonClosePath?: boolean;
  58376. cap?: number;
  58377. updatable?: boolean;
  58378. sideOrientation?: number;
  58379. frontUVs?: Vector4;
  58380. backUVs?: Vector4;
  58381. instance?: Mesh;
  58382. invertUV?: boolean;
  58383. }, scene?: Nullable<Scene>): Mesh;
  58384. private static _ExtrudeShapeGeneric;
  58385. }
  58386. }
  58387. declare module "babylonjs/Physics/Plugins/ammoJSPlugin" {
  58388. import { Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  58389. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  58390. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  58391. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  58392. import { Nullable } from "babylonjs/types";
  58393. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  58394. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  58395. /**
  58396. * AmmoJS Physics plugin
  58397. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  58398. * @see https://github.com/kripken/ammo.js/
  58399. */
  58400. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  58401. private _useDeltaForWorldStep;
  58402. /**
  58403. * Reference to the Ammo library
  58404. */
  58405. bjsAMMO: any;
  58406. /**
  58407. * Created ammoJS world which physics bodies are added to
  58408. */
  58409. world: any;
  58410. /**
  58411. * Name of the plugin
  58412. */
  58413. name: string;
  58414. private _timeStep;
  58415. private _fixedTimeStep;
  58416. private _maxSteps;
  58417. private _tmpQuaternion;
  58418. private _tmpAmmoTransform;
  58419. private _tmpAmmoQuaternion;
  58420. private _tmpAmmoConcreteContactResultCallback;
  58421. private _collisionConfiguration;
  58422. private _dispatcher;
  58423. private _overlappingPairCache;
  58424. private _solver;
  58425. private _softBodySolver;
  58426. private _tmpAmmoVectorA;
  58427. private _tmpAmmoVectorB;
  58428. private _tmpAmmoVectorC;
  58429. private _tmpAmmoVectorD;
  58430. private _tmpContactCallbackResult;
  58431. private _tmpAmmoVectorRCA;
  58432. private _tmpAmmoVectorRCB;
  58433. private _raycastResult;
  58434. private static readonly DISABLE_COLLISION_FLAG;
  58435. private static readonly KINEMATIC_FLAG;
  58436. private static readonly DISABLE_DEACTIVATION_FLAG;
  58437. /**
  58438. * Initializes the ammoJS plugin
  58439. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  58440. * @param ammoInjection can be used to inject your own ammo reference
  58441. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  58442. */
  58443. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  58444. /**
  58445. * Sets the gravity of the physics world (m/(s^2))
  58446. * @param gravity Gravity to set
  58447. */
  58448. setGravity(gravity: Vector3): void;
  58449. /**
  58450. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  58451. * @param timeStep timestep to use in seconds
  58452. */
  58453. setTimeStep(timeStep: number): void;
  58454. /**
  58455. * 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)
  58456. * @param fixedTimeStep fixedTimeStep to use in seconds
  58457. */
  58458. setFixedTimeStep(fixedTimeStep: number): void;
  58459. /**
  58460. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  58461. * @param maxSteps the maximum number of steps by the physics engine per frame
  58462. */
  58463. setMaxSteps(maxSteps: number): void;
  58464. /**
  58465. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  58466. * @returns the current timestep in seconds
  58467. */
  58468. getTimeStep(): number;
  58469. /**
  58470. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  58471. */
  58472. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  58473. private _isImpostorInContact;
  58474. private _isImpostorPairInContact;
  58475. private _stepSimulation;
  58476. /**
  58477. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  58478. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  58479. * After the step the babylon meshes are set to the position of the physics imposters
  58480. * @param delta amount of time to step forward
  58481. * @param impostors array of imposters to update before/after the step
  58482. */
  58483. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  58484. /**
  58485. * Update babylon mesh to match physics world object
  58486. * @param impostor imposter to match
  58487. */
  58488. private _afterSoftStep;
  58489. /**
  58490. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  58491. * @param impostor imposter to match
  58492. */
  58493. private _ropeStep;
  58494. /**
  58495. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  58496. * @param impostor imposter to match
  58497. */
  58498. private _softbodyOrClothStep;
  58499. private _tmpMatrix;
  58500. /**
  58501. * Applies an impulse on the imposter
  58502. * @param impostor imposter to apply impulse to
  58503. * @param force amount of force to be applied to the imposter
  58504. * @param contactPoint the location to apply the impulse on the imposter
  58505. */
  58506. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  58507. /**
  58508. * Applies a force on the imposter
  58509. * @param impostor imposter to apply force
  58510. * @param force amount of force to be applied to the imposter
  58511. * @param contactPoint the location to apply the force on the imposter
  58512. */
  58513. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  58514. /**
  58515. * Creates a physics body using the plugin
  58516. * @param impostor the imposter to create the physics body on
  58517. */
  58518. generatePhysicsBody(impostor: PhysicsImpostor): void;
  58519. /**
  58520. * Removes the physics body from the imposter and disposes of the body's memory
  58521. * @param impostor imposter to remove the physics body from
  58522. */
  58523. removePhysicsBody(impostor: PhysicsImpostor): void;
  58524. /**
  58525. * Generates a joint
  58526. * @param impostorJoint the imposter joint to create the joint with
  58527. */
  58528. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  58529. /**
  58530. * Removes a joint
  58531. * @param impostorJoint the imposter joint to remove the joint from
  58532. */
  58533. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  58534. private _addMeshVerts;
  58535. /**
  58536. * Initialise the soft body vertices to match its object's (mesh) vertices
  58537. * Softbody vertices (nodes) are in world space and to match this
  58538. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  58539. * @param impostor to create the softbody for
  58540. */
  58541. private _softVertexData;
  58542. /**
  58543. * Create an impostor's soft body
  58544. * @param impostor to create the softbody for
  58545. */
  58546. private _createSoftbody;
  58547. /**
  58548. * Create cloth for an impostor
  58549. * @param impostor to create the softbody for
  58550. */
  58551. private _createCloth;
  58552. /**
  58553. * Create rope for an impostor
  58554. * @param impostor to create the softbody for
  58555. */
  58556. private _createRope;
  58557. /**
  58558. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  58559. * @param impostor to create the custom physics shape for
  58560. */
  58561. private _createCustom;
  58562. private _addHullVerts;
  58563. private _createShape;
  58564. /**
  58565. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  58566. * @param impostor imposter containing the physics body and babylon object
  58567. */
  58568. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  58569. /**
  58570. * Sets the babylon object's position/rotation from the physics body's position/rotation
  58571. * @param impostor imposter containing the physics body and babylon object
  58572. * @param newPosition new position
  58573. * @param newRotation new rotation
  58574. */
  58575. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  58576. /**
  58577. * If this plugin is supported
  58578. * @returns true if its supported
  58579. */
  58580. isSupported(): boolean;
  58581. /**
  58582. * Sets the linear velocity of the physics body
  58583. * @param impostor imposter to set the velocity on
  58584. * @param velocity velocity to set
  58585. */
  58586. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  58587. /**
  58588. * Sets the angular velocity of the physics body
  58589. * @param impostor imposter to set the velocity on
  58590. * @param velocity velocity to set
  58591. */
  58592. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  58593. /**
  58594. * gets the linear velocity
  58595. * @param impostor imposter to get linear velocity from
  58596. * @returns linear velocity
  58597. */
  58598. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  58599. /**
  58600. * gets the angular velocity
  58601. * @param impostor imposter to get angular velocity from
  58602. * @returns angular velocity
  58603. */
  58604. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  58605. /**
  58606. * Sets the mass of physics body
  58607. * @param impostor imposter to set the mass on
  58608. * @param mass mass to set
  58609. */
  58610. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  58611. /**
  58612. * Gets the mass of the physics body
  58613. * @param impostor imposter to get the mass from
  58614. * @returns mass
  58615. */
  58616. getBodyMass(impostor: PhysicsImpostor): number;
  58617. /**
  58618. * Gets friction of the impostor
  58619. * @param impostor impostor to get friction from
  58620. * @returns friction value
  58621. */
  58622. getBodyFriction(impostor: PhysicsImpostor): number;
  58623. /**
  58624. * Sets friction of the impostor
  58625. * @param impostor impostor to set friction on
  58626. * @param friction friction value
  58627. */
  58628. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  58629. /**
  58630. * Gets restitution of the impostor
  58631. * @param impostor impostor to get restitution from
  58632. * @returns restitution value
  58633. */
  58634. getBodyRestitution(impostor: PhysicsImpostor): number;
  58635. /**
  58636. * Sets resitution of the impostor
  58637. * @param impostor impostor to set resitution on
  58638. * @param restitution resitution value
  58639. */
  58640. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  58641. /**
  58642. * Gets pressure inside the impostor
  58643. * @param impostor impostor to get pressure from
  58644. * @returns pressure value
  58645. */
  58646. getBodyPressure(impostor: PhysicsImpostor): number;
  58647. /**
  58648. * Sets pressure inside a soft body impostor
  58649. * Cloth and rope must remain 0 pressure
  58650. * @param impostor impostor to set pressure on
  58651. * @param pressure pressure value
  58652. */
  58653. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  58654. /**
  58655. * Gets stiffness of the impostor
  58656. * @param impostor impostor to get stiffness from
  58657. * @returns pressure value
  58658. */
  58659. getBodyStiffness(impostor: PhysicsImpostor): number;
  58660. /**
  58661. * Sets stiffness of the impostor
  58662. * @param impostor impostor to set stiffness on
  58663. * @param stiffness stiffness value from 0 to 1
  58664. */
  58665. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  58666. /**
  58667. * Gets velocityIterations of the impostor
  58668. * @param impostor impostor to get velocity iterations from
  58669. * @returns velocityIterations value
  58670. */
  58671. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  58672. /**
  58673. * Sets velocityIterations of the impostor
  58674. * @param impostor impostor to set velocity iterations on
  58675. * @param velocityIterations velocityIterations value
  58676. */
  58677. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  58678. /**
  58679. * Gets positionIterations of the impostor
  58680. * @param impostor impostor to get position iterations from
  58681. * @returns positionIterations value
  58682. */
  58683. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  58684. /**
  58685. * Sets positionIterations of the impostor
  58686. * @param impostor impostor to set position on
  58687. * @param positionIterations positionIterations value
  58688. */
  58689. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  58690. /**
  58691. * Append an anchor to a cloth object
  58692. * @param impostor is the cloth impostor to add anchor to
  58693. * @param otherImpostor is the rigid impostor to anchor to
  58694. * @param width ratio across width from 0 to 1
  58695. * @param height ratio up height from 0 to 1
  58696. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  58697. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  58698. */
  58699. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  58700. /**
  58701. * Append an hook to a rope object
  58702. * @param impostor is the rope impostor to add hook to
  58703. * @param otherImpostor is the rigid impostor to hook to
  58704. * @param length ratio along the rope from 0 to 1
  58705. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  58706. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  58707. */
  58708. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  58709. /**
  58710. * Sleeps the physics body and stops it from being active
  58711. * @param impostor impostor to sleep
  58712. */
  58713. sleepBody(impostor: PhysicsImpostor): void;
  58714. /**
  58715. * Activates the physics body
  58716. * @param impostor impostor to activate
  58717. */
  58718. wakeUpBody(impostor: PhysicsImpostor): void;
  58719. /**
  58720. * Updates the distance parameters of the joint
  58721. * @param joint joint to update
  58722. * @param maxDistance maximum distance of the joint
  58723. * @param minDistance minimum distance of the joint
  58724. */
  58725. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  58726. /**
  58727. * Sets a motor on the joint
  58728. * @param joint joint to set motor on
  58729. * @param speed speed of the motor
  58730. * @param maxForce maximum force of the motor
  58731. * @param motorIndex index of the motor
  58732. */
  58733. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  58734. /**
  58735. * Sets the motors limit
  58736. * @param joint joint to set limit on
  58737. * @param upperLimit upper limit
  58738. * @param lowerLimit lower limit
  58739. */
  58740. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  58741. /**
  58742. * Syncs the position and rotation of a mesh with the impostor
  58743. * @param mesh mesh to sync
  58744. * @param impostor impostor to update the mesh with
  58745. */
  58746. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  58747. /**
  58748. * Gets the radius of the impostor
  58749. * @param impostor impostor to get radius from
  58750. * @returns the radius
  58751. */
  58752. getRadius(impostor: PhysicsImpostor): number;
  58753. /**
  58754. * Gets the box size of the impostor
  58755. * @param impostor impostor to get box size from
  58756. * @param result the resulting box size
  58757. */
  58758. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  58759. /**
  58760. * Disposes of the impostor
  58761. */
  58762. dispose(): void;
  58763. /**
  58764. * Does a raycast in the physics world
  58765. * @param from when should the ray start?
  58766. * @param to when should the ray end?
  58767. * @returns PhysicsRaycastResult
  58768. */
  58769. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  58770. }
  58771. }
  58772. declare module "babylonjs/Probes/reflectionProbe" {
  58773. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  58774. import { Vector3 } from "babylonjs/Maths/math.vector";
  58775. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  58776. import { Nullable } from "babylonjs/types";
  58777. import { Scene } from "babylonjs/scene";
  58778. module "babylonjs/abstractScene" {
  58779. interface AbstractScene {
  58780. /**
  58781. * The list of reflection probes added to the scene
  58782. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  58783. */
  58784. reflectionProbes: Array<ReflectionProbe>;
  58785. /**
  58786. * Removes the given reflection probe from this scene.
  58787. * @param toRemove The reflection probe to remove
  58788. * @returns The index of the removed reflection probe
  58789. */
  58790. removeReflectionProbe(toRemove: ReflectionProbe): number;
  58791. /**
  58792. * Adds the given reflection probe to this scene.
  58793. * @param newReflectionProbe The reflection probe to add
  58794. */
  58795. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  58796. }
  58797. }
  58798. /**
  58799. * Class used to generate realtime reflection / refraction cube textures
  58800. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  58801. */
  58802. export class ReflectionProbe {
  58803. /** defines the name of the probe */
  58804. name: string;
  58805. private _scene;
  58806. private _renderTargetTexture;
  58807. private _projectionMatrix;
  58808. private _viewMatrix;
  58809. private _target;
  58810. private _add;
  58811. private _attachedMesh;
  58812. private _invertYAxis;
  58813. /** Gets or sets probe position (center of the cube map) */
  58814. position: Vector3;
  58815. /**
  58816. * Creates a new reflection probe
  58817. * @param name defines the name of the probe
  58818. * @param size defines the texture resolution (for each face)
  58819. * @param scene defines the hosting scene
  58820. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  58821. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  58822. */
  58823. constructor(
  58824. /** defines the name of the probe */
  58825. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  58826. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  58827. get samples(): number;
  58828. set samples(value: number);
  58829. /** Gets or sets the refresh rate to use (on every frame by default) */
  58830. get refreshRate(): number;
  58831. set refreshRate(value: number);
  58832. /**
  58833. * Gets the hosting scene
  58834. * @returns a Scene
  58835. */
  58836. getScene(): Scene;
  58837. /** Gets the internal CubeTexture used to render to */
  58838. get cubeTexture(): RenderTargetTexture;
  58839. /** Gets the list of meshes to render */
  58840. get renderList(): Nullable<AbstractMesh[]>;
  58841. /**
  58842. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  58843. * @param mesh defines the mesh to attach to
  58844. */
  58845. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  58846. /**
  58847. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  58848. * @param renderingGroupId The rendering group id corresponding to its index
  58849. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  58850. */
  58851. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  58852. /**
  58853. * Clean all associated resources
  58854. */
  58855. dispose(): void;
  58856. /**
  58857. * Converts the reflection probe information to a readable string for debug purpose.
  58858. * @param fullDetails Supports for multiple levels of logging within scene loading
  58859. * @returns the human readable reflection probe info
  58860. */
  58861. toString(fullDetails?: boolean): string;
  58862. /**
  58863. * Get the class name of the relfection probe.
  58864. * @returns "ReflectionProbe"
  58865. */
  58866. getClassName(): string;
  58867. /**
  58868. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  58869. * @returns The JSON representation of the texture
  58870. */
  58871. serialize(): any;
  58872. /**
  58873. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  58874. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  58875. * @param scene Define the scene the parsed reflection probe should be instantiated in
  58876. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  58877. * @returns The parsed reflection probe if successful
  58878. */
  58879. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  58880. }
  58881. }
  58882. declare module "babylonjs/Loading/Plugins/babylonFileLoader" {
  58883. /** @hidden */
  58884. export var _BabylonLoaderRegistered: boolean;
  58885. /**
  58886. * Helps setting up some configuration for the babylon file loader.
  58887. */
  58888. export class BabylonFileLoaderConfiguration {
  58889. /**
  58890. * The loader does not allow injecting custom physix engine into the plugins.
  58891. * Unfortunately in ES6, we need to manually inject them into the plugin.
  58892. * So you could set this variable to your engine import to make it work.
  58893. */
  58894. static LoaderInjectedPhysicsEngine: any;
  58895. }
  58896. }
  58897. declare module "babylonjs/Loading/Plugins/index" {
  58898. export * from "babylonjs/Loading/Plugins/babylonFileLoader";
  58899. }
  58900. declare module "babylonjs/Loading/index" {
  58901. export * from "babylonjs/Loading/loadingScreen";
  58902. export * from "babylonjs/Loading/Plugins/index";
  58903. export * from "babylonjs/Loading/sceneLoader";
  58904. export * from "babylonjs/Loading/sceneLoaderFlags";
  58905. }
  58906. declare module "babylonjs/Materials/Background/index" {
  58907. export * from "babylonjs/Materials/Background/backgroundMaterial";
  58908. }
  58909. declare module "babylonjs/Materials/PBR/pbrBaseSimpleMaterial" {
  58910. import { Scene } from "babylonjs/scene";
  58911. import { Color3 } from "babylonjs/Maths/math.color";
  58912. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  58913. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  58914. /**
  58915. * The Physically based simple base material of BJS.
  58916. *
  58917. * This enables better naming and convention enforcements on top of the pbrMaterial.
  58918. * It is used as the base class for both the specGloss and metalRough conventions.
  58919. */
  58920. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  58921. /**
  58922. * Number of Simultaneous lights allowed on the material.
  58923. */
  58924. maxSimultaneousLights: number;
  58925. /**
  58926. * If sets to true, disables all the lights affecting the material.
  58927. */
  58928. disableLighting: boolean;
  58929. /**
  58930. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  58931. */
  58932. environmentTexture: BaseTexture;
  58933. /**
  58934. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  58935. */
  58936. invertNormalMapX: boolean;
  58937. /**
  58938. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  58939. */
  58940. invertNormalMapY: boolean;
  58941. /**
  58942. * Normal map used in the model.
  58943. */
  58944. normalTexture: BaseTexture;
  58945. /**
  58946. * Emissivie color used to self-illuminate the model.
  58947. */
  58948. emissiveColor: Color3;
  58949. /**
  58950. * Emissivie texture used to self-illuminate the model.
  58951. */
  58952. emissiveTexture: BaseTexture;
  58953. /**
  58954. * Occlusion Channel Strenght.
  58955. */
  58956. occlusionStrength: number;
  58957. /**
  58958. * Occlusion Texture of the material (adding extra occlusion effects).
  58959. */
  58960. occlusionTexture: BaseTexture;
  58961. /**
  58962. * Defines the alpha limits in alpha test mode.
  58963. */
  58964. alphaCutOff: number;
  58965. /**
  58966. * Gets the current double sided mode.
  58967. */
  58968. get doubleSided(): boolean;
  58969. /**
  58970. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  58971. */
  58972. set doubleSided(value: boolean);
  58973. /**
  58974. * Stores the pre-calculated light information of a mesh in a texture.
  58975. */
  58976. lightmapTexture: BaseTexture;
  58977. /**
  58978. * If true, the light map contains occlusion information instead of lighting info.
  58979. */
  58980. useLightmapAsShadowmap: boolean;
  58981. /**
  58982. * Instantiates a new PBRMaterial instance.
  58983. *
  58984. * @param name The material name
  58985. * @param scene The scene the material will be use in.
  58986. */
  58987. constructor(name: string, scene: Scene);
  58988. getClassName(): string;
  58989. }
  58990. }
  58991. declare module "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial" {
  58992. import { Scene } from "babylonjs/scene";
  58993. import { Color3 } from "babylonjs/Maths/math.color";
  58994. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  58995. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  58996. /**
  58997. * The PBR material of BJS following the metal roughness convention.
  58998. *
  58999. * This fits to the PBR convention in the GLTF definition:
  59000. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  59001. */
  59002. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  59003. /**
  59004. * The base color has two different interpretations depending on the value of metalness.
  59005. * When the material is a metal, the base color is the specific measured reflectance value
  59006. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  59007. * of the material.
  59008. */
  59009. baseColor: Color3;
  59010. /**
  59011. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  59012. * well as opacity information in the alpha channel.
  59013. */
  59014. baseTexture: BaseTexture;
  59015. /**
  59016. * Specifies the metallic scalar value of the material.
  59017. * Can also be used to scale the metalness values of the metallic texture.
  59018. */
  59019. metallic: number;
  59020. /**
  59021. * Specifies the roughness scalar value of the material.
  59022. * Can also be used to scale the roughness values of the metallic texture.
  59023. */
  59024. roughness: number;
  59025. /**
  59026. * Texture containing both the metallic value in the B channel and the
  59027. * roughness value in the G channel to keep better precision.
  59028. */
  59029. metallicRoughnessTexture: BaseTexture;
  59030. /**
  59031. * Instantiates a new PBRMetalRoughnessMaterial instance.
  59032. *
  59033. * @param name The material name
  59034. * @param scene The scene the material will be use in.
  59035. */
  59036. constructor(name: string, scene: Scene);
  59037. /**
  59038. * Return the currrent class name of the material.
  59039. */
  59040. getClassName(): string;
  59041. /**
  59042. * Makes a duplicate of the current material.
  59043. * @param name - name to use for the new material.
  59044. */
  59045. clone(name: string): PBRMetallicRoughnessMaterial;
  59046. /**
  59047. * Serialize the material to a parsable JSON object.
  59048. */
  59049. serialize(): any;
  59050. /**
  59051. * Parses a JSON object correponding to the serialize function.
  59052. */
  59053. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  59054. }
  59055. }
  59056. declare module "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial" {
  59057. import { Scene } from "babylonjs/scene";
  59058. import { Color3 } from "babylonjs/Maths/math.color";
  59059. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  59060. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  59061. /**
  59062. * The PBR material of BJS following the specular glossiness convention.
  59063. *
  59064. * This fits to the PBR convention in the GLTF definition:
  59065. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  59066. */
  59067. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  59068. /**
  59069. * Specifies the diffuse color of the material.
  59070. */
  59071. diffuseColor: Color3;
  59072. /**
  59073. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  59074. * channel.
  59075. */
  59076. diffuseTexture: BaseTexture;
  59077. /**
  59078. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  59079. */
  59080. specularColor: Color3;
  59081. /**
  59082. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  59083. */
  59084. glossiness: number;
  59085. /**
  59086. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  59087. */
  59088. specularGlossinessTexture: BaseTexture;
  59089. /**
  59090. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  59091. *
  59092. * @param name The material name
  59093. * @param scene The scene the material will be use in.
  59094. */
  59095. constructor(name: string, scene: Scene);
  59096. /**
  59097. * Return the currrent class name of the material.
  59098. */
  59099. getClassName(): string;
  59100. /**
  59101. * Makes a duplicate of the current material.
  59102. * @param name - name to use for the new material.
  59103. */
  59104. clone(name: string): PBRSpecularGlossinessMaterial;
  59105. /**
  59106. * Serialize the material to a parsable JSON object.
  59107. */
  59108. serialize(): any;
  59109. /**
  59110. * Parses a JSON object correponding to the serialize function.
  59111. */
  59112. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  59113. }
  59114. }
  59115. declare module "babylonjs/Materials/PBR/index" {
  59116. export * from "babylonjs/Materials/PBR/pbrBaseMaterial";
  59117. export * from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  59118. export * from "babylonjs/Materials/PBR/pbrMaterial";
  59119. export * from "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial";
  59120. export * from "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial";
  59121. }
  59122. declare module "babylonjs/Materials/Textures/colorGradingTexture" {
  59123. import { Nullable } from "babylonjs/types";
  59124. import { Scene } from "babylonjs/scene";
  59125. import { Matrix } from "babylonjs/Maths/math.vector";
  59126. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  59127. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  59128. import "babylonjs/Engines/Extensions/engine.rawTexture";
  59129. /**
  59130. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  59131. * It can help converting any input color in a desired output one. This can then be used to create effects
  59132. * from sepia, black and white to sixties or futuristic rendering...
  59133. *
  59134. * The only supported format is currently 3dl.
  59135. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  59136. */
  59137. export class ColorGradingTexture extends BaseTexture {
  59138. /**
  59139. * The texture URL.
  59140. */
  59141. url: string;
  59142. /**
  59143. * Empty line regex stored for GC.
  59144. */
  59145. private static _noneEmptyLineRegex;
  59146. private _textureMatrix;
  59147. private _engine;
  59148. private _onLoad;
  59149. /**
  59150. * Instantiates a ColorGradingTexture from the following parameters.
  59151. *
  59152. * @param url The location of the color gradind data (currently only supporting 3dl)
  59153. * @param sceneOrEngine The scene or engine the texture will be used in
  59154. * @param onLoad defines a callback triggered when the texture has been loaded
  59155. */
  59156. constructor(url: string, sceneOrEngine: Scene | ThinEngine, onLoad?: Nullable<() => void>);
  59157. /**
  59158. * Fires the onload event from the constructor if requested.
  59159. */
  59160. private _triggerOnLoad;
  59161. /**
  59162. * Returns the texture matrix used in most of the material.
  59163. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  59164. */
  59165. getTextureMatrix(): Matrix;
  59166. /**
  59167. * Occurs when the file being loaded is a .3dl LUT file.
  59168. */
  59169. private load3dlTexture;
  59170. /**
  59171. * Starts the loading process of the texture.
  59172. */
  59173. private loadTexture;
  59174. /**
  59175. * Clones the color gradind texture.
  59176. */
  59177. clone(): ColorGradingTexture;
  59178. /**
  59179. * Called during delayed load for textures.
  59180. */
  59181. delayLoad(): void;
  59182. /**
  59183. * Parses a color grading texture serialized by Babylon.
  59184. * @param parsedTexture The texture information being parsedTexture
  59185. * @param scene The scene to load the texture in
  59186. * @param rootUrl The root url of the data assets to load
  59187. * @return A color gradind texture
  59188. */
  59189. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  59190. /**
  59191. * Serializes the LUT texture to json format.
  59192. */
  59193. serialize(): any;
  59194. /**
  59195. * Returns true if the passed parameter is a scene object (can be use for typings)
  59196. * @param sceneOrEngine The object to test.
  59197. */
  59198. private static _isScene;
  59199. }
  59200. }
  59201. declare module "babylonjs/Materials/Textures/equiRectangularCubeTexture" {
  59202. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  59203. import { Scene } from "babylonjs/scene";
  59204. import { Nullable } from "babylonjs/types";
  59205. import "babylonjs/Engines/Extensions/engine.rawTexture";
  59206. /**
  59207. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  59208. */
  59209. export class EquiRectangularCubeTexture extends BaseTexture {
  59210. /** The six faces of the cube. */
  59211. private static _FacesMapping;
  59212. private _noMipmap;
  59213. private _onLoad;
  59214. private _onError;
  59215. /** The size of the cubemap. */
  59216. private _size;
  59217. /** The buffer of the image. */
  59218. private _buffer;
  59219. /** The width of the input image. */
  59220. private _width;
  59221. /** The height of the input image. */
  59222. private _height;
  59223. /** The URL to the image. */
  59224. url: string;
  59225. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  59226. coordinatesMode: number;
  59227. /**
  59228. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  59229. * @param url The location of the image
  59230. * @param scene The scene the texture will be used in
  59231. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  59232. * @param noMipmap Forces to not generate the mipmap if true
  59233. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  59234. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  59235. * @param onLoad — defines a callback called when texture is loaded
  59236. * @param onError — defines a callback called if there is an error
  59237. */
  59238. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  59239. /**
  59240. * Load the image data, by putting the image on a canvas and extracting its buffer.
  59241. */
  59242. private loadImage;
  59243. /**
  59244. * Convert the image buffer into a cubemap and create a CubeTexture.
  59245. */
  59246. private loadTexture;
  59247. /**
  59248. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  59249. * @param buffer The ArrayBuffer that should be converted.
  59250. * @returns The buffer as Float32Array.
  59251. */
  59252. private getFloat32ArrayFromArrayBuffer;
  59253. /**
  59254. * Get the current class name of the texture useful for serialization or dynamic coding.
  59255. * @returns "EquiRectangularCubeTexture"
  59256. */
  59257. getClassName(): string;
  59258. /**
  59259. * Create a clone of the current EquiRectangularCubeTexture and return it.
  59260. * @returns A clone of the current EquiRectangularCubeTexture.
  59261. */
  59262. clone(): EquiRectangularCubeTexture;
  59263. }
  59264. }
  59265. declare module "babylonjs/Misc/tga" {
  59266. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  59267. /**
  59268. * Based on jsTGALoader - Javascript loader for TGA file
  59269. * By Vincent Thibault
  59270. * @see http://blog.robrowser.com/javascript-tga-loader.html
  59271. */
  59272. export class TGATools {
  59273. private static _TYPE_INDEXED;
  59274. private static _TYPE_RGB;
  59275. private static _TYPE_GREY;
  59276. private static _TYPE_RLE_INDEXED;
  59277. private static _TYPE_RLE_RGB;
  59278. private static _TYPE_RLE_GREY;
  59279. private static _ORIGIN_MASK;
  59280. private static _ORIGIN_SHIFT;
  59281. private static _ORIGIN_BL;
  59282. private static _ORIGIN_BR;
  59283. private static _ORIGIN_UL;
  59284. private static _ORIGIN_UR;
  59285. /**
  59286. * Gets the header of a TGA file
  59287. * @param data defines the TGA data
  59288. * @returns the header
  59289. */
  59290. static GetTGAHeader(data: Uint8Array): any;
  59291. /**
  59292. * Uploads TGA content to a Babylon Texture
  59293. * @hidden
  59294. */
  59295. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  59296. /** @hidden */
  59297. 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;
  59298. /** @hidden */
  59299. 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;
  59300. /** @hidden */
  59301. 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;
  59302. /** @hidden */
  59303. 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;
  59304. /** @hidden */
  59305. 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;
  59306. /** @hidden */
  59307. 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;
  59308. }
  59309. }
  59310. declare module "babylonjs/Materials/Textures/Loaders/tgaTextureLoader" {
  59311. import { Nullable } from "babylonjs/types";
  59312. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  59313. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  59314. /**
  59315. * Implementation of the TGA Texture Loader.
  59316. * @hidden
  59317. */
  59318. export class _TGATextureLoader implements IInternalTextureLoader {
  59319. /**
  59320. * Defines wether the loader supports cascade loading the different faces.
  59321. */
  59322. readonly supportCascades: boolean;
  59323. /**
  59324. * This returns if the loader support the current file information.
  59325. * @param extension defines the file extension of the file being loaded
  59326. * @returns true if the loader can load the specified file
  59327. */
  59328. canLoad(extension: string): boolean;
  59329. /**
  59330. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  59331. * @param data contains the texture data
  59332. * @param texture defines the BabylonJS internal texture
  59333. * @param createPolynomials will be true if polynomials have been requested
  59334. * @param onLoad defines the callback to trigger once the texture is ready
  59335. * @param onError defines the callback to trigger in case of error
  59336. */
  59337. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  59338. /**
  59339. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  59340. * @param data contains the texture data
  59341. * @param texture defines the BabylonJS internal texture
  59342. * @param callback defines the method to call once ready to upload
  59343. */
  59344. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  59345. }
  59346. }
  59347. declare module "babylonjs/Misc/basis" {
  59348. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  59349. /**
  59350. * Info about the .basis files
  59351. */
  59352. class BasisFileInfo {
  59353. /**
  59354. * If the file has alpha
  59355. */
  59356. hasAlpha: boolean;
  59357. /**
  59358. * Info about each image of the basis file
  59359. */
  59360. images: Array<{
  59361. levels: Array<{
  59362. width: number;
  59363. height: number;
  59364. transcodedPixels: ArrayBufferView;
  59365. }>;
  59366. }>;
  59367. }
  59368. /**
  59369. * Result of transcoding a basis file
  59370. */
  59371. class TranscodeResult {
  59372. /**
  59373. * Info about the .basis file
  59374. */
  59375. fileInfo: BasisFileInfo;
  59376. /**
  59377. * Format to use when loading the file
  59378. */
  59379. format: number;
  59380. }
  59381. /**
  59382. * Configuration options for the Basis transcoder
  59383. */
  59384. export class BasisTranscodeConfiguration {
  59385. /**
  59386. * Supported compression formats used to determine the supported output format of the transcoder
  59387. */
  59388. supportedCompressionFormats?: {
  59389. /**
  59390. * etc1 compression format
  59391. */
  59392. etc1?: boolean;
  59393. /**
  59394. * s3tc compression format
  59395. */
  59396. s3tc?: boolean;
  59397. /**
  59398. * pvrtc compression format
  59399. */
  59400. pvrtc?: boolean;
  59401. /**
  59402. * etc2 compression format
  59403. */
  59404. etc2?: boolean;
  59405. };
  59406. /**
  59407. * If mipmap levels should be loaded for transcoded images (Default: true)
  59408. */
  59409. loadMipmapLevels?: boolean;
  59410. /**
  59411. * Index of a single image to load (Default: all images)
  59412. */
  59413. loadSingleImage?: number;
  59414. }
  59415. /**
  59416. * Used to load .Basis files
  59417. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  59418. */
  59419. export class BasisTools {
  59420. private static _IgnoreSupportedFormats;
  59421. /**
  59422. * URL to use when loading the basis transcoder
  59423. */
  59424. static JSModuleURL: string;
  59425. /**
  59426. * URL to use when loading the wasm module for the transcoder
  59427. */
  59428. static WasmModuleURL: string;
  59429. /**
  59430. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  59431. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  59432. * @returns internal format corresponding to the Basis format
  59433. */
  59434. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  59435. private static _WorkerPromise;
  59436. private static _Worker;
  59437. private static _actionId;
  59438. private static _CreateWorkerAsync;
  59439. /**
  59440. * Transcodes a loaded image file to compressed pixel data
  59441. * @param data image data to transcode
  59442. * @param config configuration options for the transcoding
  59443. * @returns a promise resulting in the transcoded image
  59444. */
  59445. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  59446. /**
  59447. * Loads a texture from the transcode result
  59448. * @param texture texture load to
  59449. * @param transcodeResult the result of transcoding the basis file to load from
  59450. */
  59451. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  59452. }
  59453. }
  59454. declare module "babylonjs/Materials/Textures/Loaders/basisTextureLoader" {
  59455. import { Nullable } from "babylonjs/types";
  59456. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  59457. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  59458. /**
  59459. * Loader for .basis file format
  59460. */
  59461. export class _BasisTextureLoader implements IInternalTextureLoader {
  59462. /**
  59463. * Defines whether the loader supports cascade loading the different faces.
  59464. */
  59465. readonly supportCascades: boolean;
  59466. /**
  59467. * This returns if the loader support the current file information.
  59468. * @param extension defines the file extension of the file being loaded
  59469. * @returns true if the loader can load the specified file
  59470. */
  59471. canLoad(extension: string): boolean;
  59472. /**
  59473. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  59474. * @param data contains the texture data
  59475. * @param texture defines the BabylonJS internal texture
  59476. * @param createPolynomials will be true if polynomials have been requested
  59477. * @param onLoad defines the callback to trigger once the texture is ready
  59478. * @param onError defines the callback to trigger in case of error
  59479. */
  59480. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  59481. /**
  59482. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  59483. * @param data contains the texture data
  59484. * @param texture defines the BabylonJS internal texture
  59485. * @param callback defines the method to call once ready to upload
  59486. */
  59487. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  59488. }
  59489. }
  59490. declare module "babylonjs/Materials/Textures/Loaders/index" {
  59491. export * from "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  59492. export * from "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  59493. export * from "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  59494. export * from "babylonjs/Materials/Textures/Loaders/tgaTextureLoader";
  59495. export * from "babylonjs/Materials/Textures/Loaders/basisTextureLoader";
  59496. }
  59497. declare module "babylonjs/Materials/Textures/Procedurals/customProceduralTexture" {
  59498. import { Scene } from "babylonjs/scene";
  59499. import { Texture } from "babylonjs/Materials/Textures/texture";
  59500. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  59501. /**
  59502. * 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.
  59503. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  59504. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  59505. */
  59506. export class CustomProceduralTexture extends ProceduralTexture {
  59507. private _animate;
  59508. private _time;
  59509. private _config;
  59510. private _texturePath;
  59511. /**
  59512. * Instantiates a new Custom Procedural Texture.
  59513. * 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.
  59514. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  59515. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  59516. * @param name Define the name of the texture
  59517. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  59518. * @param size Define the size of the texture to create
  59519. * @param scene Define the scene the texture belongs to
  59520. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  59521. * @param generateMipMaps Define if the texture should creates mip maps or not
  59522. */
  59523. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  59524. private _loadJson;
  59525. /**
  59526. * Is the texture ready to be used ? (rendered at least once)
  59527. * @returns true if ready, otherwise, false.
  59528. */
  59529. isReady(): boolean;
  59530. /**
  59531. * Render the texture to its associated render target.
  59532. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  59533. */
  59534. render(useCameraPostProcess?: boolean): void;
  59535. /**
  59536. * Update the list of dependant textures samplers in the shader.
  59537. */
  59538. updateTextures(): void;
  59539. /**
  59540. * Update the uniform values of the procedural texture in the shader.
  59541. */
  59542. updateShaderUniforms(): void;
  59543. /**
  59544. * Define if the texture animates or not.
  59545. */
  59546. get animate(): boolean;
  59547. set animate(value: boolean);
  59548. }
  59549. }
  59550. declare module "babylonjs/Shaders/noise.fragment" {
  59551. /** @hidden */
  59552. export var noisePixelShader: {
  59553. name: string;
  59554. shader: string;
  59555. };
  59556. }
  59557. declare module "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture" {
  59558. import { Nullable } from "babylonjs/types";
  59559. import { Scene } from "babylonjs/scene";
  59560. import { Texture } from "babylonjs/Materials/Textures/texture";
  59561. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  59562. import "babylonjs/Shaders/noise.fragment";
  59563. /**
  59564. * Class used to generate noise procedural textures
  59565. */
  59566. export class NoiseProceduralTexture extends ProceduralTexture {
  59567. private _time;
  59568. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  59569. brightness: number;
  59570. /** Defines the number of octaves to process */
  59571. octaves: number;
  59572. /** Defines the level of persistence (0.8 by default) */
  59573. persistence: number;
  59574. /** Gets or sets animation speed factor (default is 1) */
  59575. animationSpeedFactor: number;
  59576. /**
  59577. * Creates a new NoiseProceduralTexture
  59578. * @param name defines the name fo the texture
  59579. * @param size defines the size of the texture (default is 256)
  59580. * @param scene defines the hosting scene
  59581. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  59582. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  59583. */
  59584. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  59585. private _updateShaderUniforms;
  59586. protected _getDefines(): string;
  59587. /** Generate the current state of the procedural texture */
  59588. render(useCameraPostProcess?: boolean): void;
  59589. /**
  59590. * Serializes this noise procedural texture
  59591. * @returns a serialized noise procedural texture object
  59592. */
  59593. serialize(): any;
  59594. /**
  59595. * Clone the texture.
  59596. * @returns the cloned texture
  59597. */
  59598. clone(): NoiseProceduralTexture;
  59599. /**
  59600. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  59601. * @param parsedTexture defines parsed texture data
  59602. * @param scene defines the current scene
  59603. * @param rootUrl defines the root URL containing noise procedural texture information
  59604. * @returns a parsed NoiseProceduralTexture
  59605. */
  59606. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  59607. }
  59608. }
  59609. declare module "babylonjs/Materials/Textures/Procedurals/index" {
  59610. export * from "babylonjs/Materials/Textures/Procedurals/customProceduralTexture";
  59611. export * from "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture";
  59612. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  59613. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent";
  59614. }
  59615. declare module "babylonjs/Materials/Textures/rawCubeTexture" {
  59616. import { Nullable } from "babylonjs/types";
  59617. import { Scene } from "babylonjs/scene";
  59618. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  59619. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  59620. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  59621. import "babylonjs/Engines/Extensions/engine.rawTexture";
  59622. /**
  59623. * Raw cube texture where the raw buffers are passed in
  59624. */
  59625. export class RawCubeTexture extends CubeTexture {
  59626. /**
  59627. * Creates a cube texture where the raw buffers are passed in.
  59628. * @param scene defines the scene the texture is attached to
  59629. * @param data defines the array of data to use to create each face
  59630. * @param size defines the size of the textures
  59631. * @param format defines the format of the data
  59632. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  59633. * @param generateMipMaps defines if the engine should generate the mip levels
  59634. * @param invertY defines if data must be stored with Y axis inverted
  59635. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  59636. * @param compression defines the compression used (null by default)
  59637. */
  59638. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  59639. /**
  59640. * Updates the raw cube texture.
  59641. * @param data defines the data to store
  59642. * @param format defines the data format
  59643. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  59644. * @param invertY defines if data must be stored with Y axis inverted
  59645. * @param compression defines the compression used (null by default)
  59646. * @param level defines which level of the texture to update
  59647. */
  59648. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  59649. /**
  59650. * Updates a raw cube texture with RGBD encoded data.
  59651. * @param data defines the array of data [mipmap][face] to use to create each face
  59652. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  59653. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  59654. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  59655. * @returns a promsie that resolves when the operation is complete
  59656. */
  59657. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  59658. /**
  59659. * Clones the raw cube texture.
  59660. * @return a new cube texture
  59661. */
  59662. clone(): CubeTexture;
  59663. /** @hidden */
  59664. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  59665. }
  59666. }
  59667. declare module "babylonjs/Materials/Textures/rawTexture3D" {
  59668. import { Scene } from "babylonjs/scene";
  59669. import { Texture } from "babylonjs/Materials/Textures/texture";
  59670. import "babylonjs/Engines/Extensions/engine.rawTexture";
  59671. /**
  59672. * Class used to store 3D textures containing user data
  59673. */
  59674. export class RawTexture3D extends Texture {
  59675. /** Gets or sets the texture format to use */
  59676. format: number;
  59677. private _engine;
  59678. /**
  59679. * Create a new RawTexture3D
  59680. * @param data defines the data of the texture
  59681. * @param width defines the width of the texture
  59682. * @param height defines the height of the texture
  59683. * @param depth defines the depth of the texture
  59684. * @param format defines the texture format to use
  59685. * @param scene defines the hosting scene
  59686. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  59687. * @param invertY defines if texture must be stored with Y axis inverted
  59688. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  59689. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  59690. */
  59691. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  59692. /** Gets or sets the texture format to use */
  59693. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  59694. /**
  59695. * Update the texture with new data
  59696. * @param data defines the data to store in the texture
  59697. */
  59698. update(data: ArrayBufferView): void;
  59699. }
  59700. }
  59701. declare module "babylonjs/Materials/Textures/rawTexture2DArray" {
  59702. import { Scene } from "babylonjs/scene";
  59703. import { Texture } from "babylonjs/Materials/Textures/texture";
  59704. import "babylonjs/Engines/Extensions/engine.rawTexture";
  59705. /**
  59706. * Class used to store 2D array textures containing user data
  59707. */
  59708. export class RawTexture2DArray extends Texture {
  59709. /** Gets or sets the texture format to use */
  59710. format: number;
  59711. private _engine;
  59712. /**
  59713. * Create a new RawTexture2DArray
  59714. * @param data defines the data of the texture
  59715. * @param width defines the width of the texture
  59716. * @param height defines the height of the texture
  59717. * @param depth defines the number of layers of the texture
  59718. * @param format defines the texture format to use
  59719. * @param scene defines the hosting scene
  59720. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  59721. * @param invertY defines if texture must be stored with Y axis inverted
  59722. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  59723. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  59724. */
  59725. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  59726. /** Gets or sets the texture format to use */
  59727. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  59728. /**
  59729. * Update the texture with new data
  59730. * @param data defines the data to store in the texture
  59731. */
  59732. update(data: ArrayBufferView): void;
  59733. }
  59734. }
  59735. declare module "babylonjs/Materials/Textures/refractionTexture" {
  59736. import { Scene } from "babylonjs/scene";
  59737. import { Plane } from "babylonjs/Maths/math.plane";
  59738. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  59739. /**
  59740. * Creates a refraction texture used by refraction channel of the standard material.
  59741. * It is like a mirror but to see through a material.
  59742. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  59743. */
  59744. export class RefractionTexture extends RenderTargetTexture {
  59745. /**
  59746. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  59747. * 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.
  59748. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  59749. */
  59750. refractionPlane: Plane;
  59751. /**
  59752. * Define how deep under the surface we should see.
  59753. */
  59754. depth: number;
  59755. /**
  59756. * Creates a refraction texture used by refraction channel of the standard material.
  59757. * It is like a mirror but to see through a material.
  59758. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  59759. * @param name Define the texture name
  59760. * @param size Define the size of the underlying texture
  59761. * @param scene Define the scene the refraction belongs to
  59762. * @param generateMipMaps Define if we need to generate mips level for the refraction
  59763. */
  59764. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  59765. /**
  59766. * Clone the refraction texture.
  59767. * @returns the cloned texture
  59768. */
  59769. clone(): RefractionTexture;
  59770. /**
  59771. * Serialize the texture to a JSON representation you could use in Parse later on
  59772. * @returns the serialized JSON representation
  59773. */
  59774. serialize(): any;
  59775. }
  59776. }
  59777. declare module "babylonjs/Materials/Textures/htmlElementTexture" {
  59778. import { Nullable } from "babylonjs/types";
  59779. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  59780. import { Matrix } from "babylonjs/Maths/math.vector";
  59781. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  59782. import "babylonjs/Engines/Extensions/engine.videoTexture";
  59783. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  59784. import { Scene } from "babylonjs/scene";
  59785. /**
  59786. * Defines the options related to the creation of an HtmlElementTexture
  59787. */
  59788. export interface IHtmlElementTextureOptions {
  59789. /**
  59790. * Defines wether mip maps should be created or not.
  59791. */
  59792. generateMipMaps?: boolean;
  59793. /**
  59794. * Defines the sampling mode of the texture.
  59795. */
  59796. samplingMode?: number;
  59797. /**
  59798. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  59799. */
  59800. engine: Nullable<ThinEngine>;
  59801. /**
  59802. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  59803. */
  59804. scene: Nullable<Scene>;
  59805. }
  59806. /**
  59807. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  59808. * To be as efficient as possible depending on your constraints nothing aside the first upload
  59809. * is automatically managed.
  59810. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  59811. * in your application.
  59812. *
  59813. * As the update is not automatic, you need to call them manually.
  59814. */
  59815. export class HtmlElementTexture extends BaseTexture {
  59816. /**
  59817. * The texture URL.
  59818. */
  59819. element: HTMLVideoElement | HTMLCanvasElement;
  59820. private static readonly DefaultOptions;
  59821. private _textureMatrix;
  59822. private _engine;
  59823. private _isVideo;
  59824. private _generateMipMaps;
  59825. private _samplingMode;
  59826. /**
  59827. * Instantiates a HtmlElementTexture from the following parameters.
  59828. *
  59829. * @param name Defines the name of the texture
  59830. * @param element Defines the video or canvas the texture is filled with
  59831. * @param options Defines the other none mandatory texture creation options
  59832. */
  59833. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  59834. private _createInternalTexture;
  59835. /**
  59836. * Returns the texture matrix used in most of the material.
  59837. */
  59838. getTextureMatrix(): Matrix;
  59839. /**
  59840. * Updates the content of the texture.
  59841. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  59842. */
  59843. update(invertY?: Nullable<boolean>): void;
  59844. }
  59845. }
  59846. declare module "babylonjs/Materials/Textures/Packer/frame" {
  59847. import { Vector2 } from "babylonjs/Maths/math.vector";
  59848. /**
  59849. * Defines the basic options interface of a TexturePacker Frame
  59850. */
  59851. export interface ITexturePackerFrame {
  59852. /**
  59853. * The frame ID
  59854. */
  59855. id: number;
  59856. /**
  59857. * The frames Scale
  59858. */
  59859. scale: Vector2;
  59860. /**
  59861. * The Frames offset
  59862. */
  59863. offset: Vector2;
  59864. }
  59865. /**
  59866. * This is a support class for frame Data on texture packer sets.
  59867. */
  59868. export class TexturePackerFrame implements ITexturePackerFrame {
  59869. /**
  59870. * The frame ID
  59871. */
  59872. id: number;
  59873. /**
  59874. * The frames Scale
  59875. */
  59876. scale: Vector2;
  59877. /**
  59878. * The Frames offset
  59879. */
  59880. offset: Vector2;
  59881. /**
  59882. * Initializes a texture package frame.
  59883. * @param id The numerical frame identifier
  59884. * @param scale Scalar Vector2 for UV frame
  59885. * @param offset Vector2 for the frame position in UV units.
  59886. * @returns TexturePackerFrame
  59887. */
  59888. constructor(id: number, scale: Vector2, offset: Vector2);
  59889. }
  59890. }
  59891. declare module "babylonjs/Materials/Textures/Packer/packer" {
  59892. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59893. import { Scene } from "babylonjs/scene";
  59894. import { Nullable } from "babylonjs/types";
  59895. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  59896. import { TexturePackerFrame } from "babylonjs/Materials/Textures/Packer/frame";
  59897. /**
  59898. * Defines the basic options interface of a TexturePacker
  59899. */
  59900. export interface ITexturePackerOptions {
  59901. /**
  59902. * Custom targets for the channels of a texture packer. Default is all the channels of the Standard Material
  59903. */
  59904. map?: string[];
  59905. /**
  59906. * the UV input targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  59907. */
  59908. uvsIn?: string;
  59909. /**
  59910. * the UV output targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  59911. */
  59912. uvsOut?: string;
  59913. /**
  59914. * number representing the layout style. Defaults to LAYOUT_STRIP
  59915. */
  59916. layout?: number;
  59917. /**
  59918. * number of columns if using custom column count layout(2). This defaults to 4.
  59919. */
  59920. colnum?: number;
  59921. /**
  59922. * flag to update the input meshes to the new packed texture after compilation. Defaults to true.
  59923. */
  59924. updateInputMeshes?: boolean;
  59925. /**
  59926. * boolean flag to dispose all the source textures. Defaults to true.
  59927. */
  59928. disposeSources?: boolean;
  59929. /**
  59930. * Fills the blank cells in a set to the customFillColor. Defaults to true.
  59931. */
  59932. fillBlanks?: boolean;
  59933. /**
  59934. * string value representing the context fill style color. Defaults to 'black'.
  59935. */
  59936. customFillColor?: string;
  59937. /**
  59938. * Width and Height Value of each Frame in the TexturePacker Sets
  59939. */
  59940. frameSize?: number;
  59941. /**
  59942. * Ratio of the value to add padding wise to each cell. Defaults to 0.0115
  59943. */
  59944. paddingRatio?: number;
  59945. /**
  59946. * Number that declares the fill method for the padding gutter.
  59947. */
  59948. paddingMode?: number;
  59949. /**
  59950. * If in SUBUV_COLOR padding mode what color to use.
  59951. */
  59952. paddingColor?: Color3 | Color4;
  59953. }
  59954. /**
  59955. * Defines the basic interface of a TexturePacker JSON File
  59956. */
  59957. export interface ITexturePackerJSON {
  59958. /**
  59959. * The frame ID
  59960. */
  59961. name: string;
  59962. /**
  59963. * The base64 channel data
  59964. */
  59965. sets: any;
  59966. /**
  59967. * The options of the Packer
  59968. */
  59969. options: ITexturePackerOptions;
  59970. /**
  59971. * The frame data of the Packer
  59972. */
  59973. frames: Array<number>;
  59974. }
  59975. /**
  59976. * This is a support class that generates a series of packed texture sets.
  59977. * @see https://doc.babylonjs.com/babylon101/materials
  59978. */
  59979. export class TexturePacker {
  59980. /** Packer Layout Constant 0 */
  59981. static readonly LAYOUT_STRIP: number;
  59982. /** Packer Layout Constant 1 */
  59983. static readonly LAYOUT_POWER2: number;
  59984. /** Packer Layout Constant 2 */
  59985. static readonly LAYOUT_COLNUM: number;
  59986. /** Packer Layout Constant 0 */
  59987. static readonly SUBUV_WRAP: number;
  59988. /** Packer Layout Constant 1 */
  59989. static readonly SUBUV_EXTEND: number;
  59990. /** Packer Layout Constant 2 */
  59991. static readonly SUBUV_COLOR: number;
  59992. /** The Name of the Texture Package */
  59993. name: string;
  59994. /** The scene scope of the TexturePacker */
  59995. scene: Scene;
  59996. /** The Meshes to target */
  59997. meshes: AbstractMesh[];
  59998. /** Arguments passed with the Constructor */
  59999. options: ITexturePackerOptions;
  60000. /** The promise that is started upon initialization */
  60001. promise: Nullable<Promise<TexturePacker | string>>;
  60002. /** The Container object for the channel sets that are generated */
  60003. sets: object;
  60004. /** The Container array for the frames that are generated */
  60005. frames: TexturePackerFrame[];
  60006. /** The expected number of textures the system is parsing. */
  60007. private _expecting;
  60008. /** The padding value from Math.ceil(frameSize * paddingRatio) */
  60009. private _paddingValue;
  60010. /**
  60011. * Initializes a texture package series from an array of meshes or a single mesh.
  60012. * @param name The name of the package
  60013. * @param meshes The target meshes to compose the package from
  60014. * @param options The arguments that texture packer should follow while building.
  60015. * @param scene The scene which the textures are scoped to.
  60016. * @returns TexturePacker
  60017. */
  60018. constructor(name: string, meshes: AbstractMesh[], options: ITexturePackerOptions, scene: Scene);
  60019. /**
  60020. * Starts the package process
  60021. * @param resolve The promises resolution function
  60022. * @returns TexturePacker
  60023. */
  60024. private _createFrames;
  60025. /**
  60026. * Calculates the Size of the Channel Sets
  60027. * @returns Vector2
  60028. */
  60029. private _calculateSize;
  60030. /**
  60031. * Calculates the UV data for the frames.
  60032. * @param baseSize the base frameSize
  60033. * @param padding the base frame padding
  60034. * @param dtSize size of the Dynamic Texture for that channel
  60035. * @param dtUnits is 1/dtSize
  60036. * @param update flag to update the input meshes
  60037. */
  60038. private _calculateMeshUVFrames;
  60039. /**
  60040. * Calculates the frames Offset.
  60041. * @param index of the frame
  60042. * @returns Vector2
  60043. */
  60044. private _getFrameOffset;
  60045. /**
  60046. * Updates a Mesh to the frame data
  60047. * @param mesh that is the target
  60048. * @param frameID or the frame index
  60049. */
  60050. private _updateMeshUV;
  60051. /**
  60052. * Updates a Meshes materials to use the texture packer channels
  60053. * @param m is the mesh to target
  60054. * @param force all channels on the packer to be set.
  60055. */
  60056. private _updateTextureReferences;
  60057. /**
  60058. * Public method to set a Mesh to a frame
  60059. * @param m that is the target
  60060. * @param frameID or the frame index
  60061. * @param updateMaterial trigger for if the Meshes attached Material be updated?
  60062. */
  60063. setMeshToFrame(m: AbstractMesh, frameID: number, updateMaterial?: boolean): void;
  60064. /**
  60065. * Starts the async promise to compile the texture packer.
  60066. * @returns Promise<void>
  60067. */
  60068. processAsync(): Promise<void>;
  60069. /**
  60070. * Disposes all textures associated with this packer
  60071. */
  60072. dispose(): void;
  60073. /**
  60074. * Starts the download process for all the channels converting them to base64 data and embedding it all in a JSON file.
  60075. * @param imageType is the image type to use.
  60076. * @param quality of the image if downloading as jpeg, Ranges from >0 to 1.
  60077. */
  60078. download(imageType?: string, quality?: number): void;
  60079. /**
  60080. * Public method to load a texturePacker JSON file.
  60081. * @param data of the JSON file in string format.
  60082. */
  60083. updateFromJSON(data: string): void;
  60084. }
  60085. }
  60086. declare module "babylonjs/Materials/Textures/Packer/index" {
  60087. export * from "babylonjs/Materials/Textures/Packer/packer";
  60088. export * from "babylonjs/Materials/Textures/Packer/frame";
  60089. }
  60090. declare module "babylonjs/Materials/Textures/index" {
  60091. export * from "babylonjs/Materials/Textures/baseTexture";
  60092. export * from "babylonjs/Materials/Textures/baseTexture.polynomial";
  60093. export * from "babylonjs/Materials/Textures/colorGradingTexture";
  60094. export * from "babylonjs/Materials/Textures/cubeTexture";
  60095. export * from "babylonjs/Materials/Textures/dynamicTexture";
  60096. export * from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  60097. export * from "babylonjs/Materials/Textures/hdrCubeTexture";
  60098. export * from "babylonjs/Materials/Textures/internalTexture";
  60099. export * from "babylonjs/Materials/Textures/internalTextureLoader";
  60100. export * from "babylonjs/Materials/Textures/Loaders/index";
  60101. export * from "babylonjs/Materials/Textures/mirrorTexture";
  60102. export * from "babylonjs/Materials/Textures/multiRenderTarget";
  60103. export * from "babylonjs/Materials/Textures/Procedurals/index";
  60104. export * from "babylonjs/Materials/Textures/rawCubeTexture";
  60105. export * from "babylonjs/Materials/Textures/rawTexture";
  60106. export * from "babylonjs/Materials/Textures/rawTexture3D";
  60107. export * from "babylonjs/Materials/Textures/rawTexture2DArray";
  60108. export * from "babylonjs/Materials/Textures/refractionTexture";
  60109. export * from "babylonjs/Materials/Textures/renderTargetTexture";
  60110. export * from "babylonjs/Materials/Textures/texture";
  60111. export * from "babylonjs/Materials/Textures/videoTexture";
  60112. export * from "babylonjs/Materials/Textures/htmlElementTexture";
  60113. export * from "babylonjs/Materials/Textures/Packer/index";
  60114. }
  60115. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets" {
  60116. /**
  60117. * Enum used to define the target of a block
  60118. */
  60119. export enum NodeMaterialBlockTargets {
  60120. /** Vertex shader */
  60121. Vertex = 1,
  60122. /** Fragment shader */
  60123. Fragment = 2,
  60124. /** Neutral */
  60125. Neutral = 4,
  60126. /** Vertex and Fragment */
  60127. VertexAndFragment = 3
  60128. }
  60129. }
  60130. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes" {
  60131. /**
  60132. * Defines the kind of connection point for node based material
  60133. */
  60134. export enum NodeMaterialBlockConnectionPointTypes {
  60135. /** Float */
  60136. Float = 1,
  60137. /** Int */
  60138. Int = 2,
  60139. /** Vector2 */
  60140. Vector2 = 4,
  60141. /** Vector3 */
  60142. Vector3 = 8,
  60143. /** Vector4 */
  60144. Vector4 = 16,
  60145. /** Color3 */
  60146. Color3 = 32,
  60147. /** Color4 */
  60148. Color4 = 64,
  60149. /** Matrix */
  60150. Matrix = 128,
  60151. /** Custom object */
  60152. Object = 256,
  60153. /** Detect type based on connection */
  60154. AutoDetect = 1024,
  60155. /** Output type that will be defined by input type */
  60156. BasedOnInput = 2048
  60157. }
  60158. }
  60159. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointMode" {
  60160. /**
  60161. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  60162. */
  60163. export enum NodeMaterialBlockConnectionPointMode {
  60164. /** Value is an uniform */
  60165. Uniform = 0,
  60166. /** Value is a mesh attribute */
  60167. Attribute = 1,
  60168. /** Value is a varying between vertex and fragment shaders */
  60169. Varying = 2,
  60170. /** Mode is undefined */
  60171. Undefined = 3
  60172. }
  60173. }
  60174. declare module "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues" {
  60175. /**
  60176. * Enum used to define system values e.g. values automatically provided by the system
  60177. */
  60178. export enum NodeMaterialSystemValues {
  60179. /** World */
  60180. World = 1,
  60181. /** View */
  60182. View = 2,
  60183. /** Projection */
  60184. Projection = 3,
  60185. /** ViewProjection */
  60186. ViewProjection = 4,
  60187. /** WorldView */
  60188. WorldView = 5,
  60189. /** WorldViewProjection */
  60190. WorldViewProjection = 6,
  60191. /** CameraPosition */
  60192. CameraPosition = 7,
  60193. /** Fog Color */
  60194. FogColor = 8,
  60195. /** Delta time */
  60196. DeltaTime = 9
  60197. }
  60198. }
  60199. declare module "babylonjs/Materials/Node/Enums/index" {
  60200. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  60201. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  60202. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointMode";
  60203. export * from "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues";
  60204. }
  60205. declare module "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer" {
  60206. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60207. /**
  60208. * Root class for all node material optimizers
  60209. */
  60210. export class NodeMaterialOptimizer {
  60211. /**
  60212. * Function used to optimize a NodeMaterial graph
  60213. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  60214. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  60215. */
  60216. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  60217. }
  60218. }
  60219. declare module "babylonjs/Materials/Node/Blocks/transformBlock" {
  60220. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60221. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60222. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60223. import { Scene } from "babylonjs/scene";
  60224. /**
  60225. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  60226. */
  60227. export class TransformBlock extends NodeMaterialBlock {
  60228. /**
  60229. * Defines the value to use to complement W value to transform it to a Vector4
  60230. */
  60231. complementW: number;
  60232. /**
  60233. * Defines the value to use to complement z value to transform it to a Vector4
  60234. */
  60235. complementZ: number;
  60236. /**
  60237. * Creates a new TransformBlock
  60238. * @param name defines the block name
  60239. */
  60240. constructor(name: string);
  60241. /**
  60242. * Gets the current class name
  60243. * @returns the class name
  60244. */
  60245. getClassName(): string;
  60246. /**
  60247. * Gets the vector input
  60248. */
  60249. get vector(): NodeMaterialConnectionPoint;
  60250. /**
  60251. * Gets the output component
  60252. */
  60253. get output(): NodeMaterialConnectionPoint;
  60254. /**
  60255. * Gets the xyz output component
  60256. */
  60257. get xyz(): NodeMaterialConnectionPoint;
  60258. /**
  60259. * Gets the matrix transform input
  60260. */
  60261. get transform(): NodeMaterialConnectionPoint;
  60262. protected _buildBlock(state: NodeMaterialBuildState): this;
  60263. serialize(): any;
  60264. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  60265. protected _dumpPropertiesCode(): string;
  60266. }
  60267. }
  60268. declare module "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock" {
  60269. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60270. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60271. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60272. /**
  60273. * Block used to output the vertex position
  60274. */
  60275. export class VertexOutputBlock extends NodeMaterialBlock {
  60276. /**
  60277. * Creates a new VertexOutputBlock
  60278. * @param name defines the block name
  60279. */
  60280. constructor(name: string);
  60281. /**
  60282. * Gets the current class name
  60283. * @returns the class name
  60284. */
  60285. getClassName(): string;
  60286. /**
  60287. * Gets the vector input component
  60288. */
  60289. get vector(): NodeMaterialConnectionPoint;
  60290. protected _buildBlock(state: NodeMaterialBuildState): this;
  60291. }
  60292. }
  60293. declare module "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock" {
  60294. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60295. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60296. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60297. /**
  60298. * Block used to output the final color
  60299. */
  60300. export class FragmentOutputBlock extends NodeMaterialBlock {
  60301. /**
  60302. * Create a new FragmentOutputBlock
  60303. * @param name defines the block name
  60304. */
  60305. constructor(name: string);
  60306. /**
  60307. * Gets the current class name
  60308. * @returns the class name
  60309. */
  60310. getClassName(): string;
  60311. /**
  60312. * Gets the rgba input component
  60313. */
  60314. get rgba(): NodeMaterialConnectionPoint;
  60315. /**
  60316. * Gets the rgb input component
  60317. */
  60318. get rgb(): NodeMaterialConnectionPoint;
  60319. /**
  60320. * Gets the a input component
  60321. */
  60322. get a(): NodeMaterialConnectionPoint;
  60323. protected _buildBlock(state: NodeMaterialBuildState): this;
  60324. }
  60325. }
  60326. declare module "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock" {
  60327. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60328. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60329. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60330. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  60331. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60332. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  60333. import { Effect } from "babylonjs/Materials/effect";
  60334. import { Mesh } from "babylonjs/Meshes/mesh";
  60335. import { Nullable } from "babylonjs/types";
  60336. import { Scene } from "babylonjs/scene";
  60337. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  60338. /**
  60339. * Base block used to read a reflection texture from a sampler
  60340. */
  60341. export abstract class ReflectionTextureBaseBlock extends NodeMaterialBlock {
  60342. /** @hidden */
  60343. _define3DName: string;
  60344. /** @hidden */
  60345. _defineCubicName: string;
  60346. /** @hidden */
  60347. _defineExplicitName: string;
  60348. /** @hidden */
  60349. _defineProjectionName: string;
  60350. /** @hidden */
  60351. _defineLocalCubicName: string;
  60352. /** @hidden */
  60353. _defineSphericalName: string;
  60354. /** @hidden */
  60355. _definePlanarName: string;
  60356. /** @hidden */
  60357. _defineEquirectangularName: string;
  60358. /** @hidden */
  60359. _defineMirroredEquirectangularFixedName: string;
  60360. /** @hidden */
  60361. _defineEquirectangularFixedName: string;
  60362. /** @hidden */
  60363. _defineSkyboxName: string;
  60364. /** @hidden */
  60365. _defineOppositeZ: string;
  60366. /** @hidden */
  60367. _cubeSamplerName: string;
  60368. /** @hidden */
  60369. _2DSamplerName: string;
  60370. protected _positionUVWName: string;
  60371. protected _directionWName: string;
  60372. protected _reflectionVectorName: string;
  60373. /** @hidden */
  60374. _reflectionCoordsName: string;
  60375. protected _reflectionMatrixName: string;
  60376. protected _reflectionColorName: string;
  60377. /**
  60378. * Gets or sets the texture associated with the node
  60379. */
  60380. texture: Nullable<BaseTexture>;
  60381. /**
  60382. * Create a new ReflectionTextureBaseBlock
  60383. * @param name defines the block name
  60384. */
  60385. constructor(name: string);
  60386. /**
  60387. * Gets the current class name
  60388. * @returns the class name
  60389. */
  60390. getClassName(): string;
  60391. /**
  60392. * Gets the world position input component
  60393. */
  60394. abstract get position(): NodeMaterialConnectionPoint;
  60395. /**
  60396. * Gets the world position input component
  60397. */
  60398. abstract get worldPosition(): NodeMaterialConnectionPoint;
  60399. /**
  60400. * Gets the world normal input component
  60401. */
  60402. abstract get worldNormal(): NodeMaterialConnectionPoint;
  60403. /**
  60404. * Gets the world input component
  60405. */
  60406. abstract get world(): NodeMaterialConnectionPoint;
  60407. /**
  60408. * Gets the camera (or eye) position component
  60409. */
  60410. abstract get cameraPosition(): NodeMaterialConnectionPoint;
  60411. /**
  60412. * Gets the view input component
  60413. */
  60414. abstract get view(): NodeMaterialConnectionPoint;
  60415. protected _getTexture(): Nullable<BaseTexture>;
  60416. autoConfigure(material: NodeMaterial): void;
  60417. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  60418. isReady(): boolean;
  60419. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  60420. /**
  60421. * Gets the code to inject in the vertex shader
  60422. * @param state current state of the node material building
  60423. * @returns the shader code
  60424. */
  60425. handleVertexSide(state: NodeMaterialBuildState): string;
  60426. /**
  60427. * Handles the inits for the fragment code path
  60428. * @param state node material build state
  60429. */
  60430. handleFragmentSideInits(state: NodeMaterialBuildState): void;
  60431. /**
  60432. * Generates the reflection coords code for the fragment code path
  60433. * @param worldNormalVarName name of the world normal variable
  60434. * @param worldPos name of the world position variable. If not provided, will use the world position connected to this block
  60435. * @param onlyReflectionVector if true, generates code only for the reflection vector computation, not for the reflection coordinates
  60436. * @returns the shader code
  60437. */
  60438. handleFragmentSideCodeReflectionCoords(worldNormalVarName: string, worldPos?: string, onlyReflectionVector?: boolean): string;
  60439. /**
  60440. * Generates the reflection color code for the fragment code path
  60441. * @param lodVarName name of the lod variable
  60442. * @param swizzleLookupTexture swizzle to use for the final color variable
  60443. * @returns the shader code
  60444. */
  60445. handleFragmentSideCodeReflectionColor(lodVarName?: string, swizzleLookupTexture?: string): string;
  60446. /**
  60447. * Generates the code corresponding to the connected output points
  60448. * @param state node material build state
  60449. * @param varName name of the variable to output
  60450. * @returns the shader code
  60451. */
  60452. writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  60453. protected _buildBlock(state: NodeMaterialBuildState): this;
  60454. protected _dumpPropertiesCode(): string;
  60455. serialize(): any;
  60456. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  60457. }
  60458. }
  60459. declare module "babylonjs/Materials/Node/nodeMaterial" {
  60460. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60461. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  60462. import { Scene } from "babylonjs/scene";
  60463. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60464. import { Matrix } from "babylonjs/Maths/math.vector";
  60465. import { Mesh } from "babylonjs/Meshes/mesh";
  60466. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  60467. import { Observable } from "babylonjs/Misc/observable";
  60468. import { SubMesh } from "babylonjs/Meshes/subMesh";
  60469. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  60470. import { NodeMaterialOptimizer } from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  60471. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  60472. import { Nullable } from "babylonjs/types";
  60473. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  60474. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  60475. import { ReflectionTextureBaseBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock";
  60476. /**
  60477. * Interface used to configure the node material editor
  60478. */
  60479. export interface INodeMaterialEditorOptions {
  60480. /** Define the URl to load node editor script */
  60481. editorURL?: string;
  60482. }
  60483. /** @hidden */
  60484. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  60485. NORMAL: boolean;
  60486. TANGENT: boolean;
  60487. UV1: boolean;
  60488. /** BONES */
  60489. NUM_BONE_INFLUENCERS: number;
  60490. BonesPerMesh: number;
  60491. BONETEXTURE: boolean;
  60492. /** MORPH TARGETS */
  60493. MORPHTARGETS: boolean;
  60494. MORPHTARGETS_NORMAL: boolean;
  60495. MORPHTARGETS_TANGENT: boolean;
  60496. MORPHTARGETS_UV: boolean;
  60497. NUM_MORPH_INFLUENCERS: number;
  60498. /** IMAGE PROCESSING */
  60499. IMAGEPROCESSING: boolean;
  60500. VIGNETTE: boolean;
  60501. VIGNETTEBLENDMODEMULTIPLY: boolean;
  60502. VIGNETTEBLENDMODEOPAQUE: boolean;
  60503. TONEMAPPING: boolean;
  60504. TONEMAPPING_ACES: boolean;
  60505. CONTRAST: boolean;
  60506. EXPOSURE: boolean;
  60507. COLORCURVES: boolean;
  60508. COLORGRADING: boolean;
  60509. COLORGRADING3D: boolean;
  60510. SAMPLER3DGREENDEPTH: boolean;
  60511. SAMPLER3DBGRMAP: boolean;
  60512. IMAGEPROCESSINGPOSTPROCESS: boolean;
  60513. /** MISC. */
  60514. BUMPDIRECTUV: number;
  60515. constructor();
  60516. setValue(name: string, value: any): void;
  60517. }
  60518. /**
  60519. * Class used to configure NodeMaterial
  60520. */
  60521. export interface INodeMaterialOptions {
  60522. /**
  60523. * Defines if blocks should emit comments
  60524. */
  60525. emitComments: boolean;
  60526. }
  60527. /**
  60528. * Class used to create a node based material built by assembling shader blocks
  60529. */
  60530. export class NodeMaterial extends PushMaterial {
  60531. private static _BuildIdGenerator;
  60532. private _options;
  60533. private _vertexCompilationState;
  60534. private _fragmentCompilationState;
  60535. private _sharedData;
  60536. private _buildId;
  60537. private _buildWasSuccessful;
  60538. private _cachedWorldViewMatrix;
  60539. private _cachedWorldViewProjectionMatrix;
  60540. private _optimizers;
  60541. private _animationFrame;
  60542. /** Define the Url to load node editor script */
  60543. static EditorURL: string;
  60544. /** Define the Url to load snippets */
  60545. static SnippetUrl: string;
  60546. /** Gets or sets a boolean indicating that node materials should not deserialize textures from json / snippet content */
  60547. static IgnoreTexturesAtLoadTime: boolean;
  60548. private BJSNODEMATERIALEDITOR;
  60549. /** Get the inspector from bundle or global */
  60550. private _getGlobalNodeMaterialEditor;
  60551. /**
  60552. * Snippet ID if the material was created from the snippet server
  60553. */
  60554. snippetId: string;
  60555. /**
  60556. * Gets or sets data used by visual editor
  60557. * @see https://nme.babylonjs.com
  60558. */
  60559. editorData: any;
  60560. /**
  60561. * 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)
  60562. */
  60563. ignoreAlpha: boolean;
  60564. /**
  60565. * Defines the maximum number of lights that can be used in the material
  60566. */
  60567. maxSimultaneousLights: number;
  60568. /**
  60569. * Observable raised when the material is built
  60570. */
  60571. onBuildObservable: Observable<NodeMaterial>;
  60572. /**
  60573. * Gets or sets the root nodes of the material vertex shader
  60574. */
  60575. _vertexOutputNodes: NodeMaterialBlock[];
  60576. /**
  60577. * Gets or sets the root nodes of the material fragment (pixel) shader
  60578. */
  60579. _fragmentOutputNodes: NodeMaterialBlock[];
  60580. /** Gets or sets options to control the node material overall behavior */
  60581. get options(): INodeMaterialOptions;
  60582. set options(options: INodeMaterialOptions);
  60583. /**
  60584. * Default configuration related to image processing available in the standard Material.
  60585. */
  60586. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  60587. /**
  60588. * Gets the image processing configuration used either in this material.
  60589. */
  60590. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  60591. /**
  60592. * Sets the Default image processing configuration used either in the this material.
  60593. *
  60594. * If sets to null, the scene one is in use.
  60595. */
  60596. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  60597. /**
  60598. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  60599. */
  60600. attachedBlocks: NodeMaterialBlock[];
  60601. /**
  60602. * Create a new node based material
  60603. * @param name defines the material name
  60604. * @param scene defines the hosting scene
  60605. * @param options defines creation option
  60606. */
  60607. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  60608. /**
  60609. * Gets the current class name of the material e.g. "NodeMaterial"
  60610. * @returns the class name
  60611. */
  60612. getClassName(): string;
  60613. /**
  60614. * Keep track of the image processing observer to allow dispose and replace.
  60615. */
  60616. private _imageProcessingObserver;
  60617. /**
  60618. * Attaches a new image processing configuration to the Standard Material.
  60619. * @param configuration
  60620. */
  60621. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  60622. /**
  60623. * Get a block by its name
  60624. * @param name defines the name of the block to retrieve
  60625. * @returns the required block or null if not found
  60626. */
  60627. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  60628. /**
  60629. * Get a block by its name
  60630. * @param predicate defines the predicate used to find the good candidate
  60631. * @returns the required block or null if not found
  60632. */
  60633. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  60634. /**
  60635. * Get an input block by its name
  60636. * @param predicate defines the predicate used to find the good candidate
  60637. * @returns the required input block or null if not found
  60638. */
  60639. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  60640. /**
  60641. * Gets the list of input blocks attached to this material
  60642. * @returns an array of InputBlocks
  60643. */
  60644. getInputBlocks(): InputBlock[];
  60645. /**
  60646. * Adds a new optimizer to the list of optimizers
  60647. * @param optimizer defines the optimizers to add
  60648. * @returns the current material
  60649. */
  60650. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  60651. /**
  60652. * Remove an optimizer from the list of optimizers
  60653. * @param optimizer defines the optimizers to remove
  60654. * @returns the current material
  60655. */
  60656. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  60657. /**
  60658. * Add a new block to the list of output nodes
  60659. * @param node defines the node to add
  60660. * @returns the current material
  60661. */
  60662. addOutputNode(node: NodeMaterialBlock): this;
  60663. /**
  60664. * Remove a block from the list of root nodes
  60665. * @param node defines the node to remove
  60666. * @returns the current material
  60667. */
  60668. removeOutputNode(node: NodeMaterialBlock): this;
  60669. private _addVertexOutputNode;
  60670. private _removeVertexOutputNode;
  60671. private _addFragmentOutputNode;
  60672. private _removeFragmentOutputNode;
  60673. /**
  60674. * Specifies if the material will require alpha blending
  60675. * @returns a boolean specifying if alpha blending is needed
  60676. */
  60677. needAlphaBlending(): boolean;
  60678. /**
  60679. * Specifies if this material should be rendered in alpha test mode
  60680. * @returns a boolean specifying if an alpha test is needed.
  60681. */
  60682. needAlphaTesting(): boolean;
  60683. private _initializeBlock;
  60684. private _resetDualBlocks;
  60685. /**
  60686. * Remove a block from the current node material
  60687. * @param block defines the block to remove
  60688. */
  60689. removeBlock(block: NodeMaterialBlock): void;
  60690. /**
  60691. * Build the material and generates the inner effect
  60692. * @param verbose defines if the build should log activity
  60693. */
  60694. build(verbose?: boolean): void;
  60695. /**
  60696. * Runs an otpimization phase to try to improve the shader code
  60697. */
  60698. optimize(): void;
  60699. private _prepareDefinesForAttributes;
  60700. /**
  60701. * Get if the submesh is ready to be used and all its information available.
  60702. * Child classes can use it to update shaders
  60703. * @param mesh defines the mesh to check
  60704. * @param subMesh defines which submesh to check
  60705. * @param useInstances specifies that instances should be used
  60706. * @returns a boolean indicating that the submesh is ready or not
  60707. */
  60708. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  60709. /**
  60710. * Get a string representing the shaders built by the current node graph
  60711. */
  60712. get compiledShaders(): string;
  60713. /**
  60714. * Binds the world matrix to the material
  60715. * @param world defines the world transformation matrix
  60716. */
  60717. bindOnlyWorldMatrix(world: Matrix): void;
  60718. /**
  60719. * Binds the submesh to this material by preparing the effect and shader to draw
  60720. * @param world defines the world transformation matrix
  60721. * @param mesh defines the mesh containing the submesh
  60722. * @param subMesh defines the submesh to bind the material to
  60723. */
  60724. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  60725. /**
  60726. * Gets the active textures from the material
  60727. * @returns an array of textures
  60728. */
  60729. getActiveTextures(): BaseTexture[];
  60730. /**
  60731. * Gets the list of texture blocks
  60732. * @returns an array of texture blocks
  60733. */
  60734. getTextureBlocks(): (TextureBlock | ReflectionTextureBaseBlock)[];
  60735. /**
  60736. * Specifies if the material uses a texture
  60737. * @param texture defines the texture to check against the material
  60738. * @returns a boolean specifying if the material uses the texture
  60739. */
  60740. hasTexture(texture: BaseTexture): boolean;
  60741. /**
  60742. * Disposes the material
  60743. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  60744. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  60745. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  60746. */
  60747. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  60748. /** Creates the node editor window. */
  60749. private _createNodeEditor;
  60750. /**
  60751. * Launch the node material editor
  60752. * @param config Define the configuration of the editor
  60753. * @return a promise fulfilled when the node editor is visible
  60754. */
  60755. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  60756. /**
  60757. * Clear the current material
  60758. */
  60759. clear(): void;
  60760. /**
  60761. * Clear the current material and set it to a default state
  60762. */
  60763. setToDefault(): void;
  60764. /**
  60765. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  60766. * @param url defines the url to load from
  60767. * @returns a promise that will fullfil when the material is fully loaded
  60768. */
  60769. loadAsync(url: string): Promise<void>;
  60770. private _gatherBlocks;
  60771. /**
  60772. * Generate a string containing the code declaration required to create an equivalent of this material
  60773. * @returns a string
  60774. */
  60775. generateCode(): string;
  60776. /**
  60777. * Serializes this material in a JSON representation
  60778. * @returns the serialized material object
  60779. */
  60780. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  60781. private _restoreConnections;
  60782. /**
  60783. * Clear the current graph and load a new one from a serialization object
  60784. * @param source defines the JSON representation of the material
  60785. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  60786. */
  60787. loadFromSerialization(source: any, rootUrl?: string): void;
  60788. /**
  60789. * Makes a duplicate of the current material.
  60790. * @param name - name to use for the new material.
  60791. */
  60792. clone(name: string): NodeMaterial;
  60793. /**
  60794. * Creates a node material from parsed material data
  60795. * @param source defines the JSON representation of the material
  60796. * @param scene defines the hosting scene
  60797. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  60798. * @returns a new node material
  60799. */
  60800. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  60801. /**
  60802. * Creates a node material from a snippet saved in a remote file
  60803. * @param name defines the name of the material to create
  60804. * @param url defines the url to load from
  60805. * @param scene defines the hosting scene
  60806. * @returns a promise that will resolve to the new node material
  60807. */
  60808. static ParseFromFileAsync(name: string, url: string, scene: Scene): Promise<NodeMaterial>;
  60809. /**
  60810. * Creates a node material from a snippet saved by the node material editor
  60811. * @param snippetId defines the snippet to load
  60812. * @param scene defines the hosting scene
  60813. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  60814. * @param nodeMaterial defines a node material to update (instead of creating a new one)
  60815. * @returns a promise that will resolve to the new node material
  60816. */
  60817. static ParseFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string, nodeMaterial?: NodeMaterial): Promise<NodeMaterial>;
  60818. /**
  60819. * Creates a new node material set to default basic configuration
  60820. * @param name defines the name of the material
  60821. * @param scene defines the hosting scene
  60822. * @returns a new NodeMaterial
  60823. */
  60824. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  60825. }
  60826. }
  60827. declare module "babylonjs/Materials/Node/Blocks/Dual/textureBlock" {
  60828. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60829. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60830. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  60831. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60832. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60833. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  60834. import { Effect } from "babylonjs/Materials/effect";
  60835. import { Mesh } from "babylonjs/Meshes/mesh";
  60836. import { Nullable } from "babylonjs/types";
  60837. import { Texture } from "babylonjs/Materials/Textures/texture";
  60838. import { Scene } from "babylonjs/scene";
  60839. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  60840. /**
  60841. * Block used to read a texture from a sampler
  60842. */
  60843. export class TextureBlock extends NodeMaterialBlock {
  60844. private _defineName;
  60845. private _linearDefineName;
  60846. private _gammaDefineName;
  60847. private _tempTextureRead;
  60848. private _samplerName;
  60849. private _transformedUVName;
  60850. private _textureTransformName;
  60851. private _textureInfoName;
  60852. private _mainUVName;
  60853. private _mainUVDefineName;
  60854. /**
  60855. * Gets or sets the texture associated with the node
  60856. */
  60857. texture: Nullable<Texture>;
  60858. /**
  60859. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  60860. */
  60861. convertToGammaSpace: boolean;
  60862. /**
  60863. * Gets or sets a boolean indicating if content needs to be converted to linear space
  60864. */
  60865. convertToLinearSpace: boolean;
  60866. /**
  60867. * Create a new TextureBlock
  60868. * @param name defines the block name
  60869. */
  60870. constructor(name: string);
  60871. /**
  60872. * Gets the current class name
  60873. * @returns the class name
  60874. */
  60875. getClassName(): string;
  60876. /**
  60877. * Gets the uv input component
  60878. */
  60879. get uv(): NodeMaterialConnectionPoint;
  60880. /**
  60881. * Gets the rgba output component
  60882. */
  60883. get rgba(): NodeMaterialConnectionPoint;
  60884. /**
  60885. * Gets the rgb output component
  60886. */
  60887. get rgb(): NodeMaterialConnectionPoint;
  60888. /**
  60889. * Gets the r output component
  60890. */
  60891. get r(): NodeMaterialConnectionPoint;
  60892. /**
  60893. * Gets the g output component
  60894. */
  60895. get g(): NodeMaterialConnectionPoint;
  60896. /**
  60897. * Gets the b output component
  60898. */
  60899. get b(): NodeMaterialConnectionPoint;
  60900. /**
  60901. * Gets the a output component
  60902. */
  60903. get a(): NodeMaterialConnectionPoint;
  60904. get target(): NodeMaterialBlockTargets;
  60905. autoConfigure(material: NodeMaterial): void;
  60906. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  60907. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  60908. isReady(): boolean;
  60909. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  60910. private get _isMixed();
  60911. private _injectVertexCode;
  60912. private _writeTextureRead;
  60913. private _writeOutput;
  60914. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  60915. protected _dumpPropertiesCode(): string;
  60916. serialize(): any;
  60917. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  60918. }
  60919. }
  60920. declare module "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData" {
  60921. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60922. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60923. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  60924. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  60925. import { ReflectionTextureBaseBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock";
  60926. import { Scene } from "babylonjs/scene";
  60927. /**
  60928. * Class used to store shared data between 2 NodeMaterialBuildState
  60929. */
  60930. export class NodeMaterialBuildStateSharedData {
  60931. /**
  60932. * Gets the list of emitted varyings
  60933. */
  60934. temps: string[];
  60935. /**
  60936. * Gets the list of emitted varyings
  60937. */
  60938. varyings: string[];
  60939. /**
  60940. * Gets the varying declaration string
  60941. */
  60942. varyingDeclaration: string;
  60943. /**
  60944. * Input blocks
  60945. */
  60946. inputBlocks: InputBlock[];
  60947. /**
  60948. * Input blocks
  60949. */
  60950. textureBlocks: (ReflectionTextureBaseBlock | TextureBlock)[];
  60951. /**
  60952. * Bindable blocks (Blocks that need to set data to the effect)
  60953. */
  60954. bindableBlocks: NodeMaterialBlock[];
  60955. /**
  60956. * List of blocks that can provide a compilation fallback
  60957. */
  60958. blocksWithFallbacks: NodeMaterialBlock[];
  60959. /**
  60960. * List of blocks that can provide a define update
  60961. */
  60962. blocksWithDefines: NodeMaterialBlock[];
  60963. /**
  60964. * List of blocks that can provide a repeatable content
  60965. */
  60966. repeatableContentBlocks: NodeMaterialBlock[];
  60967. /**
  60968. * List of blocks that can provide a dynamic list of uniforms
  60969. */
  60970. dynamicUniformBlocks: NodeMaterialBlock[];
  60971. /**
  60972. * List of blocks that can block the isReady function for the material
  60973. */
  60974. blockingBlocks: NodeMaterialBlock[];
  60975. /**
  60976. * Gets the list of animated inputs
  60977. */
  60978. animatedInputs: InputBlock[];
  60979. /**
  60980. * Build Id used to avoid multiple recompilations
  60981. */
  60982. buildId: number;
  60983. /** List of emitted variables */
  60984. variableNames: {
  60985. [key: string]: number;
  60986. };
  60987. /** List of emitted defines */
  60988. defineNames: {
  60989. [key: string]: number;
  60990. };
  60991. /** Should emit comments? */
  60992. emitComments: boolean;
  60993. /** Emit build activity */
  60994. verbose: boolean;
  60995. /** Gets or sets the hosting scene */
  60996. scene: Scene;
  60997. /**
  60998. * Gets the compilation hints emitted at compilation time
  60999. */
  61000. hints: {
  61001. needWorldViewMatrix: boolean;
  61002. needWorldViewProjectionMatrix: boolean;
  61003. needAlphaBlending: boolean;
  61004. needAlphaTesting: boolean;
  61005. };
  61006. /**
  61007. * List of compilation checks
  61008. */
  61009. checks: {
  61010. emitVertex: boolean;
  61011. emitFragment: boolean;
  61012. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  61013. };
  61014. /** Creates a new shared data */
  61015. constructor();
  61016. /**
  61017. * Emits console errors and exceptions if there is a failing check
  61018. */
  61019. emitErrors(): void;
  61020. }
  61021. }
  61022. declare module "babylonjs/Materials/Node/nodeMaterialBuildState" {
  61023. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  61024. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  61025. import { NodeMaterialBuildStateSharedData } from "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData";
  61026. /**
  61027. * Class used to store node based material build state
  61028. */
  61029. export class NodeMaterialBuildState {
  61030. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  61031. supportUniformBuffers: boolean;
  61032. /**
  61033. * Gets the list of emitted attributes
  61034. */
  61035. attributes: string[];
  61036. /**
  61037. * Gets the list of emitted uniforms
  61038. */
  61039. uniforms: string[];
  61040. /**
  61041. * Gets the list of emitted constants
  61042. */
  61043. constants: string[];
  61044. /**
  61045. * Gets the list of emitted samplers
  61046. */
  61047. samplers: string[];
  61048. /**
  61049. * Gets the list of emitted functions
  61050. */
  61051. functions: {
  61052. [key: string]: string;
  61053. };
  61054. /**
  61055. * Gets the list of emitted extensions
  61056. */
  61057. extensions: {
  61058. [key: string]: string;
  61059. };
  61060. /**
  61061. * Gets the target of the compilation state
  61062. */
  61063. target: NodeMaterialBlockTargets;
  61064. /**
  61065. * Gets the list of emitted counters
  61066. */
  61067. counters: {
  61068. [key: string]: number;
  61069. };
  61070. /**
  61071. * Shared data between multiple NodeMaterialBuildState instances
  61072. */
  61073. sharedData: NodeMaterialBuildStateSharedData;
  61074. /** @hidden */
  61075. _vertexState: NodeMaterialBuildState;
  61076. /** @hidden */
  61077. _attributeDeclaration: string;
  61078. /** @hidden */
  61079. _uniformDeclaration: string;
  61080. /** @hidden */
  61081. _constantDeclaration: string;
  61082. /** @hidden */
  61083. _samplerDeclaration: string;
  61084. /** @hidden */
  61085. _varyingTransfer: string;
  61086. /** @hidden */
  61087. _injectAtEnd: string;
  61088. private _repeatableContentAnchorIndex;
  61089. /** @hidden */
  61090. _builtCompilationString: string;
  61091. /**
  61092. * Gets the emitted compilation strings
  61093. */
  61094. compilationString: string;
  61095. /**
  61096. * Finalize the compilation strings
  61097. * @param state defines the current compilation state
  61098. */
  61099. finalize(state: NodeMaterialBuildState): void;
  61100. /** @hidden */
  61101. get _repeatableContentAnchor(): string;
  61102. /** @hidden */
  61103. _getFreeVariableName(prefix: string): string;
  61104. /** @hidden */
  61105. _getFreeDefineName(prefix: string): string;
  61106. /** @hidden */
  61107. _excludeVariableName(name: string): void;
  61108. /** @hidden */
  61109. _emit2DSampler(name: string): void;
  61110. /** @hidden */
  61111. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  61112. /** @hidden */
  61113. _emitExtension(name: string, extension: string): void;
  61114. /** @hidden */
  61115. _emitFunction(name: string, code: string, comments: string): void;
  61116. /** @hidden */
  61117. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  61118. replaceStrings?: {
  61119. search: RegExp;
  61120. replace: string;
  61121. }[];
  61122. repeatKey?: string;
  61123. }): string;
  61124. /** @hidden */
  61125. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  61126. repeatKey?: string;
  61127. removeAttributes?: boolean;
  61128. removeUniforms?: boolean;
  61129. removeVaryings?: boolean;
  61130. removeIfDef?: boolean;
  61131. replaceStrings?: {
  61132. search: RegExp;
  61133. replace: string;
  61134. }[];
  61135. }, storeKey?: string): void;
  61136. /** @hidden */
  61137. _registerTempVariable(name: string): boolean;
  61138. /** @hidden */
  61139. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  61140. /** @hidden */
  61141. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  61142. /** @hidden */
  61143. _emitFloat(value: number): string;
  61144. }
  61145. }
  61146. declare module "babylonjs/Materials/Node/nodeMaterialBlock" {
  61147. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  61148. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61149. import { Nullable } from "babylonjs/types";
  61150. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61151. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  61152. import { Effect } from "babylonjs/Materials/effect";
  61153. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61154. import { Mesh } from "babylonjs/Meshes/mesh";
  61155. import { SubMesh } from "babylonjs/Meshes/subMesh";
  61156. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  61157. import { Scene } from "babylonjs/scene";
  61158. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  61159. /**
  61160. * Defines a block that can be used inside a node based material
  61161. */
  61162. export class NodeMaterialBlock {
  61163. private _buildId;
  61164. private _buildTarget;
  61165. private _target;
  61166. private _isFinalMerger;
  61167. private _isInput;
  61168. protected _isUnique: boolean;
  61169. /** Gets or sets a boolean indicating that only one input can be connected at a time */
  61170. inputsAreExclusive: boolean;
  61171. /** @hidden */
  61172. _codeVariableName: string;
  61173. /** @hidden */
  61174. _inputs: NodeMaterialConnectionPoint[];
  61175. /** @hidden */
  61176. _outputs: NodeMaterialConnectionPoint[];
  61177. /** @hidden */
  61178. _preparationId: number;
  61179. /**
  61180. * Gets or sets the name of the block
  61181. */
  61182. name: string;
  61183. /**
  61184. * Gets or sets the unique id of the node
  61185. */
  61186. uniqueId: number;
  61187. /**
  61188. * Gets or sets the comments associated with this block
  61189. */
  61190. comments: string;
  61191. /**
  61192. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  61193. */
  61194. get isUnique(): boolean;
  61195. /**
  61196. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  61197. */
  61198. get isFinalMerger(): boolean;
  61199. /**
  61200. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  61201. */
  61202. get isInput(): boolean;
  61203. /**
  61204. * Gets or sets the build Id
  61205. */
  61206. get buildId(): number;
  61207. set buildId(value: number);
  61208. /**
  61209. * Gets or sets the target of the block
  61210. */
  61211. get target(): NodeMaterialBlockTargets;
  61212. set target(value: NodeMaterialBlockTargets);
  61213. /**
  61214. * Gets the list of input points
  61215. */
  61216. get inputs(): NodeMaterialConnectionPoint[];
  61217. /** Gets the list of output points */
  61218. get outputs(): NodeMaterialConnectionPoint[];
  61219. /**
  61220. * Find an input by its name
  61221. * @param name defines the name of the input to look for
  61222. * @returns the input or null if not found
  61223. */
  61224. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  61225. /**
  61226. * Find an output by its name
  61227. * @param name defines the name of the outputto look for
  61228. * @returns the output or null if not found
  61229. */
  61230. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  61231. /**
  61232. * Creates a new NodeMaterialBlock
  61233. * @param name defines the block name
  61234. * @param target defines the target of that block (Vertex by default)
  61235. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  61236. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  61237. */
  61238. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  61239. /**
  61240. * Initialize the block and prepare the context for build
  61241. * @param state defines the state that will be used for the build
  61242. */
  61243. initialize(state: NodeMaterialBuildState): void;
  61244. /**
  61245. * Bind data to effect. Will only be called for blocks with isBindable === true
  61246. * @param effect defines the effect to bind data to
  61247. * @param nodeMaterial defines the hosting NodeMaterial
  61248. * @param mesh defines the mesh that will be rendered
  61249. * @param subMesh defines the submesh that will be rendered
  61250. */
  61251. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  61252. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  61253. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  61254. protected _writeFloat(value: number): string;
  61255. /**
  61256. * Gets the current class name e.g. "NodeMaterialBlock"
  61257. * @returns the class name
  61258. */
  61259. getClassName(): string;
  61260. /**
  61261. * Register a new input. Must be called inside a block constructor
  61262. * @param name defines the connection point name
  61263. * @param type defines the connection point type
  61264. * @param isOptional defines a boolean indicating that this input can be omitted
  61265. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  61266. * @param point an already created connection point. If not provided, create a new one
  61267. * @returns the current block
  61268. */
  61269. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  61270. /**
  61271. * Register a new output. Must be called inside a block constructor
  61272. * @param name defines the connection point name
  61273. * @param type defines the connection point type
  61274. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  61275. * @param point an already created connection point. If not provided, create a new one
  61276. * @returns the current block
  61277. */
  61278. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  61279. /**
  61280. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  61281. * @param forOutput defines an optional connection point to check compatibility with
  61282. * @returns the first available input or null
  61283. */
  61284. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  61285. /**
  61286. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  61287. * @param forBlock defines an optional block to check compatibility with
  61288. * @returns the first available input or null
  61289. */
  61290. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  61291. /**
  61292. * Gets the sibling of the given output
  61293. * @param current defines the current output
  61294. * @returns the next output in the list or null
  61295. */
  61296. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  61297. /**
  61298. * Connect current block with another block
  61299. * @param other defines the block to connect with
  61300. * @param options define the various options to help pick the right connections
  61301. * @returns the current block
  61302. */
  61303. connectTo(other: NodeMaterialBlock, options?: {
  61304. input?: string;
  61305. output?: string;
  61306. outputSwizzle?: string;
  61307. }): this | undefined;
  61308. protected _buildBlock(state: NodeMaterialBuildState): void;
  61309. /**
  61310. * Add uniforms, samplers and uniform buffers at compilation time
  61311. * @param state defines the state to update
  61312. * @param nodeMaterial defines the node material requesting the update
  61313. * @param defines defines the material defines to update
  61314. * @param uniformBuffers defines the list of uniform buffer names
  61315. */
  61316. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  61317. /**
  61318. * Add potential fallbacks if shader compilation fails
  61319. * @param mesh defines the mesh to be rendered
  61320. * @param fallbacks defines the current prioritized list of fallbacks
  61321. */
  61322. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  61323. /**
  61324. * Initialize defines for shader compilation
  61325. * @param mesh defines the mesh to be rendered
  61326. * @param nodeMaterial defines the node material requesting the update
  61327. * @param defines defines the material defines to update
  61328. * @param useInstances specifies that instances should be used
  61329. */
  61330. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  61331. /**
  61332. * Update defines for shader compilation
  61333. * @param mesh defines the mesh to be rendered
  61334. * @param nodeMaterial defines the node material requesting the update
  61335. * @param defines defines the material defines to update
  61336. * @param useInstances specifies that instances should be used
  61337. */
  61338. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  61339. /**
  61340. * Lets the block try to connect some inputs automatically
  61341. * @param material defines the hosting NodeMaterial
  61342. */
  61343. autoConfigure(material: NodeMaterial): void;
  61344. /**
  61345. * Function called when a block is declared as repeatable content generator
  61346. * @param vertexShaderState defines the current compilation state for the vertex shader
  61347. * @param fragmentShaderState defines the current compilation state for the fragment shader
  61348. * @param mesh defines the mesh to be rendered
  61349. * @param defines defines the material defines to update
  61350. */
  61351. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  61352. /**
  61353. * Checks if the block is ready
  61354. * @param mesh defines the mesh to be rendered
  61355. * @param nodeMaterial defines the node material requesting the update
  61356. * @param defines defines the material defines to update
  61357. * @param useInstances specifies that instances should be used
  61358. * @returns true if the block is ready
  61359. */
  61360. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  61361. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  61362. private _processBuild;
  61363. /**
  61364. * Compile the current node and generate the shader code
  61365. * @param state defines the current compilation state (uniforms, samplers, current string)
  61366. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  61367. * @returns true if already built
  61368. */
  61369. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  61370. protected _inputRename(name: string): string;
  61371. protected _outputRename(name: string): string;
  61372. protected _dumpPropertiesCode(): string;
  61373. /** @hidden */
  61374. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  61375. /** @hidden */
  61376. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  61377. /**
  61378. * Clone the current block to a new identical block
  61379. * @param scene defines the hosting scene
  61380. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  61381. * @returns a copy of the current block
  61382. */
  61383. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  61384. /**
  61385. * Serializes this block in a JSON representation
  61386. * @returns the serialized block object
  61387. */
  61388. serialize(): any;
  61389. /** @hidden */
  61390. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61391. private _deserializePortDisplayNames;
  61392. /**
  61393. * Release resources
  61394. */
  61395. dispose(): void;
  61396. }
  61397. }
  61398. declare module "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes" {
  61399. /**
  61400. * Enum defining the type of animations supported by InputBlock
  61401. */
  61402. export enum AnimatedInputBlockTypes {
  61403. /** No animation */
  61404. None = 0,
  61405. /** Time based animation. Will only work for floats */
  61406. Time = 1
  61407. }
  61408. }
  61409. declare module "babylonjs/Materials/Node/Blocks/Input/inputBlock" {
  61410. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61411. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  61412. import { NodeMaterialSystemValues } from "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues";
  61413. import { Nullable } from "babylonjs/types";
  61414. import { Effect } from "babylonjs/Materials/effect";
  61415. import { Matrix } from "babylonjs/Maths/math.vector";
  61416. import { Scene } from "babylonjs/scene";
  61417. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61418. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61419. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  61420. import { AnimatedInputBlockTypes } from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  61421. import { Observable } from "babylonjs/Misc/observable";
  61422. /**
  61423. * Block used to expose an input value
  61424. */
  61425. export class InputBlock extends NodeMaterialBlock {
  61426. private _mode;
  61427. private _associatedVariableName;
  61428. private _storedValue;
  61429. private _valueCallback;
  61430. private _type;
  61431. private _animationType;
  61432. /** Gets or set a value used to limit the range of float values */
  61433. min: number;
  61434. /** Gets or set a value used to limit the range of float values */
  61435. max: number;
  61436. /** Gets or set a value indicating that this input can only get 0 and 1 values */
  61437. isBoolean: boolean;
  61438. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  61439. matrixMode: number;
  61440. /** @hidden */
  61441. _systemValue: Nullable<NodeMaterialSystemValues>;
  61442. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  61443. visibleInInspector: boolean;
  61444. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  61445. isConstant: boolean;
  61446. /** Gets or sets the group to use to display this block in the Inspector */
  61447. groupInInspector: string;
  61448. /** Gets an observable raised when the value is changed */
  61449. onValueChangedObservable: Observable<InputBlock>;
  61450. /**
  61451. * Gets or sets the connection point type (default is float)
  61452. */
  61453. get type(): NodeMaterialBlockConnectionPointTypes;
  61454. /**
  61455. * Creates a new InputBlock
  61456. * @param name defines the block name
  61457. * @param target defines the target of that block (Vertex by default)
  61458. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  61459. */
  61460. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  61461. /**
  61462. * Gets the output component
  61463. */
  61464. get output(): NodeMaterialConnectionPoint;
  61465. /**
  61466. * Set the source of this connection point to a vertex attribute
  61467. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  61468. * @returns the current connection point
  61469. */
  61470. setAsAttribute(attributeName?: string): InputBlock;
  61471. /**
  61472. * Set the source of this connection point to a system value
  61473. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  61474. * @returns the current connection point
  61475. */
  61476. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  61477. /**
  61478. * Gets or sets the value of that point.
  61479. * Please note that this value will be ignored if valueCallback is defined
  61480. */
  61481. get value(): any;
  61482. set value(value: any);
  61483. /**
  61484. * Gets or sets a callback used to get the value of that point.
  61485. * Please note that setting this value will force the connection point to ignore the value property
  61486. */
  61487. get valueCallback(): () => any;
  61488. set valueCallback(value: () => any);
  61489. /**
  61490. * Gets or sets the associated variable name in the shader
  61491. */
  61492. get associatedVariableName(): string;
  61493. set associatedVariableName(value: string);
  61494. /** Gets or sets the type of animation applied to the input */
  61495. get animationType(): AnimatedInputBlockTypes;
  61496. set animationType(value: AnimatedInputBlockTypes);
  61497. /**
  61498. * Gets a boolean indicating that this connection point not defined yet
  61499. */
  61500. get isUndefined(): boolean;
  61501. /**
  61502. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  61503. * In this case the connection point name must be the name of the uniform to use.
  61504. * Can only be set on inputs
  61505. */
  61506. get isUniform(): boolean;
  61507. set isUniform(value: boolean);
  61508. /**
  61509. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  61510. * In this case the connection point name must be the name of the attribute to use
  61511. * Can only be set on inputs
  61512. */
  61513. get isAttribute(): boolean;
  61514. set isAttribute(value: boolean);
  61515. /**
  61516. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  61517. * Can only be set on exit points
  61518. */
  61519. get isVarying(): boolean;
  61520. set isVarying(value: boolean);
  61521. /**
  61522. * Gets a boolean indicating that the current connection point is a system value
  61523. */
  61524. get isSystemValue(): boolean;
  61525. /**
  61526. * Gets or sets the current well known value or null if not defined as a system value
  61527. */
  61528. get systemValue(): Nullable<NodeMaterialSystemValues>;
  61529. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  61530. /**
  61531. * Gets the current class name
  61532. * @returns the class name
  61533. */
  61534. getClassName(): string;
  61535. /**
  61536. * Animate the input if animationType !== None
  61537. * @param scene defines the rendering scene
  61538. */
  61539. animate(scene: Scene): void;
  61540. private _emitDefine;
  61541. initialize(state: NodeMaterialBuildState): void;
  61542. /**
  61543. * Set the input block to its default value (based on its type)
  61544. */
  61545. setDefaultValue(): void;
  61546. private _emitConstant;
  61547. private _emit;
  61548. /** @hidden */
  61549. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  61550. /** @hidden */
  61551. _transmit(effect: Effect, scene: Scene): void;
  61552. protected _buildBlock(state: NodeMaterialBuildState): void;
  61553. protected _dumpPropertiesCode(): string;
  61554. dispose(): void;
  61555. serialize(): any;
  61556. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61557. }
  61558. }
  61559. declare module "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint" {
  61560. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  61561. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  61562. import { Nullable } from "babylonjs/types";
  61563. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  61564. import { Observable } from "babylonjs/Misc/observable";
  61565. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61566. /**
  61567. * Enum used to define the compatibility state between two connection points
  61568. */
  61569. export enum NodeMaterialConnectionPointCompatibilityStates {
  61570. /** Points are compatibles */
  61571. Compatible = 0,
  61572. /** Points are incompatible because of their types */
  61573. TypeIncompatible = 1,
  61574. /** Points are incompatible because of their targets (vertex vs fragment) */
  61575. TargetIncompatible = 2
  61576. }
  61577. /**
  61578. * Defines the direction of a connection point
  61579. */
  61580. export enum NodeMaterialConnectionPointDirection {
  61581. /** Input */
  61582. Input = 0,
  61583. /** Output */
  61584. Output = 1
  61585. }
  61586. /**
  61587. * Defines a connection point for a block
  61588. */
  61589. export class NodeMaterialConnectionPoint {
  61590. /** @hidden */
  61591. _ownerBlock: NodeMaterialBlock;
  61592. /** @hidden */
  61593. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  61594. private _endpoints;
  61595. private _associatedVariableName;
  61596. private _direction;
  61597. /** @hidden */
  61598. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  61599. /** @hidden */
  61600. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  61601. private _type;
  61602. /** @hidden */
  61603. _enforceAssociatedVariableName: boolean;
  61604. /** Gets the direction of the point */
  61605. get direction(): NodeMaterialConnectionPointDirection;
  61606. /** Indicates that this connection point needs dual validation before being connected to another point */
  61607. needDualDirectionValidation: boolean;
  61608. /**
  61609. * Gets or sets the additional types supported by this connection point
  61610. */
  61611. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  61612. /**
  61613. * Gets or sets the additional types excluded by this connection point
  61614. */
  61615. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  61616. /**
  61617. * Observable triggered when this point is connected
  61618. */
  61619. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  61620. /**
  61621. * Gets or sets the associated variable name in the shader
  61622. */
  61623. get associatedVariableName(): string;
  61624. set associatedVariableName(value: string);
  61625. /** Get the inner type (ie AutoDetect for instance instead of the inferred one) */
  61626. get innerType(): NodeMaterialBlockConnectionPointTypes;
  61627. /**
  61628. * Gets or sets the connection point type (default is float)
  61629. */
  61630. get type(): NodeMaterialBlockConnectionPointTypes;
  61631. set type(value: NodeMaterialBlockConnectionPointTypes);
  61632. /**
  61633. * Gets or sets the connection point name
  61634. */
  61635. name: string;
  61636. /**
  61637. * Gets or sets the connection point name
  61638. */
  61639. displayName: string;
  61640. /**
  61641. * Gets or sets a boolean indicating that this connection point can be omitted
  61642. */
  61643. isOptional: boolean;
  61644. /**
  61645. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  61646. */
  61647. define: string;
  61648. /** @hidden */
  61649. _prioritizeVertex: boolean;
  61650. private _target;
  61651. /** Gets or sets the target of that connection point */
  61652. get target(): NodeMaterialBlockTargets;
  61653. set target(value: NodeMaterialBlockTargets);
  61654. /**
  61655. * Gets a boolean indicating that the current point is connected
  61656. */
  61657. get isConnected(): boolean;
  61658. /**
  61659. * Gets a boolean indicating that the current point is connected to an input block
  61660. */
  61661. get isConnectedToInputBlock(): boolean;
  61662. /**
  61663. * Gets a the connected input block (if any)
  61664. */
  61665. get connectInputBlock(): Nullable<InputBlock>;
  61666. /** Get the other side of the connection (if any) */
  61667. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  61668. /** Get the block that owns this connection point */
  61669. get ownerBlock(): NodeMaterialBlock;
  61670. /** Get the block connected on the other side of this connection (if any) */
  61671. get sourceBlock(): Nullable<NodeMaterialBlock>;
  61672. /** Get the block connected on the endpoints of this connection (if any) */
  61673. get connectedBlocks(): Array<NodeMaterialBlock>;
  61674. /** Gets the list of connected endpoints */
  61675. get endpoints(): NodeMaterialConnectionPoint[];
  61676. /** Gets a boolean indicating if that output point is connected to at least one input */
  61677. get hasEndpoints(): boolean;
  61678. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  61679. get isConnectedInVertexShader(): boolean;
  61680. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  61681. get isConnectedInFragmentShader(): boolean;
  61682. /**
  61683. * Creates a block suitable to be used as an input for this input point.
  61684. * If null is returned, a block based on the point type will be created.
  61685. * @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
  61686. */
  61687. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  61688. /**
  61689. * Creates a new connection point
  61690. * @param name defines the connection point name
  61691. * @param ownerBlock defines the block hosting this connection point
  61692. * @param direction defines the direction of the connection point
  61693. */
  61694. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  61695. /**
  61696. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  61697. * @returns the class name
  61698. */
  61699. getClassName(): string;
  61700. /**
  61701. * Gets a boolean indicating if the current point can be connected to another point
  61702. * @param connectionPoint defines the other connection point
  61703. * @returns a boolean
  61704. */
  61705. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  61706. /**
  61707. * Gets a number indicating if the current point can be connected to another point
  61708. * @param connectionPoint defines the other connection point
  61709. * @returns a number defining the compatibility state
  61710. */
  61711. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  61712. /**
  61713. * Connect this point to another connection point
  61714. * @param connectionPoint defines the other connection point
  61715. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  61716. * @returns the current connection point
  61717. */
  61718. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  61719. /**
  61720. * Disconnect this point from one of his endpoint
  61721. * @param endpoint defines the other connection point
  61722. * @returns the current connection point
  61723. */
  61724. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  61725. /**
  61726. * Serializes this point in a JSON representation
  61727. * @param isInput defines if the connection point is an input (default is true)
  61728. * @returns the serialized point object
  61729. */
  61730. serialize(isInput?: boolean): any;
  61731. /**
  61732. * Release resources
  61733. */
  61734. dispose(): void;
  61735. }
  61736. }
  61737. declare module "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock" {
  61738. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61739. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61740. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61741. import { Mesh } from "babylonjs/Meshes/mesh";
  61742. import { Effect } from "babylonjs/Materials/effect";
  61743. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61744. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  61745. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  61746. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  61747. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  61748. /**
  61749. * Block used to add support for vertex skinning (bones)
  61750. */
  61751. export class BonesBlock extends NodeMaterialBlock {
  61752. /**
  61753. * Creates a new BonesBlock
  61754. * @param name defines the block name
  61755. */
  61756. constructor(name: string);
  61757. /**
  61758. * Initialize the block and prepare the context for build
  61759. * @param state defines the state that will be used for the build
  61760. */
  61761. initialize(state: NodeMaterialBuildState): void;
  61762. /**
  61763. * Gets the current class name
  61764. * @returns the class name
  61765. */
  61766. getClassName(): string;
  61767. /**
  61768. * Gets the matrix indices input component
  61769. */
  61770. get matricesIndices(): NodeMaterialConnectionPoint;
  61771. /**
  61772. * Gets the matrix weights input component
  61773. */
  61774. get matricesWeights(): NodeMaterialConnectionPoint;
  61775. /**
  61776. * Gets the extra matrix indices input component
  61777. */
  61778. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  61779. /**
  61780. * Gets the extra matrix weights input component
  61781. */
  61782. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  61783. /**
  61784. * Gets the world input component
  61785. */
  61786. get world(): NodeMaterialConnectionPoint;
  61787. /**
  61788. * Gets the output component
  61789. */
  61790. get output(): NodeMaterialConnectionPoint;
  61791. autoConfigure(material: NodeMaterial): void;
  61792. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  61793. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61794. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61795. protected _buildBlock(state: NodeMaterialBuildState): this;
  61796. }
  61797. }
  61798. declare module "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock" {
  61799. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61800. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61801. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61802. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61803. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  61804. /**
  61805. * Block used to add support for instances
  61806. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  61807. */
  61808. export class InstancesBlock extends NodeMaterialBlock {
  61809. /**
  61810. * Creates a new InstancesBlock
  61811. * @param name defines the block name
  61812. */
  61813. constructor(name: string);
  61814. /**
  61815. * Gets the current class name
  61816. * @returns the class name
  61817. */
  61818. getClassName(): string;
  61819. /**
  61820. * Gets the first world row input component
  61821. */
  61822. get world0(): NodeMaterialConnectionPoint;
  61823. /**
  61824. * Gets the second world row input component
  61825. */
  61826. get world1(): NodeMaterialConnectionPoint;
  61827. /**
  61828. * Gets the third world row input component
  61829. */
  61830. get world2(): NodeMaterialConnectionPoint;
  61831. /**
  61832. * Gets the forth world row input component
  61833. */
  61834. get world3(): NodeMaterialConnectionPoint;
  61835. /**
  61836. * Gets the world input component
  61837. */
  61838. get world(): NodeMaterialConnectionPoint;
  61839. /**
  61840. * Gets the output component
  61841. */
  61842. get output(): NodeMaterialConnectionPoint;
  61843. /**
  61844. * Gets the isntanceID component
  61845. */
  61846. get instanceID(): NodeMaterialConnectionPoint;
  61847. autoConfigure(material: NodeMaterial): void;
  61848. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  61849. protected _buildBlock(state: NodeMaterialBuildState): this;
  61850. }
  61851. }
  61852. declare module "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock" {
  61853. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61854. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61855. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61856. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61857. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  61858. import { Effect } from "babylonjs/Materials/effect";
  61859. import { Mesh } from "babylonjs/Meshes/mesh";
  61860. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  61861. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  61862. /**
  61863. * Block used to add morph targets support to vertex shader
  61864. */
  61865. export class MorphTargetsBlock extends NodeMaterialBlock {
  61866. private _repeatableContentAnchor;
  61867. /**
  61868. * Create a new MorphTargetsBlock
  61869. * @param name defines the block name
  61870. */
  61871. constructor(name: string);
  61872. /**
  61873. * Gets the current class name
  61874. * @returns the class name
  61875. */
  61876. getClassName(): string;
  61877. /**
  61878. * Gets the position input component
  61879. */
  61880. get position(): NodeMaterialConnectionPoint;
  61881. /**
  61882. * Gets the normal input component
  61883. */
  61884. get normal(): NodeMaterialConnectionPoint;
  61885. /**
  61886. * Gets the tangent input component
  61887. */
  61888. get tangent(): NodeMaterialConnectionPoint;
  61889. /**
  61890. * Gets the tangent input component
  61891. */
  61892. get uv(): NodeMaterialConnectionPoint;
  61893. /**
  61894. * Gets the position output component
  61895. */
  61896. get positionOutput(): NodeMaterialConnectionPoint;
  61897. /**
  61898. * Gets the normal output component
  61899. */
  61900. get normalOutput(): NodeMaterialConnectionPoint;
  61901. /**
  61902. * Gets the tangent output component
  61903. */
  61904. get tangentOutput(): NodeMaterialConnectionPoint;
  61905. /**
  61906. * Gets the tangent output component
  61907. */
  61908. get uvOutput(): NodeMaterialConnectionPoint;
  61909. initialize(state: NodeMaterialBuildState): void;
  61910. autoConfigure(material: NodeMaterial): void;
  61911. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61912. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61913. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  61914. protected _buildBlock(state: NodeMaterialBuildState): this;
  61915. }
  61916. }
  61917. declare module "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock" {
  61918. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61919. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61920. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61921. import { Nullable } from "babylonjs/types";
  61922. import { Scene } from "babylonjs/scene";
  61923. import { Effect } from "babylonjs/Materials/effect";
  61924. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  61925. import { Mesh } from "babylonjs/Meshes/mesh";
  61926. import { Light } from "babylonjs/Lights/light";
  61927. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61928. /**
  61929. * Block used to get data information from a light
  61930. */
  61931. export class LightInformationBlock extends NodeMaterialBlock {
  61932. private _lightDataUniformName;
  61933. private _lightColorUniformName;
  61934. private _lightTypeDefineName;
  61935. /**
  61936. * Gets or sets the light associated with this block
  61937. */
  61938. light: Nullable<Light>;
  61939. /**
  61940. * Creates a new LightInformationBlock
  61941. * @param name defines the block name
  61942. */
  61943. constructor(name: string);
  61944. /**
  61945. * Gets the current class name
  61946. * @returns the class name
  61947. */
  61948. getClassName(): string;
  61949. /**
  61950. * Gets the world position input component
  61951. */
  61952. get worldPosition(): NodeMaterialConnectionPoint;
  61953. /**
  61954. * Gets the direction output component
  61955. */
  61956. get direction(): NodeMaterialConnectionPoint;
  61957. /**
  61958. * Gets the direction output component
  61959. */
  61960. get color(): NodeMaterialConnectionPoint;
  61961. /**
  61962. * Gets the direction output component
  61963. */
  61964. get intensity(): NodeMaterialConnectionPoint;
  61965. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61966. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61967. protected _buildBlock(state: NodeMaterialBuildState): this;
  61968. serialize(): any;
  61969. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61970. }
  61971. }
  61972. declare module "babylonjs/Materials/Node/Blocks/Vertex/index" {
  61973. export * from "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock";
  61974. export * from "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock";
  61975. export * from "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock";
  61976. export * from "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock";
  61977. export * from "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock";
  61978. }
  61979. declare module "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock" {
  61980. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61981. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61982. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61983. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61984. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  61985. import { Effect } from "babylonjs/Materials/effect";
  61986. import { Mesh } from "babylonjs/Meshes/mesh";
  61987. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  61988. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  61989. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  61990. /**
  61991. * Block used to add image processing support to fragment shader
  61992. */
  61993. export class ImageProcessingBlock extends NodeMaterialBlock {
  61994. /**
  61995. * Create a new ImageProcessingBlock
  61996. * @param name defines the block name
  61997. */
  61998. constructor(name: string);
  61999. /**
  62000. * Gets the current class name
  62001. * @returns the class name
  62002. */
  62003. getClassName(): string;
  62004. /**
  62005. * Gets the color input component
  62006. */
  62007. get color(): NodeMaterialConnectionPoint;
  62008. /**
  62009. * Gets the output component
  62010. */
  62011. get output(): NodeMaterialConnectionPoint;
  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. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  62018. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  62019. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  62020. protected _buildBlock(state: NodeMaterialBuildState): this;
  62021. }
  62022. }
  62023. declare module "babylonjs/Materials/Node/nodeMaterialDecorator" {
  62024. /**
  62025. * Enum defining the type of properties that can be edited in the property pages in the NME
  62026. */
  62027. export enum PropertyTypeForEdition {
  62028. /** property is a boolean */
  62029. Boolean = 0,
  62030. /** property is a float */
  62031. Float = 1,
  62032. /** property is a Vector2 */
  62033. Vector2 = 2,
  62034. /** property is a list of values */
  62035. List = 3
  62036. }
  62037. /**
  62038. * Interface that defines an option in a variable of type list
  62039. */
  62040. export interface IEditablePropertyListOption {
  62041. /** label of the option */
  62042. "label": string;
  62043. /** value of the option */
  62044. "value": number;
  62045. }
  62046. /**
  62047. * Interface that defines the options available for an editable property
  62048. */
  62049. export interface IEditablePropertyOption {
  62050. /** min value */
  62051. "min"?: number;
  62052. /** max value */
  62053. "max"?: number;
  62054. /** notifiers: indicates which actions to take when the property is changed */
  62055. "notifiers"?: {
  62056. /** the material should be rebuilt */
  62057. "rebuild"?: boolean;
  62058. /** the preview should be updated */
  62059. "update"?: boolean;
  62060. };
  62061. /** list of the options for a variable of type list */
  62062. "options"?: IEditablePropertyListOption[];
  62063. }
  62064. /**
  62065. * Interface that describes an editable property
  62066. */
  62067. export interface IPropertyDescriptionForEdition {
  62068. /** name of the property */
  62069. "propertyName": string;
  62070. /** display name of the property */
  62071. "displayName": string;
  62072. /** type of the property */
  62073. "type": PropertyTypeForEdition;
  62074. /** group of the property - all properties with the same group value will be displayed in a specific section */
  62075. "groupName": string;
  62076. /** options for the property */
  62077. "options": IEditablePropertyOption;
  62078. }
  62079. /**
  62080. * Decorator that flags a property in a node material block as being editable
  62081. */
  62082. export function editableInPropertyPage(displayName: string, propertyType?: PropertyTypeForEdition, groupName?: string, options?: IEditablePropertyOption): (target: any, propertyKey: string) => void;
  62083. }
  62084. declare module "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock" {
  62085. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62086. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62087. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62088. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  62089. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  62090. import { Effect } from "babylonjs/Materials/effect";
  62091. import { Mesh } from "babylonjs/Meshes/mesh";
  62092. import { Scene } from "babylonjs/scene";
  62093. import "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions";
  62094. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  62095. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  62096. /**
  62097. * Block used to pertub normals based on a normal map
  62098. */
  62099. export class PerturbNormalBlock extends NodeMaterialBlock {
  62100. private _tangentSpaceParameterName;
  62101. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  62102. invertX: boolean;
  62103. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  62104. invertY: boolean;
  62105. /**
  62106. * Create a new PerturbNormalBlock
  62107. * @param name defines the block name
  62108. */
  62109. constructor(name: string);
  62110. /**
  62111. * Gets the current class name
  62112. * @returns the class name
  62113. */
  62114. getClassName(): string;
  62115. /**
  62116. * Gets the world position input component
  62117. */
  62118. get worldPosition(): NodeMaterialConnectionPoint;
  62119. /**
  62120. * Gets the world normal input component
  62121. */
  62122. get worldNormal(): NodeMaterialConnectionPoint;
  62123. /**
  62124. * Gets the world tangent input component
  62125. */
  62126. get worldTangent(): NodeMaterialConnectionPoint;
  62127. /**
  62128. * Gets the uv input component
  62129. */
  62130. get uv(): NodeMaterialConnectionPoint;
  62131. /**
  62132. * Gets the normal map color input component
  62133. */
  62134. get normalMapColor(): NodeMaterialConnectionPoint;
  62135. /**
  62136. * Gets the strength input component
  62137. */
  62138. get strength(): NodeMaterialConnectionPoint;
  62139. /**
  62140. * Gets the output component
  62141. */
  62142. get output(): NodeMaterialConnectionPoint;
  62143. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  62144. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  62145. autoConfigure(material: NodeMaterial): void;
  62146. protected _buildBlock(state: NodeMaterialBuildState): this;
  62147. protected _dumpPropertiesCode(): string;
  62148. serialize(): any;
  62149. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62150. }
  62151. }
  62152. declare module "babylonjs/Materials/Node/Blocks/Fragment/discardBlock" {
  62153. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62154. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62155. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62156. /**
  62157. * Block used to discard a pixel if a value is smaller than a cutoff
  62158. */
  62159. export class DiscardBlock extends NodeMaterialBlock {
  62160. /**
  62161. * Create a new DiscardBlock
  62162. * @param name defines the block name
  62163. */
  62164. constructor(name: string);
  62165. /**
  62166. * Gets the current class name
  62167. * @returns the class name
  62168. */
  62169. getClassName(): string;
  62170. /**
  62171. * Gets the color input component
  62172. */
  62173. get value(): NodeMaterialConnectionPoint;
  62174. /**
  62175. * Gets the cutoff input component
  62176. */
  62177. get cutoff(): NodeMaterialConnectionPoint;
  62178. protected _buildBlock(state: NodeMaterialBuildState): this;
  62179. }
  62180. }
  62181. declare module "babylonjs/Materials/Node/Blocks/Fragment/frontFacingBlock" {
  62182. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62183. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62184. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62185. /**
  62186. * Block used to test if the fragment shader is front facing
  62187. */
  62188. export class FrontFacingBlock extends NodeMaterialBlock {
  62189. /**
  62190. * Creates a new FrontFacingBlock
  62191. * @param name defines the block name
  62192. */
  62193. constructor(name: string);
  62194. /**
  62195. * Gets the current class name
  62196. * @returns the class name
  62197. */
  62198. getClassName(): string;
  62199. /**
  62200. * Gets the output component
  62201. */
  62202. get output(): NodeMaterialConnectionPoint;
  62203. protected _buildBlock(state: NodeMaterialBuildState): this;
  62204. }
  62205. }
  62206. declare module "babylonjs/Materials/Node/Blocks/Fragment/derivativeBlock" {
  62207. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62208. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62209. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62210. /**
  62211. * Block used to get the derivative value on x and y of a given input
  62212. */
  62213. export class DerivativeBlock extends NodeMaterialBlock {
  62214. /**
  62215. * Create a new DerivativeBlock
  62216. * @param name defines the block name
  62217. */
  62218. constructor(name: string);
  62219. /**
  62220. * Gets the current class name
  62221. * @returns the class name
  62222. */
  62223. getClassName(): string;
  62224. /**
  62225. * Gets the input component
  62226. */
  62227. get input(): NodeMaterialConnectionPoint;
  62228. /**
  62229. * Gets the derivative output on x
  62230. */
  62231. get dx(): NodeMaterialConnectionPoint;
  62232. /**
  62233. * Gets the derivative output on y
  62234. */
  62235. get dy(): NodeMaterialConnectionPoint;
  62236. protected _buildBlock(state: NodeMaterialBuildState): this;
  62237. }
  62238. }
  62239. declare module "babylonjs/Materials/Node/Blocks/Fragment/index" {
  62240. export * from "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock";
  62241. export * from "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock";
  62242. export * from "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock";
  62243. export * from "babylonjs/Materials/Node/Blocks/Fragment/discardBlock";
  62244. export * from "babylonjs/Materials/Node/Blocks/Fragment/frontFacingBlock";
  62245. export * from "babylonjs/Materials/Node/Blocks/Fragment/derivativeBlock";
  62246. }
  62247. declare module "babylonjs/Materials/Node/Blocks/Dual/fogBlock" {
  62248. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62249. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62250. import { Mesh } from "babylonjs/Meshes/mesh";
  62251. import { Effect } from "babylonjs/Materials/effect";
  62252. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62253. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  62254. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  62255. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  62256. /**
  62257. * Block used to add support for scene fog
  62258. */
  62259. export class FogBlock extends NodeMaterialBlock {
  62260. private _fogDistanceName;
  62261. private _fogParameters;
  62262. /**
  62263. * Create a new FogBlock
  62264. * @param name defines the block name
  62265. */
  62266. constructor(name: string);
  62267. /**
  62268. * Gets the current class name
  62269. * @returns the class name
  62270. */
  62271. getClassName(): string;
  62272. /**
  62273. * Gets the world position input component
  62274. */
  62275. get worldPosition(): NodeMaterialConnectionPoint;
  62276. /**
  62277. * Gets the view input component
  62278. */
  62279. get view(): NodeMaterialConnectionPoint;
  62280. /**
  62281. * Gets the color input component
  62282. */
  62283. get input(): NodeMaterialConnectionPoint;
  62284. /**
  62285. * Gets the fog color input component
  62286. */
  62287. get fogColor(): NodeMaterialConnectionPoint;
  62288. /**
  62289. * Gets the output component
  62290. */
  62291. get output(): NodeMaterialConnectionPoint;
  62292. autoConfigure(material: NodeMaterial): void;
  62293. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  62294. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  62295. protected _buildBlock(state: NodeMaterialBuildState): this;
  62296. }
  62297. }
  62298. declare module "babylonjs/Materials/Node/Blocks/Dual/lightBlock" {
  62299. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62300. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62301. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62302. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  62303. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  62304. import { Effect } from "babylonjs/Materials/effect";
  62305. import { Mesh } from "babylonjs/Meshes/mesh";
  62306. import { Light } from "babylonjs/Lights/light";
  62307. import { Nullable } from "babylonjs/types";
  62308. import { Scene } from "babylonjs/scene";
  62309. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  62310. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  62311. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  62312. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  62313. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  62314. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  62315. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  62316. /**
  62317. * Block used to add light in the fragment shader
  62318. */
  62319. export class LightBlock extends NodeMaterialBlock {
  62320. private _lightId;
  62321. /**
  62322. * Gets or sets the light associated with this block
  62323. */
  62324. light: Nullable<Light>;
  62325. /**
  62326. * Create a new LightBlock
  62327. * @param name defines the block name
  62328. */
  62329. constructor(name: string);
  62330. /**
  62331. * Gets the current class name
  62332. * @returns the class name
  62333. */
  62334. getClassName(): string;
  62335. /**
  62336. * Gets the world position input component
  62337. */
  62338. get worldPosition(): NodeMaterialConnectionPoint;
  62339. /**
  62340. * Gets the world normal input component
  62341. */
  62342. get worldNormal(): NodeMaterialConnectionPoint;
  62343. /**
  62344. * Gets the camera (or eye) position component
  62345. */
  62346. get cameraPosition(): NodeMaterialConnectionPoint;
  62347. /**
  62348. * Gets the glossiness component
  62349. */
  62350. get glossiness(): NodeMaterialConnectionPoint;
  62351. /**
  62352. * Gets the glossinness power component
  62353. */
  62354. get glossPower(): NodeMaterialConnectionPoint;
  62355. /**
  62356. * Gets the diffuse color component
  62357. */
  62358. get diffuseColor(): NodeMaterialConnectionPoint;
  62359. /**
  62360. * Gets the specular color component
  62361. */
  62362. get specularColor(): NodeMaterialConnectionPoint;
  62363. /**
  62364. * Gets the diffuse output component
  62365. */
  62366. get diffuseOutput(): NodeMaterialConnectionPoint;
  62367. /**
  62368. * Gets the specular output component
  62369. */
  62370. get specularOutput(): NodeMaterialConnectionPoint;
  62371. /**
  62372. * Gets the shadow output component
  62373. */
  62374. get shadow(): NodeMaterialConnectionPoint;
  62375. autoConfigure(material: NodeMaterial): void;
  62376. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  62377. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  62378. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  62379. private _injectVertexCode;
  62380. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  62381. serialize(): any;
  62382. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62383. }
  62384. }
  62385. declare module "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock" {
  62386. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62387. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62388. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  62389. import { ReflectionTextureBaseBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock";
  62390. /**
  62391. * Block used to read a reflection texture from a sampler
  62392. */
  62393. export class ReflectionTextureBlock extends ReflectionTextureBaseBlock {
  62394. /**
  62395. * Create a new ReflectionTextureBlock
  62396. * @param name defines the block name
  62397. */
  62398. constructor(name: string);
  62399. /**
  62400. * Gets the current class name
  62401. * @returns the class name
  62402. */
  62403. getClassName(): string;
  62404. /**
  62405. * Gets the world position input component
  62406. */
  62407. get position(): NodeMaterialConnectionPoint;
  62408. /**
  62409. * Gets the world position input component
  62410. */
  62411. get worldPosition(): NodeMaterialConnectionPoint;
  62412. /**
  62413. * Gets the world normal input component
  62414. */
  62415. get worldNormal(): NodeMaterialConnectionPoint;
  62416. /**
  62417. * Gets the world input component
  62418. */
  62419. get world(): NodeMaterialConnectionPoint;
  62420. /**
  62421. * Gets the camera (or eye) position component
  62422. */
  62423. get cameraPosition(): NodeMaterialConnectionPoint;
  62424. /**
  62425. * Gets the view input component
  62426. */
  62427. get view(): NodeMaterialConnectionPoint;
  62428. /**
  62429. * Gets the rgb output component
  62430. */
  62431. get rgb(): NodeMaterialConnectionPoint;
  62432. /**
  62433. * Gets the r output component
  62434. */
  62435. get r(): NodeMaterialConnectionPoint;
  62436. /**
  62437. * Gets the g output component
  62438. */
  62439. get g(): NodeMaterialConnectionPoint;
  62440. /**
  62441. * Gets the b output component
  62442. */
  62443. get b(): NodeMaterialConnectionPoint;
  62444. autoConfigure(material: NodeMaterial): void;
  62445. protected _buildBlock(state: NodeMaterialBuildState): this;
  62446. }
  62447. }
  62448. declare module "babylonjs/Materials/Node/Blocks/Dual/index" {
  62449. export * from "babylonjs/Materials/Node/Blocks/Dual/fogBlock";
  62450. export * from "babylonjs/Materials/Node/Blocks/Dual/lightBlock";
  62451. export * from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  62452. export * from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  62453. }
  62454. declare module "babylonjs/Materials/Node/Blocks/Input/index" {
  62455. export * from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  62456. export * from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  62457. }
  62458. declare module "babylonjs/Materials/Node/Blocks/multiplyBlock" {
  62459. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62460. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62461. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62462. /**
  62463. * Block used to multiply 2 values
  62464. */
  62465. export class MultiplyBlock extends NodeMaterialBlock {
  62466. /**
  62467. * Creates a new MultiplyBlock
  62468. * @param name defines the block name
  62469. */
  62470. constructor(name: string);
  62471. /**
  62472. * Gets the current class name
  62473. * @returns the class name
  62474. */
  62475. getClassName(): string;
  62476. /**
  62477. * Gets the left operand input component
  62478. */
  62479. get left(): NodeMaterialConnectionPoint;
  62480. /**
  62481. * Gets the right operand input component
  62482. */
  62483. get right(): NodeMaterialConnectionPoint;
  62484. /**
  62485. * Gets the output component
  62486. */
  62487. get output(): NodeMaterialConnectionPoint;
  62488. protected _buildBlock(state: NodeMaterialBuildState): this;
  62489. }
  62490. }
  62491. declare module "babylonjs/Materials/Node/Blocks/addBlock" {
  62492. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62493. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62494. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62495. /**
  62496. * Block used to add 2 vectors
  62497. */
  62498. export class AddBlock extends NodeMaterialBlock {
  62499. /**
  62500. * Creates a new AddBlock
  62501. * @param name defines the block name
  62502. */
  62503. constructor(name: string);
  62504. /**
  62505. * Gets the current class name
  62506. * @returns the class name
  62507. */
  62508. getClassName(): string;
  62509. /**
  62510. * Gets the left operand input component
  62511. */
  62512. get left(): NodeMaterialConnectionPoint;
  62513. /**
  62514. * Gets the right operand input component
  62515. */
  62516. get right(): NodeMaterialConnectionPoint;
  62517. /**
  62518. * Gets the output component
  62519. */
  62520. get output(): NodeMaterialConnectionPoint;
  62521. protected _buildBlock(state: NodeMaterialBuildState): this;
  62522. }
  62523. }
  62524. declare module "babylonjs/Materials/Node/Blocks/scaleBlock" {
  62525. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62526. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62527. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62528. /**
  62529. * Block used to scale a vector by a float
  62530. */
  62531. export class ScaleBlock extends NodeMaterialBlock {
  62532. /**
  62533. * Creates a new ScaleBlock
  62534. * @param name defines the block name
  62535. */
  62536. constructor(name: string);
  62537. /**
  62538. * Gets the current class name
  62539. * @returns the class name
  62540. */
  62541. getClassName(): string;
  62542. /**
  62543. * Gets the input component
  62544. */
  62545. get input(): NodeMaterialConnectionPoint;
  62546. /**
  62547. * Gets the factor input component
  62548. */
  62549. get factor(): NodeMaterialConnectionPoint;
  62550. /**
  62551. * Gets the output component
  62552. */
  62553. get output(): NodeMaterialConnectionPoint;
  62554. protected _buildBlock(state: NodeMaterialBuildState): this;
  62555. }
  62556. }
  62557. declare module "babylonjs/Materials/Node/Blocks/clampBlock" {
  62558. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62559. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62560. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62561. import { Scene } from "babylonjs/scene";
  62562. /**
  62563. * Block used to clamp a float
  62564. */
  62565. export class ClampBlock extends NodeMaterialBlock {
  62566. /** Gets or sets the minimum range */
  62567. minimum: number;
  62568. /** Gets or sets the maximum range */
  62569. maximum: number;
  62570. /**
  62571. * Creates a new ClampBlock
  62572. * @param name defines the block name
  62573. */
  62574. constructor(name: string);
  62575. /**
  62576. * Gets the current class name
  62577. * @returns the class name
  62578. */
  62579. getClassName(): string;
  62580. /**
  62581. * Gets the value input component
  62582. */
  62583. get value(): NodeMaterialConnectionPoint;
  62584. /**
  62585. * Gets the output component
  62586. */
  62587. get output(): NodeMaterialConnectionPoint;
  62588. protected _buildBlock(state: NodeMaterialBuildState): this;
  62589. protected _dumpPropertiesCode(): string;
  62590. serialize(): any;
  62591. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62592. }
  62593. }
  62594. declare module "babylonjs/Materials/Node/Blocks/crossBlock" {
  62595. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62596. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62597. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62598. /**
  62599. * Block used to apply a cross product between 2 vectors
  62600. */
  62601. export class CrossBlock extends NodeMaterialBlock {
  62602. /**
  62603. * Creates a new CrossBlock
  62604. * @param name defines the block name
  62605. */
  62606. constructor(name: string);
  62607. /**
  62608. * Gets the current class name
  62609. * @returns the class name
  62610. */
  62611. getClassName(): string;
  62612. /**
  62613. * Gets the left operand input component
  62614. */
  62615. get left(): NodeMaterialConnectionPoint;
  62616. /**
  62617. * Gets the right operand input component
  62618. */
  62619. get right(): NodeMaterialConnectionPoint;
  62620. /**
  62621. * Gets the output component
  62622. */
  62623. get output(): NodeMaterialConnectionPoint;
  62624. protected _buildBlock(state: NodeMaterialBuildState): this;
  62625. }
  62626. }
  62627. declare module "babylonjs/Materials/Node/Blocks/dotBlock" {
  62628. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62629. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62630. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62631. /**
  62632. * Block used to apply a dot product between 2 vectors
  62633. */
  62634. export class DotBlock extends NodeMaterialBlock {
  62635. /**
  62636. * Creates a new DotBlock
  62637. * @param name defines the block name
  62638. */
  62639. constructor(name: string);
  62640. /**
  62641. * Gets the current class name
  62642. * @returns the class name
  62643. */
  62644. getClassName(): string;
  62645. /**
  62646. * Gets the left operand input component
  62647. */
  62648. get left(): NodeMaterialConnectionPoint;
  62649. /**
  62650. * Gets the right operand input component
  62651. */
  62652. get right(): NodeMaterialConnectionPoint;
  62653. /**
  62654. * Gets the output component
  62655. */
  62656. get output(): NodeMaterialConnectionPoint;
  62657. protected _buildBlock(state: NodeMaterialBuildState): this;
  62658. }
  62659. }
  62660. declare module "babylonjs/Materials/Node/Blocks/remapBlock" {
  62661. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62662. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62663. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62664. import { Vector2 } from "babylonjs/Maths/math.vector";
  62665. import { Scene } from "babylonjs/scene";
  62666. /**
  62667. * Block used to remap a float from a range to a new one
  62668. */
  62669. export class RemapBlock extends NodeMaterialBlock {
  62670. /**
  62671. * Gets or sets the source range
  62672. */
  62673. sourceRange: Vector2;
  62674. /**
  62675. * Gets or sets the target range
  62676. */
  62677. targetRange: Vector2;
  62678. /**
  62679. * Creates a new RemapBlock
  62680. * @param name defines the block name
  62681. */
  62682. constructor(name: string);
  62683. /**
  62684. * Gets the current class name
  62685. * @returns the class name
  62686. */
  62687. getClassName(): string;
  62688. /**
  62689. * Gets the input component
  62690. */
  62691. get input(): NodeMaterialConnectionPoint;
  62692. /**
  62693. * Gets the source min input component
  62694. */
  62695. get sourceMin(): NodeMaterialConnectionPoint;
  62696. /**
  62697. * Gets the source max input component
  62698. */
  62699. get sourceMax(): NodeMaterialConnectionPoint;
  62700. /**
  62701. * Gets the target min input component
  62702. */
  62703. get targetMin(): NodeMaterialConnectionPoint;
  62704. /**
  62705. * Gets the target max input component
  62706. */
  62707. get targetMax(): NodeMaterialConnectionPoint;
  62708. /**
  62709. * Gets the output component
  62710. */
  62711. get output(): NodeMaterialConnectionPoint;
  62712. protected _buildBlock(state: NodeMaterialBuildState): this;
  62713. protected _dumpPropertiesCode(): string;
  62714. serialize(): any;
  62715. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62716. }
  62717. }
  62718. declare module "babylonjs/Materials/Node/Blocks/normalizeBlock" {
  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 normalize a vector
  62724. */
  62725. export class NormalizeBlock extends NodeMaterialBlock {
  62726. /**
  62727. * Creates a new NormalizeBlock
  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 output component
  62742. */
  62743. get output(): NodeMaterialConnectionPoint;
  62744. protected _buildBlock(state: NodeMaterialBuildState): this;
  62745. }
  62746. }
  62747. declare module "babylonjs/Materials/Node/Blocks/trigonometryBlock" {
  62748. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62749. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62750. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62751. import { Scene } from "babylonjs/scene";
  62752. /**
  62753. * Operations supported by the Trigonometry block
  62754. */
  62755. export enum TrigonometryBlockOperations {
  62756. /** Cos */
  62757. Cos = 0,
  62758. /** Sin */
  62759. Sin = 1,
  62760. /** Abs */
  62761. Abs = 2,
  62762. /** Exp */
  62763. Exp = 3,
  62764. /** Exp2 */
  62765. Exp2 = 4,
  62766. /** Round */
  62767. Round = 5,
  62768. /** Floor */
  62769. Floor = 6,
  62770. /** Ceiling */
  62771. Ceiling = 7,
  62772. /** Square root */
  62773. Sqrt = 8,
  62774. /** Log */
  62775. Log = 9,
  62776. /** Tangent */
  62777. Tan = 10,
  62778. /** Arc tangent */
  62779. ArcTan = 11,
  62780. /** Arc cosinus */
  62781. ArcCos = 12,
  62782. /** Arc sinus */
  62783. ArcSin = 13,
  62784. /** Fraction */
  62785. Fract = 14,
  62786. /** Sign */
  62787. Sign = 15,
  62788. /** To radians (from degrees) */
  62789. Radians = 16,
  62790. /** To degrees (from radians) */
  62791. Degrees = 17
  62792. }
  62793. /**
  62794. * Block used to apply trigonometry operation to floats
  62795. */
  62796. export class TrigonometryBlock extends NodeMaterialBlock {
  62797. /**
  62798. * Gets or sets the operation applied by the block
  62799. */
  62800. operation: TrigonometryBlockOperations;
  62801. /**
  62802. * Creates a new TrigonometryBlock
  62803. * @param name defines the block name
  62804. */
  62805. constructor(name: string);
  62806. /**
  62807. * Gets the current class name
  62808. * @returns the class name
  62809. */
  62810. getClassName(): string;
  62811. /**
  62812. * Gets the input component
  62813. */
  62814. get input(): NodeMaterialConnectionPoint;
  62815. /**
  62816. * Gets the output component
  62817. */
  62818. get output(): NodeMaterialConnectionPoint;
  62819. protected _buildBlock(state: NodeMaterialBuildState): this;
  62820. serialize(): any;
  62821. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62822. protected _dumpPropertiesCode(): string;
  62823. }
  62824. }
  62825. declare module "babylonjs/Materials/Node/Blocks/colorMergerBlock" {
  62826. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62827. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62828. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62829. /**
  62830. * Block used to create a Color3/4 out of individual inputs (one for each component)
  62831. */
  62832. export class ColorMergerBlock extends NodeMaterialBlock {
  62833. /**
  62834. * Create a new ColorMergerBlock
  62835. * @param name defines the block name
  62836. */
  62837. constructor(name: string);
  62838. /**
  62839. * Gets the current class name
  62840. * @returns the class name
  62841. */
  62842. getClassName(): string;
  62843. /**
  62844. * Gets the rgb component (input)
  62845. */
  62846. get rgbIn(): NodeMaterialConnectionPoint;
  62847. /**
  62848. * Gets the r component (input)
  62849. */
  62850. get r(): NodeMaterialConnectionPoint;
  62851. /**
  62852. * Gets the g component (input)
  62853. */
  62854. get g(): NodeMaterialConnectionPoint;
  62855. /**
  62856. * Gets the b component (input)
  62857. */
  62858. get b(): NodeMaterialConnectionPoint;
  62859. /**
  62860. * Gets the a component (input)
  62861. */
  62862. get a(): NodeMaterialConnectionPoint;
  62863. /**
  62864. * Gets the rgba component (output)
  62865. */
  62866. get rgba(): NodeMaterialConnectionPoint;
  62867. /**
  62868. * Gets the rgb component (output)
  62869. */
  62870. get rgbOut(): NodeMaterialConnectionPoint;
  62871. /**
  62872. * Gets the rgb component (output)
  62873. * @deprecated Please use rgbOut instead.
  62874. */
  62875. get rgb(): NodeMaterialConnectionPoint;
  62876. protected _buildBlock(state: NodeMaterialBuildState): this;
  62877. }
  62878. }
  62879. declare module "babylonjs/Materials/Node/Blocks/vectorMergerBlock" {
  62880. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62881. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62882. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62883. /**
  62884. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  62885. */
  62886. export class VectorMergerBlock extends NodeMaterialBlock {
  62887. /**
  62888. * Create a new VectorMergerBlock
  62889. * @param name defines the block name
  62890. */
  62891. constructor(name: string);
  62892. /**
  62893. * Gets the current class name
  62894. * @returns the class name
  62895. */
  62896. getClassName(): string;
  62897. /**
  62898. * Gets the xyz component (input)
  62899. */
  62900. get xyzIn(): NodeMaterialConnectionPoint;
  62901. /**
  62902. * Gets the xy component (input)
  62903. */
  62904. get xyIn(): NodeMaterialConnectionPoint;
  62905. /**
  62906. * Gets the x component (input)
  62907. */
  62908. get x(): NodeMaterialConnectionPoint;
  62909. /**
  62910. * Gets the y component (input)
  62911. */
  62912. get y(): NodeMaterialConnectionPoint;
  62913. /**
  62914. * Gets the z component (input)
  62915. */
  62916. get z(): NodeMaterialConnectionPoint;
  62917. /**
  62918. * Gets the w component (input)
  62919. */
  62920. get w(): NodeMaterialConnectionPoint;
  62921. /**
  62922. * Gets the xyzw component (output)
  62923. */
  62924. get xyzw(): NodeMaterialConnectionPoint;
  62925. /**
  62926. * Gets the xyz component (output)
  62927. */
  62928. get xyzOut(): NodeMaterialConnectionPoint;
  62929. /**
  62930. * Gets the xy component (output)
  62931. */
  62932. get xyOut(): NodeMaterialConnectionPoint;
  62933. /**
  62934. * Gets the xy component (output)
  62935. * @deprecated Please use xyOut instead.
  62936. */
  62937. get xy(): NodeMaterialConnectionPoint;
  62938. /**
  62939. * Gets the xyz component (output)
  62940. * @deprecated Please use xyzOut instead.
  62941. */
  62942. get xyz(): NodeMaterialConnectionPoint;
  62943. protected _buildBlock(state: NodeMaterialBuildState): this;
  62944. }
  62945. }
  62946. declare module "babylonjs/Materials/Node/Blocks/colorSplitterBlock" {
  62947. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62948. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62949. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62950. /**
  62951. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  62952. */
  62953. export class ColorSplitterBlock extends NodeMaterialBlock {
  62954. /**
  62955. * Create a new ColorSplitterBlock
  62956. * @param name defines the block name
  62957. */
  62958. constructor(name: string);
  62959. /**
  62960. * Gets the current class name
  62961. * @returns the class name
  62962. */
  62963. getClassName(): string;
  62964. /**
  62965. * Gets the rgba component (input)
  62966. */
  62967. get rgba(): NodeMaterialConnectionPoint;
  62968. /**
  62969. * Gets the rgb component (input)
  62970. */
  62971. get rgbIn(): NodeMaterialConnectionPoint;
  62972. /**
  62973. * Gets the rgb component (output)
  62974. */
  62975. get rgbOut(): NodeMaterialConnectionPoint;
  62976. /**
  62977. * Gets the r component (output)
  62978. */
  62979. get r(): NodeMaterialConnectionPoint;
  62980. /**
  62981. * Gets the g component (output)
  62982. */
  62983. get g(): NodeMaterialConnectionPoint;
  62984. /**
  62985. * Gets the b component (output)
  62986. */
  62987. get b(): NodeMaterialConnectionPoint;
  62988. /**
  62989. * Gets the a component (output)
  62990. */
  62991. get a(): NodeMaterialConnectionPoint;
  62992. protected _inputRename(name: string): string;
  62993. protected _outputRename(name: string): string;
  62994. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  62995. }
  62996. }
  62997. declare module "babylonjs/Materials/Node/Blocks/vectorSplitterBlock" {
  62998. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62999. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63000. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63001. /**
  63002. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  63003. */
  63004. export class VectorSplitterBlock extends NodeMaterialBlock {
  63005. /**
  63006. * Create a new VectorSplitterBlock
  63007. * @param name defines the block name
  63008. */
  63009. constructor(name: string);
  63010. /**
  63011. * Gets the current class name
  63012. * @returns the class name
  63013. */
  63014. getClassName(): string;
  63015. /**
  63016. * Gets the xyzw component (input)
  63017. */
  63018. get xyzw(): NodeMaterialConnectionPoint;
  63019. /**
  63020. * Gets the xyz component (input)
  63021. */
  63022. get xyzIn(): NodeMaterialConnectionPoint;
  63023. /**
  63024. * Gets the xy component (input)
  63025. */
  63026. get xyIn(): NodeMaterialConnectionPoint;
  63027. /**
  63028. * Gets the xyz component (output)
  63029. */
  63030. get xyzOut(): NodeMaterialConnectionPoint;
  63031. /**
  63032. * Gets the xy component (output)
  63033. */
  63034. get xyOut(): NodeMaterialConnectionPoint;
  63035. /**
  63036. * Gets the x component (output)
  63037. */
  63038. get x(): NodeMaterialConnectionPoint;
  63039. /**
  63040. * Gets the y component (output)
  63041. */
  63042. get y(): NodeMaterialConnectionPoint;
  63043. /**
  63044. * Gets the z component (output)
  63045. */
  63046. get z(): NodeMaterialConnectionPoint;
  63047. /**
  63048. * Gets the w component (output)
  63049. */
  63050. get w(): NodeMaterialConnectionPoint;
  63051. protected _inputRename(name: string): string;
  63052. protected _outputRename(name: string): string;
  63053. protected _buildBlock(state: NodeMaterialBuildState): this;
  63054. }
  63055. }
  63056. declare module "babylonjs/Materials/Node/Blocks/lerpBlock" {
  63057. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63058. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63059. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63060. /**
  63061. * Block used to lerp between 2 values
  63062. */
  63063. export class LerpBlock extends NodeMaterialBlock {
  63064. /**
  63065. * Creates a new LerpBlock
  63066. * @param name defines the block name
  63067. */
  63068. constructor(name: string);
  63069. /**
  63070. * Gets the current class name
  63071. * @returns the class name
  63072. */
  63073. getClassName(): string;
  63074. /**
  63075. * Gets the left operand input component
  63076. */
  63077. get left(): NodeMaterialConnectionPoint;
  63078. /**
  63079. * Gets the right operand input component
  63080. */
  63081. get right(): NodeMaterialConnectionPoint;
  63082. /**
  63083. * Gets the gradient operand input component
  63084. */
  63085. get gradient(): NodeMaterialConnectionPoint;
  63086. /**
  63087. * Gets the output component
  63088. */
  63089. get output(): NodeMaterialConnectionPoint;
  63090. protected _buildBlock(state: NodeMaterialBuildState): this;
  63091. }
  63092. }
  63093. declare module "babylonjs/Materials/Node/Blocks/divideBlock" {
  63094. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63095. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63096. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63097. /**
  63098. * Block used to divide 2 vectors
  63099. */
  63100. export class DivideBlock extends NodeMaterialBlock {
  63101. /**
  63102. * Creates a new DivideBlock
  63103. * @param name defines the block name
  63104. */
  63105. constructor(name: string);
  63106. /**
  63107. * Gets the current class name
  63108. * @returns the class name
  63109. */
  63110. getClassName(): string;
  63111. /**
  63112. * Gets the left operand input component
  63113. */
  63114. get left(): NodeMaterialConnectionPoint;
  63115. /**
  63116. * Gets the right operand input component
  63117. */
  63118. get right(): NodeMaterialConnectionPoint;
  63119. /**
  63120. * Gets the output component
  63121. */
  63122. get output(): NodeMaterialConnectionPoint;
  63123. protected _buildBlock(state: NodeMaterialBuildState): this;
  63124. }
  63125. }
  63126. declare module "babylonjs/Materials/Node/Blocks/subtractBlock" {
  63127. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63128. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63129. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63130. /**
  63131. * Block used to subtract 2 vectors
  63132. */
  63133. export class SubtractBlock extends NodeMaterialBlock {
  63134. /**
  63135. * Creates a new SubtractBlock
  63136. * @param name defines the block name
  63137. */
  63138. constructor(name: string);
  63139. /**
  63140. * Gets the current class name
  63141. * @returns the class name
  63142. */
  63143. getClassName(): string;
  63144. /**
  63145. * Gets the left operand input component
  63146. */
  63147. get left(): NodeMaterialConnectionPoint;
  63148. /**
  63149. * Gets the right operand input component
  63150. */
  63151. get right(): NodeMaterialConnectionPoint;
  63152. /**
  63153. * Gets the output component
  63154. */
  63155. get output(): NodeMaterialConnectionPoint;
  63156. protected _buildBlock(state: NodeMaterialBuildState): this;
  63157. }
  63158. }
  63159. declare module "babylonjs/Materials/Node/Blocks/stepBlock" {
  63160. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63161. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63162. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63163. /**
  63164. * Block used to step a value
  63165. */
  63166. export class StepBlock extends NodeMaterialBlock {
  63167. /**
  63168. * Creates a new StepBlock
  63169. * @param name defines the block name
  63170. */
  63171. constructor(name: string);
  63172. /**
  63173. * Gets the current class name
  63174. * @returns the class name
  63175. */
  63176. getClassName(): string;
  63177. /**
  63178. * Gets the value operand input component
  63179. */
  63180. get value(): NodeMaterialConnectionPoint;
  63181. /**
  63182. * Gets the edge operand input component
  63183. */
  63184. get edge(): NodeMaterialConnectionPoint;
  63185. /**
  63186. * Gets the output component
  63187. */
  63188. get output(): NodeMaterialConnectionPoint;
  63189. protected _buildBlock(state: NodeMaterialBuildState): this;
  63190. }
  63191. }
  63192. declare module "babylonjs/Materials/Node/Blocks/oneMinusBlock" {
  63193. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63194. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63195. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63196. /**
  63197. * Block used to get the opposite (1 - x) of a value
  63198. */
  63199. export class OneMinusBlock extends NodeMaterialBlock {
  63200. /**
  63201. * Creates a new OneMinusBlock
  63202. * @param name defines the block name
  63203. */
  63204. constructor(name: string);
  63205. /**
  63206. * Gets the current class name
  63207. * @returns the class name
  63208. */
  63209. getClassName(): string;
  63210. /**
  63211. * Gets the input component
  63212. */
  63213. get input(): NodeMaterialConnectionPoint;
  63214. /**
  63215. * Gets the output component
  63216. */
  63217. get output(): NodeMaterialConnectionPoint;
  63218. protected _buildBlock(state: NodeMaterialBuildState): this;
  63219. }
  63220. }
  63221. declare module "babylonjs/Materials/Node/Blocks/viewDirectionBlock" {
  63222. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63223. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63224. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63225. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  63226. /**
  63227. * Block used to get the view direction
  63228. */
  63229. export class ViewDirectionBlock extends NodeMaterialBlock {
  63230. /**
  63231. * Creates a new ViewDirectionBlock
  63232. * @param name defines the block name
  63233. */
  63234. constructor(name: string);
  63235. /**
  63236. * Gets the current class name
  63237. * @returns the class name
  63238. */
  63239. getClassName(): string;
  63240. /**
  63241. * Gets the world position component
  63242. */
  63243. get worldPosition(): NodeMaterialConnectionPoint;
  63244. /**
  63245. * Gets the camera position component
  63246. */
  63247. get cameraPosition(): NodeMaterialConnectionPoint;
  63248. /**
  63249. * Gets the output component
  63250. */
  63251. get output(): NodeMaterialConnectionPoint;
  63252. autoConfigure(material: NodeMaterial): void;
  63253. protected _buildBlock(state: NodeMaterialBuildState): this;
  63254. }
  63255. }
  63256. declare module "babylonjs/Materials/Node/Blocks/fresnelBlock" {
  63257. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63258. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63259. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63260. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  63261. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  63262. /**
  63263. * Block used to compute fresnel value
  63264. */
  63265. export class FresnelBlock extends NodeMaterialBlock {
  63266. /**
  63267. * Create a new FresnelBlock
  63268. * @param name defines the block name
  63269. */
  63270. constructor(name: string);
  63271. /**
  63272. * Gets the current class name
  63273. * @returns the class name
  63274. */
  63275. getClassName(): string;
  63276. /**
  63277. * Gets the world normal input component
  63278. */
  63279. get worldNormal(): NodeMaterialConnectionPoint;
  63280. /**
  63281. * Gets the view direction input component
  63282. */
  63283. get viewDirection(): NodeMaterialConnectionPoint;
  63284. /**
  63285. * Gets the bias input component
  63286. */
  63287. get bias(): NodeMaterialConnectionPoint;
  63288. /**
  63289. * Gets the camera (or eye) position component
  63290. */
  63291. get power(): NodeMaterialConnectionPoint;
  63292. /**
  63293. * Gets the fresnel output component
  63294. */
  63295. get fresnel(): NodeMaterialConnectionPoint;
  63296. autoConfigure(material: NodeMaterial): void;
  63297. protected _buildBlock(state: NodeMaterialBuildState): this;
  63298. }
  63299. }
  63300. declare module "babylonjs/Materials/Node/Blocks/maxBlock" {
  63301. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63302. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63303. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63304. /**
  63305. * Block used to get the max of 2 values
  63306. */
  63307. export class MaxBlock extends NodeMaterialBlock {
  63308. /**
  63309. * Creates a new MaxBlock
  63310. * @param name defines the block name
  63311. */
  63312. constructor(name: string);
  63313. /**
  63314. * Gets the current class name
  63315. * @returns the class name
  63316. */
  63317. getClassName(): string;
  63318. /**
  63319. * Gets the left operand input component
  63320. */
  63321. get left(): NodeMaterialConnectionPoint;
  63322. /**
  63323. * Gets the right operand input component
  63324. */
  63325. get right(): NodeMaterialConnectionPoint;
  63326. /**
  63327. * Gets the output component
  63328. */
  63329. get output(): NodeMaterialConnectionPoint;
  63330. protected _buildBlock(state: NodeMaterialBuildState): this;
  63331. }
  63332. }
  63333. declare module "babylonjs/Materials/Node/Blocks/minBlock" {
  63334. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63335. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63336. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63337. /**
  63338. * Block used to get the min of 2 values
  63339. */
  63340. export class MinBlock extends NodeMaterialBlock {
  63341. /**
  63342. * Creates a new MinBlock
  63343. * @param name defines the block name
  63344. */
  63345. constructor(name: string);
  63346. /**
  63347. * Gets the current class name
  63348. * @returns the class name
  63349. */
  63350. getClassName(): string;
  63351. /**
  63352. * Gets the left operand input component
  63353. */
  63354. get left(): NodeMaterialConnectionPoint;
  63355. /**
  63356. * Gets the right operand input component
  63357. */
  63358. get right(): NodeMaterialConnectionPoint;
  63359. /**
  63360. * Gets the output component
  63361. */
  63362. get output(): NodeMaterialConnectionPoint;
  63363. protected _buildBlock(state: NodeMaterialBuildState): this;
  63364. }
  63365. }
  63366. declare module "babylonjs/Materials/Node/Blocks/distanceBlock" {
  63367. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63368. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63369. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63370. /**
  63371. * Block used to get the distance between 2 values
  63372. */
  63373. export class DistanceBlock extends NodeMaterialBlock {
  63374. /**
  63375. * Creates a new DistanceBlock
  63376. * @param name defines the block name
  63377. */
  63378. constructor(name: string);
  63379. /**
  63380. * Gets the current class name
  63381. * @returns the class name
  63382. */
  63383. getClassName(): string;
  63384. /**
  63385. * Gets the left operand input component
  63386. */
  63387. get left(): NodeMaterialConnectionPoint;
  63388. /**
  63389. * Gets the right operand input component
  63390. */
  63391. get right(): NodeMaterialConnectionPoint;
  63392. /**
  63393. * Gets the output component
  63394. */
  63395. get output(): NodeMaterialConnectionPoint;
  63396. protected _buildBlock(state: NodeMaterialBuildState): this;
  63397. }
  63398. }
  63399. declare module "babylonjs/Materials/Node/Blocks/lengthBlock" {
  63400. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63401. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63402. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63403. /**
  63404. * Block used to get the length of a vector
  63405. */
  63406. export class LengthBlock extends NodeMaterialBlock {
  63407. /**
  63408. * Creates a new LengthBlock
  63409. * @param name defines the block name
  63410. */
  63411. constructor(name: string);
  63412. /**
  63413. * Gets the current class name
  63414. * @returns the class name
  63415. */
  63416. getClassName(): string;
  63417. /**
  63418. * Gets the value input component
  63419. */
  63420. get value(): NodeMaterialConnectionPoint;
  63421. /**
  63422. * Gets the output component
  63423. */
  63424. get output(): NodeMaterialConnectionPoint;
  63425. protected _buildBlock(state: NodeMaterialBuildState): this;
  63426. }
  63427. }
  63428. declare module "babylonjs/Materials/Node/Blocks/negateBlock" {
  63429. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63430. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63431. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63432. /**
  63433. * Block used to get negative version of a value (i.e. x * -1)
  63434. */
  63435. export class NegateBlock extends NodeMaterialBlock {
  63436. /**
  63437. * Creates a new NegateBlock
  63438. * @param name defines the block name
  63439. */
  63440. constructor(name: string);
  63441. /**
  63442. * Gets the current class name
  63443. * @returns the class name
  63444. */
  63445. getClassName(): string;
  63446. /**
  63447. * Gets the value input component
  63448. */
  63449. get value(): NodeMaterialConnectionPoint;
  63450. /**
  63451. * Gets the output component
  63452. */
  63453. get output(): NodeMaterialConnectionPoint;
  63454. protected _buildBlock(state: NodeMaterialBuildState): this;
  63455. }
  63456. }
  63457. declare module "babylonjs/Materials/Node/Blocks/powBlock" {
  63458. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63459. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63460. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63461. /**
  63462. * Block used to get the value of the first parameter raised to the power of the second
  63463. */
  63464. export class PowBlock extends NodeMaterialBlock {
  63465. /**
  63466. * Creates a new PowBlock
  63467. * @param name defines the block name
  63468. */
  63469. constructor(name: string);
  63470. /**
  63471. * Gets the current class name
  63472. * @returns the class name
  63473. */
  63474. getClassName(): string;
  63475. /**
  63476. * Gets the value operand input component
  63477. */
  63478. get value(): NodeMaterialConnectionPoint;
  63479. /**
  63480. * Gets the power operand input component
  63481. */
  63482. get power(): NodeMaterialConnectionPoint;
  63483. /**
  63484. * Gets the output component
  63485. */
  63486. get output(): NodeMaterialConnectionPoint;
  63487. protected _buildBlock(state: NodeMaterialBuildState): this;
  63488. }
  63489. }
  63490. declare module "babylonjs/Materials/Node/Blocks/randomNumberBlock" {
  63491. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63492. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63493. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63494. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  63495. /**
  63496. * Block used to get a random number
  63497. */
  63498. export class RandomNumberBlock extends NodeMaterialBlock {
  63499. /**
  63500. * Creates a new RandomNumberBlock
  63501. * @param name defines the block name
  63502. */
  63503. constructor(name: string);
  63504. /**
  63505. * Gets the current class name
  63506. * @returns the class name
  63507. */
  63508. getClassName(): string;
  63509. /**
  63510. * Gets the seed input component
  63511. */
  63512. get seed(): NodeMaterialConnectionPoint;
  63513. /**
  63514. * Gets the output component
  63515. */
  63516. get output(): NodeMaterialConnectionPoint;
  63517. protected _buildBlock(state: NodeMaterialBuildState): this;
  63518. }
  63519. }
  63520. declare module "babylonjs/Materials/Node/Blocks/arcTan2Block" {
  63521. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63522. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63523. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63524. /**
  63525. * Block used to compute arc tangent of 2 values
  63526. */
  63527. export class ArcTan2Block extends NodeMaterialBlock {
  63528. /**
  63529. * Creates a new ArcTan2Block
  63530. * @param name defines the block name
  63531. */
  63532. constructor(name: string);
  63533. /**
  63534. * Gets the current class name
  63535. * @returns the class name
  63536. */
  63537. getClassName(): string;
  63538. /**
  63539. * Gets the x operand input component
  63540. */
  63541. get x(): NodeMaterialConnectionPoint;
  63542. /**
  63543. * Gets the y operand input component
  63544. */
  63545. get y(): NodeMaterialConnectionPoint;
  63546. /**
  63547. * Gets the output component
  63548. */
  63549. get output(): NodeMaterialConnectionPoint;
  63550. protected _buildBlock(state: NodeMaterialBuildState): this;
  63551. }
  63552. }
  63553. declare module "babylonjs/Materials/Node/Blocks/smoothStepBlock" {
  63554. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63555. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63556. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63557. /**
  63558. * Block used to smooth step a value
  63559. */
  63560. export class SmoothStepBlock extends NodeMaterialBlock {
  63561. /**
  63562. * Creates a new SmoothStepBlock
  63563. * @param name defines the block name
  63564. */
  63565. constructor(name: string);
  63566. /**
  63567. * Gets the current class name
  63568. * @returns the class name
  63569. */
  63570. getClassName(): string;
  63571. /**
  63572. * Gets the value operand input component
  63573. */
  63574. get value(): NodeMaterialConnectionPoint;
  63575. /**
  63576. * Gets the first edge operand input component
  63577. */
  63578. get edge0(): NodeMaterialConnectionPoint;
  63579. /**
  63580. * Gets the second edge operand input component
  63581. */
  63582. get edge1(): NodeMaterialConnectionPoint;
  63583. /**
  63584. * Gets the output component
  63585. */
  63586. get output(): NodeMaterialConnectionPoint;
  63587. protected _buildBlock(state: NodeMaterialBuildState): this;
  63588. }
  63589. }
  63590. declare module "babylonjs/Materials/Node/Blocks/reciprocalBlock" {
  63591. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63592. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63593. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63594. /**
  63595. * Block used to get the reciprocal (1 / x) of a value
  63596. */
  63597. export class ReciprocalBlock extends NodeMaterialBlock {
  63598. /**
  63599. * Creates a new ReciprocalBlock
  63600. * @param name defines the block name
  63601. */
  63602. constructor(name: string);
  63603. /**
  63604. * Gets the current class name
  63605. * @returns the class name
  63606. */
  63607. getClassName(): string;
  63608. /**
  63609. * Gets the input component
  63610. */
  63611. get input(): NodeMaterialConnectionPoint;
  63612. /**
  63613. * Gets the output component
  63614. */
  63615. get output(): NodeMaterialConnectionPoint;
  63616. protected _buildBlock(state: NodeMaterialBuildState): this;
  63617. }
  63618. }
  63619. declare module "babylonjs/Materials/Node/Blocks/replaceColorBlock" {
  63620. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63621. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63622. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63623. /**
  63624. * Block used to replace a color by another one
  63625. */
  63626. export class ReplaceColorBlock extends NodeMaterialBlock {
  63627. /**
  63628. * Creates a new ReplaceColorBlock
  63629. * @param name defines the block name
  63630. */
  63631. constructor(name: string);
  63632. /**
  63633. * Gets the current class name
  63634. * @returns the class name
  63635. */
  63636. getClassName(): string;
  63637. /**
  63638. * Gets the value input component
  63639. */
  63640. get value(): NodeMaterialConnectionPoint;
  63641. /**
  63642. * Gets the reference input component
  63643. */
  63644. get reference(): NodeMaterialConnectionPoint;
  63645. /**
  63646. * Gets the distance input component
  63647. */
  63648. get distance(): NodeMaterialConnectionPoint;
  63649. /**
  63650. * Gets the replacement input component
  63651. */
  63652. get replacement(): NodeMaterialConnectionPoint;
  63653. /**
  63654. * Gets the output component
  63655. */
  63656. get output(): NodeMaterialConnectionPoint;
  63657. protected _buildBlock(state: NodeMaterialBuildState): this;
  63658. }
  63659. }
  63660. declare module "babylonjs/Materials/Node/Blocks/posterizeBlock" {
  63661. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63662. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63663. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63664. /**
  63665. * Block used to posterize a value
  63666. * @see https://en.wikipedia.org/wiki/Posterization
  63667. */
  63668. export class PosterizeBlock extends NodeMaterialBlock {
  63669. /**
  63670. * Creates a new PosterizeBlock
  63671. * @param name defines the block name
  63672. */
  63673. constructor(name: string);
  63674. /**
  63675. * Gets the current class name
  63676. * @returns the class name
  63677. */
  63678. getClassName(): string;
  63679. /**
  63680. * Gets the value input component
  63681. */
  63682. get value(): NodeMaterialConnectionPoint;
  63683. /**
  63684. * Gets the steps input component
  63685. */
  63686. get steps(): NodeMaterialConnectionPoint;
  63687. /**
  63688. * Gets the output component
  63689. */
  63690. get output(): NodeMaterialConnectionPoint;
  63691. protected _buildBlock(state: NodeMaterialBuildState): this;
  63692. }
  63693. }
  63694. declare module "babylonjs/Materials/Node/Blocks/waveBlock" {
  63695. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63696. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63697. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63698. import { Scene } from "babylonjs/scene";
  63699. /**
  63700. * Operations supported by the Wave block
  63701. */
  63702. export enum WaveBlockKind {
  63703. /** SawTooth */
  63704. SawTooth = 0,
  63705. /** Square */
  63706. Square = 1,
  63707. /** Triangle */
  63708. Triangle = 2
  63709. }
  63710. /**
  63711. * Block used to apply wave operation to floats
  63712. */
  63713. export class WaveBlock extends NodeMaterialBlock {
  63714. /**
  63715. * Gets or sets the kibnd of wave to be applied by the block
  63716. */
  63717. kind: WaveBlockKind;
  63718. /**
  63719. * Creates a new WaveBlock
  63720. * @param name defines the block name
  63721. */
  63722. constructor(name: string);
  63723. /**
  63724. * Gets the current class name
  63725. * @returns the class name
  63726. */
  63727. getClassName(): string;
  63728. /**
  63729. * Gets the input component
  63730. */
  63731. get input(): NodeMaterialConnectionPoint;
  63732. /**
  63733. * Gets the output component
  63734. */
  63735. get output(): NodeMaterialConnectionPoint;
  63736. protected _buildBlock(state: NodeMaterialBuildState): this;
  63737. serialize(): any;
  63738. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  63739. }
  63740. }
  63741. declare module "babylonjs/Materials/Node/Blocks/gradientBlock" {
  63742. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63743. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63744. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63745. import { Color3 } from "babylonjs/Maths/math.color";
  63746. import { Scene } from "babylonjs/scene";
  63747. /**
  63748. * Class used to store a color step for the GradientBlock
  63749. */
  63750. export class GradientBlockColorStep {
  63751. /**
  63752. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  63753. */
  63754. step: number;
  63755. /**
  63756. * Gets or sets the color associated with this step
  63757. */
  63758. color: Color3;
  63759. /**
  63760. * Creates a new GradientBlockColorStep
  63761. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  63762. * @param color defines the color associated with this step
  63763. */
  63764. constructor(
  63765. /**
  63766. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  63767. */
  63768. step: number,
  63769. /**
  63770. * Gets or sets the color associated with this step
  63771. */
  63772. color: Color3);
  63773. }
  63774. /**
  63775. * Block used to return a color from a gradient based on an input value between 0 and 1
  63776. */
  63777. export class GradientBlock extends NodeMaterialBlock {
  63778. /**
  63779. * Gets or sets the list of color steps
  63780. */
  63781. colorSteps: GradientBlockColorStep[];
  63782. /**
  63783. * Creates a new GradientBlock
  63784. * @param name defines the block name
  63785. */
  63786. constructor(name: string);
  63787. /**
  63788. * Gets the current class name
  63789. * @returns the class name
  63790. */
  63791. getClassName(): string;
  63792. /**
  63793. * Gets the gradient input component
  63794. */
  63795. get gradient(): NodeMaterialConnectionPoint;
  63796. /**
  63797. * Gets the output component
  63798. */
  63799. get output(): NodeMaterialConnectionPoint;
  63800. private _writeColorConstant;
  63801. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  63802. serialize(): any;
  63803. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  63804. protected _dumpPropertiesCode(): string;
  63805. }
  63806. }
  63807. declare module "babylonjs/Materials/Node/Blocks/nLerpBlock" {
  63808. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63809. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63810. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63811. /**
  63812. * Block used to normalize lerp between 2 values
  63813. */
  63814. export class NLerpBlock extends NodeMaterialBlock {
  63815. /**
  63816. * Creates a new NLerpBlock
  63817. * @param name defines the block name
  63818. */
  63819. constructor(name: string);
  63820. /**
  63821. * Gets the current class name
  63822. * @returns the class name
  63823. */
  63824. getClassName(): string;
  63825. /**
  63826. * Gets the left operand input component
  63827. */
  63828. get left(): NodeMaterialConnectionPoint;
  63829. /**
  63830. * Gets the right operand input component
  63831. */
  63832. get right(): NodeMaterialConnectionPoint;
  63833. /**
  63834. * Gets the gradient operand input component
  63835. */
  63836. get gradient(): NodeMaterialConnectionPoint;
  63837. /**
  63838. * Gets the output component
  63839. */
  63840. get output(): NodeMaterialConnectionPoint;
  63841. protected _buildBlock(state: NodeMaterialBuildState): this;
  63842. }
  63843. }
  63844. declare module "babylonjs/Materials/Node/Blocks/worleyNoise3DBlock" {
  63845. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63846. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63847. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63848. import { Scene } from "babylonjs/scene";
  63849. /**
  63850. * block used to Generate a Worley Noise 3D Noise Pattern
  63851. */
  63852. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  63853. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  63854. manhattanDistance: boolean;
  63855. /**
  63856. * Creates a new WorleyNoise3DBlock
  63857. * @param name defines the block name
  63858. */
  63859. constructor(name: string);
  63860. /**
  63861. * Gets the current class name
  63862. * @returns the class name
  63863. */
  63864. getClassName(): string;
  63865. /**
  63866. * Gets the seed input component
  63867. */
  63868. get seed(): NodeMaterialConnectionPoint;
  63869. /**
  63870. * Gets the jitter input component
  63871. */
  63872. get jitter(): NodeMaterialConnectionPoint;
  63873. /**
  63874. * Gets the output component
  63875. */
  63876. get output(): NodeMaterialConnectionPoint;
  63877. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  63878. /**
  63879. * Exposes the properties to the UI?
  63880. */
  63881. protected _dumpPropertiesCode(): string;
  63882. /**
  63883. * Exposes the properties to the Seralize?
  63884. */
  63885. serialize(): any;
  63886. /**
  63887. * Exposes the properties to the deseralize?
  63888. */
  63889. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  63890. }
  63891. }
  63892. declare module "babylonjs/Materials/Node/Blocks/simplexPerlin3DBlock" {
  63893. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63894. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63895. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63896. /**
  63897. * block used to Generate a Simplex Perlin 3d Noise Pattern
  63898. */
  63899. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  63900. /**
  63901. * Creates a new SimplexPerlin3DBlock
  63902. * @param name defines the block name
  63903. */
  63904. constructor(name: string);
  63905. /**
  63906. * Gets the current class name
  63907. * @returns the class name
  63908. */
  63909. getClassName(): string;
  63910. /**
  63911. * Gets the seed operand input component
  63912. */
  63913. get seed(): NodeMaterialConnectionPoint;
  63914. /**
  63915. * Gets the output component
  63916. */
  63917. get output(): NodeMaterialConnectionPoint;
  63918. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  63919. }
  63920. }
  63921. declare module "babylonjs/Materials/Node/Blocks/normalBlendBlock" {
  63922. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63923. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63924. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63925. /**
  63926. * Block used to blend normals
  63927. */
  63928. export class NormalBlendBlock extends NodeMaterialBlock {
  63929. /**
  63930. * Creates a new NormalBlendBlock
  63931. * @param name defines the block name
  63932. */
  63933. constructor(name: string);
  63934. /**
  63935. * Gets the current class name
  63936. * @returns the class name
  63937. */
  63938. getClassName(): string;
  63939. /**
  63940. * Gets the first input component
  63941. */
  63942. get normalMap0(): NodeMaterialConnectionPoint;
  63943. /**
  63944. * Gets the second input component
  63945. */
  63946. get normalMap1(): NodeMaterialConnectionPoint;
  63947. /**
  63948. * Gets the output component
  63949. */
  63950. get output(): NodeMaterialConnectionPoint;
  63951. protected _buildBlock(state: NodeMaterialBuildState): this;
  63952. }
  63953. }
  63954. declare module "babylonjs/Materials/Node/Blocks/rotate2dBlock" {
  63955. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63956. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63957. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63958. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  63959. /**
  63960. * Block used to rotate a 2d vector by a given angle
  63961. */
  63962. export class Rotate2dBlock extends NodeMaterialBlock {
  63963. /**
  63964. * Creates a new Rotate2dBlock
  63965. * @param name defines the block name
  63966. */
  63967. constructor(name: string);
  63968. /**
  63969. * Gets the current class name
  63970. * @returns the class name
  63971. */
  63972. getClassName(): string;
  63973. /**
  63974. * Gets the input vector
  63975. */
  63976. get input(): NodeMaterialConnectionPoint;
  63977. /**
  63978. * Gets the input angle
  63979. */
  63980. get angle(): NodeMaterialConnectionPoint;
  63981. /**
  63982. * Gets the output component
  63983. */
  63984. get output(): NodeMaterialConnectionPoint;
  63985. autoConfigure(material: NodeMaterial): void;
  63986. protected _buildBlock(state: NodeMaterialBuildState): this;
  63987. }
  63988. }
  63989. declare module "babylonjs/Materials/Node/Blocks/reflectBlock" {
  63990. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63991. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63992. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63993. /**
  63994. * Block used to get the reflected vector from a direction and a normal
  63995. */
  63996. export class ReflectBlock extends NodeMaterialBlock {
  63997. /**
  63998. * Creates a new ReflectBlock
  63999. * @param name defines the block name
  64000. */
  64001. constructor(name: string);
  64002. /**
  64003. * Gets the current class name
  64004. * @returns the class name
  64005. */
  64006. getClassName(): string;
  64007. /**
  64008. * Gets the incident component
  64009. */
  64010. get incident(): NodeMaterialConnectionPoint;
  64011. /**
  64012. * Gets the normal component
  64013. */
  64014. get normal(): NodeMaterialConnectionPoint;
  64015. /**
  64016. * Gets the output component
  64017. */
  64018. get output(): NodeMaterialConnectionPoint;
  64019. protected _buildBlock(state: NodeMaterialBuildState): this;
  64020. }
  64021. }
  64022. declare module "babylonjs/Materials/Node/Blocks/refractBlock" {
  64023. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64024. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64025. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64026. /**
  64027. * Block used to get the refracted vector from a direction and a normal
  64028. */
  64029. export class RefractBlock extends NodeMaterialBlock {
  64030. /**
  64031. * Creates a new RefractBlock
  64032. * @param name defines the block name
  64033. */
  64034. constructor(name: string);
  64035. /**
  64036. * Gets the current class name
  64037. * @returns the class name
  64038. */
  64039. getClassName(): string;
  64040. /**
  64041. * Gets the incident component
  64042. */
  64043. get incident(): NodeMaterialConnectionPoint;
  64044. /**
  64045. * Gets the normal component
  64046. */
  64047. get normal(): NodeMaterialConnectionPoint;
  64048. /**
  64049. * Gets the index of refraction component
  64050. */
  64051. get ior(): NodeMaterialConnectionPoint;
  64052. /**
  64053. * Gets the output component
  64054. */
  64055. get output(): NodeMaterialConnectionPoint;
  64056. protected _buildBlock(state: NodeMaterialBuildState): this;
  64057. }
  64058. }
  64059. declare module "babylonjs/Materials/Node/Blocks/desaturateBlock" {
  64060. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64061. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64062. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64063. /**
  64064. * Block used to desaturate a color
  64065. */
  64066. export class DesaturateBlock extends NodeMaterialBlock {
  64067. /**
  64068. * Creates a new DesaturateBlock
  64069. * @param name defines the block name
  64070. */
  64071. constructor(name: string);
  64072. /**
  64073. * Gets the current class name
  64074. * @returns the class name
  64075. */
  64076. getClassName(): string;
  64077. /**
  64078. * Gets the color operand input component
  64079. */
  64080. get color(): NodeMaterialConnectionPoint;
  64081. /**
  64082. * Gets the level operand input component
  64083. */
  64084. get level(): NodeMaterialConnectionPoint;
  64085. /**
  64086. * Gets the output component
  64087. */
  64088. get output(): NodeMaterialConnectionPoint;
  64089. protected _buildBlock(state: NodeMaterialBuildState): this;
  64090. }
  64091. }
  64092. declare module "babylonjs/Materials/Node/nodeMaterialConnectionPointCustomObject" {
  64093. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64094. import { NodeMaterialConnectionPoint, NodeMaterialConnectionPointDirection, NodeMaterialConnectionPointCompatibilityStates } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64095. import { Nullable } from "babylonjs/types";
  64096. /**
  64097. * Defines a connection point to be used for points with a custom object type
  64098. */
  64099. export class NodeMaterialConnectionPointCustomObject<T extends NodeMaterialBlock> extends NodeMaterialConnectionPoint {
  64100. private _blockType;
  64101. private _blockName;
  64102. private _nameForCheking?;
  64103. /**
  64104. * Creates a new connection point
  64105. * @param name defines the connection point name
  64106. * @param ownerBlock defines the block hosting this connection point
  64107. * @param direction defines the direction of the connection point
  64108. */
  64109. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection, _blockType: new (...args: any[]) => T, _blockName: string, _nameForCheking?: string | undefined);
  64110. /**
  64111. * Gets a number indicating if the current point can be connected to another point
  64112. * @param connectionPoint defines the other connection point
  64113. * @returns a number defining the compatibility state
  64114. */
  64115. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  64116. /**
  64117. * Creates a block suitable to be used as an input for this input point.
  64118. * If null is returned, a block based on the point type will be created.
  64119. * @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
  64120. */
  64121. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  64122. }
  64123. }
  64124. declare module "babylonjs/Materials/Node/Blocks/PBR/ambientOcclusionBlock" {
  64125. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64126. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64127. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64128. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  64129. import { Nullable } from "babylonjs/types";
  64130. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64131. import { Scene } from "babylonjs/scene";
  64132. /**
  64133. * Block used to implement the ambient occlusion module of the PBR material
  64134. */
  64135. export class AmbientOcclusionBlock extends NodeMaterialBlock {
  64136. /**
  64137. * Create a new AmbientOcclusionBlock
  64138. * @param name defines the block name
  64139. */
  64140. constructor(name: string);
  64141. /**
  64142. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  64143. */
  64144. useAmbientInGrayScale: boolean;
  64145. /**
  64146. * Initialize the block and prepare the context for build
  64147. * @param state defines the state that will be used for the build
  64148. */
  64149. initialize(state: NodeMaterialBuildState): void;
  64150. /**
  64151. * Gets the current class name
  64152. * @returns the class name
  64153. */
  64154. getClassName(): string;
  64155. /**
  64156. * Gets the texture input component
  64157. */
  64158. get texture(): NodeMaterialConnectionPoint;
  64159. /**
  64160. * Gets the texture intensity component
  64161. */
  64162. get intensity(): NodeMaterialConnectionPoint;
  64163. /**
  64164. * Gets the direct light intensity input component
  64165. */
  64166. get directLightIntensity(): NodeMaterialConnectionPoint;
  64167. /**
  64168. * Gets the ambient occlusion object output component
  64169. */
  64170. get ambientOcclusion(): NodeMaterialConnectionPoint;
  64171. /**
  64172. * Gets the main code of the block (fragment side)
  64173. * @param block instance of an AmbientOcclusionBlock or null if the code must be generated without an active ambient occlusion module
  64174. * @returns the shader code
  64175. */
  64176. static GetCode(block: Nullable<AmbientOcclusionBlock>): string;
  64177. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64178. protected _buildBlock(state: NodeMaterialBuildState): this;
  64179. protected _dumpPropertiesCode(): string;
  64180. serialize(): any;
  64181. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  64182. }
  64183. }
  64184. declare module "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock" {
  64185. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64186. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64187. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  64188. import { ReflectionTextureBaseBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock";
  64189. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64190. import { Nullable } from "babylonjs/types";
  64191. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  64192. import { Mesh } from "babylonjs/Meshes/mesh";
  64193. import { SubMesh } from "babylonjs/Meshes/subMesh";
  64194. import { Effect } from "babylonjs/Materials/effect";
  64195. import { Scene } from "babylonjs/scene";
  64196. /**
  64197. * Block used to implement the reflection module of the PBR material
  64198. */
  64199. export class ReflectionBlock extends ReflectionTextureBaseBlock {
  64200. /** @hidden */
  64201. _defineLODReflectionAlpha: string;
  64202. /** @hidden */
  64203. _defineLinearSpecularReflection: string;
  64204. private _vEnvironmentIrradianceName;
  64205. /** @hidden */
  64206. _vReflectionMicrosurfaceInfosName: string;
  64207. /** @hidden */
  64208. _vReflectionInfosName: string;
  64209. private _scene;
  64210. /**
  64211. * The three properties below are set by the main PBR block prior to calling methods of this class.
  64212. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  64213. * It's less burden on the user side in the editor part.
  64214. */
  64215. /** @hidden */
  64216. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  64217. /** @hidden */
  64218. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  64219. /** @hidden */
  64220. cameraPositionConnectionPoint: NodeMaterialConnectionPoint;
  64221. /**
  64222. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  64223. * diffuse part of the IBL.
  64224. */
  64225. useSphericalHarmonics: boolean;
  64226. /**
  64227. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  64228. */
  64229. forceIrradianceInFragment: boolean;
  64230. /**
  64231. * Create a new ReflectionBlock
  64232. * @param name defines the block name
  64233. */
  64234. constructor(name: string);
  64235. /**
  64236. * Gets the current class name
  64237. * @returns the class name
  64238. */
  64239. getClassName(): string;
  64240. /**
  64241. * Gets the position input component
  64242. */
  64243. get position(): NodeMaterialConnectionPoint;
  64244. /**
  64245. * Gets the world position input component
  64246. */
  64247. get worldPosition(): NodeMaterialConnectionPoint;
  64248. /**
  64249. * Gets the world normal input component
  64250. */
  64251. get worldNormal(): NodeMaterialConnectionPoint;
  64252. /**
  64253. * Gets the world input component
  64254. */
  64255. get world(): NodeMaterialConnectionPoint;
  64256. /**
  64257. * Gets the camera (or eye) position component
  64258. */
  64259. get cameraPosition(): NodeMaterialConnectionPoint;
  64260. /**
  64261. * Gets the view input component
  64262. */
  64263. get view(): NodeMaterialConnectionPoint;
  64264. /**
  64265. * Gets the color input component
  64266. */
  64267. get color(): NodeMaterialConnectionPoint;
  64268. /**
  64269. * Gets the reflection object output component
  64270. */
  64271. get reflection(): NodeMaterialConnectionPoint;
  64272. /**
  64273. * Returns true if the block has a texture (either its own texture or the environment texture from the scene, if set)
  64274. */
  64275. get hasTexture(): boolean;
  64276. /**
  64277. * Gets the reflection color (either the name of the variable if the color input is connected, else a default value)
  64278. */
  64279. get reflectionColor(): string;
  64280. protected _getTexture(): Nullable<BaseTexture>;
  64281. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64282. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  64283. /**
  64284. * Gets the code to inject in the vertex shader
  64285. * @param state current state of the node material building
  64286. * @returns the shader code
  64287. */
  64288. handleVertexSide(state: NodeMaterialBuildState): string;
  64289. /**
  64290. * Gets the main code of the block (fragment side)
  64291. * @param state current state of the node material building
  64292. * @param normalVarName name of the existing variable corresponding to the normal
  64293. * @returns the shader code
  64294. */
  64295. getCode(state: NodeMaterialBuildState, normalVarName: string): string;
  64296. protected _buildBlock(state: NodeMaterialBuildState): this;
  64297. protected _dumpPropertiesCode(): string;
  64298. serialize(): any;
  64299. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  64300. }
  64301. }
  64302. declare module "babylonjs/Materials/Node/Blocks/PBR/sheenBlock" {
  64303. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64304. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64305. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64306. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  64307. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64308. import { ReflectionBlock } from "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock";
  64309. import { Scene } from "babylonjs/scene";
  64310. import { Nullable } from "babylonjs/types";
  64311. /**
  64312. * Block used to implement the sheen module of the PBR material
  64313. */
  64314. export class SheenBlock extends NodeMaterialBlock {
  64315. /**
  64316. * Create a new SheenBlock
  64317. * @param name defines the block name
  64318. */
  64319. constructor(name: string);
  64320. /**
  64321. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  64322. * It allows the strength of the sheen effect to not depend on the base color of the material,
  64323. * making it easier to setup and tweak the effect
  64324. */
  64325. albedoScaling: boolean;
  64326. /**
  64327. * Defines if the sheen is linked to the sheen color.
  64328. */
  64329. linkSheenWithAlbedo: boolean;
  64330. /**
  64331. * Initialize the block and prepare the context for build
  64332. * @param state defines the state that will be used for the build
  64333. */
  64334. initialize(state: NodeMaterialBuildState): void;
  64335. /**
  64336. * Gets the current class name
  64337. * @returns the class name
  64338. */
  64339. getClassName(): string;
  64340. /**
  64341. * Gets the intensity input component
  64342. */
  64343. get intensity(): NodeMaterialConnectionPoint;
  64344. /**
  64345. * Gets the color input component
  64346. */
  64347. get color(): NodeMaterialConnectionPoint;
  64348. /**
  64349. * Gets the roughness input component
  64350. */
  64351. get roughness(): NodeMaterialConnectionPoint;
  64352. /**
  64353. * Gets the texture input component
  64354. */
  64355. get texture(): NodeMaterialConnectionPoint;
  64356. /**
  64357. * Gets the sheen object output component
  64358. */
  64359. get sheen(): NodeMaterialConnectionPoint;
  64360. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64361. /**
  64362. * Gets the main code of the block (fragment side)
  64363. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  64364. * @returns the shader code
  64365. */
  64366. getCode(reflectionBlock: Nullable<ReflectionBlock>): string;
  64367. protected _buildBlock(state: NodeMaterialBuildState): this;
  64368. protected _dumpPropertiesCode(): string;
  64369. serialize(): any;
  64370. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  64371. }
  64372. }
  64373. declare module "babylonjs/Materials/Node/Blocks/PBR/reflectivityBlock" {
  64374. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  64375. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64376. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64377. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64378. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64379. import { Scene } from "babylonjs/scene";
  64380. /**
  64381. * Block used to implement the reflectivity module of the PBR material
  64382. */
  64383. export class ReflectivityBlock extends NodeMaterialBlock {
  64384. /**
  64385. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  64386. */
  64387. useAmbientOcclusionFromMetallicTextureRed: boolean;
  64388. /**
  64389. * Specifies if the metallic texture contains the metallness information in its blue channel.
  64390. */
  64391. useMetallnessFromMetallicTextureBlue: boolean;
  64392. /**
  64393. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  64394. */
  64395. useRoughnessFromMetallicTextureAlpha: boolean;
  64396. /**
  64397. * Specifies if the metallic texture contains the roughness information in its green channel.
  64398. */
  64399. useRoughnessFromMetallicTextureGreen: boolean;
  64400. /**
  64401. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  64402. */
  64403. useMetallicF0FactorFromMetallicTexture: boolean;
  64404. /**
  64405. * Create a new ReflectivityBlock
  64406. * @param name defines the block name
  64407. */
  64408. constructor(name: string);
  64409. /**
  64410. * Initialize the block and prepare the context for build
  64411. * @param state defines the state that will be used for the build
  64412. */
  64413. initialize(state: NodeMaterialBuildState): void;
  64414. /**
  64415. * Gets the current class name
  64416. * @returns the class name
  64417. */
  64418. getClassName(): string;
  64419. /**
  64420. * Gets the metallic input component
  64421. */
  64422. get metallic(): NodeMaterialConnectionPoint;
  64423. /**
  64424. * Gets the roughness input component
  64425. */
  64426. get roughness(): NodeMaterialConnectionPoint;
  64427. /**
  64428. * Gets the texture input component
  64429. */
  64430. get texture(): NodeMaterialConnectionPoint;
  64431. /**
  64432. * Gets the reflectivity object output component
  64433. */
  64434. get reflectivity(): NodeMaterialConnectionPoint;
  64435. /**
  64436. * Gets the main code of the block (fragment side)
  64437. * @param aoIntensityVarName name of the variable with the ambient occlusion intensity
  64438. * @returns the shader code
  64439. */
  64440. getCode(aoIntensityVarName: string): string;
  64441. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64442. protected _buildBlock(state: NodeMaterialBuildState): this;
  64443. protected _dumpPropertiesCode(): string;
  64444. serialize(): any;
  64445. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  64446. }
  64447. }
  64448. declare module "babylonjs/Materials/Node/Blocks/PBR/anisotropyBlock" {
  64449. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  64450. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64451. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64452. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64453. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64454. /**
  64455. * Block used to implement the anisotropy module of the PBR material
  64456. */
  64457. export class AnisotropyBlock extends NodeMaterialBlock {
  64458. /**
  64459. * The two properties below are set by the main PBR block prior to calling methods of this class.
  64460. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  64461. * It's less burden on the user side in the editor part.
  64462. */
  64463. /** @hidden */
  64464. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  64465. /** @hidden */
  64466. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  64467. /**
  64468. * Create a new AnisotropyBlock
  64469. * @param name defines the block name
  64470. */
  64471. constructor(name: string);
  64472. /**
  64473. * Initialize the block and prepare the context for build
  64474. * @param state defines the state that will be used for the build
  64475. */
  64476. initialize(state: NodeMaterialBuildState): void;
  64477. /**
  64478. * Gets the current class name
  64479. * @returns the class name
  64480. */
  64481. getClassName(): string;
  64482. /**
  64483. * Gets the intensity input component
  64484. */
  64485. get intensity(): NodeMaterialConnectionPoint;
  64486. /**
  64487. * Gets the direction input component
  64488. */
  64489. get direction(): NodeMaterialConnectionPoint;
  64490. /**
  64491. * Gets the texture input component
  64492. */
  64493. get texture(): NodeMaterialConnectionPoint;
  64494. /**
  64495. * Gets the uv input component
  64496. */
  64497. get uv(): NodeMaterialConnectionPoint;
  64498. /**
  64499. * Gets the worldTangent input component
  64500. */
  64501. get worldTangent(): NodeMaterialConnectionPoint;
  64502. /**
  64503. * Gets the anisotropy object output component
  64504. */
  64505. get anisotropy(): NodeMaterialConnectionPoint;
  64506. private _generateTBNSpace;
  64507. /**
  64508. * Gets the main code of the block (fragment side)
  64509. * @param state current state of the node material building
  64510. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  64511. * @returns the shader code
  64512. */
  64513. getCode(state: NodeMaterialBuildState, generateTBNSpace?: boolean): string;
  64514. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64515. protected _buildBlock(state: NodeMaterialBuildState): this;
  64516. }
  64517. }
  64518. declare module "babylonjs/Materials/Node/Blocks/PBR/pbrMetallicRoughnessBlock" {
  64519. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64520. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64521. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64522. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  64523. import { Light } from "babylonjs/Lights/light";
  64524. import { Nullable } from "babylonjs/types";
  64525. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64526. import { Effect } from "babylonjs/Materials/effect";
  64527. import { Mesh } from "babylonjs/Meshes/mesh";
  64528. import { Scene } from "babylonjs/scene";
  64529. /**
  64530. * Block used to implement the PBR metallic/roughness model
  64531. */
  64532. export class PBRMetallicRoughnessBlock extends NodeMaterialBlock {
  64533. /**
  64534. * Gets or sets the light associated with this block
  64535. */
  64536. light: Nullable<Light>;
  64537. private _lightId;
  64538. private _scene;
  64539. private _environmentBRDFTexture;
  64540. private _environmentBrdfSamplerName;
  64541. private _vNormalWName;
  64542. /**
  64543. * Create a new ReflectionBlock
  64544. * @param name defines the block name
  64545. */
  64546. constructor(name: string);
  64547. /**
  64548. * Defines the falloff type used in this material.
  64549. * It by default is Physical.
  64550. */
  64551. lightFalloff: number;
  64552. /**
  64553. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  64554. */
  64555. useAlphaFromAlbedoTexture: boolean;
  64556. /**
  64557. * Specifies that alpha test should be used
  64558. */
  64559. useAlphaTest: boolean;
  64560. /**
  64561. * Defines the alpha limits in alpha test mode.
  64562. */
  64563. alphaTestCutoff: number;
  64564. /**
  64565. * Specifies that alpha blending should be used
  64566. */
  64567. useAlphaBlending: boolean;
  64568. /**
  64569. * Defines if the alpha value should be determined via the rgb values.
  64570. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  64571. */
  64572. opacityRGB: boolean;
  64573. /**
  64574. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most luminous ones).
  64575. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  64576. */
  64577. useRadianceOverAlpha: boolean;
  64578. /**
  64579. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most luminous ones).
  64580. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  64581. */
  64582. useSpecularOverAlpha: boolean;
  64583. /**
  64584. * Enables specular anti aliasing in the PBR shader.
  64585. * It will both interacts on the Geometry for analytical and IBL lighting.
  64586. * It also prefilter the roughness map based on the bump values.
  64587. */
  64588. enableSpecularAntiAliasing: boolean;
  64589. /**
  64590. * Defines if the material uses energy conservation.
  64591. */
  64592. useEnergyConservation: boolean;
  64593. /**
  64594. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  64595. * too much the area relying on ambient texture to define their ambient occlusion.
  64596. */
  64597. useRadianceOcclusion: boolean;
  64598. /**
  64599. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  64600. * makes the reflect vector face the model (under horizon).
  64601. */
  64602. useHorizonOcclusion: boolean;
  64603. /**
  64604. * If set to true, no lighting calculations will be applied.
  64605. */
  64606. unlit: boolean;
  64607. /**
  64608. * Defines the material debug mode.
  64609. * It helps seeing only some components of the material while troubleshooting.
  64610. */
  64611. debugMode: number;
  64612. /**
  64613. * Specify from where on screen the debug mode should start.
  64614. * The value goes from -1 (full screen) to 1 (not visible)
  64615. * It helps with side by side comparison against the final render
  64616. * This defaults to 0
  64617. */
  64618. debugLimit: number;
  64619. /**
  64620. * As the default viewing range might not be enough (if the ambient is really small for instance)
  64621. * You can use the factor to better multiply the final value.
  64622. */
  64623. debugFactor: number;
  64624. /**
  64625. * Initialize the block and prepare the context for build
  64626. * @param state defines the state that will be used for the build
  64627. */
  64628. initialize(state: NodeMaterialBuildState): void;
  64629. /**
  64630. * Gets the current class name
  64631. * @returns the class name
  64632. */
  64633. getClassName(): string;
  64634. /**
  64635. * Gets the world position input component
  64636. */
  64637. get worldPosition(): NodeMaterialConnectionPoint;
  64638. /**
  64639. * Gets the world normal input component
  64640. */
  64641. get worldNormal(): NodeMaterialConnectionPoint;
  64642. /**
  64643. * Gets the perturbed normal input component
  64644. */
  64645. get perturbedNormal(): NodeMaterialConnectionPoint;
  64646. /**
  64647. * Gets the camera position input component
  64648. */
  64649. get cameraPosition(): NodeMaterialConnectionPoint;
  64650. /**
  64651. * Gets the base color input component
  64652. */
  64653. get baseColor(): NodeMaterialConnectionPoint;
  64654. /**
  64655. * Gets the base texture input component
  64656. */
  64657. get baseTexture(): NodeMaterialConnectionPoint;
  64658. /**
  64659. * Gets the opacity texture input component
  64660. */
  64661. get opacityTexture(): NodeMaterialConnectionPoint;
  64662. /**
  64663. * Gets the ambient color input component
  64664. */
  64665. get ambientColor(): NodeMaterialConnectionPoint;
  64666. /**
  64667. * Gets the reflectivity object parameters
  64668. */
  64669. get reflectivity(): NodeMaterialConnectionPoint;
  64670. /**
  64671. * Gets the ambient occlusion object parameters
  64672. */
  64673. get ambientOcclusion(): NodeMaterialConnectionPoint;
  64674. /**
  64675. * Gets the reflection object parameters
  64676. */
  64677. get reflection(): NodeMaterialConnectionPoint;
  64678. /**
  64679. * Gets the sheen object parameters
  64680. */
  64681. get sheen(): NodeMaterialConnectionPoint;
  64682. /**
  64683. * Gets the clear coat object parameters
  64684. */
  64685. get clearcoat(): NodeMaterialConnectionPoint;
  64686. /**
  64687. * Gets the sub surface object parameters
  64688. */
  64689. get subSurface(): NodeMaterialConnectionPoint;
  64690. /**
  64691. * Gets the anisotropy object parameters
  64692. */
  64693. get anisotropy(): NodeMaterialConnectionPoint;
  64694. /**
  64695. * Gets the ambient output component
  64696. */
  64697. get ambient(): NodeMaterialConnectionPoint;
  64698. /**
  64699. * Gets the diffuse output component
  64700. */
  64701. get diffuse(): NodeMaterialConnectionPoint;
  64702. /**
  64703. * Gets the specular output component
  64704. */
  64705. get specular(): NodeMaterialConnectionPoint;
  64706. /**
  64707. * Gets the sheen output component
  64708. */
  64709. get sheenDir(): NodeMaterialConnectionPoint;
  64710. /**
  64711. * Gets the clear coat output component
  64712. */
  64713. get clearcoatDir(): NodeMaterialConnectionPoint;
  64714. /**
  64715. * Gets the indirect diffuse output component
  64716. */
  64717. get diffuseIndirect(): NodeMaterialConnectionPoint;
  64718. /**
  64719. * Gets the indirect specular output component
  64720. */
  64721. get specularIndirect(): NodeMaterialConnectionPoint;
  64722. /**
  64723. * Gets the indirect sheen output component
  64724. */
  64725. get sheenIndirect(): NodeMaterialConnectionPoint;
  64726. /**
  64727. * Gets the indirect clear coat output component
  64728. */
  64729. get clearcoatIndirect(): NodeMaterialConnectionPoint;
  64730. /**
  64731. * Gets the refraction output component
  64732. */
  64733. get refraction(): NodeMaterialConnectionPoint;
  64734. /**
  64735. * Gets the global lighting output component
  64736. */
  64737. get lighting(): NodeMaterialConnectionPoint;
  64738. /**
  64739. * Gets the shadow output component
  64740. */
  64741. get shadow(): NodeMaterialConnectionPoint;
  64742. /**
  64743. * Gets the alpha output component
  64744. */
  64745. get alpha(): NodeMaterialConnectionPoint;
  64746. autoConfigure(material: NodeMaterial): void;
  64747. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64748. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  64749. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  64750. private _injectVertexCode;
  64751. /**
  64752. * Gets the code corresponding to the albedo/opacity module
  64753. * @returns the shader code
  64754. */
  64755. getAlbedoOpacityCode(): string;
  64756. protected _buildBlock(state: NodeMaterialBuildState): this;
  64757. protected _dumpPropertiesCode(): string;
  64758. serialize(): any;
  64759. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  64760. }
  64761. }
  64762. declare module "babylonjs/Materials/Node/Blocks/PBR/index" {
  64763. export * from "babylonjs/Materials/Node/Blocks/PBR/pbrMetallicRoughnessBlock";
  64764. export * from "babylonjs/Materials/Node/Blocks/PBR/sheenBlock";
  64765. export * from "babylonjs/Materials/Node/Blocks/PBR/ambientOcclusionBlock";
  64766. export * from "babylonjs/Materials/Node/Blocks/PBR/reflectivityBlock";
  64767. export * from "babylonjs/Materials/Node/Blocks/PBR/anisotropyBlock";
  64768. export * from "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock";
  64769. }
  64770. declare module "babylonjs/Materials/Node/Blocks/index" {
  64771. export * from "babylonjs/Materials/Node/Blocks/Vertex/index";
  64772. export * from "babylonjs/Materials/Node/Blocks/Fragment/index";
  64773. export * from "babylonjs/Materials/Node/Blocks/Dual/index";
  64774. export * from "babylonjs/Materials/Node/Blocks/Input/index";
  64775. export * from "babylonjs/Materials/Node/Blocks/multiplyBlock";
  64776. export * from "babylonjs/Materials/Node/Blocks/addBlock";
  64777. export * from "babylonjs/Materials/Node/Blocks/scaleBlock";
  64778. export * from "babylonjs/Materials/Node/Blocks/clampBlock";
  64779. export * from "babylonjs/Materials/Node/Blocks/crossBlock";
  64780. export * from "babylonjs/Materials/Node/Blocks/dotBlock";
  64781. export * from "babylonjs/Materials/Node/Blocks/transformBlock";
  64782. export * from "babylonjs/Materials/Node/Blocks/remapBlock";
  64783. export * from "babylonjs/Materials/Node/Blocks/normalizeBlock";
  64784. export * from "babylonjs/Materials/Node/Blocks/trigonometryBlock";
  64785. export * from "babylonjs/Materials/Node/Blocks/colorMergerBlock";
  64786. export * from "babylonjs/Materials/Node/Blocks/vectorMergerBlock";
  64787. export * from "babylonjs/Materials/Node/Blocks/colorSplitterBlock";
  64788. export * from "babylonjs/Materials/Node/Blocks/vectorSplitterBlock";
  64789. export * from "babylonjs/Materials/Node/Blocks/lerpBlock";
  64790. export * from "babylonjs/Materials/Node/Blocks/divideBlock";
  64791. export * from "babylonjs/Materials/Node/Blocks/subtractBlock";
  64792. export * from "babylonjs/Materials/Node/Blocks/stepBlock";
  64793. export * from "babylonjs/Materials/Node/Blocks/oneMinusBlock";
  64794. export * from "babylonjs/Materials/Node/Blocks/viewDirectionBlock";
  64795. export * from "babylonjs/Materials/Node/Blocks/fresnelBlock";
  64796. export * from "babylonjs/Materials/Node/Blocks/maxBlock";
  64797. export * from "babylonjs/Materials/Node/Blocks/minBlock";
  64798. export * from "babylonjs/Materials/Node/Blocks/distanceBlock";
  64799. export * from "babylonjs/Materials/Node/Blocks/lengthBlock";
  64800. export * from "babylonjs/Materials/Node/Blocks/negateBlock";
  64801. export * from "babylonjs/Materials/Node/Blocks/powBlock";
  64802. export * from "babylonjs/Materials/Node/Blocks/randomNumberBlock";
  64803. export * from "babylonjs/Materials/Node/Blocks/arcTan2Block";
  64804. export * from "babylonjs/Materials/Node/Blocks/smoothStepBlock";
  64805. export * from "babylonjs/Materials/Node/Blocks/reciprocalBlock";
  64806. export * from "babylonjs/Materials/Node/Blocks/replaceColorBlock";
  64807. export * from "babylonjs/Materials/Node/Blocks/posterizeBlock";
  64808. export * from "babylonjs/Materials/Node/Blocks/waveBlock";
  64809. export * from "babylonjs/Materials/Node/Blocks/gradientBlock";
  64810. export * from "babylonjs/Materials/Node/Blocks/nLerpBlock";
  64811. export * from "babylonjs/Materials/Node/Blocks/worleyNoise3DBlock";
  64812. export * from "babylonjs/Materials/Node/Blocks/simplexPerlin3DBlock";
  64813. export * from "babylonjs/Materials/Node/Blocks/normalBlendBlock";
  64814. export * from "babylonjs/Materials/Node/Blocks/rotate2dBlock";
  64815. export * from "babylonjs/Materials/Node/Blocks/reflectBlock";
  64816. export * from "babylonjs/Materials/Node/Blocks/refractBlock";
  64817. export * from "babylonjs/Materials/Node/Blocks/desaturateBlock";
  64818. export * from "babylonjs/Materials/Node/Blocks/PBR/index";
  64819. }
  64820. declare module "babylonjs/Materials/Node/Optimizers/index" {
  64821. export * from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  64822. }
  64823. declare module "babylonjs/Materials/Node/index" {
  64824. export * from "babylonjs/Materials/Node/Enums/index";
  64825. export * from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64826. export * from "babylonjs/Materials/Node/nodeMaterialBlock";
  64827. export * from "babylonjs/Materials/Node/nodeMaterial";
  64828. export * from "babylonjs/Materials/Node/Blocks/index";
  64829. export * from "babylonjs/Materials/Node/Optimizers/index";
  64830. export * from "babylonjs/Materials/Node/nodeMaterialDecorator";
  64831. }
  64832. declare module "babylonjs/Materials/effectRenderer" {
  64833. import { Nullable } from "babylonjs/types";
  64834. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  64835. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  64836. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  64837. import { Viewport } from "babylonjs/Maths/math.viewport";
  64838. import { Observable } from "babylonjs/Misc/observable";
  64839. import { Effect } from "babylonjs/Materials/effect";
  64840. import "babylonjs/Shaders/postprocess.vertex";
  64841. /**
  64842. * Effect Render Options
  64843. */
  64844. export interface IEffectRendererOptions {
  64845. /**
  64846. * Defines the vertices positions.
  64847. */
  64848. positions?: number[];
  64849. /**
  64850. * Defines the indices.
  64851. */
  64852. indices?: number[];
  64853. }
  64854. /**
  64855. * Helper class to render one or more effects.
  64856. * You can access the previous rendering in your shader by declaring a sampler named textureSampler
  64857. */
  64858. export class EffectRenderer {
  64859. private engine;
  64860. private static _DefaultOptions;
  64861. private _vertexBuffers;
  64862. private _indexBuffer;
  64863. private _fullscreenViewport;
  64864. /**
  64865. * Creates an effect renderer
  64866. * @param engine the engine to use for rendering
  64867. * @param options defines the options of the effect renderer
  64868. */
  64869. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  64870. /**
  64871. * Sets the current viewport in normalized coordinates 0-1
  64872. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  64873. */
  64874. setViewport(viewport?: Viewport): void;
  64875. /**
  64876. * Binds the embedded attributes buffer to the effect.
  64877. * @param effect Defines the effect to bind the attributes for
  64878. */
  64879. bindBuffers(effect: Effect): void;
  64880. /**
  64881. * Sets the current effect wrapper to use during draw.
  64882. * The effect needs to be ready before calling this api.
  64883. * This also sets the default full screen position attribute.
  64884. * @param effectWrapper Defines the effect to draw with
  64885. */
  64886. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  64887. /**
  64888. * Draws a full screen quad.
  64889. */
  64890. draw(): void;
  64891. private isRenderTargetTexture;
  64892. /**
  64893. * renders one or more effects to a specified texture
  64894. * @param effectWrapper the effect to renderer
  64895. * @param outputTexture texture to draw to, if null it will render to the screen.
  64896. */
  64897. render(effectWrapper: EffectWrapper, outputTexture?: Nullable<InternalTexture | RenderTargetTexture>): void;
  64898. /**
  64899. * Disposes of the effect renderer
  64900. */
  64901. dispose(): void;
  64902. }
  64903. /**
  64904. * Options to create an EffectWrapper
  64905. */
  64906. interface EffectWrapperCreationOptions {
  64907. /**
  64908. * Engine to use to create the effect
  64909. */
  64910. engine: ThinEngine;
  64911. /**
  64912. * Fragment shader for the effect
  64913. */
  64914. fragmentShader: string;
  64915. /**
  64916. * Vertex shader for the effect
  64917. */
  64918. vertexShader?: string;
  64919. /**
  64920. * Attributes to use in the shader
  64921. */
  64922. attributeNames?: Array<string>;
  64923. /**
  64924. * Uniforms to use in the shader
  64925. */
  64926. uniformNames?: Array<string>;
  64927. /**
  64928. * Texture sampler names to use in the shader
  64929. */
  64930. samplerNames?: Array<string>;
  64931. /**
  64932. * The friendly name of the effect displayed in Spector.
  64933. */
  64934. name?: string;
  64935. }
  64936. /**
  64937. * Wraps an effect to be used for rendering
  64938. */
  64939. export class EffectWrapper {
  64940. /**
  64941. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  64942. */
  64943. onApplyObservable: Observable<{}>;
  64944. /**
  64945. * The underlying effect
  64946. */
  64947. effect: Effect;
  64948. /**
  64949. * Creates an effect to be renderer
  64950. * @param creationOptions options to create the effect
  64951. */
  64952. constructor(creationOptions: EffectWrapperCreationOptions);
  64953. /**
  64954. * Disposes of the effect wrapper
  64955. */
  64956. dispose(): void;
  64957. }
  64958. }
  64959. declare module "babylonjs/Materials/index" {
  64960. export * from "babylonjs/Materials/Background/index";
  64961. export * from "babylonjs/Materials/colorCurves";
  64962. export * from "babylonjs/Materials/iEffectFallbacks";
  64963. export * from "babylonjs/Materials/effectFallbacks";
  64964. export * from "babylonjs/Materials/effect";
  64965. export * from "babylonjs/Materials/fresnelParameters";
  64966. export * from "babylonjs/Materials/imageProcessingConfiguration";
  64967. export * from "babylonjs/Materials/material";
  64968. export * from "babylonjs/Materials/materialDefines";
  64969. export * from "babylonjs/Materials/materialHelper";
  64970. export * from "babylonjs/Materials/multiMaterial";
  64971. export * from "babylonjs/Materials/PBR/index";
  64972. export * from "babylonjs/Materials/pushMaterial";
  64973. export * from "babylonjs/Materials/shaderMaterial";
  64974. export * from "babylonjs/Materials/standardMaterial";
  64975. export * from "babylonjs/Materials/Textures/index";
  64976. export * from "babylonjs/Materials/uniformBuffer";
  64977. export * from "babylonjs/Materials/materialFlags";
  64978. export * from "babylonjs/Materials/Node/index";
  64979. export * from "babylonjs/Materials/effectRenderer";
  64980. export * from "babylonjs/Materials/shadowDepthWrapper";
  64981. }
  64982. declare module "babylonjs/Maths/index" {
  64983. export * from "babylonjs/Maths/math.scalar";
  64984. export * from "babylonjs/Maths/math";
  64985. export * from "babylonjs/Maths/sphericalPolynomial";
  64986. }
  64987. declare module "babylonjs/Misc/workerPool" {
  64988. import { IDisposable } from "babylonjs/scene";
  64989. /**
  64990. * Helper class to push actions to a pool of workers.
  64991. */
  64992. export class WorkerPool implements IDisposable {
  64993. private _workerInfos;
  64994. private _pendingActions;
  64995. /**
  64996. * Constructor
  64997. * @param workers Array of workers to use for actions
  64998. */
  64999. constructor(workers: Array<Worker>);
  65000. /**
  65001. * Terminates all workers and clears any pending actions.
  65002. */
  65003. dispose(): void;
  65004. /**
  65005. * Pushes an action to the worker pool. If all the workers are active, the action will be
  65006. * pended until a worker has completed its action.
  65007. * @param action The action to perform. Call onComplete when the action is complete.
  65008. */
  65009. push(action: (worker: Worker, onComplete: () => void) => void): void;
  65010. private _execute;
  65011. }
  65012. }
  65013. declare module "babylonjs/Meshes/Compression/dracoCompression" {
  65014. import { IDisposable } from "babylonjs/scene";
  65015. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  65016. /**
  65017. * Configuration for Draco compression
  65018. */
  65019. export interface IDracoCompressionConfiguration {
  65020. /**
  65021. * Configuration for the decoder.
  65022. */
  65023. decoder: {
  65024. /**
  65025. * The url to the WebAssembly module.
  65026. */
  65027. wasmUrl?: string;
  65028. /**
  65029. * The url to the WebAssembly binary.
  65030. */
  65031. wasmBinaryUrl?: string;
  65032. /**
  65033. * The url to the fallback JavaScript module.
  65034. */
  65035. fallbackUrl?: string;
  65036. };
  65037. }
  65038. /**
  65039. * Draco compression (https://google.github.io/draco/)
  65040. *
  65041. * This class wraps the Draco module.
  65042. *
  65043. * **Encoder**
  65044. *
  65045. * The encoder is not currently implemented.
  65046. *
  65047. * **Decoder**
  65048. *
  65049. * 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.
  65050. *
  65051. * To update the configuration, use the following code:
  65052. * ```javascript
  65053. * DracoCompression.Configuration = {
  65054. * decoder: {
  65055. * wasmUrl: "<url to the WebAssembly library>",
  65056. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  65057. * fallbackUrl: "<url to the fallback JavaScript library>",
  65058. * }
  65059. * };
  65060. * ```
  65061. *
  65062. * 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.
  65063. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  65064. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  65065. *
  65066. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  65067. * ```javascript
  65068. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  65069. * ```
  65070. *
  65071. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  65072. */
  65073. export class DracoCompression implements IDisposable {
  65074. private _workerPoolPromise?;
  65075. private _decoderModulePromise?;
  65076. /**
  65077. * The configuration. Defaults to the following urls:
  65078. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  65079. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  65080. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  65081. */
  65082. static Configuration: IDracoCompressionConfiguration;
  65083. /**
  65084. * Returns true if the decoder configuration is available.
  65085. */
  65086. static get DecoderAvailable(): boolean;
  65087. /**
  65088. * Default number of workers to create when creating the draco compression object.
  65089. */
  65090. static DefaultNumWorkers: number;
  65091. private static GetDefaultNumWorkers;
  65092. private static _Default;
  65093. /**
  65094. * Default instance for the draco compression object.
  65095. */
  65096. static get Default(): DracoCompression;
  65097. /**
  65098. * Constructor
  65099. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  65100. */
  65101. constructor(numWorkers?: number);
  65102. /**
  65103. * Stop all async operations and release resources.
  65104. */
  65105. dispose(): void;
  65106. /**
  65107. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  65108. * @returns a promise that resolves when ready
  65109. */
  65110. whenReadyAsync(): Promise<void>;
  65111. /**
  65112. * Decode Draco compressed mesh data to vertex data.
  65113. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  65114. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  65115. * @returns A promise that resolves with the decoded vertex data
  65116. */
  65117. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  65118. [kind: string]: number;
  65119. }): Promise<VertexData>;
  65120. }
  65121. }
  65122. declare module "babylonjs/Meshes/Compression/index" {
  65123. export * from "babylonjs/Meshes/Compression/dracoCompression";
  65124. }
  65125. declare module "babylonjs/Meshes/csg" {
  65126. import { Nullable } from "babylonjs/types";
  65127. import { Scene } from "babylonjs/scene";
  65128. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  65129. import { Mesh } from "babylonjs/Meshes/mesh";
  65130. import { Material } from "babylonjs/Materials/material";
  65131. /**
  65132. * Class for building Constructive Solid Geometry
  65133. */
  65134. export class CSG {
  65135. private polygons;
  65136. /**
  65137. * The world matrix
  65138. */
  65139. matrix: Matrix;
  65140. /**
  65141. * Stores the position
  65142. */
  65143. position: Vector3;
  65144. /**
  65145. * Stores the rotation
  65146. */
  65147. rotation: Vector3;
  65148. /**
  65149. * Stores the rotation quaternion
  65150. */
  65151. rotationQuaternion: Nullable<Quaternion>;
  65152. /**
  65153. * Stores the scaling vector
  65154. */
  65155. scaling: Vector3;
  65156. /**
  65157. * Convert the Mesh to CSG
  65158. * @param mesh The Mesh to convert to CSG
  65159. * @returns A new CSG from the Mesh
  65160. */
  65161. static FromMesh(mesh: Mesh): CSG;
  65162. /**
  65163. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  65164. * @param polygons Polygons used to construct a CSG solid
  65165. */
  65166. private static FromPolygons;
  65167. /**
  65168. * Clones, or makes a deep copy, of the CSG
  65169. * @returns A new CSG
  65170. */
  65171. clone(): CSG;
  65172. /**
  65173. * Unions this CSG with another CSG
  65174. * @param csg The CSG to union against this CSG
  65175. * @returns The unioned CSG
  65176. */
  65177. union(csg: CSG): CSG;
  65178. /**
  65179. * Unions this CSG with another CSG in place
  65180. * @param csg The CSG to union against this CSG
  65181. */
  65182. unionInPlace(csg: CSG): void;
  65183. /**
  65184. * Subtracts this CSG with another CSG
  65185. * @param csg The CSG to subtract against this CSG
  65186. * @returns A new CSG
  65187. */
  65188. subtract(csg: CSG): CSG;
  65189. /**
  65190. * Subtracts this CSG with another CSG in place
  65191. * @param csg The CSG to subtact against this CSG
  65192. */
  65193. subtractInPlace(csg: CSG): void;
  65194. /**
  65195. * Intersect this CSG with another CSG
  65196. * @param csg The CSG to intersect against this CSG
  65197. * @returns A new CSG
  65198. */
  65199. intersect(csg: CSG): CSG;
  65200. /**
  65201. * Intersects this CSG with another CSG in place
  65202. * @param csg The CSG to intersect against this CSG
  65203. */
  65204. intersectInPlace(csg: CSG): void;
  65205. /**
  65206. * Return a new CSG solid with solid and empty space switched. This solid is
  65207. * not modified.
  65208. * @returns A new CSG solid with solid and empty space switched
  65209. */
  65210. inverse(): CSG;
  65211. /**
  65212. * Inverses the CSG in place
  65213. */
  65214. inverseInPlace(): void;
  65215. /**
  65216. * This is used to keep meshes transformations so they can be restored
  65217. * when we build back a Babylon Mesh
  65218. * NB : All CSG operations are performed in world coordinates
  65219. * @param csg The CSG to copy the transform attributes from
  65220. * @returns This CSG
  65221. */
  65222. copyTransformAttributes(csg: CSG): CSG;
  65223. /**
  65224. * Build Raw mesh from CSG
  65225. * Coordinates here are in world space
  65226. * @param name The name of the mesh geometry
  65227. * @param scene The Scene
  65228. * @param keepSubMeshes Specifies if the submeshes should be kept
  65229. * @returns A new Mesh
  65230. */
  65231. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  65232. /**
  65233. * Build Mesh from CSG taking material and transforms into account
  65234. * @param name The name of the Mesh
  65235. * @param material The material of the Mesh
  65236. * @param scene The Scene
  65237. * @param keepSubMeshes Specifies if submeshes should be kept
  65238. * @returns The new Mesh
  65239. */
  65240. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  65241. }
  65242. }
  65243. declare module "babylonjs/Meshes/trailMesh" {
  65244. import { Mesh } from "babylonjs/Meshes/mesh";
  65245. import { Scene } from "babylonjs/scene";
  65246. import { TransformNode } from "babylonjs/Meshes/transformNode";
  65247. /**
  65248. * Class used to create a trail following a mesh
  65249. */
  65250. export class TrailMesh extends Mesh {
  65251. private _generator;
  65252. private _autoStart;
  65253. private _running;
  65254. private _diameter;
  65255. private _length;
  65256. private _sectionPolygonPointsCount;
  65257. private _sectionVectors;
  65258. private _sectionNormalVectors;
  65259. private _beforeRenderObserver;
  65260. /**
  65261. * @constructor
  65262. * @param name The value used by scene.getMeshByName() to do a lookup.
  65263. * @param generator The mesh or transform node to generate a trail.
  65264. * @param scene The scene to add this mesh to.
  65265. * @param diameter Diameter of trailing mesh. Default is 1.
  65266. * @param length Length of trailing mesh. Default is 60.
  65267. * @param autoStart Automatically start trailing mesh. Default true.
  65268. */
  65269. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  65270. /**
  65271. * "TrailMesh"
  65272. * @returns "TrailMesh"
  65273. */
  65274. getClassName(): string;
  65275. private _createMesh;
  65276. /**
  65277. * Start trailing mesh.
  65278. */
  65279. start(): void;
  65280. /**
  65281. * Stop trailing mesh.
  65282. */
  65283. stop(): void;
  65284. /**
  65285. * Update trailing mesh geometry.
  65286. */
  65287. update(): void;
  65288. /**
  65289. * Returns a new TrailMesh object.
  65290. * @param name is a string, the name given to the new mesh
  65291. * @param newGenerator use new generator object for cloned trail mesh
  65292. * @returns a new mesh
  65293. */
  65294. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  65295. /**
  65296. * Serializes this trail mesh
  65297. * @param serializationObject object to write serialization to
  65298. */
  65299. serialize(serializationObject: any): void;
  65300. /**
  65301. * Parses a serialized trail mesh
  65302. * @param parsedMesh the serialized mesh
  65303. * @param scene the scene to create the trail mesh in
  65304. * @returns the created trail mesh
  65305. */
  65306. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  65307. }
  65308. }
  65309. declare module "babylonjs/Meshes/Builders/tiledBoxBuilder" {
  65310. import { Nullable } from "babylonjs/types";
  65311. import { Scene } from "babylonjs/scene";
  65312. import { Vector4 } from "babylonjs/Maths/math.vector";
  65313. import { Color4 } from "babylonjs/Maths/math.color";
  65314. import { Mesh } from "babylonjs/Meshes/mesh";
  65315. /**
  65316. * Class containing static functions to help procedurally build meshes
  65317. */
  65318. export class TiledBoxBuilder {
  65319. /**
  65320. * Creates a box mesh
  65321. * 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)
  65322. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  65323. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65324. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  65325. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65326. * @param name defines the name of the mesh
  65327. * @param options defines the options used to create the mesh
  65328. * @param scene defines the hosting scene
  65329. * @returns the box mesh
  65330. */
  65331. static CreateTiledBox(name: string, options: {
  65332. pattern?: number;
  65333. width?: number;
  65334. height?: number;
  65335. depth?: number;
  65336. tileSize?: number;
  65337. tileWidth?: number;
  65338. tileHeight?: number;
  65339. alignHorizontal?: number;
  65340. alignVertical?: number;
  65341. faceUV?: Vector4[];
  65342. faceColors?: Color4[];
  65343. sideOrientation?: number;
  65344. updatable?: boolean;
  65345. }, scene?: Nullable<Scene>): Mesh;
  65346. }
  65347. }
  65348. declare module "babylonjs/Meshes/Builders/torusKnotBuilder" {
  65349. import { Vector4 } from "babylonjs/Maths/math.vector";
  65350. import { Mesh } from "babylonjs/Meshes/mesh";
  65351. /**
  65352. * Class containing static functions to help procedurally build meshes
  65353. */
  65354. export class TorusKnotBuilder {
  65355. /**
  65356. * Creates a torus knot mesh
  65357. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  65358. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  65359. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  65360. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  65361. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65362. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  65363. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  65364. * @param name defines the name of the mesh
  65365. * @param options defines the options used to create the mesh
  65366. * @param scene defines the hosting scene
  65367. * @returns the torus knot mesh
  65368. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  65369. */
  65370. static CreateTorusKnot(name: string, options: {
  65371. radius?: number;
  65372. tube?: number;
  65373. radialSegments?: number;
  65374. tubularSegments?: number;
  65375. p?: number;
  65376. q?: number;
  65377. updatable?: boolean;
  65378. sideOrientation?: number;
  65379. frontUVs?: Vector4;
  65380. backUVs?: Vector4;
  65381. }, scene: any): Mesh;
  65382. }
  65383. }
  65384. declare module "babylonjs/Meshes/polygonMesh" {
  65385. import { Scene } from "babylonjs/scene";
  65386. import { Vector2 } from "babylonjs/Maths/math.vector";
  65387. import { Mesh } from "babylonjs/Meshes/mesh";
  65388. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  65389. import { Path2 } from "babylonjs/Maths/math.path";
  65390. /**
  65391. * Polygon
  65392. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  65393. */
  65394. export class Polygon {
  65395. /**
  65396. * Creates a rectangle
  65397. * @param xmin bottom X coord
  65398. * @param ymin bottom Y coord
  65399. * @param xmax top X coord
  65400. * @param ymax top Y coord
  65401. * @returns points that make the resulting rectation
  65402. */
  65403. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  65404. /**
  65405. * Creates a circle
  65406. * @param radius radius of circle
  65407. * @param cx scale in x
  65408. * @param cy scale in y
  65409. * @param numberOfSides number of sides that make up the circle
  65410. * @returns points that make the resulting circle
  65411. */
  65412. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  65413. /**
  65414. * Creates a polygon from input string
  65415. * @param input Input polygon data
  65416. * @returns the parsed points
  65417. */
  65418. static Parse(input: string): Vector2[];
  65419. /**
  65420. * Starts building a polygon from x and y coordinates
  65421. * @param x x coordinate
  65422. * @param y y coordinate
  65423. * @returns the started path2
  65424. */
  65425. static StartingAt(x: number, y: number): Path2;
  65426. }
  65427. /**
  65428. * Builds a polygon
  65429. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  65430. */
  65431. export class PolygonMeshBuilder {
  65432. private _points;
  65433. private _outlinepoints;
  65434. private _holes;
  65435. private _name;
  65436. private _scene;
  65437. private _epoints;
  65438. private _eholes;
  65439. private _addToepoint;
  65440. /**
  65441. * Babylon reference to the earcut plugin.
  65442. */
  65443. bjsEarcut: any;
  65444. /**
  65445. * Creates a PolygonMeshBuilder
  65446. * @param name name of the builder
  65447. * @param contours Path of the polygon
  65448. * @param scene scene to add to when creating the mesh
  65449. * @param earcutInjection can be used to inject your own earcut reference
  65450. */
  65451. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  65452. /**
  65453. * Adds a whole within the polygon
  65454. * @param hole Array of points defining the hole
  65455. * @returns this
  65456. */
  65457. addHole(hole: Vector2[]): PolygonMeshBuilder;
  65458. /**
  65459. * Creates the polygon
  65460. * @param updatable If the mesh should be updatable
  65461. * @param depth The depth of the mesh created
  65462. * @returns the created mesh
  65463. */
  65464. build(updatable?: boolean, depth?: number): Mesh;
  65465. /**
  65466. * Creates the polygon
  65467. * @param depth The depth of the mesh created
  65468. * @returns the created VertexData
  65469. */
  65470. buildVertexData(depth?: number): VertexData;
  65471. /**
  65472. * Adds a side to the polygon
  65473. * @param positions points that make the polygon
  65474. * @param normals normals of the polygon
  65475. * @param uvs uvs of the polygon
  65476. * @param indices indices of the polygon
  65477. * @param bounds bounds of the polygon
  65478. * @param points points of the polygon
  65479. * @param depth depth of the polygon
  65480. * @param flip flip of the polygon
  65481. */
  65482. private addSide;
  65483. }
  65484. }
  65485. declare module "babylonjs/Meshes/Builders/polygonBuilder" {
  65486. import { Scene } from "babylonjs/scene";
  65487. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  65488. import { Color4 } from "babylonjs/Maths/math.color";
  65489. import { Mesh } from "babylonjs/Meshes/mesh";
  65490. import { Nullable } from "babylonjs/types";
  65491. /**
  65492. * Class containing static functions to help procedurally build meshes
  65493. */
  65494. export class PolygonBuilder {
  65495. /**
  65496. * Creates a polygon mesh
  65497. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  65498. * * 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
  65499. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  65500. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65501. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  65502. * * Remember you can only change the shape positions, not their number when updating a polygon
  65503. * @param name defines the name of the mesh
  65504. * @param options defines the options used to create the mesh
  65505. * @param scene defines the hosting scene
  65506. * @param earcutInjection can be used to inject your own earcut reference
  65507. * @returns the polygon mesh
  65508. */
  65509. static CreatePolygon(name: string, options: {
  65510. shape: Vector3[];
  65511. holes?: Vector3[][];
  65512. depth?: number;
  65513. faceUV?: Vector4[];
  65514. faceColors?: Color4[];
  65515. updatable?: boolean;
  65516. sideOrientation?: number;
  65517. frontUVs?: Vector4;
  65518. backUVs?: Vector4;
  65519. wrap?: boolean;
  65520. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  65521. /**
  65522. * Creates an extruded polygon mesh, with depth in the Y direction.
  65523. * * 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)
  65524. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  65525. * @param name defines the name of the mesh
  65526. * @param options defines the options used to create the mesh
  65527. * @param scene defines the hosting scene
  65528. * @param earcutInjection can be used to inject your own earcut reference
  65529. * @returns the polygon mesh
  65530. */
  65531. static ExtrudePolygon(name: string, options: {
  65532. shape: Vector3[];
  65533. holes?: Vector3[][];
  65534. depth?: number;
  65535. faceUV?: Vector4[];
  65536. faceColors?: Color4[];
  65537. updatable?: boolean;
  65538. sideOrientation?: number;
  65539. frontUVs?: Vector4;
  65540. backUVs?: Vector4;
  65541. wrap?: boolean;
  65542. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  65543. }
  65544. }
  65545. declare module "babylonjs/Meshes/Builders/latheBuilder" {
  65546. import { Scene } from "babylonjs/scene";
  65547. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  65548. import { Mesh } from "babylonjs/Meshes/mesh";
  65549. import { Nullable } from "babylonjs/types";
  65550. /**
  65551. * Class containing static functions to help procedurally build meshes
  65552. */
  65553. export class LatheBuilder {
  65554. /**
  65555. * Creates lathe mesh.
  65556. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  65557. * * 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
  65558. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  65559. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  65560. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  65561. * * 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
  65562. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  65563. * * 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
  65564. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65565. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  65566. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  65567. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65568. * @param name defines the name of the mesh
  65569. * @param options defines the options used to create the mesh
  65570. * @param scene defines the hosting scene
  65571. * @returns the lathe mesh
  65572. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  65573. */
  65574. static CreateLathe(name: string, options: {
  65575. shape: Vector3[];
  65576. radius?: number;
  65577. tessellation?: number;
  65578. clip?: number;
  65579. arc?: number;
  65580. closed?: boolean;
  65581. updatable?: boolean;
  65582. sideOrientation?: number;
  65583. frontUVs?: Vector4;
  65584. backUVs?: Vector4;
  65585. cap?: number;
  65586. invertUV?: boolean;
  65587. }, scene?: Nullable<Scene>): Mesh;
  65588. }
  65589. }
  65590. declare module "babylonjs/Meshes/Builders/tiledPlaneBuilder" {
  65591. import { Nullable } from "babylonjs/types";
  65592. import { Scene } from "babylonjs/scene";
  65593. import { Vector4 } from "babylonjs/Maths/math.vector";
  65594. import { Mesh } from "babylonjs/Meshes/mesh";
  65595. /**
  65596. * Class containing static functions to help procedurally build meshes
  65597. */
  65598. export class TiledPlaneBuilder {
  65599. /**
  65600. * Creates a tiled plane mesh
  65601. * * The parameter `pattern` will, depending on value, do nothing or
  65602. * * * flip (reflect about central vertical) alternate tiles across and up
  65603. * * * flip every tile on alternate rows
  65604. * * * rotate (180 degs) alternate tiles across and up
  65605. * * * rotate every tile on alternate rows
  65606. * * * flip and rotate alternate tiles across and up
  65607. * * * flip and rotate every tile on alternate rows
  65608. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  65609. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  65610. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  65611. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  65612. * * 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)
  65613. * * 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)
  65614. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  65615. * @param name defines the name of the mesh
  65616. * @param options defines the options used to create the mesh
  65617. * @param scene defines the hosting scene
  65618. * @returns the box mesh
  65619. */
  65620. static CreateTiledPlane(name: string, options: {
  65621. pattern?: number;
  65622. tileSize?: number;
  65623. tileWidth?: number;
  65624. tileHeight?: number;
  65625. size?: number;
  65626. width?: number;
  65627. height?: number;
  65628. alignHorizontal?: number;
  65629. alignVertical?: number;
  65630. sideOrientation?: number;
  65631. frontUVs?: Vector4;
  65632. backUVs?: Vector4;
  65633. updatable?: boolean;
  65634. }, scene?: Nullable<Scene>): Mesh;
  65635. }
  65636. }
  65637. declare module "babylonjs/Meshes/Builders/tubeBuilder" {
  65638. import { Nullable } from "babylonjs/types";
  65639. import { Scene } from "babylonjs/scene";
  65640. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  65641. import { Mesh } from "babylonjs/Meshes/mesh";
  65642. /**
  65643. * Class containing static functions to help procedurally build meshes
  65644. */
  65645. export class TubeBuilder {
  65646. /**
  65647. * Creates a tube mesh.
  65648. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  65649. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  65650. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  65651. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  65652. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  65653. * * 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)
  65654. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  65655. * * 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
  65656. * * 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
  65657. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65658. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  65659. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  65660. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65661. * @param name defines the name of the mesh
  65662. * @param options defines the options used to create the mesh
  65663. * @param scene defines the hosting scene
  65664. * @returns the tube mesh
  65665. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  65666. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  65667. */
  65668. static CreateTube(name: string, options: {
  65669. path: Vector3[];
  65670. radius?: number;
  65671. tessellation?: number;
  65672. radiusFunction?: {
  65673. (i: number, distance: number): number;
  65674. };
  65675. cap?: number;
  65676. arc?: number;
  65677. updatable?: boolean;
  65678. sideOrientation?: number;
  65679. frontUVs?: Vector4;
  65680. backUVs?: Vector4;
  65681. instance?: Mesh;
  65682. invertUV?: boolean;
  65683. }, scene?: Nullable<Scene>): Mesh;
  65684. }
  65685. }
  65686. declare module "babylonjs/Meshes/Builders/icoSphereBuilder" {
  65687. import { Scene } from "babylonjs/scene";
  65688. import { Vector4 } from "babylonjs/Maths/math.vector";
  65689. import { Mesh } from "babylonjs/Meshes/mesh";
  65690. import { Nullable } from "babylonjs/types";
  65691. /**
  65692. * Class containing static functions to help procedurally build meshes
  65693. */
  65694. export class IcoSphereBuilder {
  65695. /**
  65696. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  65697. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  65698. * * 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`)
  65699. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  65700. * * 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
  65701. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65702. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  65703. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65704. * @param name defines the name of the mesh
  65705. * @param options defines the options used to create the mesh
  65706. * @param scene defines the hosting scene
  65707. * @returns the icosahedron mesh
  65708. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  65709. */
  65710. static CreateIcoSphere(name: string, options: {
  65711. radius?: number;
  65712. radiusX?: number;
  65713. radiusY?: number;
  65714. radiusZ?: number;
  65715. flat?: boolean;
  65716. subdivisions?: number;
  65717. sideOrientation?: number;
  65718. frontUVs?: Vector4;
  65719. backUVs?: Vector4;
  65720. updatable?: boolean;
  65721. }, scene?: Nullable<Scene>): Mesh;
  65722. }
  65723. }
  65724. declare module "babylonjs/Meshes/Builders/decalBuilder" {
  65725. import { Vector3 } from "babylonjs/Maths/math.vector";
  65726. import { Mesh } from "babylonjs/Meshes/mesh";
  65727. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  65728. /**
  65729. * Class containing static functions to help procedurally build meshes
  65730. */
  65731. export class DecalBuilder {
  65732. /**
  65733. * Creates a decal mesh.
  65734. * 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
  65735. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  65736. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  65737. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  65738. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  65739. * @param name defines the name of the mesh
  65740. * @param sourceMesh defines the mesh where the decal must be applied
  65741. * @param options defines the options used to create the mesh
  65742. * @param scene defines the hosting scene
  65743. * @returns the decal mesh
  65744. * @see https://doc.babylonjs.com/how_to/decals
  65745. */
  65746. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  65747. position?: Vector3;
  65748. normal?: Vector3;
  65749. size?: Vector3;
  65750. angle?: number;
  65751. }): Mesh;
  65752. }
  65753. }
  65754. declare module "babylonjs/Meshes/meshBuilder" {
  65755. import { Vector4, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  65756. import { Nullable } from "babylonjs/types";
  65757. import { Scene } from "babylonjs/scene";
  65758. import { Mesh } from "babylonjs/Meshes/mesh";
  65759. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  65760. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  65761. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  65762. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  65763. import { Plane } from "babylonjs/Maths/math.plane";
  65764. /**
  65765. * Class containing static functions to help procedurally build meshes
  65766. */
  65767. export class MeshBuilder {
  65768. /**
  65769. * Creates a box mesh
  65770. * * The parameter `size` sets the size (float) of each box side (default 1)
  65771. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  65772. * * 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)
  65773. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  65774. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65775. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  65776. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65777. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  65778. * @param name defines the name of the mesh
  65779. * @param options defines the options used to create the mesh
  65780. * @param scene defines the hosting scene
  65781. * @returns the box mesh
  65782. */
  65783. static CreateBox(name: string, options: {
  65784. size?: number;
  65785. width?: number;
  65786. height?: number;
  65787. depth?: number;
  65788. faceUV?: Vector4[];
  65789. faceColors?: Color4[];
  65790. sideOrientation?: number;
  65791. frontUVs?: Vector4;
  65792. backUVs?: Vector4;
  65793. wrap?: boolean;
  65794. topBaseAt?: number;
  65795. bottomBaseAt?: number;
  65796. updatable?: boolean;
  65797. }, scene?: Nullable<Scene>): Mesh;
  65798. /**
  65799. * Creates a tiled box mesh
  65800. * * faceTiles sets the pattern, tile size and number of tiles for a face
  65801. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65802. * @param name defines the name of the mesh
  65803. * @param options defines the options used to create the mesh
  65804. * @param scene defines the hosting scene
  65805. * @returns the tiled box mesh
  65806. */
  65807. static CreateTiledBox(name: string, options: {
  65808. pattern?: number;
  65809. size?: number;
  65810. width?: number;
  65811. height?: number;
  65812. depth: number;
  65813. tileSize?: number;
  65814. tileWidth?: number;
  65815. tileHeight?: number;
  65816. faceUV?: Vector4[];
  65817. faceColors?: Color4[];
  65818. alignHorizontal?: number;
  65819. alignVertical?: number;
  65820. sideOrientation?: number;
  65821. updatable?: boolean;
  65822. }, scene?: Nullable<Scene>): Mesh;
  65823. /**
  65824. * Creates a sphere mesh
  65825. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  65826. * * 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`)
  65827. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  65828. * * 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
  65829. * * 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)
  65830. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65831. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  65832. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65833. * @param name defines the name of the mesh
  65834. * @param options defines the options used to create the mesh
  65835. * @param scene defines the hosting scene
  65836. * @returns the sphere mesh
  65837. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  65838. */
  65839. static CreateSphere(name: string, options: {
  65840. segments?: number;
  65841. diameter?: number;
  65842. diameterX?: number;
  65843. diameterY?: number;
  65844. diameterZ?: number;
  65845. arc?: number;
  65846. slice?: number;
  65847. sideOrientation?: number;
  65848. frontUVs?: Vector4;
  65849. backUVs?: Vector4;
  65850. updatable?: boolean;
  65851. }, scene?: Nullable<Scene>): Mesh;
  65852. /**
  65853. * Creates a plane polygonal mesh. By default, this is a disc
  65854. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  65855. * * 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
  65856. * * 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
  65857. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65858. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  65859. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65860. * @param name defines the name of the mesh
  65861. * @param options defines the options used to create the mesh
  65862. * @param scene defines the hosting scene
  65863. * @returns the plane polygonal mesh
  65864. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  65865. */
  65866. static CreateDisc(name: string, options: {
  65867. radius?: number;
  65868. tessellation?: number;
  65869. arc?: number;
  65870. updatable?: boolean;
  65871. sideOrientation?: number;
  65872. frontUVs?: Vector4;
  65873. backUVs?: Vector4;
  65874. }, scene?: Nullable<Scene>): Mesh;
  65875. /**
  65876. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  65877. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  65878. * * 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`)
  65879. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  65880. * * 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
  65881. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65882. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  65883. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65884. * @param name defines the name of the mesh
  65885. * @param options defines the options used to create the mesh
  65886. * @param scene defines the hosting scene
  65887. * @returns the icosahedron mesh
  65888. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  65889. */
  65890. static CreateIcoSphere(name: string, options: {
  65891. radius?: number;
  65892. radiusX?: number;
  65893. radiusY?: number;
  65894. radiusZ?: number;
  65895. flat?: boolean;
  65896. subdivisions?: number;
  65897. sideOrientation?: number;
  65898. frontUVs?: Vector4;
  65899. backUVs?: Vector4;
  65900. updatable?: boolean;
  65901. }, scene?: Nullable<Scene>): Mesh;
  65902. /**
  65903. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  65904. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  65905. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  65906. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  65907. * * 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
  65908. * * 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
  65909. * * 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
  65910. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65911. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  65912. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  65913. * * 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
  65914. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  65915. * * 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
  65916. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  65917. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65918. * @param name defines the name of the mesh
  65919. * @param options defines the options used to create the mesh
  65920. * @param scene defines the hosting scene
  65921. * @returns the ribbon mesh
  65922. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  65923. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  65924. */
  65925. static CreateRibbon(name: string, options: {
  65926. pathArray: Vector3[][];
  65927. closeArray?: boolean;
  65928. closePath?: boolean;
  65929. offset?: number;
  65930. updatable?: boolean;
  65931. sideOrientation?: number;
  65932. frontUVs?: Vector4;
  65933. backUVs?: Vector4;
  65934. instance?: Mesh;
  65935. invertUV?: boolean;
  65936. uvs?: Vector2[];
  65937. colors?: Color4[];
  65938. }, scene?: Nullable<Scene>): Mesh;
  65939. /**
  65940. * Creates a cylinder or a cone mesh
  65941. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  65942. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  65943. * * 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.
  65944. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  65945. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  65946. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  65947. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  65948. * * 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).
  65949. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  65950. * * 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).
  65951. * * 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
  65952. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  65953. * * 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
  65954. * * 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.
  65955. * * If `enclose` is false, a ring surface is one element.
  65956. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  65957. * * 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
  65958. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65959. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  65960. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  65961. * @param name defines the name of the mesh
  65962. * @param options defines the options used to create the mesh
  65963. * @param scene defines the hosting scene
  65964. * @returns the cylinder mesh
  65965. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  65966. */
  65967. static CreateCylinder(name: string, options: {
  65968. height?: number;
  65969. diameterTop?: number;
  65970. diameterBottom?: number;
  65971. diameter?: number;
  65972. tessellation?: number;
  65973. subdivisions?: number;
  65974. arc?: number;
  65975. faceColors?: Color4[];
  65976. faceUV?: Vector4[];
  65977. updatable?: boolean;
  65978. hasRings?: boolean;
  65979. enclose?: boolean;
  65980. cap?: number;
  65981. sideOrientation?: number;
  65982. frontUVs?: Vector4;
  65983. backUVs?: Vector4;
  65984. }, scene?: Nullable<Scene>): Mesh;
  65985. /**
  65986. * Creates a torus mesh
  65987. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  65988. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  65989. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  65990. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65991. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  65992. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  65993. * @param name defines the name of the mesh
  65994. * @param options defines the options used to create the mesh
  65995. * @param scene defines the hosting scene
  65996. * @returns the torus mesh
  65997. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  65998. */
  65999. static CreateTorus(name: string, options: {
  66000. diameter?: number;
  66001. thickness?: number;
  66002. tessellation?: number;
  66003. updatable?: boolean;
  66004. sideOrientation?: number;
  66005. frontUVs?: Vector4;
  66006. backUVs?: Vector4;
  66007. }, scene?: Nullable<Scene>): Mesh;
  66008. /**
  66009. * Creates a torus knot mesh
  66010. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  66011. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  66012. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  66013. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  66014. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66015. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  66016. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  66017. * @param name defines the name of the mesh
  66018. * @param options defines the options used to create the mesh
  66019. * @param scene defines the hosting scene
  66020. * @returns the torus knot mesh
  66021. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  66022. */
  66023. static CreateTorusKnot(name: string, options: {
  66024. radius?: number;
  66025. tube?: number;
  66026. radialSegments?: number;
  66027. tubularSegments?: number;
  66028. p?: number;
  66029. q?: number;
  66030. updatable?: boolean;
  66031. sideOrientation?: number;
  66032. frontUVs?: Vector4;
  66033. backUVs?: Vector4;
  66034. }, scene?: Nullable<Scene>): Mesh;
  66035. /**
  66036. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  66037. * * 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
  66038. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  66039. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  66040. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  66041. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  66042. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  66043. * * 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
  66044. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  66045. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66046. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  66047. * @param name defines the name of the new line system
  66048. * @param options defines the options used to create the line system
  66049. * @param scene defines the hosting scene
  66050. * @returns a new line system mesh
  66051. */
  66052. static CreateLineSystem(name: string, options: {
  66053. lines: Vector3[][];
  66054. updatable?: boolean;
  66055. instance?: Nullable<LinesMesh>;
  66056. colors?: Nullable<Color4[][]>;
  66057. useVertexAlpha?: boolean;
  66058. }, scene: Nullable<Scene>): LinesMesh;
  66059. /**
  66060. * Creates a line mesh
  66061. * 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
  66062. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  66063. * * The parameter `points` is an array successive Vector3
  66064. * * 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
  66065. * * The optional parameter `colors` is an array of successive Color4, one per line point
  66066. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  66067. * * When updating an instance, remember that only point positions can change, not the number of points
  66068. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66069. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  66070. * @param name defines the name of the new line system
  66071. * @param options defines the options used to create the line system
  66072. * @param scene defines the hosting scene
  66073. * @returns a new line mesh
  66074. */
  66075. static CreateLines(name: string, options: {
  66076. points: Vector3[];
  66077. updatable?: boolean;
  66078. instance?: Nullable<LinesMesh>;
  66079. colors?: Color4[];
  66080. useVertexAlpha?: boolean;
  66081. }, scene?: Nullable<Scene>): LinesMesh;
  66082. /**
  66083. * Creates a dashed line mesh
  66084. * * 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
  66085. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  66086. * * The parameter `points` is an array successive Vector3
  66087. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  66088. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  66089. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  66090. * * 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
  66091. * * When updating an instance, remember that only point positions can change, not the number of points
  66092. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66093. * @param name defines the name of the mesh
  66094. * @param options defines the options used to create the mesh
  66095. * @param scene defines the hosting scene
  66096. * @returns the dashed line mesh
  66097. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  66098. */
  66099. static CreateDashedLines(name: string, options: {
  66100. points: Vector3[];
  66101. dashSize?: number;
  66102. gapSize?: number;
  66103. dashNb?: number;
  66104. updatable?: boolean;
  66105. instance?: LinesMesh;
  66106. }, scene?: Nullable<Scene>): LinesMesh;
  66107. /**
  66108. * 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.
  66109. * * 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.
  66110. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  66111. * * 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.
  66112. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  66113. * * 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
  66114. * * 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
  66115. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  66116. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66117. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  66118. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  66119. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  66120. * @param name defines the name of the mesh
  66121. * @param options defines the options used to create the mesh
  66122. * @param scene defines the hosting scene
  66123. * @returns the extruded shape mesh
  66124. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  66125. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  66126. */
  66127. static ExtrudeShape(name: string, options: {
  66128. shape: Vector3[];
  66129. path: Vector3[];
  66130. scale?: number;
  66131. rotation?: number;
  66132. cap?: number;
  66133. updatable?: boolean;
  66134. sideOrientation?: number;
  66135. frontUVs?: Vector4;
  66136. backUVs?: Vector4;
  66137. instance?: Mesh;
  66138. invertUV?: boolean;
  66139. }, scene?: Nullable<Scene>): Mesh;
  66140. /**
  66141. * Creates an custom extruded shape mesh.
  66142. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  66143. * * 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.
  66144. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  66145. * * 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
  66146. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  66147. * * 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
  66148. * * It must returns a float value that will be the scale value applied to the shape on each path point
  66149. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  66150. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  66151. * * 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
  66152. * * 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
  66153. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  66154. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66155. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  66156. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  66157. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66158. * @param name defines the name of the mesh
  66159. * @param options defines the options used to create the mesh
  66160. * @param scene defines the hosting scene
  66161. * @returns the custom extruded shape mesh
  66162. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  66163. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  66164. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  66165. */
  66166. static ExtrudeShapeCustom(name: string, options: {
  66167. shape: Vector3[];
  66168. path: Vector3[];
  66169. scaleFunction?: any;
  66170. rotationFunction?: any;
  66171. ribbonCloseArray?: boolean;
  66172. ribbonClosePath?: boolean;
  66173. cap?: number;
  66174. updatable?: boolean;
  66175. sideOrientation?: number;
  66176. frontUVs?: Vector4;
  66177. backUVs?: Vector4;
  66178. instance?: Mesh;
  66179. invertUV?: boolean;
  66180. }, scene?: Nullable<Scene>): Mesh;
  66181. /**
  66182. * Creates lathe mesh.
  66183. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  66184. * * 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
  66185. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  66186. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  66187. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  66188. * * 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
  66189. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  66190. * * 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
  66191. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66192. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  66193. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  66194. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66195. * @param name defines the name of the mesh
  66196. * @param options defines the options used to create the mesh
  66197. * @param scene defines the hosting scene
  66198. * @returns the lathe mesh
  66199. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  66200. */
  66201. static CreateLathe(name: string, options: {
  66202. shape: Vector3[];
  66203. radius?: number;
  66204. tessellation?: number;
  66205. clip?: number;
  66206. arc?: number;
  66207. closed?: boolean;
  66208. updatable?: boolean;
  66209. sideOrientation?: number;
  66210. frontUVs?: Vector4;
  66211. backUVs?: Vector4;
  66212. cap?: number;
  66213. invertUV?: boolean;
  66214. }, scene?: Nullable<Scene>): Mesh;
  66215. /**
  66216. * Creates a tiled plane mesh
  66217. * * You can set a limited pattern arrangement with the tiles
  66218. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66219. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  66220. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66221. * @param name defines the name of the mesh
  66222. * @param options defines the options used to create the mesh
  66223. * @param scene defines the hosting scene
  66224. * @returns the plane mesh
  66225. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  66226. */
  66227. static CreateTiledPlane(name: string, options: {
  66228. pattern?: number;
  66229. tileSize?: number;
  66230. tileWidth?: number;
  66231. tileHeight?: number;
  66232. size?: number;
  66233. width?: number;
  66234. height?: number;
  66235. alignHorizontal?: number;
  66236. alignVertical?: number;
  66237. sideOrientation?: number;
  66238. frontUVs?: Vector4;
  66239. backUVs?: Vector4;
  66240. updatable?: boolean;
  66241. }, scene?: Nullable<Scene>): Mesh;
  66242. /**
  66243. * Creates a plane mesh
  66244. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  66245. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  66246. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  66247. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66248. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  66249. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66250. * @param name defines the name of the mesh
  66251. * @param options defines the options used to create the mesh
  66252. * @param scene defines the hosting scene
  66253. * @returns the plane mesh
  66254. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  66255. */
  66256. static CreatePlane(name: string, options: {
  66257. size?: number;
  66258. width?: number;
  66259. height?: number;
  66260. sideOrientation?: number;
  66261. frontUVs?: Vector4;
  66262. backUVs?: Vector4;
  66263. updatable?: boolean;
  66264. sourcePlane?: Plane;
  66265. }, scene?: Nullable<Scene>): Mesh;
  66266. /**
  66267. * Creates a ground mesh
  66268. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  66269. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  66270. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66271. * @param name defines the name of the mesh
  66272. * @param options defines the options used to create the mesh
  66273. * @param scene defines the hosting scene
  66274. * @returns the ground mesh
  66275. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  66276. */
  66277. static CreateGround(name: string, options: {
  66278. width?: number;
  66279. height?: number;
  66280. subdivisions?: number;
  66281. subdivisionsX?: number;
  66282. subdivisionsY?: number;
  66283. updatable?: boolean;
  66284. }, scene?: Nullable<Scene>): Mesh;
  66285. /**
  66286. * Creates a tiled ground mesh
  66287. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  66288. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  66289. * * 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
  66290. * * 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
  66291. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  66292. * @param name defines the name of the mesh
  66293. * @param options defines the options used to create the mesh
  66294. * @param scene defines the hosting scene
  66295. * @returns the tiled ground mesh
  66296. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  66297. */
  66298. static CreateTiledGround(name: string, options: {
  66299. xmin: number;
  66300. zmin: number;
  66301. xmax: number;
  66302. zmax: number;
  66303. subdivisions?: {
  66304. w: number;
  66305. h: number;
  66306. };
  66307. precision?: {
  66308. w: number;
  66309. h: number;
  66310. };
  66311. updatable?: boolean;
  66312. }, scene?: Nullable<Scene>): Mesh;
  66313. /**
  66314. * Creates a ground mesh from a height map
  66315. * * The parameter `url` sets the URL of the height map image resource.
  66316. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  66317. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  66318. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  66319. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  66320. * * 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.
  66321. * * 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).
  66322. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  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 url defines the url to the height map
  66326. * @param options defines the options used to create the mesh
  66327. * @param scene defines the hosting scene
  66328. * @returns the ground mesh
  66329. * @see https://doc.babylonjs.com/babylon101/height_map
  66330. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  66331. */
  66332. static CreateGroundFromHeightMap(name: string, url: string, options: {
  66333. width?: number;
  66334. height?: number;
  66335. subdivisions?: number;
  66336. minHeight?: number;
  66337. maxHeight?: number;
  66338. colorFilter?: Color3;
  66339. alphaFilter?: number;
  66340. updatable?: boolean;
  66341. onReady?: (mesh: GroundMesh) => void;
  66342. }, scene?: Nullable<Scene>): GroundMesh;
  66343. /**
  66344. * Creates a polygon mesh
  66345. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  66346. * * 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
  66347. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  66348. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66349. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  66350. * * Remember you can only change the shape positions, not their number when updating a polygon
  66351. * @param name defines the name of the mesh
  66352. * @param options defines the options used to create the mesh
  66353. * @param scene defines the hosting scene
  66354. * @param earcutInjection can be used to inject your own earcut reference
  66355. * @returns the polygon mesh
  66356. */
  66357. static CreatePolygon(name: string, options: {
  66358. shape: Vector3[];
  66359. holes?: Vector3[][];
  66360. depth?: number;
  66361. faceUV?: Vector4[];
  66362. faceColors?: Color4[];
  66363. updatable?: boolean;
  66364. sideOrientation?: number;
  66365. frontUVs?: Vector4;
  66366. backUVs?: Vector4;
  66367. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  66368. /**
  66369. * Creates an extruded polygon mesh, with depth in the Y direction.
  66370. * * 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)
  66371. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  66372. * @param name defines the name of the mesh
  66373. * @param options defines the options used to create the mesh
  66374. * @param scene defines the hosting scene
  66375. * @param earcutInjection can be used to inject your own earcut reference
  66376. * @returns the polygon mesh
  66377. */
  66378. static ExtrudePolygon(name: string, options: {
  66379. shape: Vector3[];
  66380. holes?: Vector3[][];
  66381. depth?: number;
  66382. faceUV?: Vector4[];
  66383. faceColors?: Color4[];
  66384. updatable?: boolean;
  66385. sideOrientation?: number;
  66386. frontUVs?: Vector4;
  66387. backUVs?: Vector4;
  66388. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  66389. /**
  66390. * Creates a tube mesh.
  66391. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  66392. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  66393. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  66394. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  66395. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  66396. * * 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)
  66397. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  66398. * * 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
  66399. * * 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
  66400. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66401. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  66402. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  66403. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66404. * @param name defines the name of the mesh
  66405. * @param options defines the options used to create the mesh
  66406. * @param scene defines the hosting scene
  66407. * @returns the tube mesh
  66408. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  66409. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  66410. */
  66411. static CreateTube(name: string, options: {
  66412. path: Vector3[];
  66413. radius?: number;
  66414. tessellation?: number;
  66415. radiusFunction?: {
  66416. (i: number, distance: number): number;
  66417. };
  66418. cap?: number;
  66419. arc?: number;
  66420. updatable?: boolean;
  66421. sideOrientation?: number;
  66422. frontUVs?: Vector4;
  66423. backUVs?: Vector4;
  66424. instance?: Mesh;
  66425. invertUV?: boolean;
  66426. }, scene?: Nullable<Scene>): Mesh;
  66427. /**
  66428. * Creates a polyhedron mesh
  66429. * * 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
  66430. * * The parameter `size` (positive float, default 1) sets the polygon size
  66431. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  66432. * * 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`
  66433. * * 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
  66434. * * 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)`)
  66435. * * 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
  66436. * * 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
  66437. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66438. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  66439. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66440. * @param name defines the name of the mesh
  66441. * @param options defines the options used to create the mesh
  66442. * @param scene defines the hosting scene
  66443. * @returns the polyhedron mesh
  66444. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  66445. */
  66446. static CreatePolyhedron(name: string, options: {
  66447. type?: number;
  66448. size?: number;
  66449. sizeX?: number;
  66450. sizeY?: number;
  66451. sizeZ?: number;
  66452. custom?: any;
  66453. faceUV?: Vector4[];
  66454. faceColors?: Color4[];
  66455. flat?: boolean;
  66456. updatable?: boolean;
  66457. sideOrientation?: number;
  66458. frontUVs?: Vector4;
  66459. backUVs?: Vector4;
  66460. }, scene?: Nullable<Scene>): Mesh;
  66461. /**
  66462. * Creates a decal mesh.
  66463. * 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
  66464. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  66465. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  66466. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  66467. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  66468. * @param name defines the name of the mesh
  66469. * @param sourceMesh defines the mesh where the decal must be applied
  66470. * @param options defines the options used to create the mesh
  66471. * @param scene defines the hosting scene
  66472. * @returns the decal mesh
  66473. * @see https://doc.babylonjs.com/how_to/decals
  66474. */
  66475. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  66476. position?: Vector3;
  66477. normal?: Vector3;
  66478. size?: Vector3;
  66479. angle?: number;
  66480. }): Mesh;
  66481. }
  66482. }
  66483. declare module "babylonjs/Meshes/meshSimplification" {
  66484. import { Mesh } from "babylonjs/Meshes/mesh";
  66485. /**
  66486. * A simplifier interface for future simplification implementations
  66487. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  66488. */
  66489. export interface ISimplifier {
  66490. /**
  66491. * Simplification of a given mesh according to the given settings.
  66492. * Since this requires computation, it is assumed that the function runs async.
  66493. * @param settings The settings of the simplification, including quality and distance
  66494. * @param successCallback A callback that will be called after the mesh was simplified.
  66495. * @param errorCallback in case of an error, this callback will be called. optional.
  66496. */
  66497. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  66498. }
  66499. /**
  66500. * Expected simplification settings.
  66501. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  66502. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  66503. */
  66504. export interface ISimplificationSettings {
  66505. /**
  66506. * Gets or sets the expected quality
  66507. */
  66508. quality: number;
  66509. /**
  66510. * Gets or sets the distance when this optimized version should be used
  66511. */
  66512. distance: number;
  66513. /**
  66514. * Gets an already optimized mesh
  66515. */
  66516. optimizeMesh?: boolean;
  66517. }
  66518. /**
  66519. * Class used to specify simplification options
  66520. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  66521. */
  66522. export class SimplificationSettings implements ISimplificationSettings {
  66523. /** expected quality */
  66524. quality: number;
  66525. /** distance when this optimized version should be used */
  66526. distance: number;
  66527. /** already optimized mesh */
  66528. optimizeMesh?: boolean | undefined;
  66529. /**
  66530. * Creates a SimplificationSettings
  66531. * @param quality expected quality
  66532. * @param distance distance when this optimized version should be used
  66533. * @param optimizeMesh already optimized mesh
  66534. */
  66535. constructor(
  66536. /** expected quality */
  66537. quality: number,
  66538. /** distance when this optimized version should be used */
  66539. distance: number,
  66540. /** already optimized mesh */
  66541. optimizeMesh?: boolean | undefined);
  66542. }
  66543. /**
  66544. * Interface used to define a simplification task
  66545. */
  66546. export interface ISimplificationTask {
  66547. /**
  66548. * Array of settings
  66549. */
  66550. settings: Array<ISimplificationSettings>;
  66551. /**
  66552. * Simplification type
  66553. */
  66554. simplificationType: SimplificationType;
  66555. /**
  66556. * Mesh to simplify
  66557. */
  66558. mesh: Mesh;
  66559. /**
  66560. * Callback called on success
  66561. */
  66562. successCallback?: () => void;
  66563. /**
  66564. * Defines if parallel processing can be used
  66565. */
  66566. parallelProcessing: boolean;
  66567. }
  66568. /**
  66569. * Queue used to order the simplification tasks
  66570. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  66571. */
  66572. export class SimplificationQueue {
  66573. private _simplificationArray;
  66574. /**
  66575. * Gets a boolean indicating that the process is still running
  66576. */
  66577. running: boolean;
  66578. /**
  66579. * Creates a new queue
  66580. */
  66581. constructor();
  66582. /**
  66583. * Adds a new simplification task
  66584. * @param task defines a task to add
  66585. */
  66586. addTask(task: ISimplificationTask): void;
  66587. /**
  66588. * Execute next task
  66589. */
  66590. executeNext(): void;
  66591. /**
  66592. * Execute a simplification task
  66593. * @param task defines the task to run
  66594. */
  66595. runSimplification(task: ISimplificationTask): void;
  66596. private getSimplifier;
  66597. }
  66598. /**
  66599. * The implemented types of simplification
  66600. * At the moment only Quadratic Error Decimation is implemented
  66601. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  66602. */
  66603. export enum SimplificationType {
  66604. /** Quadratic error decimation */
  66605. QUADRATIC = 0
  66606. }
  66607. /**
  66608. * An implementation of the Quadratic Error simplification algorithm.
  66609. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  66610. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  66611. * @author RaananW
  66612. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  66613. */
  66614. export class QuadraticErrorSimplification implements ISimplifier {
  66615. private _mesh;
  66616. private triangles;
  66617. private vertices;
  66618. private references;
  66619. private _reconstructedMesh;
  66620. /** Gets or sets the number pf sync interations */
  66621. syncIterations: number;
  66622. /** Gets or sets the aggressiveness of the simplifier */
  66623. aggressiveness: number;
  66624. /** Gets or sets the number of allowed iterations for decimation */
  66625. decimationIterations: number;
  66626. /** Gets or sets the espilon to use for bounding box computation */
  66627. boundingBoxEpsilon: number;
  66628. /**
  66629. * Creates a new QuadraticErrorSimplification
  66630. * @param _mesh defines the target mesh
  66631. */
  66632. constructor(_mesh: Mesh);
  66633. /**
  66634. * Simplification of a given mesh according to the given settings.
  66635. * Since this requires computation, it is assumed that the function runs async.
  66636. * @param settings The settings of the simplification, including quality and distance
  66637. * @param successCallback A callback that will be called after the mesh was simplified.
  66638. */
  66639. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  66640. private runDecimation;
  66641. private initWithMesh;
  66642. private init;
  66643. private reconstructMesh;
  66644. private initDecimatedMesh;
  66645. private isFlipped;
  66646. private updateTriangles;
  66647. private identifyBorder;
  66648. private updateMesh;
  66649. private vertexError;
  66650. private calculateError;
  66651. }
  66652. }
  66653. declare module "babylonjs/Meshes/meshSimplificationSceneComponent" {
  66654. import { Scene } from "babylonjs/scene";
  66655. import { SimplificationQueue, ISimplificationSettings, SimplificationType } from "babylonjs/Meshes/meshSimplification";
  66656. import { ISceneComponent } from "babylonjs/sceneComponent";
  66657. module "babylonjs/scene" {
  66658. interface Scene {
  66659. /** @hidden (Backing field) */
  66660. _simplificationQueue: SimplificationQueue;
  66661. /**
  66662. * Gets or sets the simplification queue attached to the scene
  66663. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  66664. */
  66665. simplificationQueue: SimplificationQueue;
  66666. }
  66667. }
  66668. module "babylonjs/Meshes/mesh" {
  66669. interface Mesh {
  66670. /**
  66671. * Simplify the mesh according to the given array of settings.
  66672. * Function will return immediately and will simplify async
  66673. * @param settings a collection of simplification settings
  66674. * @param parallelProcessing should all levels calculate parallel or one after the other
  66675. * @param simplificationType the type of simplification to run
  66676. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  66677. * @returns the current mesh
  66678. */
  66679. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  66680. }
  66681. }
  66682. /**
  66683. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  66684. * created in a scene
  66685. */
  66686. export class SimplicationQueueSceneComponent implements ISceneComponent {
  66687. /**
  66688. * The component name helpfull to identify the component in the list of scene components.
  66689. */
  66690. readonly name: string;
  66691. /**
  66692. * The scene the component belongs to.
  66693. */
  66694. scene: Scene;
  66695. /**
  66696. * Creates a new instance of the component for the given scene
  66697. * @param scene Defines the scene to register the component in
  66698. */
  66699. constructor(scene: Scene);
  66700. /**
  66701. * Registers the component in a given scene
  66702. */
  66703. register(): void;
  66704. /**
  66705. * Rebuilds the elements related to this component in case of
  66706. * context lost for instance.
  66707. */
  66708. rebuild(): void;
  66709. /**
  66710. * Disposes the component and the associated ressources
  66711. */
  66712. dispose(): void;
  66713. private _beforeCameraUpdate;
  66714. }
  66715. }
  66716. declare module "babylonjs/Meshes/Builders/index" {
  66717. export * from "babylonjs/Meshes/Builders/boxBuilder";
  66718. export * from "babylonjs/Meshes/Builders/tiledBoxBuilder";
  66719. export * from "babylonjs/Meshes/Builders/discBuilder";
  66720. export * from "babylonjs/Meshes/Builders/ribbonBuilder";
  66721. export * from "babylonjs/Meshes/Builders/sphereBuilder";
  66722. export * from "babylonjs/Meshes/Builders/hemisphereBuilder";
  66723. export * from "babylonjs/Meshes/Builders/cylinderBuilder";
  66724. export * from "babylonjs/Meshes/Builders/torusBuilder";
  66725. export * from "babylonjs/Meshes/Builders/torusKnotBuilder";
  66726. export * from "babylonjs/Meshes/Builders/linesBuilder";
  66727. export * from "babylonjs/Meshes/Builders/polygonBuilder";
  66728. export * from "babylonjs/Meshes/Builders/shapeBuilder";
  66729. export * from "babylonjs/Meshes/Builders/latheBuilder";
  66730. export * from "babylonjs/Meshes/Builders/planeBuilder";
  66731. export * from "babylonjs/Meshes/Builders/tiledPlaneBuilder";
  66732. export * from "babylonjs/Meshes/Builders/groundBuilder";
  66733. export * from "babylonjs/Meshes/Builders/tubeBuilder";
  66734. export * from "babylonjs/Meshes/Builders/polyhedronBuilder";
  66735. export * from "babylonjs/Meshes/Builders/icoSphereBuilder";
  66736. export * from "babylonjs/Meshes/Builders/decalBuilder";
  66737. }
  66738. declare module "babylonjs/Meshes/index" {
  66739. export * from "babylonjs/Meshes/abstractMesh";
  66740. export * from "babylonjs/Meshes/buffer";
  66741. export * from "babylonjs/Meshes/Compression/index";
  66742. export * from "babylonjs/Meshes/csg";
  66743. export * from "babylonjs/Meshes/geometry";
  66744. export * from "babylonjs/Meshes/groundMesh";
  66745. export * from "babylonjs/Meshes/trailMesh";
  66746. export * from "babylonjs/Meshes/instancedMesh";
  66747. export * from "babylonjs/Meshes/linesMesh";
  66748. export * from "babylonjs/Meshes/mesh";
  66749. export * from "babylonjs/Meshes/mesh.vertexData";
  66750. export * from "babylonjs/Meshes/meshBuilder";
  66751. export * from "babylonjs/Meshes/meshSimplification";
  66752. export * from "babylonjs/Meshes/meshSimplificationSceneComponent";
  66753. export * from "babylonjs/Meshes/polygonMesh";
  66754. export * from "babylonjs/Meshes/subMesh";
  66755. export * from "babylonjs/Meshes/meshLODLevel";
  66756. export * from "babylonjs/Meshes/transformNode";
  66757. export * from "babylonjs/Meshes/Builders/index";
  66758. export * from "babylonjs/Meshes/dataBuffer";
  66759. export * from "babylonjs/Meshes/WebGL/webGLDataBuffer";
  66760. }
  66761. declare module "babylonjs/Morph/index" {
  66762. export * from "babylonjs/Morph/morphTarget";
  66763. export * from "babylonjs/Morph/morphTargetManager";
  66764. }
  66765. declare module "babylonjs/Navigation/INavigationEngine" {
  66766. import { TransformNode } from "babylonjs/Meshes/transformNode";
  66767. import { Vector3 } from "babylonjs/Maths/math";
  66768. import { Mesh } from "babylonjs/Meshes/mesh";
  66769. import { Scene } from "babylonjs/scene";
  66770. /**
  66771. * Navigation plugin interface to add navigation constrained by a navigation mesh
  66772. */
  66773. export interface INavigationEnginePlugin {
  66774. /**
  66775. * plugin name
  66776. */
  66777. name: string;
  66778. /**
  66779. * Creates a navigation mesh
  66780. * @param meshes array of all the geometry used to compute the navigatio mesh
  66781. * @param parameters bunch of parameters used to filter geometry
  66782. */
  66783. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  66784. /**
  66785. * Create a navigation mesh debug mesh
  66786. * @param scene is where the mesh will be added
  66787. * @returns debug display mesh
  66788. */
  66789. createDebugNavMesh(scene: Scene): Mesh;
  66790. /**
  66791. * Get a navigation mesh constrained position, closest to the parameter position
  66792. * @param position world position
  66793. * @returns the closest point to position constrained by the navigation mesh
  66794. */
  66795. getClosestPoint(position: Vector3): Vector3;
  66796. /**
  66797. * Get a navigation mesh constrained position, closest to the parameter position
  66798. * @param position world position
  66799. * @param result output the closest point to position constrained by the navigation mesh
  66800. */
  66801. getClosestPointToRef(position: Vector3, result: Vector3): void;
  66802. /**
  66803. * Get a navigation mesh constrained position, within a particular radius
  66804. * @param position world position
  66805. * @param maxRadius the maximum distance to the constrained world position
  66806. * @returns the closest point to position constrained by the navigation mesh
  66807. */
  66808. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  66809. /**
  66810. * Get a navigation mesh constrained position, within a particular radius
  66811. * @param position world position
  66812. * @param maxRadius the maximum distance to the constrained world position
  66813. * @param result output the closest point to position constrained by the navigation mesh
  66814. */
  66815. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  66816. /**
  66817. * Compute the final position from a segment made of destination-position
  66818. * @param position world position
  66819. * @param destination world position
  66820. * @returns the resulting point along the navmesh
  66821. */
  66822. moveAlong(position: Vector3, destination: Vector3): Vector3;
  66823. /**
  66824. * Compute the final position from a segment made of destination-position
  66825. * @param position world position
  66826. * @param destination world position
  66827. * @param result output the resulting point along the navmesh
  66828. */
  66829. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  66830. /**
  66831. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  66832. * @param start world position
  66833. * @param end world position
  66834. * @returns array containing world position composing the path
  66835. */
  66836. computePath(start: Vector3, end: Vector3): Vector3[];
  66837. /**
  66838. * If this plugin is supported
  66839. * @returns true if plugin is supported
  66840. */
  66841. isSupported(): boolean;
  66842. /**
  66843. * Create a new Crowd so you can add agents
  66844. * @param maxAgents the maximum agent count in the crowd
  66845. * @param maxAgentRadius the maximum radius an agent can have
  66846. * @param scene to attach the crowd to
  66847. * @returns the crowd you can add agents to
  66848. */
  66849. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  66850. /**
  66851. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  66852. * The queries will try to find a solution within those bounds
  66853. * default is (1,1,1)
  66854. * @param extent x,y,z value that define the extent around the queries point of reference
  66855. */
  66856. setDefaultQueryExtent(extent: Vector3): void;
  66857. /**
  66858. * Get the Bounding box extent specified by setDefaultQueryExtent
  66859. * @returns the box extent values
  66860. */
  66861. getDefaultQueryExtent(): Vector3;
  66862. /**
  66863. * build the navmesh from a previously saved state using getNavmeshData
  66864. * @param data the Uint8Array returned by getNavmeshData
  66865. */
  66866. buildFromNavmeshData(data: Uint8Array): void;
  66867. /**
  66868. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  66869. * @returns data the Uint8Array that can be saved and reused
  66870. */
  66871. getNavmeshData(): Uint8Array;
  66872. /**
  66873. * Get the Bounding box extent result specified by setDefaultQueryExtent
  66874. * @param result output the box extent values
  66875. */
  66876. getDefaultQueryExtentToRef(result: Vector3): void;
  66877. /**
  66878. * Release all resources
  66879. */
  66880. dispose(): void;
  66881. }
  66882. /**
  66883. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  66884. */
  66885. export interface ICrowd {
  66886. /**
  66887. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  66888. * You can attach anything to that node. The node position is updated in the scene update tick.
  66889. * @param pos world position that will be constrained by the navigation mesh
  66890. * @param parameters agent parameters
  66891. * @param transform hooked to the agent that will be update by the scene
  66892. * @returns agent index
  66893. */
  66894. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  66895. /**
  66896. * Returns the agent position in world space
  66897. * @param index agent index returned by addAgent
  66898. * @returns world space position
  66899. */
  66900. getAgentPosition(index: number): Vector3;
  66901. /**
  66902. * Gets the agent position result in world space
  66903. * @param index agent index returned by addAgent
  66904. * @param result output world space position
  66905. */
  66906. getAgentPositionToRef(index: number, result: Vector3): void;
  66907. /**
  66908. * Gets the agent velocity in world space
  66909. * @param index agent index returned by addAgent
  66910. * @returns world space velocity
  66911. */
  66912. getAgentVelocity(index: number): Vector3;
  66913. /**
  66914. * Gets the agent velocity result in world space
  66915. * @param index agent index returned by addAgent
  66916. * @param result output world space velocity
  66917. */
  66918. getAgentVelocityToRef(index: number, result: Vector3): void;
  66919. /**
  66920. * remove a particular agent previously created
  66921. * @param index agent index returned by addAgent
  66922. */
  66923. removeAgent(index: number): void;
  66924. /**
  66925. * get the list of all agents attached to this crowd
  66926. * @returns list of agent indices
  66927. */
  66928. getAgents(): number[];
  66929. /**
  66930. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  66931. * @param deltaTime in seconds
  66932. */
  66933. update(deltaTime: number): void;
  66934. /**
  66935. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  66936. * @param index agent index returned by addAgent
  66937. * @param destination targeted world position
  66938. */
  66939. agentGoto(index: number, destination: Vector3): void;
  66940. /**
  66941. * Teleport the agent to a new position
  66942. * @param index agent index returned by addAgent
  66943. * @param destination targeted world position
  66944. */
  66945. agentTeleport(index: number, destination: Vector3): void;
  66946. /**
  66947. * Update agent parameters
  66948. * @param index agent index returned by addAgent
  66949. * @param parameters agent parameters
  66950. */
  66951. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  66952. /**
  66953. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  66954. * The queries will try to find a solution within those bounds
  66955. * default is (1,1,1)
  66956. * @param extent x,y,z value that define the extent around the queries point of reference
  66957. */
  66958. setDefaultQueryExtent(extent: Vector3): void;
  66959. /**
  66960. * Get the Bounding box extent specified by setDefaultQueryExtent
  66961. * @returns the box extent values
  66962. */
  66963. getDefaultQueryExtent(): Vector3;
  66964. /**
  66965. * Get the Bounding box extent result specified by setDefaultQueryExtent
  66966. * @param result output the box extent values
  66967. */
  66968. getDefaultQueryExtentToRef(result: Vector3): void;
  66969. /**
  66970. * Release all resources
  66971. */
  66972. dispose(): void;
  66973. }
  66974. /**
  66975. * Configures an agent
  66976. */
  66977. export interface IAgentParameters {
  66978. /**
  66979. * Agent radius. [Limit: >= 0]
  66980. */
  66981. radius: number;
  66982. /**
  66983. * Agent height. [Limit: > 0]
  66984. */
  66985. height: number;
  66986. /**
  66987. * Maximum allowed acceleration. [Limit: >= 0]
  66988. */
  66989. maxAcceleration: number;
  66990. /**
  66991. * Maximum allowed speed. [Limit: >= 0]
  66992. */
  66993. maxSpeed: number;
  66994. /**
  66995. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  66996. */
  66997. collisionQueryRange: number;
  66998. /**
  66999. * The path visibility optimization range. [Limit: > 0]
  67000. */
  67001. pathOptimizationRange: number;
  67002. /**
  67003. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  67004. */
  67005. separationWeight: number;
  67006. }
  67007. /**
  67008. * Configures the navigation mesh creation
  67009. */
  67010. export interface INavMeshParameters {
  67011. /**
  67012. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  67013. */
  67014. cs: number;
  67015. /**
  67016. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  67017. */
  67018. ch: number;
  67019. /**
  67020. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  67021. */
  67022. walkableSlopeAngle: number;
  67023. /**
  67024. * Minimum floor to 'ceiling' height that will still allow the floor area to
  67025. * be considered walkable. [Limit: >= 3] [Units: vx]
  67026. */
  67027. walkableHeight: number;
  67028. /**
  67029. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  67030. */
  67031. walkableClimb: number;
  67032. /**
  67033. * The distance to erode/shrink the walkable area of the heightfield away from
  67034. * obstructions. [Limit: >=0] [Units: vx]
  67035. */
  67036. walkableRadius: number;
  67037. /**
  67038. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  67039. */
  67040. maxEdgeLen: number;
  67041. /**
  67042. * The maximum distance a simplfied contour's border edges should deviate
  67043. * the original raw contour. [Limit: >=0] [Units: vx]
  67044. */
  67045. maxSimplificationError: number;
  67046. /**
  67047. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  67048. */
  67049. minRegionArea: number;
  67050. /**
  67051. * Any regions with a span count smaller than this value will, if possible,
  67052. * be merged with larger regions. [Limit: >=0] [Units: vx]
  67053. */
  67054. mergeRegionArea: number;
  67055. /**
  67056. * The maximum number of vertices allowed for polygons generated during the
  67057. * contour to polygon conversion process. [Limit: >= 3]
  67058. */
  67059. maxVertsPerPoly: number;
  67060. /**
  67061. * Sets the sampling distance to use when generating the detail mesh.
  67062. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  67063. */
  67064. detailSampleDist: number;
  67065. /**
  67066. * The maximum distance the detail mesh surface should deviate from heightfield
  67067. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  67068. */
  67069. detailSampleMaxError: number;
  67070. }
  67071. }
  67072. declare module "babylonjs/Navigation/Plugins/recastJSPlugin" {
  67073. import { INavigationEnginePlugin, ICrowd, IAgentParameters, INavMeshParameters } from "babylonjs/Navigation/INavigationEngine";
  67074. import { Mesh } from "babylonjs/Meshes/mesh";
  67075. import { Scene } from "babylonjs/scene";
  67076. import { Vector3 } from "babylonjs/Maths/math";
  67077. import { TransformNode } from "babylonjs/Meshes/transformNode";
  67078. /**
  67079. * RecastJS navigation plugin
  67080. */
  67081. export class RecastJSPlugin implements INavigationEnginePlugin {
  67082. /**
  67083. * Reference to the Recast library
  67084. */
  67085. bjsRECAST: any;
  67086. /**
  67087. * plugin name
  67088. */
  67089. name: string;
  67090. /**
  67091. * the first navmesh created. We might extend this to support multiple navmeshes
  67092. */
  67093. navMesh: any;
  67094. /**
  67095. * Initializes the recastJS plugin
  67096. * @param recastInjection can be used to inject your own recast reference
  67097. */
  67098. constructor(recastInjection?: any);
  67099. /**
  67100. * Creates a navigation mesh
  67101. * @param meshes array of all the geometry used to compute the navigatio mesh
  67102. * @param parameters bunch of parameters used to filter geometry
  67103. */
  67104. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  67105. /**
  67106. * Create a navigation mesh debug mesh
  67107. * @param scene is where the mesh will be added
  67108. * @returns debug display mesh
  67109. */
  67110. createDebugNavMesh(scene: Scene): Mesh;
  67111. /**
  67112. * Get a navigation mesh constrained position, closest to the parameter position
  67113. * @param position world position
  67114. * @returns the closest point to position constrained by the navigation mesh
  67115. */
  67116. getClosestPoint(position: Vector3): Vector3;
  67117. /**
  67118. * Get a navigation mesh constrained position, closest to the parameter position
  67119. * @param position world position
  67120. * @param result output the closest point to position constrained by the navigation mesh
  67121. */
  67122. getClosestPointToRef(position: Vector3, result: Vector3): void;
  67123. /**
  67124. * Get a navigation mesh constrained position, within a particular radius
  67125. * @param position world position
  67126. * @param maxRadius the maximum distance to the constrained world position
  67127. * @returns the closest point to position constrained by the navigation mesh
  67128. */
  67129. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  67130. /**
  67131. * Get a navigation mesh constrained position, within a particular radius
  67132. * @param position world position
  67133. * @param maxRadius the maximum distance to the constrained world position
  67134. * @param result output the closest point to position constrained by the navigation mesh
  67135. */
  67136. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  67137. /**
  67138. * Compute the final position from a segment made of destination-position
  67139. * @param position world position
  67140. * @param destination world position
  67141. * @returns the resulting point along the navmesh
  67142. */
  67143. moveAlong(position: Vector3, destination: Vector3): Vector3;
  67144. /**
  67145. * Compute the final position from a segment made of destination-position
  67146. * @param position world position
  67147. * @param destination world position
  67148. * @param result output the resulting point along the navmesh
  67149. */
  67150. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  67151. /**
  67152. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  67153. * @param start world position
  67154. * @param end world position
  67155. * @returns array containing world position composing the path
  67156. */
  67157. computePath(start: Vector3, end: Vector3): Vector3[];
  67158. /**
  67159. * Create a new Crowd so you can add agents
  67160. * @param maxAgents the maximum agent count in the crowd
  67161. * @param maxAgentRadius the maximum radius an agent can have
  67162. * @param scene to attach the crowd to
  67163. * @returns the crowd you can add agents to
  67164. */
  67165. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  67166. /**
  67167. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  67168. * The queries will try to find a solution within those bounds
  67169. * default is (1,1,1)
  67170. * @param extent x,y,z value that define the extent around the queries point of reference
  67171. */
  67172. setDefaultQueryExtent(extent: Vector3): void;
  67173. /**
  67174. * Get the Bounding box extent specified by setDefaultQueryExtent
  67175. * @returns the box extent values
  67176. */
  67177. getDefaultQueryExtent(): Vector3;
  67178. /**
  67179. * build the navmesh from a previously saved state using getNavmeshData
  67180. * @param data the Uint8Array returned by getNavmeshData
  67181. */
  67182. buildFromNavmeshData(data: Uint8Array): void;
  67183. /**
  67184. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  67185. * @returns data the Uint8Array that can be saved and reused
  67186. */
  67187. getNavmeshData(): Uint8Array;
  67188. /**
  67189. * Get the Bounding box extent result specified by setDefaultQueryExtent
  67190. * @param result output the box extent values
  67191. */
  67192. getDefaultQueryExtentToRef(result: Vector3): void;
  67193. /**
  67194. * Disposes
  67195. */
  67196. dispose(): void;
  67197. /**
  67198. * If this plugin is supported
  67199. * @returns true if plugin is supported
  67200. */
  67201. isSupported(): boolean;
  67202. }
  67203. /**
  67204. * Recast detour crowd implementation
  67205. */
  67206. export class RecastJSCrowd implements ICrowd {
  67207. /**
  67208. * Recast/detour plugin
  67209. */
  67210. bjsRECASTPlugin: RecastJSPlugin;
  67211. /**
  67212. * Link to the detour crowd
  67213. */
  67214. recastCrowd: any;
  67215. /**
  67216. * One transform per agent
  67217. */
  67218. transforms: TransformNode[];
  67219. /**
  67220. * All agents created
  67221. */
  67222. agents: number[];
  67223. /**
  67224. * Link to the scene is kept to unregister the crowd from the scene
  67225. */
  67226. private _scene;
  67227. /**
  67228. * Observer for crowd updates
  67229. */
  67230. private _onBeforeAnimationsObserver;
  67231. /**
  67232. * Constructor
  67233. * @param plugin recastJS plugin
  67234. * @param maxAgents the maximum agent count in the crowd
  67235. * @param maxAgentRadius the maximum radius an agent can have
  67236. * @param scene to attach the crowd to
  67237. * @returns the crowd you can add agents to
  67238. */
  67239. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  67240. /**
  67241. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  67242. * You can attach anything to that node. The node position is updated in the scene update tick.
  67243. * @param pos world position that will be constrained by the navigation mesh
  67244. * @param parameters agent parameters
  67245. * @param transform hooked to the agent that will be update by the scene
  67246. * @returns agent index
  67247. */
  67248. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  67249. /**
  67250. * Returns the agent position in world space
  67251. * @param index agent index returned by addAgent
  67252. * @returns world space position
  67253. */
  67254. getAgentPosition(index: number): Vector3;
  67255. /**
  67256. * Returns the agent position result in world space
  67257. * @param index agent index returned by addAgent
  67258. * @param result output world space position
  67259. */
  67260. getAgentPositionToRef(index: number, result: Vector3): void;
  67261. /**
  67262. * Returns the agent velocity in world space
  67263. * @param index agent index returned by addAgent
  67264. * @returns world space velocity
  67265. */
  67266. getAgentVelocity(index: number): Vector3;
  67267. /**
  67268. * Returns the agent velocity result in world space
  67269. * @param index agent index returned by addAgent
  67270. * @param result output world space velocity
  67271. */
  67272. getAgentVelocityToRef(index: number, result: Vector3): void;
  67273. /**
  67274. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  67275. * @param index agent index returned by addAgent
  67276. * @param destination targeted world position
  67277. */
  67278. agentGoto(index: number, destination: Vector3): void;
  67279. /**
  67280. * Teleport the agent to a new position
  67281. * @param index agent index returned by addAgent
  67282. * @param destination targeted world position
  67283. */
  67284. agentTeleport(index: number, destination: Vector3): void;
  67285. /**
  67286. * Update agent parameters
  67287. * @param index agent index returned by addAgent
  67288. * @param parameters agent parameters
  67289. */
  67290. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  67291. /**
  67292. * remove a particular agent previously created
  67293. * @param index agent index returned by addAgent
  67294. */
  67295. removeAgent(index: number): void;
  67296. /**
  67297. * get the list of all agents attached to this crowd
  67298. * @returns list of agent indices
  67299. */
  67300. getAgents(): number[];
  67301. /**
  67302. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  67303. * @param deltaTime in seconds
  67304. */
  67305. update(deltaTime: number): void;
  67306. /**
  67307. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  67308. * The queries will try to find a solution within those bounds
  67309. * default is (1,1,1)
  67310. * @param extent x,y,z value that define the extent around the queries point of reference
  67311. */
  67312. setDefaultQueryExtent(extent: Vector3): void;
  67313. /**
  67314. * Get the Bounding box extent specified by setDefaultQueryExtent
  67315. * @returns the box extent values
  67316. */
  67317. getDefaultQueryExtent(): Vector3;
  67318. /**
  67319. * Get the Bounding box extent result specified by setDefaultQueryExtent
  67320. * @param result output the box extent values
  67321. */
  67322. getDefaultQueryExtentToRef(result: Vector3): void;
  67323. /**
  67324. * Release all resources
  67325. */
  67326. dispose(): void;
  67327. }
  67328. }
  67329. declare module "babylonjs/Navigation/Plugins/index" {
  67330. export * from "babylonjs/Navigation/Plugins/recastJSPlugin";
  67331. }
  67332. declare module "babylonjs/Navigation/index" {
  67333. export * from "babylonjs/Navigation/INavigationEngine";
  67334. export * from "babylonjs/Navigation/Plugins/index";
  67335. }
  67336. declare module "babylonjs/Offline/database" {
  67337. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  67338. /**
  67339. * Class used to enable access to IndexedDB
  67340. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  67341. */
  67342. export class Database implements IOfflineProvider {
  67343. private _callbackManifestChecked;
  67344. private _currentSceneUrl;
  67345. private _db;
  67346. private _enableSceneOffline;
  67347. private _enableTexturesOffline;
  67348. private _manifestVersionFound;
  67349. private _mustUpdateRessources;
  67350. private _hasReachedQuota;
  67351. private _isSupported;
  67352. private _idbFactory;
  67353. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  67354. private static IsUASupportingBlobStorage;
  67355. /**
  67356. * Gets a boolean indicating if Database storate is enabled (off by default)
  67357. */
  67358. static IDBStorageEnabled: boolean;
  67359. /**
  67360. * Gets a boolean indicating if scene must be saved in the database
  67361. */
  67362. get enableSceneOffline(): boolean;
  67363. /**
  67364. * Gets a boolean indicating if textures must be saved in the database
  67365. */
  67366. get enableTexturesOffline(): boolean;
  67367. /**
  67368. * Creates a new Database
  67369. * @param urlToScene defines the url to load the scene
  67370. * @param callbackManifestChecked defines the callback to use when manifest is checked
  67371. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  67372. */
  67373. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  67374. private static _ParseURL;
  67375. private static _ReturnFullUrlLocation;
  67376. private _checkManifestFile;
  67377. /**
  67378. * Open the database and make it available
  67379. * @param successCallback defines the callback to call on success
  67380. * @param errorCallback defines the callback to call on error
  67381. */
  67382. open(successCallback: () => void, errorCallback: () => void): void;
  67383. /**
  67384. * Loads an image from the database
  67385. * @param url defines the url to load from
  67386. * @param image defines the target DOM image
  67387. */
  67388. loadImage(url: string, image: HTMLImageElement): void;
  67389. private _loadImageFromDBAsync;
  67390. private _saveImageIntoDBAsync;
  67391. private _checkVersionFromDB;
  67392. private _loadVersionFromDBAsync;
  67393. private _saveVersionIntoDBAsync;
  67394. /**
  67395. * Loads a file from database
  67396. * @param url defines the URL to load from
  67397. * @param sceneLoaded defines a callback to call on success
  67398. * @param progressCallBack defines a callback to call when progress changed
  67399. * @param errorCallback defines a callback to call on error
  67400. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  67401. */
  67402. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  67403. private _loadFileAsync;
  67404. private _saveFileAsync;
  67405. /**
  67406. * Validates if xhr data is correct
  67407. * @param xhr defines the request to validate
  67408. * @param dataType defines the expected data type
  67409. * @returns true if data is correct
  67410. */
  67411. private static _ValidateXHRData;
  67412. }
  67413. }
  67414. declare module "babylonjs/Offline/index" {
  67415. export * from "babylonjs/Offline/database";
  67416. export * from "babylonjs/Offline/IOfflineProvider";
  67417. }
  67418. declare module "babylonjs/Shaders/gpuUpdateParticles.fragment" {
  67419. /** @hidden */
  67420. export var gpuUpdateParticlesPixelShader: {
  67421. name: string;
  67422. shader: string;
  67423. };
  67424. }
  67425. declare module "babylonjs/Shaders/gpuUpdateParticles.vertex" {
  67426. /** @hidden */
  67427. export var gpuUpdateParticlesVertexShader: {
  67428. name: string;
  67429. shader: string;
  67430. };
  67431. }
  67432. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2" {
  67433. /** @hidden */
  67434. export var clipPlaneFragmentDeclaration2: {
  67435. name: string;
  67436. shader: string;
  67437. };
  67438. }
  67439. declare module "babylonjs/Shaders/gpuRenderParticles.fragment" {
  67440. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2";
  67441. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  67442. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  67443. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  67444. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  67445. /** @hidden */
  67446. export var gpuRenderParticlesPixelShader: {
  67447. name: string;
  67448. shader: string;
  67449. };
  67450. }
  67451. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2" {
  67452. /** @hidden */
  67453. export var clipPlaneVertexDeclaration2: {
  67454. name: string;
  67455. shader: string;
  67456. };
  67457. }
  67458. declare module "babylonjs/Shaders/gpuRenderParticles.vertex" {
  67459. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2";
  67460. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  67461. /** @hidden */
  67462. export var gpuRenderParticlesVertexShader: {
  67463. name: string;
  67464. shader: string;
  67465. };
  67466. }
  67467. declare module "babylonjs/Particles/gpuParticleSystem" {
  67468. import { Nullable } from "babylonjs/types";
  67469. import { Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  67470. import { Observable } from "babylonjs/Misc/observable";
  67471. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  67472. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  67473. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  67474. import { Scene, IDisposable } from "babylonjs/scene";
  67475. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  67476. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  67477. import "babylonjs/Shaders/gpuUpdateParticles.fragment";
  67478. import "babylonjs/Shaders/gpuUpdateParticles.vertex";
  67479. import "babylonjs/Shaders/gpuRenderParticles.fragment";
  67480. import "babylonjs/Shaders/gpuRenderParticles.vertex";
  67481. /**
  67482. * This represents a GPU particle system in Babylon
  67483. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  67484. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  67485. */
  67486. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  67487. /**
  67488. * The layer mask we are rendering the particles through.
  67489. */
  67490. layerMask: number;
  67491. private _capacity;
  67492. private _activeCount;
  67493. private _currentActiveCount;
  67494. private _accumulatedCount;
  67495. private _renderEffect;
  67496. private _updateEffect;
  67497. private _buffer0;
  67498. private _buffer1;
  67499. private _spriteBuffer;
  67500. private _updateVAO;
  67501. private _renderVAO;
  67502. private _targetIndex;
  67503. private _sourceBuffer;
  67504. private _targetBuffer;
  67505. private _engine;
  67506. private _currentRenderId;
  67507. private _started;
  67508. private _stopped;
  67509. private _timeDelta;
  67510. private _randomTexture;
  67511. private _randomTexture2;
  67512. private _attributesStrideSize;
  67513. private _updateEffectOptions;
  67514. private _randomTextureSize;
  67515. private _actualFrame;
  67516. private readonly _rawTextureWidth;
  67517. /**
  67518. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  67519. */
  67520. static get IsSupported(): boolean;
  67521. /**
  67522. * An event triggered when the system is disposed.
  67523. */
  67524. onDisposeObservable: Observable<GPUParticleSystem>;
  67525. /**
  67526. * Gets the maximum number of particles active at the same time.
  67527. * @returns The max number of active particles.
  67528. */
  67529. getCapacity(): number;
  67530. /**
  67531. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  67532. * to override the particles.
  67533. */
  67534. forceDepthWrite: boolean;
  67535. /**
  67536. * Gets or set the number of active particles
  67537. */
  67538. get activeParticleCount(): number;
  67539. set activeParticleCount(value: number);
  67540. private _preWarmDone;
  67541. /**
  67542. * Specifies if the particles are updated in emitter local space or world space.
  67543. */
  67544. isLocal: boolean;
  67545. /**
  67546. * Is this system ready to be used/rendered
  67547. * @return true if the system is ready
  67548. */
  67549. isReady(): boolean;
  67550. /**
  67551. * Gets if the system has been started. (Note: this will still be true after stop is called)
  67552. * @returns True if it has been started, otherwise false.
  67553. */
  67554. isStarted(): boolean;
  67555. /**
  67556. * Gets if the system has been stopped. (Note: rendering is still happening but the system is frozen)
  67557. * @returns True if it has been stopped, otherwise false.
  67558. */
  67559. isStopped(): boolean;
  67560. /**
  67561. * Gets a boolean indicating that the system is stopping
  67562. * @returns true if the system is currently stopping
  67563. */
  67564. isStopping(): boolean;
  67565. /**
  67566. * Gets the number of particles active at the same time.
  67567. * @returns The number of active particles.
  67568. */
  67569. getActiveCount(): number;
  67570. /**
  67571. * Starts the particle system and begins to emit
  67572. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  67573. */
  67574. start(delay?: number): void;
  67575. /**
  67576. * Stops the particle system.
  67577. */
  67578. stop(): void;
  67579. /**
  67580. * Remove all active particles
  67581. */
  67582. reset(): void;
  67583. /**
  67584. * Returns the string "GPUParticleSystem"
  67585. * @returns a string containing the class name
  67586. */
  67587. getClassName(): string;
  67588. private _colorGradientsTexture;
  67589. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  67590. /**
  67591. * Adds a new color gradient
  67592. * @param gradient defines the gradient to use (between 0 and 1)
  67593. * @param color1 defines the color to affect to the specified gradient
  67594. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  67595. * @returns the current particle system
  67596. */
  67597. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  67598. private _refreshColorGradient;
  67599. /** Force the system to rebuild all gradients that need to be resync */
  67600. forceRefreshGradients(): void;
  67601. /**
  67602. * Remove a specific color gradient
  67603. * @param gradient defines the gradient to remove
  67604. * @returns the current particle system
  67605. */
  67606. removeColorGradient(gradient: number): GPUParticleSystem;
  67607. private _angularSpeedGradientsTexture;
  67608. private _sizeGradientsTexture;
  67609. private _velocityGradientsTexture;
  67610. private _limitVelocityGradientsTexture;
  67611. private _dragGradientsTexture;
  67612. private _addFactorGradient;
  67613. /**
  67614. * Adds a new size gradient
  67615. * @param gradient defines the gradient to use (between 0 and 1)
  67616. * @param factor defines the size factor to affect to the specified gradient
  67617. * @returns the current particle system
  67618. */
  67619. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  67620. /**
  67621. * Remove a specific size gradient
  67622. * @param gradient defines the gradient to remove
  67623. * @returns the current particle system
  67624. */
  67625. removeSizeGradient(gradient: number): GPUParticleSystem;
  67626. private _refreshFactorGradient;
  67627. /**
  67628. * Adds a new angular speed gradient
  67629. * @param gradient defines the gradient to use (between 0 and 1)
  67630. * @param factor defines the angular speed to affect to the specified gradient
  67631. * @returns the current particle system
  67632. */
  67633. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  67634. /**
  67635. * Remove a specific angular speed gradient
  67636. * @param gradient defines the gradient to remove
  67637. * @returns the current particle system
  67638. */
  67639. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  67640. /**
  67641. * Adds a new velocity gradient
  67642. * @param gradient defines the gradient to use (between 0 and 1)
  67643. * @param factor defines the velocity to affect to the specified gradient
  67644. * @returns the current particle system
  67645. */
  67646. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  67647. /**
  67648. * Remove a specific velocity gradient
  67649. * @param gradient defines the gradient to remove
  67650. * @returns the current particle system
  67651. */
  67652. removeVelocityGradient(gradient: number): GPUParticleSystem;
  67653. /**
  67654. * Adds a new limit velocity gradient
  67655. * @param gradient defines the gradient to use (between 0 and 1)
  67656. * @param factor defines the limit velocity value to affect to the specified gradient
  67657. * @returns the current particle system
  67658. */
  67659. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  67660. /**
  67661. * Remove a specific limit velocity gradient
  67662. * @param gradient defines the gradient to remove
  67663. * @returns the current particle system
  67664. */
  67665. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  67666. /**
  67667. * Adds a new drag gradient
  67668. * @param gradient defines the gradient to use (between 0 and 1)
  67669. * @param factor defines the drag value to affect to the specified gradient
  67670. * @returns the current particle system
  67671. */
  67672. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  67673. /**
  67674. * Remove a specific drag gradient
  67675. * @param gradient defines the gradient to remove
  67676. * @returns the current particle system
  67677. */
  67678. removeDragGradient(gradient: number): GPUParticleSystem;
  67679. /**
  67680. * Not supported by GPUParticleSystem
  67681. * @param gradient defines the gradient to use (between 0 and 1)
  67682. * @param factor defines the emit rate value to affect to the specified gradient
  67683. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  67684. * @returns the current particle system
  67685. */
  67686. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  67687. /**
  67688. * Not supported by GPUParticleSystem
  67689. * @param gradient defines the gradient to remove
  67690. * @returns the current particle system
  67691. */
  67692. removeEmitRateGradient(gradient: number): IParticleSystem;
  67693. /**
  67694. * Not supported by GPUParticleSystem
  67695. * @param gradient defines the gradient to use (between 0 and 1)
  67696. * @param factor defines the start size value to affect to the specified gradient
  67697. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  67698. * @returns the current particle system
  67699. */
  67700. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  67701. /**
  67702. * Not supported by GPUParticleSystem
  67703. * @param gradient defines the gradient to remove
  67704. * @returns the current particle system
  67705. */
  67706. removeStartSizeGradient(gradient: number): IParticleSystem;
  67707. /**
  67708. * Not supported by GPUParticleSystem
  67709. * @param gradient defines the gradient to use (between 0 and 1)
  67710. * @param min defines the color remap minimal range
  67711. * @param max defines the color remap maximal range
  67712. * @returns the current particle system
  67713. */
  67714. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  67715. /**
  67716. * Not supported by GPUParticleSystem
  67717. * @param gradient defines the gradient to remove
  67718. * @returns the current particle system
  67719. */
  67720. removeColorRemapGradient(): IParticleSystem;
  67721. /**
  67722. * Not supported by GPUParticleSystem
  67723. * @param gradient defines the gradient to use (between 0 and 1)
  67724. * @param min defines the alpha remap minimal range
  67725. * @param max defines the alpha remap maximal range
  67726. * @returns the current particle system
  67727. */
  67728. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  67729. /**
  67730. * Not supported by GPUParticleSystem
  67731. * @param gradient defines the gradient to remove
  67732. * @returns the current particle system
  67733. */
  67734. removeAlphaRemapGradient(): IParticleSystem;
  67735. /**
  67736. * Not supported by GPUParticleSystem
  67737. * @param gradient defines the gradient to use (between 0 and 1)
  67738. * @param color defines the color to affect to the specified gradient
  67739. * @returns the current particle system
  67740. */
  67741. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  67742. /**
  67743. * Not supported by GPUParticleSystem
  67744. * @param gradient defines the gradient to remove
  67745. * @returns the current particle system
  67746. */
  67747. removeRampGradient(): IParticleSystem;
  67748. /**
  67749. * Not supported by GPUParticleSystem
  67750. * @returns the list of ramp gradients
  67751. */
  67752. getRampGradients(): Nullable<Array<Color3Gradient>>;
  67753. /**
  67754. * Not supported by GPUParticleSystem
  67755. * Gets or sets a boolean indicating that ramp gradients must be used
  67756. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  67757. */
  67758. get useRampGradients(): boolean;
  67759. set useRampGradients(value: boolean);
  67760. /**
  67761. * Not supported by GPUParticleSystem
  67762. * @param gradient defines the gradient to use (between 0 and 1)
  67763. * @param factor defines the life time factor to affect to the specified gradient
  67764. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  67765. * @returns the current particle system
  67766. */
  67767. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  67768. /**
  67769. * Not supported by GPUParticleSystem
  67770. * @param gradient defines the gradient to remove
  67771. * @returns the current particle system
  67772. */
  67773. removeLifeTimeGradient(gradient: number): IParticleSystem;
  67774. /**
  67775. * Instantiates a GPU particle system.
  67776. * 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.
  67777. * @param name The name of the particle system
  67778. * @param options The options used to create the system
  67779. * @param scene The scene the particle system belongs to
  67780. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  67781. */
  67782. constructor(name: string, options: Partial<{
  67783. capacity: number;
  67784. randomTextureSize: number;
  67785. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  67786. protected _reset(): void;
  67787. private _createUpdateVAO;
  67788. private _createRenderVAO;
  67789. private _initialize;
  67790. /** @hidden */
  67791. _recreateUpdateEffect(): void;
  67792. /** @hidden */
  67793. _recreateRenderEffect(): void;
  67794. /**
  67795. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  67796. * @param preWarm defines if we are in the pre-warmimg phase
  67797. */
  67798. animate(preWarm?: boolean): void;
  67799. private _createFactorGradientTexture;
  67800. private _createSizeGradientTexture;
  67801. private _createAngularSpeedGradientTexture;
  67802. private _createVelocityGradientTexture;
  67803. private _createLimitVelocityGradientTexture;
  67804. private _createDragGradientTexture;
  67805. private _createColorGradientTexture;
  67806. /**
  67807. * Renders the particle system in its current state
  67808. * @param preWarm defines if the system should only update the particles but not render them
  67809. * @returns the current number of particles
  67810. */
  67811. render(preWarm?: boolean): number;
  67812. /**
  67813. * Rebuilds the particle system
  67814. */
  67815. rebuild(): void;
  67816. private _releaseBuffers;
  67817. private _releaseVAOs;
  67818. /**
  67819. * Disposes the particle system and free the associated resources
  67820. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  67821. */
  67822. dispose(disposeTexture?: boolean): void;
  67823. /**
  67824. * Clones the particle system.
  67825. * @param name The name of the cloned object
  67826. * @param newEmitter The new emitter to use
  67827. * @returns the cloned particle system
  67828. */
  67829. clone(name: string, newEmitter: any): GPUParticleSystem;
  67830. /**
  67831. * Serializes the particle system to a JSON object
  67832. * @param serializeTexture defines if the texture must be serialized as well
  67833. * @returns the JSON object
  67834. */
  67835. serialize(serializeTexture?: boolean): any;
  67836. /**
  67837. * Parses a JSON object to create a GPU particle system.
  67838. * @param parsedParticleSystem The JSON object to parse
  67839. * @param scene The scene to create the particle system in
  67840. * @param rootUrl The root url to use to load external dependencies like texture
  67841. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  67842. * @returns the parsed GPU particle system
  67843. */
  67844. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  67845. }
  67846. }
  67847. declare module "babylonjs/Particles/particleSystemSet" {
  67848. import { Nullable } from "babylonjs/types";
  67849. import { Color3 } from "babylonjs/Maths/math.color";
  67850. import { TransformNode } from "babylonjs/Meshes/transformNode";
  67851. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  67852. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  67853. import { Scene, IDisposable } from "babylonjs/scene";
  67854. /**
  67855. * Represents a set of particle systems working together to create a specific effect
  67856. */
  67857. export class ParticleSystemSet implements IDisposable {
  67858. /**
  67859. * Gets or sets base Assets URL
  67860. */
  67861. static BaseAssetsUrl: string;
  67862. private _emitterCreationOptions;
  67863. private _emitterNode;
  67864. /**
  67865. * Gets the particle system list
  67866. */
  67867. systems: IParticleSystem[];
  67868. /**
  67869. * Gets the emitter node used with this set
  67870. */
  67871. get emitterNode(): Nullable<TransformNode>;
  67872. /**
  67873. * Creates a new emitter mesh as a sphere
  67874. * @param options defines the options used to create the sphere
  67875. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  67876. * @param scene defines the hosting scene
  67877. */
  67878. setEmitterAsSphere(options: {
  67879. diameter: number;
  67880. segments: number;
  67881. color: Color3;
  67882. }, renderingGroupId: number, scene: Scene): void;
  67883. /**
  67884. * Starts all particle systems of the set
  67885. * @param emitter defines an optional mesh to use as emitter for the particle systems
  67886. */
  67887. start(emitter?: AbstractMesh): void;
  67888. /**
  67889. * Release all associated resources
  67890. */
  67891. dispose(): void;
  67892. /**
  67893. * Serialize the set into a JSON compatible object
  67894. * @param serializeTexture defines if the texture must be serialized as well
  67895. * @returns a JSON compatible representation of the set
  67896. */
  67897. serialize(serializeTexture?: boolean): any;
  67898. /**
  67899. * Parse a new ParticleSystemSet from a serialized source
  67900. * @param data defines a JSON compatible representation of the set
  67901. * @param scene defines the hosting scene
  67902. * @param gpu defines if we want GPU particles or CPU particles
  67903. * @returns a new ParticleSystemSet
  67904. */
  67905. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  67906. }
  67907. }
  67908. declare module "babylonjs/Particles/particleHelper" {
  67909. import { Nullable } from "babylonjs/types";
  67910. import { Scene } from "babylonjs/scene";
  67911. import { Vector3 } from "babylonjs/Maths/math.vector";
  67912. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  67913. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  67914. import { ParticleSystemSet } from "babylonjs/Particles/particleSystemSet";
  67915. /**
  67916. * This class is made for on one-liner static method to help creating particle system set.
  67917. */
  67918. export class ParticleHelper {
  67919. /**
  67920. * Gets or sets base Assets URL
  67921. */
  67922. static BaseAssetsUrl: string;
  67923. /** Define the Url to load snippets */
  67924. static SnippetUrl: string;
  67925. /**
  67926. * Create a default particle system that you can tweak
  67927. * @param emitter defines the emitter to use
  67928. * @param capacity defines the system capacity (default is 500 particles)
  67929. * @param scene defines the hosting scene
  67930. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  67931. * @returns the new Particle system
  67932. */
  67933. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  67934. /**
  67935. * This is the main static method (one-liner) of this helper to create different particle systems
  67936. * @param type This string represents the type to the particle system to create
  67937. * @param scene The scene where the particle system should live
  67938. * @param gpu If the system will use gpu
  67939. * @returns the ParticleSystemSet created
  67940. */
  67941. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  67942. /**
  67943. * Static function used to export a particle system to a ParticleSystemSet variable.
  67944. * Please note that the emitter shape is not exported
  67945. * @param systems defines the particle systems to export
  67946. * @returns the created particle system set
  67947. */
  67948. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  67949. /**
  67950. * Creates a particle system from a snippet saved in a remote file
  67951. * @param name defines the name of the particle system to create
  67952. * @param url defines the url to load from
  67953. * @param scene defines the hosting scene
  67954. * @param gpu If the system will use gpu
  67955. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  67956. * @returns a promise that will resolve to the new particle system
  67957. */
  67958. static ParseFromFileAsync(name: string, url: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  67959. /**
  67960. * Creates a particle system from a snippet saved by the particle system editor
  67961. * @param snippetId defines the snippet to load
  67962. * @param scene defines the hosting scene
  67963. * @param gpu If the system will use gpu
  67964. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  67965. * @returns a promise that will resolve to the new particle system
  67966. */
  67967. static CreateFromSnippetAsync(snippetId: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  67968. }
  67969. }
  67970. declare module "babylonjs/Particles/particleSystemComponent" {
  67971. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  67972. import { Effect } from "babylonjs/Materials/effect";
  67973. import "babylonjs/Shaders/particles.vertex";
  67974. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  67975. module "babylonjs/Engines/engine" {
  67976. interface Engine {
  67977. /**
  67978. * Create an effect to use with particle systems.
  67979. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  67980. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  67981. * @param uniformsNames defines a list of attribute names
  67982. * @param samplers defines an array of string used to represent textures
  67983. * @param defines defines the string containing the defines to use to compile the shaders
  67984. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  67985. * @param onCompiled defines a function to call when the effect creation is successful
  67986. * @param onError defines a function to call when the effect creation has failed
  67987. * @returns the new Effect
  67988. */
  67989. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  67990. }
  67991. }
  67992. module "babylonjs/Meshes/mesh" {
  67993. interface Mesh {
  67994. /**
  67995. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  67996. * @returns an array of IParticleSystem
  67997. */
  67998. getEmittedParticleSystems(): IParticleSystem[];
  67999. /**
  68000. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  68001. * @returns an array of IParticleSystem
  68002. */
  68003. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  68004. }
  68005. }
  68006. /**
  68007. * @hidden
  68008. */
  68009. export var _IDoNeedToBeInTheBuild: number;
  68010. }
  68011. declare module "babylonjs/Particles/pointsCloudSystem" {
  68012. import { Color4 } from "babylonjs/Maths/math";
  68013. import { Mesh } from "babylonjs/Meshes/mesh";
  68014. import { Scene, IDisposable } from "babylonjs/scene";
  68015. import { CloudPoint } from "babylonjs/Particles/cloudPoint";
  68016. /** Defines the 4 color options */
  68017. export enum PointColor {
  68018. /** color value */
  68019. Color = 2,
  68020. /** uv value */
  68021. UV = 1,
  68022. /** random value */
  68023. Random = 0,
  68024. /** stated value */
  68025. Stated = 3
  68026. }
  68027. /**
  68028. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  68029. * 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.
  68030. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  68031. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  68032. *
  68033. * Full documentation here : TO BE ENTERED
  68034. */
  68035. export class PointsCloudSystem implements IDisposable {
  68036. /**
  68037. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  68038. * Example : var p = SPS.particles[i];
  68039. */
  68040. particles: CloudPoint[];
  68041. /**
  68042. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  68043. */
  68044. nbParticles: number;
  68045. /**
  68046. * This a counter for your own usage. It's not set by any SPS functions.
  68047. */
  68048. counter: number;
  68049. /**
  68050. * The PCS name. This name is also given to the underlying mesh.
  68051. */
  68052. name: string;
  68053. /**
  68054. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  68055. */
  68056. mesh: Mesh;
  68057. /**
  68058. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  68059. * Please read :
  68060. */
  68061. vars: any;
  68062. /**
  68063. * @hidden
  68064. */
  68065. _size: number;
  68066. private _scene;
  68067. private _promises;
  68068. private _positions;
  68069. private _indices;
  68070. private _normals;
  68071. private _colors;
  68072. private _uvs;
  68073. private _indices32;
  68074. private _positions32;
  68075. private _colors32;
  68076. private _uvs32;
  68077. private _updatable;
  68078. private _isVisibilityBoxLocked;
  68079. private _alwaysVisible;
  68080. private _groups;
  68081. private _groupCounter;
  68082. private _computeParticleColor;
  68083. private _computeParticleTexture;
  68084. private _computeParticleRotation;
  68085. private _computeBoundingBox;
  68086. private _isReady;
  68087. /**
  68088. * Creates a PCS (Points Cloud System) object
  68089. * @param name (String) is the PCS name, this will be the underlying mesh name
  68090. * @param pointSize (number) is the size for each point
  68091. * @param scene (Scene) is the scene in which the PCS is added
  68092. * @param options defines the options of the PCS e.g.
  68093. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  68094. */
  68095. constructor(name: string, pointSize: number, scene: Scene, options?: {
  68096. updatable?: boolean;
  68097. });
  68098. /**
  68099. * Builds the PCS underlying mesh. Returns a standard Mesh.
  68100. * If no points were added to the PCS, the returned mesh is just a single point.
  68101. * @returns a promise for the created mesh
  68102. */
  68103. buildMeshAsync(): Promise<Mesh>;
  68104. /**
  68105. * @hidden
  68106. */
  68107. private _buildMesh;
  68108. private _addParticle;
  68109. private _randomUnitVector;
  68110. private _getColorIndicesForCoord;
  68111. private _setPointsColorOrUV;
  68112. private _colorFromTexture;
  68113. private _calculateDensity;
  68114. /**
  68115. * Adds points to the PCS in random positions within a unit sphere
  68116. * @param nb (positive integer) the number of particles to be created from this model
  68117. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  68118. * @returns the number of groups in the system
  68119. */
  68120. addPoints(nb: number, pointFunction?: any): number;
  68121. /**
  68122. * Adds points to the PCS from the surface of the model shape
  68123. * @param mesh is any Mesh object that will be used as a surface model for the points
  68124. * @param nb (positive integer) the number of particles to be created from this model
  68125. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  68126. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  68127. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  68128. * @returns the number of groups in the system
  68129. */
  68130. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  68131. /**
  68132. * Adds points to the PCS inside the model shape
  68133. * @param mesh is any Mesh object that will be used as a surface model for the points
  68134. * @param nb (positive integer) the number of particles to be created from this model
  68135. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  68136. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  68137. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  68138. * @returns the number of groups in the system
  68139. */
  68140. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  68141. /**
  68142. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  68143. * This method calls `updateParticle()` for each particle of the SPS.
  68144. * For an animated SPS, it is usually called within the render loop.
  68145. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  68146. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  68147. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  68148. * @returns the PCS.
  68149. */
  68150. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  68151. /**
  68152. * Disposes the PCS.
  68153. */
  68154. dispose(): void;
  68155. /**
  68156. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  68157. * doc :
  68158. * @returns the PCS.
  68159. */
  68160. refreshVisibleSize(): PointsCloudSystem;
  68161. /**
  68162. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  68163. * @param size the size (float) of the visibility box
  68164. * note : this doesn't lock the PCS mesh bounding box.
  68165. * doc :
  68166. */
  68167. setVisibilityBox(size: number): void;
  68168. /**
  68169. * Gets whether the PCS is always visible or not
  68170. * doc :
  68171. */
  68172. get isAlwaysVisible(): boolean;
  68173. /**
  68174. * Sets the PCS as always visible or not
  68175. * doc :
  68176. */
  68177. set isAlwaysVisible(val: boolean);
  68178. /**
  68179. * Tells to `setParticles()` to compute the particle rotations or not
  68180. * Default value : false. The PCS is faster when it's set to false
  68181. * Note : particle rotations are only applied to parent particles
  68182. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  68183. */
  68184. set computeParticleRotation(val: boolean);
  68185. /**
  68186. * Tells to `setParticles()` to compute the particle colors or not.
  68187. * Default value : true. The PCS is faster when it's set to false.
  68188. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  68189. */
  68190. set computeParticleColor(val: boolean);
  68191. set computeParticleTexture(val: boolean);
  68192. /**
  68193. * Gets if `setParticles()` computes the particle colors or not.
  68194. * Default value : false. The PCS is faster when it's set to false.
  68195. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  68196. */
  68197. get computeParticleColor(): boolean;
  68198. /**
  68199. * Gets if `setParticles()` computes the particle textures or not.
  68200. * Default value : false. The PCS is faster when it's set to false.
  68201. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  68202. */
  68203. get computeParticleTexture(): boolean;
  68204. /**
  68205. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  68206. */
  68207. set computeBoundingBox(val: boolean);
  68208. /**
  68209. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  68210. */
  68211. get computeBoundingBox(): boolean;
  68212. /**
  68213. * This function does nothing. It may be overwritten to set all the particle first values.
  68214. * The PCS doesn't call this function, you may have to call it by your own.
  68215. * doc :
  68216. */
  68217. initParticles(): void;
  68218. /**
  68219. * This function does nothing. It may be overwritten to recycle a particle
  68220. * The PCS doesn't call this function, you can to call it
  68221. * doc :
  68222. * @param particle The particle to recycle
  68223. * @returns the recycled particle
  68224. */
  68225. recycleParticle(particle: CloudPoint): CloudPoint;
  68226. /**
  68227. * Updates a particle : this function should be overwritten by the user.
  68228. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  68229. * doc :
  68230. * @example : just set a particle position or velocity and recycle conditions
  68231. * @param particle The particle to update
  68232. * @returns the updated particle
  68233. */
  68234. updateParticle(particle: CloudPoint): CloudPoint;
  68235. /**
  68236. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  68237. * This does nothing and may be overwritten by the user.
  68238. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  68239. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  68240. * @param update the boolean update value actually passed to setParticles()
  68241. */
  68242. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  68243. /**
  68244. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  68245. * This will be passed three parameters.
  68246. * This does nothing and may be overwritten by the user.
  68247. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  68248. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  68249. * @param update the boolean update value actually passed to setParticles()
  68250. */
  68251. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  68252. }
  68253. }
  68254. declare module "babylonjs/Particles/cloudPoint" {
  68255. import { Nullable } from "babylonjs/types";
  68256. import { Color4, Vector2, Vector3, Matrix, Quaternion } from "babylonjs/Maths/math";
  68257. import { Mesh } from "babylonjs/Meshes/mesh";
  68258. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  68259. import { PointsCloudSystem } from "babylonjs/Particles/pointsCloudSystem";
  68260. /**
  68261. * Represents one particle of a points cloud system.
  68262. */
  68263. export class CloudPoint {
  68264. /**
  68265. * particle global index
  68266. */
  68267. idx: number;
  68268. /**
  68269. * The color of the particle
  68270. */
  68271. color: Nullable<Color4>;
  68272. /**
  68273. * The world space position of the particle.
  68274. */
  68275. position: Vector3;
  68276. /**
  68277. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  68278. */
  68279. rotation: Vector3;
  68280. /**
  68281. * The world space rotation quaternion of the particle.
  68282. */
  68283. rotationQuaternion: Nullable<Quaternion>;
  68284. /**
  68285. * The uv of the particle.
  68286. */
  68287. uv: Nullable<Vector2>;
  68288. /**
  68289. * The current speed of the particle.
  68290. */
  68291. velocity: Vector3;
  68292. /**
  68293. * The pivot point in the particle local space.
  68294. */
  68295. pivot: Vector3;
  68296. /**
  68297. * Must the particle be translated from its pivot point in its local space ?
  68298. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  68299. * Default : false
  68300. */
  68301. translateFromPivot: boolean;
  68302. /**
  68303. * Index of this particle in the global "positions" array (Internal use)
  68304. * @hidden
  68305. */
  68306. _pos: number;
  68307. /**
  68308. * @hidden Index of this particle in the global "indices" array (Internal use)
  68309. */
  68310. _ind: number;
  68311. /**
  68312. * Group this particle belongs to
  68313. */
  68314. _group: PointsGroup;
  68315. /**
  68316. * Group id of this particle
  68317. */
  68318. groupId: number;
  68319. /**
  68320. * Index of the particle in its group id (Internal use)
  68321. */
  68322. idxInGroup: number;
  68323. /**
  68324. * @hidden Particle BoundingInfo object (Internal use)
  68325. */
  68326. _boundingInfo: BoundingInfo;
  68327. /**
  68328. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  68329. */
  68330. _pcs: PointsCloudSystem;
  68331. /**
  68332. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  68333. */
  68334. _stillInvisible: boolean;
  68335. /**
  68336. * @hidden Last computed particle rotation matrix
  68337. */
  68338. _rotationMatrix: number[];
  68339. /**
  68340. * Parent particle Id, if any.
  68341. * Default null.
  68342. */
  68343. parentId: Nullable<number>;
  68344. /**
  68345. * @hidden Internal global position in the PCS.
  68346. */
  68347. _globalPosition: Vector3;
  68348. /**
  68349. * Creates a Point Cloud object.
  68350. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  68351. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  68352. * @param group (PointsGroup) is the group the particle belongs to
  68353. * @param groupId (integer) is the group identifier in the PCS.
  68354. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  68355. * @param pcs defines the PCS it is associated to
  68356. */
  68357. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  68358. /**
  68359. * get point size
  68360. */
  68361. get size(): Vector3;
  68362. /**
  68363. * Set point size
  68364. */
  68365. set size(scale: Vector3);
  68366. /**
  68367. * Legacy support, changed quaternion to rotationQuaternion
  68368. */
  68369. get quaternion(): Nullable<Quaternion>;
  68370. /**
  68371. * Legacy support, changed quaternion to rotationQuaternion
  68372. */
  68373. set quaternion(q: Nullable<Quaternion>);
  68374. /**
  68375. * Returns a boolean. True if the particle intersects a mesh, else false
  68376. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  68377. * @param target is the object (point or mesh) what the intersection is computed against
  68378. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  68379. * @returns true if it intersects
  68380. */
  68381. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  68382. /**
  68383. * get the rotation matrix of the particle
  68384. * @hidden
  68385. */
  68386. getRotationMatrix(m: Matrix): void;
  68387. }
  68388. /**
  68389. * Represents a group of points in a points cloud system
  68390. * * PCS internal tool, don't use it manually.
  68391. */
  68392. export class PointsGroup {
  68393. /**
  68394. * The group id
  68395. * @hidden
  68396. */
  68397. groupID: number;
  68398. /**
  68399. * image data for group (internal use)
  68400. * @hidden
  68401. */
  68402. _groupImageData: Nullable<ArrayBufferView>;
  68403. /**
  68404. * Image Width (internal use)
  68405. * @hidden
  68406. */
  68407. _groupImgWidth: number;
  68408. /**
  68409. * Image Height (internal use)
  68410. * @hidden
  68411. */
  68412. _groupImgHeight: number;
  68413. /**
  68414. * Custom position function (internal use)
  68415. * @hidden
  68416. */
  68417. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  68418. /**
  68419. * density per facet for surface points
  68420. * @hidden
  68421. */
  68422. _groupDensity: number[];
  68423. /**
  68424. * Only when points are colored by texture carries pointer to texture list array
  68425. * @hidden
  68426. */
  68427. _textureNb: number;
  68428. /**
  68429. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  68430. * PCS internal tool, don't use it manually.
  68431. * @hidden
  68432. */
  68433. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  68434. }
  68435. }
  68436. declare module "babylonjs/Particles/index" {
  68437. export * from "babylonjs/Particles/baseParticleSystem";
  68438. export * from "babylonjs/Particles/EmitterTypes/index";
  68439. export * from "babylonjs/Particles/gpuParticleSystem";
  68440. export * from "babylonjs/Particles/IParticleSystem";
  68441. export * from "babylonjs/Particles/particle";
  68442. export * from "babylonjs/Particles/particleHelper";
  68443. export * from "babylonjs/Particles/particleSystem";
  68444. export * from "babylonjs/Particles/particleSystemComponent";
  68445. export * from "babylonjs/Particles/particleSystemSet";
  68446. export * from "babylonjs/Particles/solidParticle";
  68447. export * from "babylonjs/Particles/solidParticleSystem";
  68448. export * from "babylonjs/Particles/cloudPoint";
  68449. export * from "babylonjs/Particles/pointsCloudSystem";
  68450. export * from "babylonjs/Particles/subEmitter";
  68451. }
  68452. declare module "babylonjs/Physics/physicsEngineComponent" {
  68453. import { Nullable } from "babylonjs/types";
  68454. import { Observable, Observer } from "babylonjs/Misc/observable";
  68455. import { Vector3 } from "babylonjs/Maths/math.vector";
  68456. import { Mesh } from "babylonjs/Meshes/mesh";
  68457. import { ISceneComponent } from "babylonjs/sceneComponent";
  68458. import { Scene } from "babylonjs/scene";
  68459. import { Node } from "babylonjs/node";
  68460. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  68461. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  68462. module "babylonjs/scene" {
  68463. interface Scene {
  68464. /** @hidden (Backing field) */
  68465. _physicsEngine: Nullable<IPhysicsEngine>;
  68466. /** @hidden */
  68467. _physicsTimeAccumulator: number;
  68468. /**
  68469. * Gets the current physics engine
  68470. * @returns a IPhysicsEngine or null if none attached
  68471. */
  68472. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  68473. /**
  68474. * Enables physics to the current scene
  68475. * @param gravity defines the scene's gravity for the physics engine
  68476. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  68477. * @return a boolean indicating if the physics engine was initialized
  68478. */
  68479. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  68480. /**
  68481. * Disables and disposes the physics engine associated with the scene
  68482. */
  68483. disablePhysicsEngine(): void;
  68484. /**
  68485. * Gets a boolean indicating if there is an active physics engine
  68486. * @returns a boolean indicating if there is an active physics engine
  68487. */
  68488. isPhysicsEnabled(): boolean;
  68489. /**
  68490. * Deletes a physics compound impostor
  68491. * @param compound defines the compound to delete
  68492. */
  68493. deleteCompoundImpostor(compound: any): void;
  68494. /**
  68495. * An event triggered when physic simulation is about to be run
  68496. */
  68497. onBeforePhysicsObservable: Observable<Scene>;
  68498. /**
  68499. * An event triggered when physic simulation has been done
  68500. */
  68501. onAfterPhysicsObservable: Observable<Scene>;
  68502. }
  68503. }
  68504. module "babylonjs/Meshes/abstractMesh" {
  68505. interface AbstractMesh {
  68506. /** @hidden */
  68507. _physicsImpostor: Nullable<PhysicsImpostor>;
  68508. /**
  68509. * Gets or sets impostor used for physic simulation
  68510. * @see http://doc.babylonjs.com/features/physics_engine
  68511. */
  68512. physicsImpostor: Nullable<PhysicsImpostor>;
  68513. /**
  68514. * Gets the current physics impostor
  68515. * @see http://doc.babylonjs.com/features/physics_engine
  68516. * @returns a physics impostor or null
  68517. */
  68518. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  68519. /** Apply a physic impulse to the mesh
  68520. * @param force defines the force to apply
  68521. * @param contactPoint defines where to apply the force
  68522. * @returns the current mesh
  68523. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  68524. */
  68525. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  68526. /**
  68527. * Creates a physic joint between two meshes
  68528. * @param otherMesh defines the other mesh to use
  68529. * @param pivot1 defines the pivot to use on this mesh
  68530. * @param pivot2 defines the pivot to use on the other mesh
  68531. * @param options defines additional options (can be plugin dependent)
  68532. * @returns the current mesh
  68533. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  68534. */
  68535. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  68536. /** @hidden */
  68537. _disposePhysicsObserver: Nullable<Observer<Node>>;
  68538. }
  68539. }
  68540. /**
  68541. * Defines the physics engine scene component responsible to manage a physics engine
  68542. */
  68543. export class PhysicsEngineSceneComponent implements ISceneComponent {
  68544. /**
  68545. * The component name helpful to identify the component in the list of scene components.
  68546. */
  68547. readonly name: string;
  68548. /**
  68549. * The scene the component belongs to.
  68550. */
  68551. scene: Scene;
  68552. /**
  68553. * Creates a new instance of the component for the given scene
  68554. * @param scene Defines the scene to register the component in
  68555. */
  68556. constructor(scene: Scene);
  68557. /**
  68558. * Registers the component in a given scene
  68559. */
  68560. register(): void;
  68561. /**
  68562. * Rebuilds the elements related to this component in case of
  68563. * context lost for instance.
  68564. */
  68565. rebuild(): void;
  68566. /**
  68567. * Disposes the component and the associated ressources
  68568. */
  68569. dispose(): void;
  68570. }
  68571. }
  68572. declare module "babylonjs/Physics/physicsHelper" {
  68573. import { Nullable } from "babylonjs/types";
  68574. import { Vector3 } from "babylonjs/Maths/math.vector";
  68575. import { Mesh } from "babylonjs/Meshes/mesh";
  68576. import { Scene } from "babylonjs/scene";
  68577. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  68578. /**
  68579. * A helper for physics simulations
  68580. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  68581. */
  68582. export class PhysicsHelper {
  68583. private _scene;
  68584. private _physicsEngine;
  68585. /**
  68586. * Initializes the Physics helper
  68587. * @param scene Babylon.js scene
  68588. */
  68589. constructor(scene: Scene);
  68590. /**
  68591. * Applies a radial explosion impulse
  68592. * @param origin the origin of the explosion
  68593. * @param radiusOrEventOptions the radius or the options of radial explosion
  68594. * @param strength the explosion strength
  68595. * @param falloff possible options: Constant & Linear. Defaults to Constant
  68596. * @returns A physics radial explosion event, or null
  68597. */
  68598. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  68599. /**
  68600. * Applies a radial explosion force
  68601. * @param origin the origin of the explosion
  68602. * @param radiusOrEventOptions the radius or the options of radial explosion
  68603. * @param strength the explosion strength
  68604. * @param falloff possible options: Constant & Linear. Defaults to Constant
  68605. * @returns A physics radial explosion event, or null
  68606. */
  68607. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  68608. /**
  68609. * Creates a gravitational field
  68610. * @param origin the origin of the explosion
  68611. * @param radiusOrEventOptions the radius or the options of radial explosion
  68612. * @param strength the explosion strength
  68613. * @param falloff possible options: Constant & Linear. Defaults to Constant
  68614. * @returns A physics gravitational field event, or null
  68615. */
  68616. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  68617. /**
  68618. * Creates a physics updraft event
  68619. * @param origin the origin of the updraft
  68620. * @param radiusOrEventOptions the radius or the options of the updraft
  68621. * @param strength the strength of the updraft
  68622. * @param height the height of the updraft
  68623. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  68624. * @returns A physics updraft event, or null
  68625. */
  68626. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  68627. /**
  68628. * Creates a physics vortex event
  68629. * @param origin the of the vortex
  68630. * @param radiusOrEventOptions the radius or the options of the vortex
  68631. * @param strength the strength of the vortex
  68632. * @param height the height of the vortex
  68633. * @returns a Physics vortex event, or null
  68634. * A physics vortex event or null
  68635. */
  68636. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  68637. }
  68638. /**
  68639. * Represents a physics radial explosion event
  68640. */
  68641. class PhysicsRadialExplosionEvent {
  68642. private _scene;
  68643. private _options;
  68644. private _sphere;
  68645. private _dataFetched;
  68646. /**
  68647. * Initializes a radial explosioin event
  68648. * @param _scene BabylonJS scene
  68649. * @param _options The options for the vortex event
  68650. */
  68651. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  68652. /**
  68653. * Returns the data related to the radial explosion event (sphere).
  68654. * @returns The radial explosion event data
  68655. */
  68656. getData(): PhysicsRadialExplosionEventData;
  68657. /**
  68658. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  68659. * @param impostor A physics imposter
  68660. * @param origin the origin of the explosion
  68661. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  68662. */
  68663. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  68664. /**
  68665. * Triggers affecterd impostors callbacks
  68666. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  68667. */
  68668. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  68669. /**
  68670. * Disposes the sphere.
  68671. * @param force Specifies if the sphere should be disposed by force
  68672. */
  68673. dispose(force?: boolean): void;
  68674. /*** Helpers ***/
  68675. private _prepareSphere;
  68676. private _intersectsWithSphere;
  68677. }
  68678. /**
  68679. * Represents a gravitational field event
  68680. */
  68681. class PhysicsGravitationalFieldEvent {
  68682. private _physicsHelper;
  68683. private _scene;
  68684. private _origin;
  68685. private _options;
  68686. private _tickCallback;
  68687. private _sphere;
  68688. private _dataFetched;
  68689. /**
  68690. * Initializes the physics gravitational field event
  68691. * @param _physicsHelper A physics helper
  68692. * @param _scene BabylonJS scene
  68693. * @param _origin The origin position of the gravitational field event
  68694. * @param _options The options for the vortex event
  68695. */
  68696. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  68697. /**
  68698. * Returns the data related to the gravitational field event (sphere).
  68699. * @returns A gravitational field event
  68700. */
  68701. getData(): PhysicsGravitationalFieldEventData;
  68702. /**
  68703. * Enables the gravitational field.
  68704. */
  68705. enable(): void;
  68706. /**
  68707. * Disables the gravitational field.
  68708. */
  68709. disable(): void;
  68710. /**
  68711. * Disposes the sphere.
  68712. * @param force The force to dispose from the gravitational field event
  68713. */
  68714. dispose(force?: boolean): void;
  68715. private _tick;
  68716. }
  68717. /**
  68718. * Represents a physics updraft event
  68719. */
  68720. class PhysicsUpdraftEvent {
  68721. private _scene;
  68722. private _origin;
  68723. private _options;
  68724. private _physicsEngine;
  68725. private _originTop;
  68726. private _originDirection;
  68727. private _tickCallback;
  68728. private _cylinder;
  68729. private _cylinderPosition;
  68730. private _dataFetched;
  68731. /**
  68732. * Initializes the physics updraft event
  68733. * @param _scene BabylonJS scene
  68734. * @param _origin The origin position of the updraft
  68735. * @param _options The options for the updraft event
  68736. */
  68737. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  68738. /**
  68739. * Returns the data related to the updraft event (cylinder).
  68740. * @returns A physics updraft event
  68741. */
  68742. getData(): PhysicsUpdraftEventData;
  68743. /**
  68744. * Enables the updraft.
  68745. */
  68746. enable(): void;
  68747. /**
  68748. * Disables the updraft.
  68749. */
  68750. disable(): void;
  68751. /**
  68752. * Disposes the cylinder.
  68753. * @param force Specifies if the updraft should be disposed by force
  68754. */
  68755. dispose(force?: boolean): void;
  68756. private getImpostorHitData;
  68757. private _tick;
  68758. /*** Helpers ***/
  68759. private _prepareCylinder;
  68760. private _intersectsWithCylinder;
  68761. }
  68762. /**
  68763. * Represents a physics vortex event
  68764. */
  68765. class PhysicsVortexEvent {
  68766. private _scene;
  68767. private _origin;
  68768. private _options;
  68769. private _physicsEngine;
  68770. private _originTop;
  68771. private _tickCallback;
  68772. private _cylinder;
  68773. private _cylinderPosition;
  68774. private _dataFetched;
  68775. /**
  68776. * Initializes the physics vortex event
  68777. * @param _scene The BabylonJS scene
  68778. * @param _origin The origin position of the vortex
  68779. * @param _options The options for the vortex event
  68780. */
  68781. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  68782. /**
  68783. * Returns the data related to the vortex event (cylinder).
  68784. * @returns The physics vortex event data
  68785. */
  68786. getData(): PhysicsVortexEventData;
  68787. /**
  68788. * Enables the vortex.
  68789. */
  68790. enable(): void;
  68791. /**
  68792. * Disables the cortex.
  68793. */
  68794. disable(): void;
  68795. /**
  68796. * Disposes the sphere.
  68797. * @param force
  68798. */
  68799. dispose(force?: boolean): void;
  68800. private getImpostorHitData;
  68801. private _tick;
  68802. /*** Helpers ***/
  68803. private _prepareCylinder;
  68804. private _intersectsWithCylinder;
  68805. }
  68806. /**
  68807. * Options fot the radial explosion event
  68808. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  68809. */
  68810. export class PhysicsRadialExplosionEventOptions {
  68811. /**
  68812. * The radius of the sphere for the radial explosion.
  68813. */
  68814. radius: number;
  68815. /**
  68816. * The strenth of the explosion.
  68817. */
  68818. strength: number;
  68819. /**
  68820. * The strenght of the force in correspondence to the distance of the affected object
  68821. */
  68822. falloff: PhysicsRadialImpulseFalloff;
  68823. /**
  68824. * Sphere options for the radial explosion.
  68825. */
  68826. sphere: {
  68827. segments: number;
  68828. diameter: number;
  68829. };
  68830. /**
  68831. * Sphere options for the radial explosion.
  68832. */
  68833. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  68834. }
  68835. /**
  68836. * Options fot the updraft event
  68837. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  68838. */
  68839. export class PhysicsUpdraftEventOptions {
  68840. /**
  68841. * The radius of the cylinder for the vortex
  68842. */
  68843. radius: number;
  68844. /**
  68845. * The strenth of the updraft.
  68846. */
  68847. strength: number;
  68848. /**
  68849. * The height of the cylinder for the updraft.
  68850. */
  68851. height: number;
  68852. /**
  68853. * The mode for the the updraft.
  68854. */
  68855. updraftMode: PhysicsUpdraftMode;
  68856. }
  68857. /**
  68858. * Options fot the vortex event
  68859. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  68860. */
  68861. export class PhysicsVortexEventOptions {
  68862. /**
  68863. * The radius of the cylinder for the vortex
  68864. */
  68865. radius: number;
  68866. /**
  68867. * The strenth of the vortex.
  68868. */
  68869. strength: number;
  68870. /**
  68871. * The height of the cylinder for the vortex.
  68872. */
  68873. height: number;
  68874. /**
  68875. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  68876. */
  68877. centripetalForceThreshold: number;
  68878. /**
  68879. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  68880. */
  68881. centripetalForceMultiplier: number;
  68882. /**
  68883. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  68884. */
  68885. centrifugalForceMultiplier: number;
  68886. /**
  68887. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  68888. */
  68889. updraftForceMultiplier: number;
  68890. }
  68891. /**
  68892. * The strenght of the force in correspondence to the distance of the affected object
  68893. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  68894. */
  68895. export enum PhysicsRadialImpulseFalloff {
  68896. /** Defines that impulse is constant in strength across it's whole radius */
  68897. Constant = 0,
  68898. /** Defines that impulse gets weaker if it's further from the origin */
  68899. Linear = 1
  68900. }
  68901. /**
  68902. * The strength of the force in correspondence to the distance of the affected object
  68903. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  68904. */
  68905. export enum PhysicsUpdraftMode {
  68906. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  68907. Center = 0,
  68908. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  68909. Perpendicular = 1
  68910. }
  68911. /**
  68912. * Interface for a physics hit data
  68913. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  68914. */
  68915. export interface PhysicsHitData {
  68916. /**
  68917. * The force applied at the contact point
  68918. */
  68919. force: Vector3;
  68920. /**
  68921. * The contact point
  68922. */
  68923. contactPoint: Vector3;
  68924. /**
  68925. * The distance from the origin to the contact point
  68926. */
  68927. distanceFromOrigin: number;
  68928. }
  68929. /**
  68930. * Interface for radial explosion event data
  68931. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  68932. */
  68933. export interface PhysicsRadialExplosionEventData {
  68934. /**
  68935. * A sphere used for the radial explosion event
  68936. */
  68937. sphere: Mesh;
  68938. }
  68939. /**
  68940. * Interface for gravitational field event data
  68941. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  68942. */
  68943. export interface PhysicsGravitationalFieldEventData {
  68944. /**
  68945. * A sphere mesh used for the gravitational field event
  68946. */
  68947. sphere: Mesh;
  68948. }
  68949. /**
  68950. * Interface for updraft event data
  68951. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  68952. */
  68953. export interface PhysicsUpdraftEventData {
  68954. /**
  68955. * A cylinder used for the updraft event
  68956. */
  68957. cylinder: Mesh;
  68958. }
  68959. /**
  68960. * Interface for vortex event data
  68961. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  68962. */
  68963. export interface PhysicsVortexEventData {
  68964. /**
  68965. * A cylinder used for the vortex event
  68966. */
  68967. cylinder: Mesh;
  68968. }
  68969. /**
  68970. * Interface for an affected physics impostor
  68971. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  68972. */
  68973. export interface PhysicsAffectedImpostorWithData {
  68974. /**
  68975. * The impostor affected by the effect
  68976. */
  68977. impostor: PhysicsImpostor;
  68978. /**
  68979. * The data about the hit/horce from the explosion
  68980. */
  68981. hitData: PhysicsHitData;
  68982. }
  68983. }
  68984. declare module "babylonjs/Physics/Plugins/index" {
  68985. export * from "babylonjs/Physics/Plugins/cannonJSPlugin";
  68986. export * from "babylonjs/Physics/Plugins/ammoJSPlugin";
  68987. export * from "babylonjs/Physics/Plugins/oimoJSPlugin";
  68988. }
  68989. declare module "babylonjs/Physics/index" {
  68990. export * from "babylonjs/Physics/IPhysicsEngine";
  68991. export * from "babylonjs/Physics/physicsEngine";
  68992. export * from "babylonjs/Physics/physicsEngineComponent";
  68993. export * from "babylonjs/Physics/physicsHelper";
  68994. export * from "babylonjs/Physics/physicsImpostor";
  68995. export * from "babylonjs/Physics/physicsJoint";
  68996. export * from "babylonjs/Physics/Plugins/index";
  68997. }
  68998. declare module "babylonjs/Shaders/blackAndWhite.fragment" {
  68999. /** @hidden */
  69000. export var blackAndWhitePixelShader: {
  69001. name: string;
  69002. shader: string;
  69003. };
  69004. }
  69005. declare module "babylonjs/PostProcesses/blackAndWhitePostProcess" {
  69006. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  69007. import { Camera } from "babylonjs/Cameras/camera";
  69008. import { Engine } from "babylonjs/Engines/engine";
  69009. import "babylonjs/Shaders/blackAndWhite.fragment";
  69010. /**
  69011. * Post process used to render in black and white
  69012. */
  69013. export class BlackAndWhitePostProcess extends PostProcess {
  69014. /**
  69015. * Linear about to convert he result to black and white (default: 1)
  69016. */
  69017. degree: number;
  69018. /**
  69019. * Creates a black and white post process
  69020. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  69021. * @param name The name of the effect.
  69022. * @param options The required width/height ratio to downsize to before computing the render pass.
  69023. * @param camera The camera to apply the render pass to.
  69024. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69025. * @param engine The engine which the post process will be applied. (default: current engine)
  69026. * @param reusable If the post process can be reused on the same frame. (default: false)
  69027. */
  69028. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  69029. }
  69030. }
  69031. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect" {
  69032. import { Nullable } from "babylonjs/types";
  69033. import { Camera } from "babylonjs/Cameras/camera";
  69034. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  69035. import { Engine } from "babylonjs/Engines/engine";
  69036. /**
  69037. * This represents a set of one or more post processes in Babylon.
  69038. * A post process can be used to apply a shader to a texture after it is rendered.
  69039. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  69040. */
  69041. export class PostProcessRenderEffect {
  69042. private _postProcesses;
  69043. private _getPostProcesses;
  69044. private _singleInstance;
  69045. private _cameras;
  69046. private _indicesForCamera;
  69047. /**
  69048. * Name of the effect
  69049. * @hidden
  69050. */
  69051. _name: string;
  69052. /**
  69053. * Instantiates a post process render effect.
  69054. * A post process can be used to apply a shader to a texture after it is rendered.
  69055. * @param engine The engine the effect is tied to
  69056. * @param name The name of the effect
  69057. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  69058. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  69059. */
  69060. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  69061. /**
  69062. * Checks if all the post processes in the effect are supported.
  69063. */
  69064. get isSupported(): boolean;
  69065. /**
  69066. * Updates the current state of the effect
  69067. * @hidden
  69068. */
  69069. _update(): void;
  69070. /**
  69071. * Attaches the effect on cameras
  69072. * @param cameras The camera to attach to.
  69073. * @hidden
  69074. */
  69075. _attachCameras(cameras: Camera): void;
  69076. /**
  69077. * Attaches the effect on cameras
  69078. * @param cameras The camera to attach to.
  69079. * @hidden
  69080. */
  69081. _attachCameras(cameras: Camera[]): void;
  69082. /**
  69083. * Detaches the effect on cameras
  69084. * @param cameras The camera to detatch from.
  69085. * @hidden
  69086. */
  69087. _detachCameras(cameras: Camera): void;
  69088. /**
  69089. * Detatches the effect on cameras
  69090. * @param cameras The camera to detatch from.
  69091. * @hidden
  69092. */
  69093. _detachCameras(cameras: Camera[]): void;
  69094. /**
  69095. * Enables the effect on given cameras
  69096. * @param cameras The camera to enable.
  69097. * @hidden
  69098. */
  69099. _enable(cameras: Camera): void;
  69100. /**
  69101. * Enables the effect on given cameras
  69102. * @param cameras The camera to enable.
  69103. * @hidden
  69104. */
  69105. _enable(cameras: Nullable<Camera[]>): void;
  69106. /**
  69107. * Disables the effect on the given cameras
  69108. * @param cameras The camera to disable.
  69109. * @hidden
  69110. */
  69111. _disable(cameras: Camera): void;
  69112. /**
  69113. * Disables the effect on the given cameras
  69114. * @param cameras The camera to disable.
  69115. * @hidden
  69116. */
  69117. _disable(cameras: Nullable<Camera[]>): void;
  69118. /**
  69119. * Gets a list of the post processes contained in the effect.
  69120. * @param camera The camera to get the post processes on.
  69121. * @returns The list of the post processes in the effect.
  69122. */
  69123. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  69124. }
  69125. }
  69126. declare module "babylonjs/Shaders/extractHighlights.fragment" {
  69127. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  69128. /** @hidden */
  69129. export var extractHighlightsPixelShader: {
  69130. name: string;
  69131. shader: string;
  69132. };
  69133. }
  69134. declare module "babylonjs/PostProcesses/extractHighlightsPostProcess" {
  69135. import { Nullable } from "babylonjs/types";
  69136. import { Camera } from "babylonjs/Cameras/camera";
  69137. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  69138. import { Engine } from "babylonjs/Engines/engine";
  69139. import "babylonjs/Shaders/extractHighlights.fragment";
  69140. /**
  69141. * 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.
  69142. */
  69143. export class ExtractHighlightsPostProcess extends PostProcess {
  69144. /**
  69145. * The luminance threshold, pixels below this value will be set to black.
  69146. */
  69147. threshold: number;
  69148. /** @hidden */
  69149. _exposure: number;
  69150. /**
  69151. * Post process which has the input texture to be used when performing highlight extraction
  69152. * @hidden
  69153. */
  69154. _inputPostProcess: Nullable<PostProcess>;
  69155. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  69156. }
  69157. }
  69158. declare module "babylonjs/Shaders/bloomMerge.fragment" {
  69159. /** @hidden */
  69160. export var bloomMergePixelShader: {
  69161. name: string;
  69162. shader: string;
  69163. };
  69164. }
  69165. declare module "babylonjs/PostProcesses/bloomMergePostProcess" {
  69166. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  69167. import { Nullable } from "babylonjs/types";
  69168. import { Engine } from "babylonjs/Engines/engine";
  69169. import { Camera } from "babylonjs/Cameras/camera";
  69170. import "babylonjs/Shaders/bloomMerge.fragment";
  69171. /**
  69172. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  69173. */
  69174. export class BloomMergePostProcess extends PostProcess {
  69175. /** Weight of the bloom to be added to the original input. */
  69176. weight: number;
  69177. /**
  69178. * Creates a new instance of @see BloomMergePostProcess
  69179. * @param name The name of the effect.
  69180. * @param originalFromInput Post process which's input will be used for the merge.
  69181. * @param blurred Blurred highlights post process which's output will be used.
  69182. * @param weight Weight of the bloom to be added to the original input.
  69183. * @param options The required width/height ratio to downsize to before computing the render pass.
  69184. * @param camera The camera to apply the render pass to.
  69185. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69186. * @param engine The engine which the post process will be applied. (default: current engine)
  69187. * @param reusable If the post process can be reused on the same frame. (default: false)
  69188. * @param textureType Type of textures used when performing the post process. (default: 0)
  69189. * @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)
  69190. */
  69191. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  69192. /** Weight of the bloom to be added to the original input. */
  69193. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  69194. }
  69195. }
  69196. declare module "babylonjs/PostProcesses/bloomEffect" {
  69197. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  69198. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  69199. import { ExtractHighlightsPostProcess } from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  69200. import { Camera } from "babylonjs/Cameras/camera";
  69201. import { Scene } from "babylonjs/scene";
  69202. /**
  69203. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  69204. */
  69205. export class BloomEffect extends PostProcessRenderEffect {
  69206. private bloomScale;
  69207. /**
  69208. * @hidden Internal
  69209. */
  69210. _effects: Array<PostProcess>;
  69211. /**
  69212. * @hidden Internal
  69213. */
  69214. _downscale: ExtractHighlightsPostProcess;
  69215. private _blurX;
  69216. private _blurY;
  69217. private _merge;
  69218. /**
  69219. * The luminance threshold to find bright areas of the image to bloom.
  69220. */
  69221. get threshold(): number;
  69222. set threshold(value: number);
  69223. /**
  69224. * The strength of the bloom.
  69225. */
  69226. get weight(): number;
  69227. set weight(value: number);
  69228. /**
  69229. * Specifies the size of the bloom blur kernel, relative to the final output size
  69230. */
  69231. get kernel(): number;
  69232. set kernel(value: number);
  69233. /**
  69234. * Creates a new instance of @see BloomEffect
  69235. * @param scene The scene the effect belongs to.
  69236. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  69237. * @param bloomKernel The size of the kernel to be used when applying the blur.
  69238. * @param bloomWeight The the strength of bloom.
  69239. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  69240. * @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)
  69241. */
  69242. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  69243. /**
  69244. * Disposes each of the internal effects for a given camera.
  69245. * @param camera The camera to dispose the effect on.
  69246. */
  69247. disposeEffects(camera: Camera): void;
  69248. /**
  69249. * @hidden Internal
  69250. */
  69251. _updateEffects(): void;
  69252. /**
  69253. * Internal
  69254. * @returns if all the contained post processes are ready.
  69255. * @hidden
  69256. */
  69257. _isReady(): boolean;
  69258. }
  69259. }
  69260. declare module "babylonjs/Shaders/chromaticAberration.fragment" {
  69261. /** @hidden */
  69262. export var chromaticAberrationPixelShader: {
  69263. name: string;
  69264. shader: string;
  69265. };
  69266. }
  69267. declare module "babylonjs/PostProcesses/chromaticAberrationPostProcess" {
  69268. import { Vector2 } from "babylonjs/Maths/math.vector";
  69269. import { Nullable } from "babylonjs/types";
  69270. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  69271. import { Camera } from "babylonjs/Cameras/camera";
  69272. import { Engine } from "babylonjs/Engines/engine";
  69273. import "babylonjs/Shaders/chromaticAberration.fragment";
  69274. /**
  69275. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  69276. */
  69277. export class ChromaticAberrationPostProcess extends PostProcess {
  69278. /**
  69279. * The amount of seperation of rgb channels (default: 30)
  69280. */
  69281. aberrationAmount: number;
  69282. /**
  69283. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  69284. */
  69285. radialIntensity: number;
  69286. /**
  69287. * 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))
  69288. */
  69289. direction: Vector2;
  69290. /**
  69291. * 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))
  69292. */
  69293. centerPosition: Vector2;
  69294. /**
  69295. * Creates a new instance ChromaticAberrationPostProcess
  69296. * @param name The name of the effect.
  69297. * @param screenWidth The width of the screen to apply the effect on.
  69298. * @param screenHeight The height of the screen to apply the effect on.
  69299. * @param options The required width/height ratio to downsize to before computing the render pass.
  69300. * @param camera The camera to apply the render pass to.
  69301. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69302. * @param engine The engine which the post process will be applied. (default: current engine)
  69303. * @param reusable If the post process can be reused on the same frame. (default: false)
  69304. * @param textureType Type of textures used when performing the post process. (default: 0)
  69305. * @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)
  69306. */
  69307. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  69308. }
  69309. }
  69310. declare module "babylonjs/Shaders/circleOfConfusion.fragment" {
  69311. /** @hidden */
  69312. export var circleOfConfusionPixelShader: {
  69313. name: string;
  69314. shader: string;
  69315. };
  69316. }
  69317. declare module "babylonjs/PostProcesses/circleOfConfusionPostProcess" {
  69318. import { Nullable } from "babylonjs/types";
  69319. import { Engine } from "babylonjs/Engines/engine";
  69320. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  69321. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  69322. import { Camera } from "babylonjs/Cameras/camera";
  69323. import "babylonjs/Shaders/circleOfConfusion.fragment";
  69324. /**
  69325. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  69326. */
  69327. export class CircleOfConfusionPostProcess extends PostProcess {
  69328. /**
  69329. * 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.
  69330. */
  69331. lensSize: number;
  69332. /**
  69333. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  69334. */
  69335. fStop: number;
  69336. /**
  69337. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  69338. */
  69339. focusDistance: number;
  69340. /**
  69341. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  69342. */
  69343. focalLength: number;
  69344. private _depthTexture;
  69345. /**
  69346. * Creates a new instance CircleOfConfusionPostProcess
  69347. * @param name The name of the effect.
  69348. * @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.
  69349. * @param options The required width/height ratio to downsize to before computing the render pass.
  69350. * @param camera The camera to apply the render pass to.
  69351. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69352. * @param engine The engine which the post process will be applied. (default: current engine)
  69353. * @param reusable If the post process can be reused on the same frame. (default: false)
  69354. * @param textureType Type of textures used when performing the post process. (default: 0)
  69355. * @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)
  69356. */
  69357. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  69358. /**
  69359. * 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.
  69360. */
  69361. set depthTexture(value: RenderTargetTexture);
  69362. }
  69363. }
  69364. declare module "babylonjs/Shaders/colorCorrection.fragment" {
  69365. /** @hidden */
  69366. export var colorCorrectionPixelShader: {
  69367. name: string;
  69368. shader: string;
  69369. };
  69370. }
  69371. declare module "babylonjs/PostProcesses/colorCorrectionPostProcess" {
  69372. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  69373. import { Engine } from "babylonjs/Engines/engine";
  69374. import { Camera } from "babylonjs/Cameras/camera";
  69375. import "babylonjs/Shaders/colorCorrection.fragment";
  69376. /**
  69377. *
  69378. * This post-process allows the modification of rendered colors by using
  69379. * a 'look-up table' (LUT). This effect is also called Color Grading.
  69380. *
  69381. * The object needs to be provided an url to a texture containing the color
  69382. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  69383. * Use an image editing software to tweak the LUT to match your needs.
  69384. *
  69385. * For an example of a color LUT, see here:
  69386. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  69387. * For explanations on color grading, see here:
  69388. * @see http://udn.epicgames.com/Three/ColorGrading.html
  69389. *
  69390. */
  69391. export class ColorCorrectionPostProcess extends PostProcess {
  69392. private _colorTableTexture;
  69393. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  69394. }
  69395. }
  69396. declare module "babylonjs/Shaders/convolution.fragment" {
  69397. /** @hidden */
  69398. export var convolutionPixelShader: {
  69399. name: string;
  69400. shader: string;
  69401. };
  69402. }
  69403. declare module "babylonjs/PostProcesses/convolutionPostProcess" {
  69404. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  69405. import { Nullable } from "babylonjs/types";
  69406. import { Camera } from "babylonjs/Cameras/camera";
  69407. import { Engine } from "babylonjs/Engines/engine";
  69408. import "babylonjs/Shaders/convolution.fragment";
  69409. /**
  69410. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  69411. * input texture to perform effects such as edge detection or sharpening
  69412. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  69413. */
  69414. export class ConvolutionPostProcess extends PostProcess {
  69415. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  69416. kernel: number[];
  69417. /**
  69418. * Creates a new instance ConvolutionPostProcess
  69419. * @param name The name of the effect.
  69420. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  69421. * @param options The required width/height ratio to downsize to before computing the render pass.
  69422. * @param camera The camera to apply the render pass to.
  69423. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69424. * @param engine The engine which the post process will be applied. (default: current engine)
  69425. * @param reusable If the post process can be reused on the same frame. (default: false)
  69426. * @param textureType Type of textures used when performing the post process. (default: 0)
  69427. */
  69428. constructor(name: string,
  69429. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  69430. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  69431. /**
  69432. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  69433. */
  69434. static EdgeDetect0Kernel: number[];
  69435. /**
  69436. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  69437. */
  69438. static EdgeDetect1Kernel: number[];
  69439. /**
  69440. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  69441. */
  69442. static EdgeDetect2Kernel: number[];
  69443. /**
  69444. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  69445. */
  69446. static SharpenKernel: number[];
  69447. /**
  69448. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  69449. */
  69450. static EmbossKernel: number[];
  69451. /**
  69452. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  69453. */
  69454. static GaussianKernel: number[];
  69455. }
  69456. }
  69457. declare module "babylonjs/PostProcesses/depthOfFieldBlurPostProcess" {
  69458. import { Nullable } from "babylonjs/types";
  69459. import { Vector2 } from "babylonjs/Maths/math.vector";
  69460. import { Camera } from "babylonjs/Cameras/camera";
  69461. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  69462. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  69463. import { Engine } from "babylonjs/Engines/engine";
  69464. import { Scene } from "babylonjs/scene";
  69465. /**
  69466. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  69467. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  69468. * based on samples that have a large difference in distance than the center pixel.
  69469. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  69470. */
  69471. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  69472. direction: Vector2;
  69473. /**
  69474. * Creates a new instance CircleOfConfusionPostProcess
  69475. * @param name The name of the effect.
  69476. * @param scene The scene the effect belongs to.
  69477. * @param direction The direction the blur should be applied.
  69478. * @param kernel The size of the kernel used to blur.
  69479. * @param options The required width/height ratio to downsize to before computing the render pass.
  69480. * @param camera The camera to apply the render pass to.
  69481. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  69482. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  69483. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69484. * @param engine The engine which the post process will be applied. (default: current engine)
  69485. * @param reusable If the post process can be reused on the same frame. (default: false)
  69486. * @param textureType Type of textures used when performing the post process. (default: 0)
  69487. * @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)
  69488. */
  69489. 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);
  69490. }
  69491. }
  69492. declare module "babylonjs/Shaders/depthOfFieldMerge.fragment" {
  69493. /** @hidden */
  69494. export var depthOfFieldMergePixelShader: {
  69495. name: string;
  69496. shader: string;
  69497. };
  69498. }
  69499. declare module "babylonjs/PostProcesses/depthOfFieldMergePostProcess" {
  69500. import { Nullable } from "babylonjs/types";
  69501. import { Camera } from "babylonjs/Cameras/camera";
  69502. import { Effect } from "babylonjs/Materials/effect";
  69503. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  69504. import { Engine } from "babylonjs/Engines/engine";
  69505. import "babylonjs/Shaders/depthOfFieldMerge.fragment";
  69506. /**
  69507. * Options to be set when merging outputs from the default pipeline.
  69508. */
  69509. export class DepthOfFieldMergePostProcessOptions {
  69510. /**
  69511. * The original image to merge on top of
  69512. */
  69513. originalFromInput: PostProcess;
  69514. /**
  69515. * Parameters to perform the merge of the depth of field effect
  69516. */
  69517. depthOfField?: {
  69518. circleOfConfusion: PostProcess;
  69519. blurSteps: Array<PostProcess>;
  69520. };
  69521. /**
  69522. * Parameters to perform the merge of bloom effect
  69523. */
  69524. bloom?: {
  69525. blurred: PostProcess;
  69526. weight: number;
  69527. };
  69528. }
  69529. /**
  69530. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  69531. */
  69532. export class DepthOfFieldMergePostProcess extends PostProcess {
  69533. private blurSteps;
  69534. /**
  69535. * Creates a new instance of DepthOfFieldMergePostProcess
  69536. * @param name The name of the effect.
  69537. * @param originalFromInput Post process which's input will be used for the merge.
  69538. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  69539. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  69540. * @param options The required width/height ratio to downsize to before computing the render pass.
  69541. * @param camera The camera to apply the render pass to.
  69542. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69543. * @param engine The engine which the post process will be applied. (default: current engine)
  69544. * @param reusable If the post process can be reused on the same frame. (default: false)
  69545. * @param textureType Type of textures used when performing the post process. (default: 0)
  69546. * @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)
  69547. */
  69548. 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);
  69549. /**
  69550. * Updates the effect with the current post process compile time values and recompiles the shader.
  69551. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  69552. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  69553. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  69554. * @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
  69555. * @param onCompiled Called when the shader has been compiled.
  69556. * @param onError Called if there is an error when compiling a shader.
  69557. */
  69558. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  69559. }
  69560. }
  69561. declare module "babylonjs/PostProcesses/depthOfFieldEffect" {
  69562. import { Nullable } from "babylonjs/types";
  69563. import { Camera } from "babylonjs/Cameras/camera";
  69564. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  69565. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  69566. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  69567. import { DepthOfFieldBlurPostProcess } from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  69568. import { Scene } from "babylonjs/scene";
  69569. /**
  69570. * Specifies the level of max blur that should be applied when using the depth of field effect
  69571. */
  69572. export enum DepthOfFieldEffectBlurLevel {
  69573. /**
  69574. * Subtle blur
  69575. */
  69576. Low = 0,
  69577. /**
  69578. * Medium blur
  69579. */
  69580. Medium = 1,
  69581. /**
  69582. * Large blur
  69583. */
  69584. High = 2
  69585. }
  69586. /**
  69587. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  69588. */
  69589. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  69590. private _circleOfConfusion;
  69591. /**
  69592. * @hidden Internal, blurs from high to low
  69593. */
  69594. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  69595. private _depthOfFieldBlurY;
  69596. private _dofMerge;
  69597. /**
  69598. * @hidden Internal post processes in depth of field effect
  69599. */
  69600. _effects: Array<PostProcess>;
  69601. /**
  69602. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  69603. */
  69604. set focalLength(value: number);
  69605. get focalLength(): number;
  69606. /**
  69607. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  69608. */
  69609. set fStop(value: number);
  69610. get fStop(): number;
  69611. /**
  69612. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  69613. */
  69614. set focusDistance(value: number);
  69615. get focusDistance(): number;
  69616. /**
  69617. * 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.
  69618. */
  69619. set lensSize(value: number);
  69620. get lensSize(): number;
  69621. /**
  69622. * Creates a new instance DepthOfFieldEffect
  69623. * @param scene The scene the effect belongs to.
  69624. * @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.
  69625. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  69626. * @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)
  69627. */
  69628. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  69629. /**
  69630. * Get the current class name of the current effet
  69631. * @returns "DepthOfFieldEffect"
  69632. */
  69633. getClassName(): string;
  69634. /**
  69635. * 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.
  69636. */
  69637. set depthTexture(value: RenderTargetTexture);
  69638. /**
  69639. * Disposes each of the internal effects for a given camera.
  69640. * @param camera The camera to dispose the effect on.
  69641. */
  69642. disposeEffects(camera: Camera): void;
  69643. /**
  69644. * @hidden Internal
  69645. */
  69646. _updateEffects(): void;
  69647. /**
  69648. * Internal
  69649. * @returns if all the contained post processes are ready.
  69650. * @hidden
  69651. */
  69652. _isReady(): boolean;
  69653. }
  69654. }
  69655. declare module "babylonjs/Shaders/displayPass.fragment" {
  69656. /** @hidden */
  69657. export var displayPassPixelShader: {
  69658. name: string;
  69659. shader: string;
  69660. };
  69661. }
  69662. declare module "babylonjs/PostProcesses/displayPassPostProcess" {
  69663. import { Nullable } from "babylonjs/types";
  69664. import { Camera } from "babylonjs/Cameras/camera";
  69665. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  69666. import { Engine } from "babylonjs/Engines/engine";
  69667. import "babylonjs/Shaders/displayPass.fragment";
  69668. /**
  69669. * DisplayPassPostProcess which produces an output the same as it's input
  69670. */
  69671. export class DisplayPassPostProcess extends PostProcess {
  69672. /**
  69673. * Creates the DisplayPassPostProcess
  69674. * @param name The name of the effect.
  69675. * @param options The required width/height ratio to downsize to before computing the render pass.
  69676. * @param camera The camera to apply the render pass to.
  69677. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69678. * @param engine The engine which the post process will be applied. (default: current engine)
  69679. * @param reusable If the post process can be reused on the same frame. (default: false)
  69680. */
  69681. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  69682. }
  69683. }
  69684. declare module "babylonjs/Shaders/filter.fragment" {
  69685. /** @hidden */
  69686. export var filterPixelShader: {
  69687. name: string;
  69688. shader: string;
  69689. };
  69690. }
  69691. declare module "babylonjs/PostProcesses/filterPostProcess" {
  69692. import { Nullable } from "babylonjs/types";
  69693. import { Matrix } from "babylonjs/Maths/math.vector";
  69694. import { Camera } from "babylonjs/Cameras/camera";
  69695. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  69696. import { Engine } from "babylonjs/Engines/engine";
  69697. import "babylonjs/Shaders/filter.fragment";
  69698. /**
  69699. * Applies a kernel filter to the image
  69700. */
  69701. export class FilterPostProcess extends PostProcess {
  69702. /** The matrix to be applied to the image */
  69703. kernelMatrix: Matrix;
  69704. /**
  69705. *
  69706. * @param name The name of the effect.
  69707. * @param kernelMatrix The matrix to be applied to the image
  69708. * @param options The required width/height ratio to downsize to before computing the render pass.
  69709. * @param camera The camera to apply the render pass to.
  69710. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69711. * @param engine The engine which the post process will be applied. (default: current engine)
  69712. * @param reusable If the post process can be reused on the same frame. (default: false)
  69713. */
  69714. constructor(name: string,
  69715. /** The matrix to be applied to the image */
  69716. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  69717. }
  69718. }
  69719. declare module "babylonjs/Shaders/fxaa.fragment" {
  69720. /** @hidden */
  69721. export var fxaaPixelShader: {
  69722. name: string;
  69723. shader: string;
  69724. };
  69725. }
  69726. declare module "babylonjs/Shaders/fxaa.vertex" {
  69727. /** @hidden */
  69728. export var fxaaVertexShader: {
  69729. name: string;
  69730. shader: string;
  69731. };
  69732. }
  69733. declare module "babylonjs/PostProcesses/fxaaPostProcess" {
  69734. import { Nullable } from "babylonjs/types";
  69735. import { Camera } from "babylonjs/Cameras/camera";
  69736. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  69737. import { Engine } from "babylonjs/Engines/engine";
  69738. import "babylonjs/Shaders/fxaa.fragment";
  69739. import "babylonjs/Shaders/fxaa.vertex";
  69740. /**
  69741. * Fxaa post process
  69742. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  69743. */
  69744. export class FxaaPostProcess extends PostProcess {
  69745. /** @hidden */
  69746. texelWidth: number;
  69747. /** @hidden */
  69748. texelHeight: number;
  69749. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  69750. private _getDefines;
  69751. }
  69752. }
  69753. declare module "babylonjs/Shaders/grain.fragment" {
  69754. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  69755. /** @hidden */
  69756. export var grainPixelShader: {
  69757. name: string;
  69758. shader: string;
  69759. };
  69760. }
  69761. declare module "babylonjs/PostProcesses/grainPostProcess" {
  69762. import { Nullable } from "babylonjs/types";
  69763. import { Camera } from "babylonjs/Cameras/camera";
  69764. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  69765. import { Engine } from "babylonjs/Engines/engine";
  69766. import "babylonjs/Shaders/grain.fragment";
  69767. /**
  69768. * The GrainPostProcess adds noise to the image at mid luminance levels
  69769. */
  69770. export class GrainPostProcess extends PostProcess {
  69771. /**
  69772. * The intensity of the grain added (default: 30)
  69773. */
  69774. intensity: number;
  69775. /**
  69776. * If the grain should be randomized on every frame
  69777. */
  69778. animated: boolean;
  69779. /**
  69780. * Creates a new instance of @see GrainPostProcess
  69781. * @param name The name of the effect.
  69782. * @param options The required width/height ratio to downsize to before computing the render pass.
  69783. * @param camera The camera to apply the render pass to.
  69784. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69785. * @param engine The engine which the post process will be applied. (default: current engine)
  69786. * @param reusable If the post process can be reused on the same frame. (default: false)
  69787. * @param textureType Type of textures used when performing the post process. (default: 0)
  69788. * @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)
  69789. */
  69790. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  69791. }
  69792. }
  69793. declare module "babylonjs/Shaders/highlights.fragment" {
  69794. /** @hidden */
  69795. export var highlightsPixelShader: {
  69796. name: string;
  69797. shader: string;
  69798. };
  69799. }
  69800. declare module "babylonjs/PostProcesses/highlightsPostProcess" {
  69801. import { Nullable } from "babylonjs/types";
  69802. import { Camera } from "babylonjs/Cameras/camera";
  69803. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  69804. import { Engine } from "babylonjs/Engines/engine";
  69805. import "babylonjs/Shaders/highlights.fragment";
  69806. /**
  69807. * Extracts highlights from the image
  69808. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  69809. */
  69810. export class HighlightsPostProcess extends PostProcess {
  69811. /**
  69812. * Extracts highlights from the image
  69813. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  69814. * @param name The name of the effect.
  69815. * @param options The required width/height ratio to downsize to before computing the render pass.
  69816. * @param camera The camera to apply the render pass to.
  69817. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69818. * @param engine The engine which the post process will be applied. (default: current engine)
  69819. * @param reusable If the post process can be reused on the same frame. (default: false)
  69820. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  69821. */
  69822. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  69823. }
  69824. }
  69825. declare module "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration" {
  69826. /** @hidden */
  69827. export var mrtFragmentDeclaration: {
  69828. name: string;
  69829. shader: string;
  69830. };
  69831. }
  69832. declare module "babylonjs/Shaders/geometry.fragment" {
  69833. import "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration";
  69834. import "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions";
  69835. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  69836. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  69837. /** @hidden */
  69838. export var geometryPixelShader: {
  69839. name: string;
  69840. shader: string;
  69841. };
  69842. }
  69843. declare module "babylonjs/Shaders/geometry.vertex" {
  69844. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  69845. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  69846. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  69847. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  69848. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  69849. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  69850. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  69851. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  69852. /** @hidden */
  69853. export var geometryVertexShader: {
  69854. name: string;
  69855. shader: string;
  69856. };
  69857. }
  69858. declare module "babylonjs/Rendering/geometryBufferRenderer" {
  69859. import { Matrix } from "babylonjs/Maths/math.vector";
  69860. import { SubMesh } from "babylonjs/Meshes/subMesh";
  69861. import { Mesh } from "babylonjs/Meshes/mesh";
  69862. import { MultiRenderTarget } from "babylonjs/Materials/Textures/multiRenderTarget";
  69863. import { Effect } from "babylonjs/Materials/effect";
  69864. import { Scene } from "babylonjs/scene";
  69865. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  69866. import "babylonjs/Shaders/geometry.fragment";
  69867. import "babylonjs/Shaders/geometry.vertex";
  69868. /** @hidden */
  69869. interface ISavedTransformationMatrix {
  69870. world: Matrix;
  69871. viewProjection: Matrix;
  69872. }
  69873. /**
  69874. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  69875. */
  69876. export class GeometryBufferRenderer {
  69877. /**
  69878. * Constant used to retrieve the position texture index in the G-Buffer textures array
  69879. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  69880. */
  69881. static readonly POSITION_TEXTURE_TYPE: number;
  69882. /**
  69883. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  69884. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  69885. */
  69886. static readonly VELOCITY_TEXTURE_TYPE: number;
  69887. /**
  69888. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  69889. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  69890. */
  69891. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  69892. /**
  69893. * Dictionary used to store the previous transformation matrices of each rendered mesh
  69894. * in order to compute objects velocities when enableVelocity is set to "true"
  69895. * @hidden
  69896. */
  69897. _previousTransformationMatrices: {
  69898. [index: number]: ISavedTransformationMatrix;
  69899. };
  69900. /**
  69901. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  69902. * in order to compute objects velocities when enableVelocity is set to "true"
  69903. * @hidden
  69904. */
  69905. _previousBonesTransformationMatrices: {
  69906. [index: number]: Float32Array;
  69907. };
  69908. /**
  69909. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  69910. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  69911. */
  69912. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  69913. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  69914. renderTransparentMeshes: boolean;
  69915. private _scene;
  69916. private _multiRenderTarget;
  69917. private _ratio;
  69918. private _enablePosition;
  69919. private _enableVelocity;
  69920. private _enableReflectivity;
  69921. private _positionIndex;
  69922. private _velocityIndex;
  69923. private _reflectivityIndex;
  69924. protected _effect: Effect;
  69925. protected _cachedDefines: string;
  69926. /**
  69927. * Set the render list (meshes to be rendered) used in the G buffer.
  69928. */
  69929. set renderList(meshes: Mesh[]);
  69930. /**
  69931. * Gets wether or not G buffer are supported by the running hardware.
  69932. * This requires draw buffer supports
  69933. */
  69934. get isSupported(): boolean;
  69935. /**
  69936. * Returns the index of the given texture type in the G-Buffer textures array
  69937. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  69938. * @returns the index of the given texture type in the G-Buffer textures array
  69939. */
  69940. getTextureIndex(textureType: number): number;
  69941. /**
  69942. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  69943. */
  69944. get enablePosition(): boolean;
  69945. /**
  69946. * Sets whether or not objects positions are enabled for the G buffer.
  69947. */
  69948. set enablePosition(enable: boolean);
  69949. /**
  69950. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  69951. */
  69952. get enableVelocity(): boolean;
  69953. /**
  69954. * Sets wether or not objects velocities are enabled for the G buffer.
  69955. */
  69956. set enableVelocity(enable: boolean);
  69957. /**
  69958. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  69959. */
  69960. get enableReflectivity(): boolean;
  69961. /**
  69962. * Sets wether or not objects roughness are enabled for the G buffer.
  69963. */
  69964. set enableReflectivity(enable: boolean);
  69965. /**
  69966. * Gets the scene associated with the buffer.
  69967. */
  69968. get scene(): Scene;
  69969. /**
  69970. * Gets the ratio used by the buffer during its creation.
  69971. * How big is the buffer related to the main canvas.
  69972. */
  69973. get ratio(): number;
  69974. /** @hidden */
  69975. static _SceneComponentInitialization: (scene: Scene) => void;
  69976. /**
  69977. * Creates a new G Buffer for the scene
  69978. * @param scene The scene the buffer belongs to
  69979. * @param ratio How big is the buffer related to the main canvas.
  69980. */
  69981. constructor(scene: Scene, ratio?: number);
  69982. /**
  69983. * Checks wether everything is ready to render a submesh to the G buffer.
  69984. * @param subMesh the submesh to check readiness for
  69985. * @param useInstances is the mesh drawn using instance or not
  69986. * @returns true if ready otherwise false
  69987. */
  69988. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  69989. /**
  69990. * Gets the current underlying G Buffer.
  69991. * @returns the buffer
  69992. */
  69993. getGBuffer(): MultiRenderTarget;
  69994. /**
  69995. * Gets the number of samples used to render the buffer (anti aliasing).
  69996. */
  69997. get samples(): number;
  69998. /**
  69999. * Sets the number of samples used to render the buffer (anti aliasing).
  70000. */
  70001. set samples(value: number);
  70002. /**
  70003. * Disposes the renderer and frees up associated resources.
  70004. */
  70005. dispose(): void;
  70006. protected _createRenderTargets(): void;
  70007. private _copyBonesTransformationMatrices;
  70008. }
  70009. }
  70010. declare module "babylonjs/Rendering/geometryBufferRendererSceneComponent" {
  70011. import { Nullable } from "babylonjs/types";
  70012. import { Scene } from "babylonjs/scene";
  70013. import { ISceneComponent } from "babylonjs/sceneComponent";
  70014. import { GeometryBufferRenderer } from "babylonjs/Rendering/geometryBufferRenderer";
  70015. module "babylonjs/scene" {
  70016. interface Scene {
  70017. /** @hidden (Backing field) */
  70018. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  70019. /**
  70020. * Gets or Sets the current geometry buffer associated to the scene.
  70021. */
  70022. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  70023. /**
  70024. * Enables a GeometryBufferRender and associates it with the scene
  70025. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  70026. * @returns the GeometryBufferRenderer
  70027. */
  70028. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  70029. /**
  70030. * Disables the GeometryBufferRender associated with the scene
  70031. */
  70032. disableGeometryBufferRenderer(): void;
  70033. }
  70034. }
  70035. /**
  70036. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  70037. * in several rendering techniques.
  70038. */
  70039. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  70040. /**
  70041. * The component name helpful to identify the component in the list of scene components.
  70042. */
  70043. readonly name: string;
  70044. /**
  70045. * The scene the component belongs to.
  70046. */
  70047. scene: Scene;
  70048. /**
  70049. * Creates a new instance of the component for the given scene
  70050. * @param scene Defines the scene to register the component in
  70051. */
  70052. constructor(scene: Scene);
  70053. /**
  70054. * Registers the component in a given scene
  70055. */
  70056. register(): void;
  70057. /**
  70058. * Rebuilds the elements related to this component in case of
  70059. * context lost for instance.
  70060. */
  70061. rebuild(): void;
  70062. /**
  70063. * Disposes the component and the associated ressources
  70064. */
  70065. dispose(): void;
  70066. private _gatherRenderTargets;
  70067. }
  70068. }
  70069. declare module "babylonjs/Shaders/motionBlur.fragment" {
  70070. /** @hidden */
  70071. export var motionBlurPixelShader: {
  70072. name: string;
  70073. shader: string;
  70074. };
  70075. }
  70076. declare module "babylonjs/PostProcesses/motionBlurPostProcess" {
  70077. import { Nullable } from "babylonjs/types";
  70078. import { Camera } from "babylonjs/Cameras/camera";
  70079. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  70080. import { Scene } from "babylonjs/scene";
  70081. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  70082. import "babylonjs/Animations/animatable";
  70083. import "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  70084. import "babylonjs/Shaders/motionBlur.fragment";
  70085. import { Engine } from "babylonjs/Engines/engine";
  70086. /**
  70087. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  70088. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  70089. * As an example, all you have to do is to create the post-process:
  70090. * var mb = new BABYLON.MotionBlurPostProcess(
  70091. * 'mb', // The name of the effect.
  70092. * scene, // The scene containing the objects to blur according to their velocity.
  70093. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  70094. * camera // The camera to apply the render pass to.
  70095. * );
  70096. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  70097. */
  70098. export class MotionBlurPostProcess extends PostProcess {
  70099. /**
  70100. * Defines how much the image is blurred by the movement. Default value is equal to 1
  70101. */
  70102. motionStrength: number;
  70103. /**
  70104. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  70105. */
  70106. get motionBlurSamples(): number;
  70107. /**
  70108. * Sets the number of iterations to be used for motion blur quality
  70109. */
  70110. set motionBlurSamples(samples: number);
  70111. private _motionBlurSamples;
  70112. private _geometryBufferRenderer;
  70113. /**
  70114. * Creates a new instance MotionBlurPostProcess
  70115. * @param name The name of the effect.
  70116. * @param scene The scene containing the objects to blur according to their velocity.
  70117. * @param options The required width/height ratio to downsize to before computing the render pass.
  70118. * @param camera The camera to apply the render pass to.
  70119. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70120. * @param engine The engine which the post process will be applied. (default: current engine)
  70121. * @param reusable If the post process can be reused on the same frame. (default: false)
  70122. * @param textureType Type of textures used when performing the post process. (default: 0)
  70123. * @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)
  70124. */
  70125. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  70126. /**
  70127. * Excludes the given skinned mesh from computing bones velocities.
  70128. * 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.
  70129. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  70130. */
  70131. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  70132. /**
  70133. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  70134. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  70135. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  70136. */
  70137. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  70138. /**
  70139. * Disposes the post process.
  70140. * @param camera The camera to dispose the post process on.
  70141. */
  70142. dispose(camera?: Camera): void;
  70143. }
  70144. }
  70145. declare module "babylonjs/Shaders/refraction.fragment" {
  70146. /** @hidden */
  70147. export var refractionPixelShader: {
  70148. name: string;
  70149. shader: string;
  70150. };
  70151. }
  70152. declare module "babylonjs/PostProcesses/refractionPostProcess" {
  70153. import { Color3 } from "babylonjs/Maths/math.color";
  70154. import { Camera } from "babylonjs/Cameras/camera";
  70155. import { Texture } from "babylonjs/Materials/Textures/texture";
  70156. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  70157. import { Engine } from "babylonjs/Engines/engine";
  70158. import "babylonjs/Shaders/refraction.fragment";
  70159. /**
  70160. * Post process which applies a refractin texture
  70161. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  70162. */
  70163. export class RefractionPostProcess extends PostProcess {
  70164. /** the base color of the refraction (used to taint the rendering) */
  70165. color: Color3;
  70166. /** simulated refraction depth */
  70167. depth: number;
  70168. /** the coefficient of the base color (0 to remove base color tainting) */
  70169. colorLevel: number;
  70170. private _refTexture;
  70171. private _ownRefractionTexture;
  70172. /**
  70173. * Gets or sets the refraction texture
  70174. * Please note that you are responsible for disposing the texture if you set it manually
  70175. */
  70176. get refractionTexture(): Texture;
  70177. set refractionTexture(value: Texture);
  70178. /**
  70179. * Initializes the RefractionPostProcess
  70180. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  70181. * @param name The name of the effect.
  70182. * @param refractionTextureUrl Url of the refraction texture to use
  70183. * @param color the base color of the refraction (used to taint the rendering)
  70184. * @param depth simulated refraction depth
  70185. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  70186. * @param camera The camera to apply the render pass to.
  70187. * @param options The required width/height ratio to downsize to before computing the render pass.
  70188. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70189. * @param engine The engine which the post process will be applied. (default: current engine)
  70190. * @param reusable If the post process can be reused on the same frame. (default: false)
  70191. */
  70192. constructor(name: string, refractionTextureUrl: string,
  70193. /** the base color of the refraction (used to taint the rendering) */
  70194. color: Color3,
  70195. /** simulated refraction depth */
  70196. depth: number,
  70197. /** the coefficient of the base color (0 to remove base color tainting) */
  70198. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  70199. /**
  70200. * Disposes of the post process
  70201. * @param camera Camera to dispose post process on
  70202. */
  70203. dispose(camera: Camera): void;
  70204. }
  70205. }
  70206. declare module "babylonjs/Shaders/sharpen.fragment" {
  70207. /** @hidden */
  70208. export var sharpenPixelShader: {
  70209. name: string;
  70210. shader: string;
  70211. };
  70212. }
  70213. declare module "babylonjs/PostProcesses/sharpenPostProcess" {
  70214. import { Nullable } from "babylonjs/types";
  70215. import { Camera } from "babylonjs/Cameras/camera";
  70216. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  70217. import "babylonjs/Shaders/sharpen.fragment";
  70218. import { Engine } from "babylonjs/Engines/engine";
  70219. /**
  70220. * The SharpenPostProcess applies a sharpen kernel to every pixel
  70221. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  70222. */
  70223. export class SharpenPostProcess extends PostProcess {
  70224. /**
  70225. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  70226. */
  70227. colorAmount: number;
  70228. /**
  70229. * How much sharpness should be applied (default: 0.3)
  70230. */
  70231. edgeAmount: number;
  70232. /**
  70233. * Creates a new instance ConvolutionPostProcess
  70234. * @param name The name of the effect.
  70235. * @param options The required width/height ratio to downsize to before computing the render pass.
  70236. * @param camera The camera to apply the render pass to.
  70237. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70238. * @param engine The engine which the post process will be applied. (default: current engine)
  70239. * @param reusable If the post process can be reused on the same frame. (default: false)
  70240. * @param textureType Type of textures used when performing the post process. (default: 0)
  70241. * @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)
  70242. */
  70243. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  70244. }
  70245. }
  70246. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline" {
  70247. import { Nullable } from "babylonjs/types";
  70248. import { Camera } from "babylonjs/Cameras/camera";
  70249. import { Engine } from "babylonjs/Engines/engine";
  70250. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  70251. import { IInspectable } from "babylonjs/Misc/iInspectable";
  70252. /**
  70253. * PostProcessRenderPipeline
  70254. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  70255. */
  70256. export class PostProcessRenderPipeline {
  70257. private engine;
  70258. private _renderEffects;
  70259. private _renderEffectsForIsolatedPass;
  70260. /**
  70261. * List of inspectable custom properties (used by the Inspector)
  70262. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  70263. */
  70264. inspectableCustomProperties: IInspectable[];
  70265. /**
  70266. * @hidden
  70267. */
  70268. protected _cameras: Camera[];
  70269. /** @hidden */
  70270. _name: string;
  70271. /**
  70272. * Gets pipeline name
  70273. */
  70274. get name(): string;
  70275. /** Gets the list of attached cameras */
  70276. get cameras(): Camera[];
  70277. /**
  70278. * Initializes a PostProcessRenderPipeline
  70279. * @param engine engine to add the pipeline to
  70280. * @param name name of the pipeline
  70281. */
  70282. constructor(engine: Engine, name: string);
  70283. /**
  70284. * Gets the class name
  70285. * @returns "PostProcessRenderPipeline"
  70286. */
  70287. getClassName(): string;
  70288. /**
  70289. * If all the render effects in the pipeline are supported
  70290. */
  70291. get isSupported(): boolean;
  70292. /**
  70293. * Adds an effect to the pipeline
  70294. * @param renderEffect the effect to add
  70295. */
  70296. addEffect(renderEffect: PostProcessRenderEffect): void;
  70297. /** @hidden */
  70298. _rebuild(): void;
  70299. /** @hidden */
  70300. _enableEffect(renderEffectName: string, cameras: Camera): void;
  70301. /** @hidden */
  70302. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  70303. /** @hidden */
  70304. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  70305. /** @hidden */
  70306. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  70307. /** @hidden */
  70308. _attachCameras(cameras: Camera, unique: boolean): void;
  70309. /** @hidden */
  70310. _attachCameras(cameras: Camera[], unique: boolean): void;
  70311. /** @hidden */
  70312. _detachCameras(cameras: Camera): void;
  70313. /** @hidden */
  70314. _detachCameras(cameras: Nullable<Camera[]>): void;
  70315. /** @hidden */
  70316. _update(): void;
  70317. /** @hidden */
  70318. _reset(): void;
  70319. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  70320. /**
  70321. * Disposes of the pipeline
  70322. */
  70323. dispose(): void;
  70324. }
  70325. }
  70326. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager" {
  70327. import { Camera } from "babylonjs/Cameras/camera";
  70328. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  70329. /**
  70330. * PostProcessRenderPipelineManager class
  70331. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  70332. */
  70333. export class PostProcessRenderPipelineManager {
  70334. private _renderPipelines;
  70335. /**
  70336. * Initializes a PostProcessRenderPipelineManager
  70337. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  70338. */
  70339. constructor();
  70340. /**
  70341. * Gets the list of supported render pipelines
  70342. */
  70343. get supportedPipelines(): PostProcessRenderPipeline[];
  70344. /**
  70345. * Adds a pipeline to the manager
  70346. * @param renderPipeline The pipeline to add
  70347. */
  70348. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  70349. /**
  70350. * Attaches a camera to the pipeline
  70351. * @param renderPipelineName The name of the pipeline to attach to
  70352. * @param cameras the camera to attach
  70353. * @param unique if the camera can be attached multiple times to the pipeline
  70354. */
  70355. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  70356. /**
  70357. * Detaches a camera from the pipeline
  70358. * @param renderPipelineName The name of the pipeline to detach from
  70359. * @param cameras the camera to detach
  70360. */
  70361. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  70362. /**
  70363. * Enables an effect by name on a pipeline
  70364. * @param renderPipelineName the name of the pipeline to enable the effect in
  70365. * @param renderEffectName the name of the effect to enable
  70366. * @param cameras the cameras that the effect should be enabled on
  70367. */
  70368. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  70369. /**
  70370. * Disables an effect by name on a pipeline
  70371. * @param renderPipelineName the name of the pipeline to disable the effect in
  70372. * @param renderEffectName the name of the effect to disable
  70373. * @param cameras the cameras that the effect should be disabled on
  70374. */
  70375. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  70376. /**
  70377. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  70378. */
  70379. update(): void;
  70380. /** @hidden */
  70381. _rebuild(): void;
  70382. /**
  70383. * Disposes of the manager and pipelines
  70384. */
  70385. dispose(): void;
  70386. }
  70387. }
  70388. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent" {
  70389. import { ISceneComponent } from "babylonjs/sceneComponent";
  70390. import { PostProcessRenderPipelineManager } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  70391. import { Scene } from "babylonjs/scene";
  70392. module "babylonjs/scene" {
  70393. interface Scene {
  70394. /** @hidden (Backing field) */
  70395. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  70396. /**
  70397. * Gets the postprocess render pipeline manager
  70398. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  70399. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  70400. */
  70401. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  70402. }
  70403. }
  70404. /**
  70405. * Defines the Render Pipeline scene component responsible to rendering pipelines
  70406. */
  70407. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  70408. /**
  70409. * The component name helpfull to identify the component in the list of scene components.
  70410. */
  70411. readonly name: string;
  70412. /**
  70413. * The scene the component belongs to.
  70414. */
  70415. scene: Scene;
  70416. /**
  70417. * Creates a new instance of the component for the given scene
  70418. * @param scene Defines the scene to register the component in
  70419. */
  70420. constructor(scene: Scene);
  70421. /**
  70422. * Registers the component in a given scene
  70423. */
  70424. register(): void;
  70425. /**
  70426. * Rebuilds the elements related to this component in case of
  70427. * context lost for instance.
  70428. */
  70429. rebuild(): void;
  70430. /**
  70431. * Disposes the component and the associated ressources
  70432. */
  70433. dispose(): void;
  70434. private _gatherRenderTargets;
  70435. }
  70436. }
  70437. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline" {
  70438. import { Nullable } from "babylonjs/types";
  70439. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  70440. import { Camera } from "babylonjs/Cameras/camera";
  70441. import { IDisposable } from "babylonjs/scene";
  70442. import { GlowLayer } from "babylonjs/Layers/glowLayer";
  70443. import { Scene } from "babylonjs/scene";
  70444. import { SharpenPostProcess } from "babylonjs/PostProcesses/sharpenPostProcess";
  70445. import { ImageProcessingPostProcess } from "babylonjs/PostProcesses/imageProcessingPostProcess";
  70446. import { ChromaticAberrationPostProcess } from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  70447. import { GrainPostProcess } from "babylonjs/PostProcesses/grainPostProcess";
  70448. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  70449. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  70450. import { DepthOfFieldEffect, DepthOfFieldEffectBlurLevel } from "babylonjs/PostProcesses/depthOfFieldEffect";
  70451. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  70452. import { Animation } from "babylonjs/Animations/animation";
  70453. /**
  70454. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  70455. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  70456. */
  70457. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  70458. private _scene;
  70459. private _camerasToBeAttached;
  70460. /**
  70461. * ID of the sharpen post process,
  70462. */
  70463. private readonly SharpenPostProcessId;
  70464. /**
  70465. * @ignore
  70466. * ID of the image processing post process;
  70467. */
  70468. readonly ImageProcessingPostProcessId: string;
  70469. /**
  70470. * @ignore
  70471. * ID of the Fast Approximate Anti-Aliasing post process;
  70472. */
  70473. readonly FxaaPostProcessId: string;
  70474. /**
  70475. * ID of the chromatic aberration post process,
  70476. */
  70477. private readonly ChromaticAberrationPostProcessId;
  70478. /**
  70479. * ID of the grain post process
  70480. */
  70481. private readonly GrainPostProcessId;
  70482. /**
  70483. * Sharpen post process which will apply a sharpen convolution to enhance edges
  70484. */
  70485. sharpen: SharpenPostProcess;
  70486. private _sharpenEffect;
  70487. private bloom;
  70488. /**
  70489. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  70490. */
  70491. depthOfField: DepthOfFieldEffect;
  70492. /**
  70493. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  70494. */
  70495. fxaa: FxaaPostProcess;
  70496. /**
  70497. * Image post processing pass used to perform operations such as tone mapping or color grading.
  70498. */
  70499. imageProcessing: ImageProcessingPostProcess;
  70500. /**
  70501. * Chromatic aberration post process which will shift rgb colors in the image
  70502. */
  70503. chromaticAberration: ChromaticAberrationPostProcess;
  70504. private _chromaticAberrationEffect;
  70505. /**
  70506. * Grain post process which add noise to the image
  70507. */
  70508. grain: GrainPostProcess;
  70509. private _grainEffect;
  70510. /**
  70511. * Glow post process which adds a glow to emissive areas of the image
  70512. */
  70513. private _glowLayer;
  70514. /**
  70515. * Animations which can be used to tweak settings over a period of time
  70516. */
  70517. animations: Animation[];
  70518. private _imageProcessingConfigurationObserver;
  70519. private _sharpenEnabled;
  70520. private _bloomEnabled;
  70521. private _depthOfFieldEnabled;
  70522. private _depthOfFieldBlurLevel;
  70523. private _fxaaEnabled;
  70524. private _imageProcessingEnabled;
  70525. private _defaultPipelineTextureType;
  70526. private _bloomScale;
  70527. private _chromaticAberrationEnabled;
  70528. private _grainEnabled;
  70529. private _buildAllowed;
  70530. /**
  70531. * Gets active scene
  70532. */
  70533. get scene(): Scene;
  70534. /**
  70535. * Enable or disable the sharpen process from the pipeline
  70536. */
  70537. set sharpenEnabled(enabled: boolean);
  70538. get sharpenEnabled(): boolean;
  70539. private _resizeObserver;
  70540. private _hardwareScaleLevel;
  70541. private _bloomKernel;
  70542. /**
  70543. * Specifies the size of the bloom blur kernel, relative to the final output size
  70544. */
  70545. get bloomKernel(): number;
  70546. set bloomKernel(value: number);
  70547. /**
  70548. * Specifies the weight of the bloom in the final rendering
  70549. */
  70550. private _bloomWeight;
  70551. /**
  70552. * Specifies the luma threshold for the area that will be blurred by the bloom
  70553. */
  70554. private _bloomThreshold;
  70555. private _hdr;
  70556. /**
  70557. * The strength of the bloom.
  70558. */
  70559. set bloomWeight(value: number);
  70560. get bloomWeight(): number;
  70561. /**
  70562. * The strength of the bloom.
  70563. */
  70564. set bloomThreshold(value: number);
  70565. get bloomThreshold(): number;
  70566. /**
  70567. * The scale of the bloom, lower value will provide better performance.
  70568. */
  70569. set bloomScale(value: number);
  70570. get bloomScale(): number;
  70571. /**
  70572. * Enable or disable the bloom from the pipeline
  70573. */
  70574. set bloomEnabled(enabled: boolean);
  70575. get bloomEnabled(): boolean;
  70576. private _rebuildBloom;
  70577. /**
  70578. * If the depth of field is enabled.
  70579. */
  70580. get depthOfFieldEnabled(): boolean;
  70581. set depthOfFieldEnabled(enabled: boolean);
  70582. /**
  70583. * Blur level of the depth of field effect. (Higher blur will effect performance)
  70584. */
  70585. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  70586. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  70587. /**
  70588. * If the anti aliasing is enabled.
  70589. */
  70590. set fxaaEnabled(enabled: boolean);
  70591. get fxaaEnabled(): boolean;
  70592. private _samples;
  70593. /**
  70594. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  70595. */
  70596. set samples(sampleCount: number);
  70597. get samples(): number;
  70598. /**
  70599. * If image processing is enabled.
  70600. */
  70601. set imageProcessingEnabled(enabled: boolean);
  70602. get imageProcessingEnabled(): boolean;
  70603. /**
  70604. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  70605. */
  70606. set glowLayerEnabled(enabled: boolean);
  70607. get glowLayerEnabled(): boolean;
  70608. /**
  70609. * Gets the glow layer (or null if not defined)
  70610. */
  70611. get glowLayer(): Nullable<GlowLayer>;
  70612. /**
  70613. * Enable or disable the chromaticAberration process from the pipeline
  70614. */
  70615. set chromaticAberrationEnabled(enabled: boolean);
  70616. get chromaticAberrationEnabled(): boolean;
  70617. /**
  70618. * Enable or disable the grain process from the pipeline
  70619. */
  70620. set grainEnabled(enabled: boolean);
  70621. get grainEnabled(): boolean;
  70622. /**
  70623. * @constructor
  70624. * @param name - The rendering pipeline name (default: "")
  70625. * @param hdr - If high dynamic range textures should be used (default: true)
  70626. * @param scene - The scene linked to this pipeline (default: the last created scene)
  70627. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  70628. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  70629. */
  70630. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  70631. /**
  70632. * Get the class name
  70633. * @returns "DefaultRenderingPipeline"
  70634. */
  70635. getClassName(): string;
  70636. /**
  70637. * Force the compilation of the entire pipeline.
  70638. */
  70639. prepare(): void;
  70640. private _hasCleared;
  70641. private _prevPostProcess;
  70642. private _prevPrevPostProcess;
  70643. private _setAutoClearAndTextureSharing;
  70644. private _depthOfFieldSceneObserver;
  70645. private _buildPipeline;
  70646. private _disposePostProcesses;
  70647. /**
  70648. * Adds a camera to the pipeline
  70649. * @param camera the camera to be added
  70650. */
  70651. addCamera(camera: Camera): void;
  70652. /**
  70653. * Removes a camera from the pipeline
  70654. * @param camera the camera to remove
  70655. */
  70656. removeCamera(camera: Camera): void;
  70657. /**
  70658. * Dispose of the pipeline and stop all post processes
  70659. */
  70660. dispose(): void;
  70661. /**
  70662. * Serialize the rendering pipeline (Used when exporting)
  70663. * @returns the serialized object
  70664. */
  70665. serialize(): any;
  70666. /**
  70667. * Parse the serialized pipeline
  70668. * @param source Source pipeline.
  70669. * @param scene The scene to load the pipeline to.
  70670. * @param rootUrl The URL of the serialized pipeline.
  70671. * @returns An instantiated pipeline from the serialized object.
  70672. */
  70673. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  70674. }
  70675. }
  70676. declare module "babylonjs/Shaders/lensHighlights.fragment" {
  70677. /** @hidden */
  70678. export var lensHighlightsPixelShader: {
  70679. name: string;
  70680. shader: string;
  70681. };
  70682. }
  70683. declare module "babylonjs/Shaders/depthOfField.fragment" {
  70684. /** @hidden */
  70685. export var depthOfFieldPixelShader: {
  70686. name: string;
  70687. shader: string;
  70688. };
  70689. }
  70690. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline" {
  70691. import { Camera } from "babylonjs/Cameras/camera";
  70692. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  70693. import { Scene } from "babylonjs/scene";
  70694. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  70695. import "babylonjs/Shaders/chromaticAberration.fragment";
  70696. import "babylonjs/Shaders/lensHighlights.fragment";
  70697. import "babylonjs/Shaders/depthOfField.fragment";
  70698. /**
  70699. * BABYLON.JS Chromatic Aberration GLSL Shader
  70700. * Author: Olivier Guyot
  70701. * Separates very slightly R, G and B colors on the edges of the screen
  70702. * Inspired by Francois Tarlier & Martins Upitis
  70703. */
  70704. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  70705. /**
  70706. * @ignore
  70707. * The chromatic aberration PostProcess id in the pipeline
  70708. */
  70709. LensChromaticAberrationEffect: string;
  70710. /**
  70711. * @ignore
  70712. * The highlights enhancing PostProcess id in the pipeline
  70713. */
  70714. HighlightsEnhancingEffect: string;
  70715. /**
  70716. * @ignore
  70717. * The depth-of-field PostProcess id in the pipeline
  70718. */
  70719. LensDepthOfFieldEffect: string;
  70720. private _scene;
  70721. private _depthTexture;
  70722. private _grainTexture;
  70723. private _chromaticAberrationPostProcess;
  70724. private _highlightsPostProcess;
  70725. private _depthOfFieldPostProcess;
  70726. private _edgeBlur;
  70727. private _grainAmount;
  70728. private _chromaticAberration;
  70729. private _distortion;
  70730. private _highlightsGain;
  70731. private _highlightsThreshold;
  70732. private _dofDistance;
  70733. private _dofAperture;
  70734. private _dofDarken;
  70735. private _dofPentagon;
  70736. private _blurNoise;
  70737. /**
  70738. * @constructor
  70739. *
  70740. * Effect parameters are as follow:
  70741. * {
  70742. * chromatic_aberration: number; // from 0 to x (1 for realism)
  70743. * edge_blur: number; // from 0 to x (1 for realism)
  70744. * distortion: number; // from 0 to x (1 for realism)
  70745. * grain_amount: number; // from 0 to 1
  70746. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  70747. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  70748. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  70749. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  70750. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  70751. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  70752. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  70753. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  70754. * }
  70755. * Note: if an effect parameter is unset, effect is disabled
  70756. *
  70757. * @param name The rendering pipeline name
  70758. * @param parameters - An object containing all parameters (see above)
  70759. * @param scene The scene linked to this pipeline
  70760. * @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)
  70761. * @param cameras The array of cameras that the rendering pipeline will be attached to
  70762. */
  70763. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  70764. /**
  70765. * Get the class name
  70766. * @returns "LensRenderingPipeline"
  70767. */
  70768. getClassName(): string;
  70769. /**
  70770. * Gets associated scene
  70771. */
  70772. get scene(): Scene;
  70773. /**
  70774. * Gets or sets the edge blur
  70775. */
  70776. get edgeBlur(): number;
  70777. set edgeBlur(value: number);
  70778. /**
  70779. * Gets or sets the grain amount
  70780. */
  70781. get grainAmount(): number;
  70782. set grainAmount(value: number);
  70783. /**
  70784. * Gets or sets the chromatic aberration amount
  70785. */
  70786. get chromaticAberration(): number;
  70787. set chromaticAberration(value: number);
  70788. /**
  70789. * Gets or sets the depth of field aperture
  70790. */
  70791. get dofAperture(): number;
  70792. set dofAperture(value: number);
  70793. /**
  70794. * Gets or sets the edge distortion
  70795. */
  70796. get edgeDistortion(): number;
  70797. set edgeDistortion(value: number);
  70798. /**
  70799. * Gets or sets the depth of field distortion
  70800. */
  70801. get dofDistortion(): number;
  70802. set dofDistortion(value: number);
  70803. /**
  70804. * Gets or sets the darken out of focus amount
  70805. */
  70806. get darkenOutOfFocus(): number;
  70807. set darkenOutOfFocus(value: number);
  70808. /**
  70809. * Gets or sets a boolean indicating if blur noise is enabled
  70810. */
  70811. get blurNoise(): boolean;
  70812. set blurNoise(value: boolean);
  70813. /**
  70814. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  70815. */
  70816. get pentagonBokeh(): boolean;
  70817. set pentagonBokeh(value: boolean);
  70818. /**
  70819. * Gets or sets the highlight grain amount
  70820. */
  70821. get highlightsGain(): number;
  70822. set highlightsGain(value: number);
  70823. /**
  70824. * Gets or sets the highlight threshold
  70825. */
  70826. get highlightsThreshold(): number;
  70827. set highlightsThreshold(value: number);
  70828. /**
  70829. * Sets the amount of blur at the edges
  70830. * @param amount blur amount
  70831. */
  70832. setEdgeBlur(amount: number): void;
  70833. /**
  70834. * Sets edge blur to 0
  70835. */
  70836. disableEdgeBlur(): void;
  70837. /**
  70838. * Sets the amout of grain
  70839. * @param amount Amount of grain
  70840. */
  70841. setGrainAmount(amount: number): void;
  70842. /**
  70843. * Set grain amount to 0
  70844. */
  70845. disableGrain(): void;
  70846. /**
  70847. * Sets the chromatic aberration amount
  70848. * @param amount amount of chromatic aberration
  70849. */
  70850. setChromaticAberration(amount: number): void;
  70851. /**
  70852. * Sets chromatic aberration amount to 0
  70853. */
  70854. disableChromaticAberration(): void;
  70855. /**
  70856. * Sets the EdgeDistortion amount
  70857. * @param amount amount of EdgeDistortion
  70858. */
  70859. setEdgeDistortion(amount: number): void;
  70860. /**
  70861. * Sets edge distortion to 0
  70862. */
  70863. disableEdgeDistortion(): void;
  70864. /**
  70865. * Sets the FocusDistance amount
  70866. * @param amount amount of FocusDistance
  70867. */
  70868. setFocusDistance(amount: number): void;
  70869. /**
  70870. * Disables depth of field
  70871. */
  70872. disableDepthOfField(): void;
  70873. /**
  70874. * Sets the Aperture amount
  70875. * @param amount amount of Aperture
  70876. */
  70877. setAperture(amount: number): void;
  70878. /**
  70879. * Sets the DarkenOutOfFocus amount
  70880. * @param amount amount of DarkenOutOfFocus
  70881. */
  70882. setDarkenOutOfFocus(amount: number): void;
  70883. private _pentagonBokehIsEnabled;
  70884. /**
  70885. * Creates a pentagon bokeh effect
  70886. */
  70887. enablePentagonBokeh(): void;
  70888. /**
  70889. * Disables the pentagon bokeh effect
  70890. */
  70891. disablePentagonBokeh(): void;
  70892. /**
  70893. * Enables noise blur
  70894. */
  70895. enableNoiseBlur(): void;
  70896. /**
  70897. * Disables noise blur
  70898. */
  70899. disableNoiseBlur(): void;
  70900. /**
  70901. * Sets the HighlightsGain amount
  70902. * @param amount amount of HighlightsGain
  70903. */
  70904. setHighlightsGain(amount: number): void;
  70905. /**
  70906. * Sets the HighlightsThreshold amount
  70907. * @param amount amount of HighlightsThreshold
  70908. */
  70909. setHighlightsThreshold(amount: number): void;
  70910. /**
  70911. * Disables highlights
  70912. */
  70913. disableHighlights(): void;
  70914. /**
  70915. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  70916. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  70917. */
  70918. dispose(disableDepthRender?: boolean): void;
  70919. private _createChromaticAberrationPostProcess;
  70920. private _createHighlightsPostProcess;
  70921. private _createDepthOfFieldPostProcess;
  70922. private _createGrainTexture;
  70923. }
  70924. }
  70925. declare module "babylonjs/Shaders/ssao2.fragment" {
  70926. /** @hidden */
  70927. export var ssao2PixelShader: {
  70928. name: string;
  70929. shader: string;
  70930. };
  70931. }
  70932. declare module "babylonjs/Shaders/ssaoCombine.fragment" {
  70933. /** @hidden */
  70934. export var ssaoCombinePixelShader: {
  70935. name: string;
  70936. shader: string;
  70937. };
  70938. }
  70939. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline" {
  70940. import { Camera } from "babylonjs/Cameras/camera";
  70941. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  70942. import { Scene } from "babylonjs/scene";
  70943. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  70944. import "babylonjs/Shaders/ssao2.fragment";
  70945. import "babylonjs/Shaders/ssaoCombine.fragment";
  70946. /**
  70947. * Render pipeline to produce ssao effect
  70948. */
  70949. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  70950. /**
  70951. * @ignore
  70952. * The PassPostProcess id in the pipeline that contains the original scene color
  70953. */
  70954. SSAOOriginalSceneColorEffect: string;
  70955. /**
  70956. * @ignore
  70957. * The SSAO PostProcess id in the pipeline
  70958. */
  70959. SSAORenderEffect: string;
  70960. /**
  70961. * @ignore
  70962. * The horizontal blur PostProcess id in the pipeline
  70963. */
  70964. SSAOBlurHRenderEffect: string;
  70965. /**
  70966. * @ignore
  70967. * The vertical blur PostProcess id in the pipeline
  70968. */
  70969. SSAOBlurVRenderEffect: string;
  70970. /**
  70971. * @ignore
  70972. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  70973. */
  70974. SSAOCombineRenderEffect: string;
  70975. /**
  70976. * The output strength of the SSAO post-process. Default value is 1.0.
  70977. */
  70978. totalStrength: number;
  70979. /**
  70980. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  70981. */
  70982. maxZ: number;
  70983. /**
  70984. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  70985. */
  70986. minZAspect: number;
  70987. private _samples;
  70988. /**
  70989. * Number of samples used for the SSAO calculations. Default value is 8
  70990. */
  70991. set samples(n: number);
  70992. get samples(): number;
  70993. private _textureSamples;
  70994. /**
  70995. * Number of samples to use for antialiasing
  70996. */
  70997. set textureSamples(n: number);
  70998. get textureSamples(): number;
  70999. /**
  71000. * Ratio object used for SSAO ratio and blur ratio
  71001. */
  71002. private _ratio;
  71003. /**
  71004. * Dynamically generated sphere sampler.
  71005. */
  71006. private _sampleSphere;
  71007. /**
  71008. * Blur filter offsets
  71009. */
  71010. private _samplerOffsets;
  71011. private _expensiveBlur;
  71012. /**
  71013. * If bilateral blur should be used
  71014. */
  71015. set expensiveBlur(b: boolean);
  71016. get expensiveBlur(): boolean;
  71017. /**
  71018. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  71019. */
  71020. radius: number;
  71021. /**
  71022. * The base color of the SSAO post-process
  71023. * The final result is "base + ssao" between [0, 1]
  71024. */
  71025. base: number;
  71026. /**
  71027. * Support test.
  71028. */
  71029. static get IsSupported(): boolean;
  71030. private _scene;
  71031. private _depthTexture;
  71032. private _normalTexture;
  71033. private _randomTexture;
  71034. private _originalColorPostProcess;
  71035. private _ssaoPostProcess;
  71036. private _blurHPostProcess;
  71037. private _blurVPostProcess;
  71038. private _ssaoCombinePostProcess;
  71039. /**
  71040. * Gets active scene
  71041. */
  71042. get scene(): Scene;
  71043. /**
  71044. * @constructor
  71045. * @param name The rendering pipeline name
  71046. * @param scene The scene linked to this pipeline
  71047. * @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 }
  71048. * @param cameras The array of cameras that the rendering pipeline will be attached to
  71049. */
  71050. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  71051. /**
  71052. * Get the class name
  71053. * @returns "SSAO2RenderingPipeline"
  71054. */
  71055. getClassName(): string;
  71056. /**
  71057. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  71058. */
  71059. dispose(disableGeometryBufferRenderer?: boolean): void;
  71060. private _createBlurPostProcess;
  71061. /** @hidden */
  71062. _rebuild(): void;
  71063. private _bits;
  71064. private _radicalInverse_VdC;
  71065. private _hammersley;
  71066. private _hemisphereSample_uniform;
  71067. private _generateHemisphere;
  71068. private _createSSAOPostProcess;
  71069. private _createSSAOCombinePostProcess;
  71070. private _createRandomTexture;
  71071. /**
  71072. * Serialize the rendering pipeline (Used when exporting)
  71073. * @returns the serialized object
  71074. */
  71075. serialize(): any;
  71076. /**
  71077. * Parse the serialized pipeline
  71078. * @param source Source pipeline.
  71079. * @param scene The scene to load the pipeline to.
  71080. * @param rootUrl The URL of the serialized pipeline.
  71081. * @returns An instantiated pipeline from the serialized object.
  71082. */
  71083. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  71084. }
  71085. }
  71086. declare module "babylonjs/Shaders/ssao.fragment" {
  71087. /** @hidden */
  71088. export var ssaoPixelShader: {
  71089. name: string;
  71090. shader: string;
  71091. };
  71092. }
  71093. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline" {
  71094. import { Camera } from "babylonjs/Cameras/camera";
  71095. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  71096. import { Scene } from "babylonjs/scene";
  71097. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  71098. import "babylonjs/Shaders/ssao.fragment";
  71099. import "babylonjs/Shaders/ssaoCombine.fragment";
  71100. /**
  71101. * Render pipeline to produce ssao effect
  71102. */
  71103. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  71104. /**
  71105. * @ignore
  71106. * The PassPostProcess id in the pipeline that contains the original scene color
  71107. */
  71108. SSAOOriginalSceneColorEffect: string;
  71109. /**
  71110. * @ignore
  71111. * The SSAO PostProcess id in the pipeline
  71112. */
  71113. SSAORenderEffect: string;
  71114. /**
  71115. * @ignore
  71116. * The horizontal blur PostProcess id in the pipeline
  71117. */
  71118. SSAOBlurHRenderEffect: string;
  71119. /**
  71120. * @ignore
  71121. * The vertical blur PostProcess id in the pipeline
  71122. */
  71123. SSAOBlurVRenderEffect: string;
  71124. /**
  71125. * @ignore
  71126. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  71127. */
  71128. SSAOCombineRenderEffect: string;
  71129. /**
  71130. * The output strength of the SSAO post-process. Default value is 1.0.
  71131. */
  71132. totalStrength: number;
  71133. /**
  71134. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  71135. */
  71136. radius: number;
  71137. /**
  71138. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  71139. * Must not be equal to fallOff and superior to fallOff.
  71140. * Default value is 0.0075
  71141. */
  71142. area: number;
  71143. /**
  71144. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  71145. * Must not be equal to area and inferior to area.
  71146. * Default value is 0.000001
  71147. */
  71148. fallOff: number;
  71149. /**
  71150. * The base color of the SSAO post-process
  71151. * The final result is "base + ssao" between [0, 1]
  71152. */
  71153. base: number;
  71154. private _scene;
  71155. private _depthTexture;
  71156. private _randomTexture;
  71157. private _originalColorPostProcess;
  71158. private _ssaoPostProcess;
  71159. private _blurHPostProcess;
  71160. private _blurVPostProcess;
  71161. private _ssaoCombinePostProcess;
  71162. private _firstUpdate;
  71163. /**
  71164. * Gets active scene
  71165. */
  71166. get scene(): Scene;
  71167. /**
  71168. * @constructor
  71169. * @param name - The rendering pipeline name
  71170. * @param scene - The scene linked to this pipeline
  71171. * @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 }
  71172. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  71173. */
  71174. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  71175. /**
  71176. * Get the class name
  71177. * @returns "SSAORenderingPipeline"
  71178. */
  71179. getClassName(): string;
  71180. /**
  71181. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  71182. */
  71183. dispose(disableDepthRender?: boolean): void;
  71184. private _createBlurPostProcess;
  71185. /** @hidden */
  71186. _rebuild(): void;
  71187. private _createSSAOPostProcess;
  71188. private _createSSAOCombinePostProcess;
  71189. private _createRandomTexture;
  71190. }
  71191. }
  71192. declare module "babylonjs/Shaders/screenSpaceReflection.fragment" {
  71193. /** @hidden */
  71194. export var screenSpaceReflectionPixelShader: {
  71195. name: string;
  71196. shader: string;
  71197. };
  71198. }
  71199. declare module "babylonjs/PostProcesses/screenSpaceReflectionPostProcess" {
  71200. import { Nullable } from "babylonjs/types";
  71201. import { Camera } from "babylonjs/Cameras/camera";
  71202. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  71203. import { Scene } from "babylonjs/scene";
  71204. import "babylonjs/Shaders/screenSpaceReflection.fragment";
  71205. import { Engine } from "babylonjs/Engines/engine";
  71206. /**
  71207. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  71208. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  71209. */
  71210. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  71211. /**
  71212. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  71213. */
  71214. threshold: number;
  71215. /**
  71216. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  71217. */
  71218. strength: number;
  71219. /**
  71220. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  71221. */
  71222. reflectionSpecularFalloffExponent: number;
  71223. /**
  71224. * 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]
  71225. */
  71226. step: number;
  71227. /**
  71228. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  71229. */
  71230. roughnessFactor: number;
  71231. private _geometryBufferRenderer;
  71232. private _enableSmoothReflections;
  71233. private _reflectionSamples;
  71234. private _smoothSteps;
  71235. /**
  71236. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  71237. * @param name The name of the effect.
  71238. * @param scene The scene containing the objects to calculate reflections.
  71239. * @param options The required width/height ratio to downsize to before computing the render pass.
  71240. * @param camera The camera to apply the render pass to.
  71241. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71242. * @param engine The engine which the post process will be applied. (default: current engine)
  71243. * @param reusable If the post process can be reused on the same frame. (default: false)
  71244. * @param textureType Type of textures used when performing the post process. (default: 0)
  71245. * @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)
  71246. */
  71247. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  71248. /**
  71249. * Gets wether or not smoothing reflections is enabled.
  71250. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  71251. */
  71252. get enableSmoothReflections(): boolean;
  71253. /**
  71254. * Sets wether or not smoothing reflections is enabled.
  71255. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  71256. */
  71257. set enableSmoothReflections(enabled: boolean);
  71258. /**
  71259. * Gets the number of samples taken while computing reflections. More samples count is high,
  71260. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  71261. */
  71262. get reflectionSamples(): number;
  71263. /**
  71264. * Sets the number of samples taken while computing reflections. More samples count is high,
  71265. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  71266. */
  71267. set reflectionSamples(samples: number);
  71268. /**
  71269. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  71270. * more the post-process will require GPU power and can generate a drop in FPS.
  71271. * Default value (5.0) work pretty well in all cases but can be adjusted.
  71272. */
  71273. get smoothSteps(): number;
  71274. set smoothSteps(steps: number);
  71275. private _updateEffectDefines;
  71276. }
  71277. }
  71278. declare module "babylonjs/Shaders/standard.fragment" {
  71279. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  71280. /** @hidden */
  71281. export var standardPixelShader: {
  71282. name: string;
  71283. shader: string;
  71284. };
  71285. }
  71286. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline" {
  71287. import { Nullable } from "babylonjs/types";
  71288. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  71289. import { Camera } from "babylonjs/Cameras/camera";
  71290. import { Texture } from "babylonjs/Materials/Textures/texture";
  71291. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  71292. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  71293. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  71294. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  71295. import { IDisposable } from "babylonjs/scene";
  71296. import { SpotLight } from "babylonjs/Lights/spotLight";
  71297. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  71298. import { Scene } from "babylonjs/scene";
  71299. import { ScreenSpaceReflectionPostProcess } from "babylonjs/PostProcesses/screenSpaceReflectionPostProcess";
  71300. import { Animation } from "babylonjs/Animations/animation";
  71301. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  71302. import "babylonjs/Shaders/standard.fragment";
  71303. /**
  71304. * Standard rendering pipeline
  71305. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  71306. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  71307. */
  71308. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  71309. /**
  71310. * Public members
  71311. */
  71312. /**
  71313. * Post-process which contains the original scene color before the pipeline applies all the effects
  71314. */
  71315. originalPostProcess: Nullable<PostProcess>;
  71316. /**
  71317. * Post-process used to down scale an image x4
  71318. */
  71319. downSampleX4PostProcess: Nullable<PostProcess>;
  71320. /**
  71321. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  71322. */
  71323. brightPassPostProcess: Nullable<PostProcess>;
  71324. /**
  71325. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  71326. */
  71327. blurHPostProcesses: PostProcess[];
  71328. /**
  71329. * Post-process array storing all the vertical blur post-processes used by the pipeline
  71330. */
  71331. blurVPostProcesses: PostProcess[];
  71332. /**
  71333. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  71334. */
  71335. textureAdderPostProcess: Nullable<PostProcess>;
  71336. /**
  71337. * Post-process used to create volumetric lighting effect
  71338. */
  71339. volumetricLightPostProcess: Nullable<PostProcess>;
  71340. /**
  71341. * Post-process used to smooth the previous volumetric light post-process on the X axis
  71342. */
  71343. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  71344. /**
  71345. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  71346. */
  71347. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  71348. /**
  71349. * Post-process used to merge the volumetric light effect and the real scene color
  71350. */
  71351. volumetricLightMergePostProces: Nullable<PostProcess>;
  71352. /**
  71353. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  71354. */
  71355. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  71356. /**
  71357. * Base post-process used to calculate the average luminance of the final image for HDR
  71358. */
  71359. luminancePostProcess: Nullable<PostProcess>;
  71360. /**
  71361. * Post-processes used to create down sample post-processes in order to get
  71362. * the average luminance of the final image for HDR
  71363. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  71364. */
  71365. luminanceDownSamplePostProcesses: PostProcess[];
  71366. /**
  71367. * Post-process used to create a HDR effect (light adaptation)
  71368. */
  71369. hdrPostProcess: Nullable<PostProcess>;
  71370. /**
  71371. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  71372. */
  71373. textureAdderFinalPostProcess: Nullable<PostProcess>;
  71374. /**
  71375. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  71376. */
  71377. lensFlareFinalPostProcess: Nullable<PostProcess>;
  71378. /**
  71379. * Post-process used to merge the final HDR post-process and the real scene color
  71380. */
  71381. hdrFinalPostProcess: Nullable<PostProcess>;
  71382. /**
  71383. * Post-process used to create a lens flare effect
  71384. */
  71385. lensFlarePostProcess: Nullable<PostProcess>;
  71386. /**
  71387. * Post-process that merges the result of the lens flare post-process and the real scene color
  71388. */
  71389. lensFlareComposePostProcess: Nullable<PostProcess>;
  71390. /**
  71391. * Post-process used to create a motion blur effect
  71392. */
  71393. motionBlurPostProcess: Nullable<PostProcess>;
  71394. /**
  71395. * Post-process used to create a depth of field effect
  71396. */
  71397. depthOfFieldPostProcess: Nullable<PostProcess>;
  71398. /**
  71399. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  71400. */
  71401. fxaaPostProcess: Nullable<FxaaPostProcess>;
  71402. /**
  71403. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  71404. */
  71405. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  71406. /**
  71407. * Represents the brightness threshold in order to configure the illuminated surfaces
  71408. */
  71409. brightThreshold: number;
  71410. /**
  71411. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  71412. */
  71413. blurWidth: number;
  71414. /**
  71415. * Sets if the blur for highlighted surfaces must be only horizontal
  71416. */
  71417. horizontalBlur: boolean;
  71418. /**
  71419. * Gets the overall exposure used by the pipeline
  71420. */
  71421. get exposure(): number;
  71422. /**
  71423. * Sets the overall exposure used by the pipeline
  71424. */
  71425. set exposure(value: number);
  71426. /**
  71427. * Texture used typically to simulate "dirty" on camera lens
  71428. */
  71429. lensTexture: Nullable<Texture>;
  71430. /**
  71431. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  71432. */
  71433. volumetricLightCoefficient: number;
  71434. /**
  71435. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  71436. */
  71437. volumetricLightPower: number;
  71438. /**
  71439. * Used the set the blur intensity to smooth the volumetric lights
  71440. */
  71441. volumetricLightBlurScale: number;
  71442. /**
  71443. * Light (spot or directional) used to generate the volumetric lights rays
  71444. * The source light must have a shadow generate so the pipeline can get its
  71445. * depth map
  71446. */
  71447. sourceLight: Nullable<SpotLight | DirectionalLight>;
  71448. /**
  71449. * For eye adaptation, represents the minimum luminance the eye can see
  71450. */
  71451. hdrMinimumLuminance: number;
  71452. /**
  71453. * For eye adaptation, represents the decrease luminance speed
  71454. */
  71455. hdrDecreaseRate: number;
  71456. /**
  71457. * For eye adaptation, represents the increase luminance speed
  71458. */
  71459. hdrIncreaseRate: number;
  71460. /**
  71461. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  71462. */
  71463. get hdrAutoExposure(): boolean;
  71464. /**
  71465. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  71466. */
  71467. set hdrAutoExposure(value: boolean);
  71468. /**
  71469. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  71470. */
  71471. lensColorTexture: Nullable<Texture>;
  71472. /**
  71473. * The overall strengh for the lens flare effect
  71474. */
  71475. lensFlareStrength: number;
  71476. /**
  71477. * Dispersion coefficient for lens flare ghosts
  71478. */
  71479. lensFlareGhostDispersal: number;
  71480. /**
  71481. * Main lens flare halo width
  71482. */
  71483. lensFlareHaloWidth: number;
  71484. /**
  71485. * Based on the lens distortion effect, defines how much the lens flare result
  71486. * is distorted
  71487. */
  71488. lensFlareDistortionStrength: number;
  71489. /**
  71490. * Configures the blur intensity used for for lens flare (halo)
  71491. */
  71492. lensFlareBlurWidth: number;
  71493. /**
  71494. * Lens star texture must be used to simulate rays on the flares and is available
  71495. * in the documentation
  71496. */
  71497. lensStarTexture: Nullable<Texture>;
  71498. /**
  71499. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  71500. * flare effect by taking account of the dirt texture
  71501. */
  71502. lensFlareDirtTexture: Nullable<Texture>;
  71503. /**
  71504. * Represents the focal length for the depth of field effect
  71505. */
  71506. depthOfFieldDistance: number;
  71507. /**
  71508. * Represents the blur intensity for the blurred part of the depth of field effect
  71509. */
  71510. depthOfFieldBlurWidth: number;
  71511. /**
  71512. * Gets how much the image is blurred by the movement while using the motion blur post-process
  71513. */
  71514. get motionStrength(): number;
  71515. /**
  71516. * Sets how much the image is blurred by the movement while using the motion blur post-process
  71517. */
  71518. set motionStrength(strength: number);
  71519. /**
  71520. * Gets wether or not the motion blur post-process is object based or screen based.
  71521. */
  71522. get objectBasedMotionBlur(): boolean;
  71523. /**
  71524. * Sets wether or not the motion blur post-process should be object based or screen based
  71525. */
  71526. set objectBasedMotionBlur(value: boolean);
  71527. /**
  71528. * List of animations for the pipeline (IAnimatable implementation)
  71529. */
  71530. animations: Animation[];
  71531. /**
  71532. * Private members
  71533. */
  71534. private _scene;
  71535. private _currentDepthOfFieldSource;
  71536. private _basePostProcess;
  71537. private _fixedExposure;
  71538. private _currentExposure;
  71539. private _hdrAutoExposure;
  71540. private _hdrCurrentLuminance;
  71541. private _motionStrength;
  71542. private _isObjectBasedMotionBlur;
  71543. private _floatTextureType;
  71544. private _camerasToBeAttached;
  71545. private _ratio;
  71546. private _bloomEnabled;
  71547. private _depthOfFieldEnabled;
  71548. private _vlsEnabled;
  71549. private _lensFlareEnabled;
  71550. private _hdrEnabled;
  71551. private _motionBlurEnabled;
  71552. private _fxaaEnabled;
  71553. private _screenSpaceReflectionsEnabled;
  71554. private _motionBlurSamples;
  71555. private _volumetricLightStepsCount;
  71556. private _samples;
  71557. /**
  71558. * @ignore
  71559. * Specifies if the bloom pipeline is enabled
  71560. */
  71561. get BloomEnabled(): boolean;
  71562. set BloomEnabled(enabled: boolean);
  71563. /**
  71564. * @ignore
  71565. * Specifies if the depth of field pipeline is enabed
  71566. */
  71567. get DepthOfFieldEnabled(): boolean;
  71568. set DepthOfFieldEnabled(enabled: boolean);
  71569. /**
  71570. * @ignore
  71571. * Specifies if the lens flare pipeline is enabed
  71572. */
  71573. get LensFlareEnabled(): boolean;
  71574. set LensFlareEnabled(enabled: boolean);
  71575. /**
  71576. * @ignore
  71577. * Specifies if the HDR pipeline is enabled
  71578. */
  71579. get HDREnabled(): boolean;
  71580. set HDREnabled(enabled: boolean);
  71581. /**
  71582. * @ignore
  71583. * Specifies if the volumetric lights scattering effect is enabled
  71584. */
  71585. get VLSEnabled(): boolean;
  71586. set VLSEnabled(enabled: boolean);
  71587. /**
  71588. * @ignore
  71589. * Specifies if the motion blur effect is enabled
  71590. */
  71591. get MotionBlurEnabled(): boolean;
  71592. set MotionBlurEnabled(enabled: boolean);
  71593. /**
  71594. * Specifies if anti-aliasing is enabled
  71595. */
  71596. get fxaaEnabled(): boolean;
  71597. set fxaaEnabled(enabled: boolean);
  71598. /**
  71599. * Specifies if screen space reflections are enabled.
  71600. */
  71601. get screenSpaceReflectionsEnabled(): boolean;
  71602. set screenSpaceReflectionsEnabled(enabled: boolean);
  71603. /**
  71604. * Specifies the number of steps used to calculate the volumetric lights
  71605. * Typically in interval [50, 200]
  71606. */
  71607. get volumetricLightStepsCount(): number;
  71608. set volumetricLightStepsCount(count: number);
  71609. /**
  71610. * Specifies the number of samples used for the motion blur effect
  71611. * Typically in interval [16, 64]
  71612. */
  71613. get motionBlurSamples(): number;
  71614. set motionBlurSamples(samples: number);
  71615. /**
  71616. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  71617. */
  71618. get samples(): number;
  71619. set samples(sampleCount: number);
  71620. /**
  71621. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  71622. * @constructor
  71623. * @param name The rendering pipeline name
  71624. * @param scene The scene linked to this pipeline
  71625. * @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)
  71626. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  71627. * @param cameras The array of cameras that the rendering pipeline will be attached to
  71628. */
  71629. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  71630. private _buildPipeline;
  71631. private _createDownSampleX4PostProcess;
  71632. private _createBrightPassPostProcess;
  71633. private _createBlurPostProcesses;
  71634. private _createTextureAdderPostProcess;
  71635. private _createVolumetricLightPostProcess;
  71636. private _createLuminancePostProcesses;
  71637. private _createHdrPostProcess;
  71638. private _createLensFlarePostProcess;
  71639. private _createDepthOfFieldPostProcess;
  71640. private _createMotionBlurPostProcess;
  71641. private _getDepthTexture;
  71642. private _disposePostProcesses;
  71643. /**
  71644. * Dispose of the pipeline and stop all post processes
  71645. */
  71646. dispose(): void;
  71647. /**
  71648. * Serialize the rendering pipeline (Used when exporting)
  71649. * @returns the serialized object
  71650. */
  71651. serialize(): any;
  71652. /**
  71653. * Parse the serialized pipeline
  71654. * @param source Source pipeline.
  71655. * @param scene The scene to load the pipeline to.
  71656. * @param rootUrl The URL of the serialized pipeline.
  71657. * @returns An instantiated pipeline from the serialized object.
  71658. */
  71659. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  71660. /**
  71661. * Luminance steps
  71662. */
  71663. static LuminanceSteps: number;
  71664. }
  71665. }
  71666. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/index" {
  71667. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline";
  71668. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline";
  71669. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline";
  71670. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline";
  71671. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline";
  71672. }
  71673. declare module "babylonjs/PostProcesses/RenderPipeline/index" {
  71674. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/index";
  71675. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  71676. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  71677. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  71678. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  71679. }
  71680. declare module "babylonjs/Shaders/stereoscopicInterlace.fragment" {
  71681. /** @hidden */
  71682. export var stereoscopicInterlacePixelShader: {
  71683. name: string;
  71684. shader: string;
  71685. };
  71686. }
  71687. declare module "babylonjs/PostProcesses/stereoscopicInterlacePostProcess" {
  71688. import { Camera } from "babylonjs/Cameras/camera";
  71689. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  71690. import { Engine } from "babylonjs/Engines/engine";
  71691. import "babylonjs/Shaders/stereoscopicInterlace.fragment";
  71692. /**
  71693. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  71694. */
  71695. export class StereoscopicInterlacePostProcessI extends PostProcess {
  71696. private _stepSize;
  71697. private _passedProcess;
  71698. /**
  71699. * Initializes a StereoscopicInterlacePostProcessI
  71700. * @param name The name of the effect.
  71701. * @param rigCameras The rig cameras to be appled to the post process
  71702. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  71703. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  71704. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71705. * @param engine The engine which the post process will be applied. (default: current engine)
  71706. * @param reusable If the post process can be reused on the same frame. (default: false)
  71707. */
  71708. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  71709. }
  71710. /**
  71711. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  71712. */
  71713. export class StereoscopicInterlacePostProcess extends PostProcess {
  71714. private _stepSize;
  71715. private _passedProcess;
  71716. /**
  71717. * Initializes a StereoscopicInterlacePostProcess
  71718. * @param name The name of the effect.
  71719. * @param rigCameras The rig cameras to be appled to the post process
  71720. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  71721. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71722. * @param engine The engine which the post process will be applied. (default: current engine)
  71723. * @param reusable If the post process can be reused on the same frame. (default: false)
  71724. */
  71725. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  71726. }
  71727. }
  71728. declare module "babylonjs/Shaders/tonemap.fragment" {
  71729. /** @hidden */
  71730. export var tonemapPixelShader: {
  71731. name: string;
  71732. shader: string;
  71733. };
  71734. }
  71735. declare module "babylonjs/PostProcesses/tonemapPostProcess" {
  71736. import { Camera } from "babylonjs/Cameras/camera";
  71737. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  71738. import "babylonjs/Shaders/tonemap.fragment";
  71739. import { Engine } from "babylonjs/Engines/engine";
  71740. /** Defines operator used for tonemapping */
  71741. export enum TonemappingOperator {
  71742. /** Hable */
  71743. Hable = 0,
  71744. /** Reinhard */
  71745. Reinhard = 1,
  71746. /** HejiDawson */
  71747. HejiDawson = 2,
  71748. /** Photographic */
  71749. Photographic = 3
  71750. }
  71751. /**
  71752. * Defines a post process to apply tone mapping
  71753. */
  71754. export class TonemapPostProcess extends PostProcess {
  71755. private _operator;
  71756. /** Defines the required exposure adjustement */
  71757. exposureAdjustment: number;
  71758. /**
  71759. * Creates a new TonemapPostProcess
  71760. * @param name defines the name of the postprocess
  71761. * @param _operator defines the operator to use
  71762. * @param exposureAdjustment defines the required exposure adjustement
  71763. * @param camera defines the camera to use (can be null)
  71764. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  71765. * @param engine defines the hosting engine (can be ignore if camera is set)
  71766. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  71767. */
  71768. constructor(name: string, _operator: TonemappingOperator,
  71769. /** Defines the required exposure adjustement */
  71770. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  71771. }
  71772. }
  71773. declare module "babylonjs/Shaders/volumetricLightScattering.fragment" {
  71774. /** @hidden */
  71775. export var volumetricLightScatteringPixelShader: {
  71776. name: string;
  71777. shader: string;
  71778. };
  71779. }
  71780. declare module "babylonjs/Shaders/volumetricLightScatteringPass.vertex" {
  71781. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  71782. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  71783. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  71784. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  71785. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  71786. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  71787. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  71788. /** @hidden */
  71789. export var volumetricLightScatteringPassVertexShader: {
  71790. name: string;
  71791. shader: string;
  71792. };
  71793. }
  71794. declare module "babylonjs/Shaders/volumetricLightScatteringPass.fragment" {
  71795. /** @hidden */
  71796. export var volumetricLightScatteringPassPixelShader: {
  71797. name: string;
  71798. shader: string;
  71799. };
  71800. }
  71801. declare module "babylonjs/PostProcesses/volumetricLightScatteringPostProcess" {
  71802. import { Vector3 } from "babylonjs/Maths/math.vector";
  71803. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  71804. import { Mesh } from "babylonjs/Meshes/mesh";
  71805. import { Camera } from "babylonjs/Cameras/camera";
  71806. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  71807. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  71808. import { Scene } from "babylonjs/scene";
  71809. import "babylonjs/Meshes/Builders/planeBuilder";
  71810. import "babylonjs/Shaders/depth.vertex";
  71811. import "babylonjs/Shaders/volumetricLightScattering.fragment";
  71812. import "babylonjs/Shaders/volumetricLightScatteringPass.vertex";
  71813. import "babylonjs/Shaders/volumetricLightScatteringPass.fragment";
  71814. import { Engine } from "babylonjs/Engines/engine";
  71815. /**
  71816. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  71817. */
  71818. export class VolumetricLightScatteringPostProcess extends PostProcess {
  71819. private _volumetricLightScatteringPass;
  71820. private _volumetricLightScatteringRTT;
  71821. private _viewPort;
  71822. private _screenCoordinates;
  71823. private _cachedDefines;
  71824. /**
  71825. * If not undefined, the mesh position is computed from the attached node position
  71826. */
  71827. attachedNode: {
  71828. position: Vector3;
  71829. };
  71830. /**
  71831. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  71832. */
  71833. customMeshPosition: Vector3;
  71834. /**
  71835. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  71836. */
  71837. useCustomMeshPosition: boolean;
  71838. /**
  71839. * If the post-process should inverse the light scattering direction
  71840. */
  71841. invert: boolean;
  71842. /**
  71843. * The internal mesh used by the post-process
  71844. */
  71845. mesh: Mesh;
  71846. /**
  71847. * @hidden
  71848. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  71849. */
  71850. get useDiffuseColor(): boolean;
  71851. set useDiffuseColor(useDiffuseColor: boolean);
  71852. /**
  71853. * Array containing the excluded meshes not rendered in the internal pass
  71854. */
  71855. excludedMeshes: AbstractMesh[];
  71856. /**
  71857. * Controls the overall intensity of the post-process
  71858. */
  71859. exposure: number;
  71860. /**
  71861. * Dissipates each sample's contribution in range [0, 1]
  71862. */
  71863. decay: number;
  71864. /**
  71865. * Controls the overall intensity of each sample
  71866. */
  71867. weight: number;
  71868. /**
  71869. * Controls the density of each sample
  71870. */
  71871. density: number;
  71872. /**
  71873. * @constructor
  71874. * @param name The post-process name
  71875. * @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)
  71876. * @param camera The camera that the post-process will be attached to
  71877. * @param mesh The mesh used to create the light scattering
  71878. * @param samples The post-process quality, default 100
  71879. * @param samplingModeThe post-process filtering mode
  71880. * @param engine The babylon engine
  71881. * @param reusable If the post-process is reusable
  71882. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  71883. */
  71884. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  71885. /**
  71886. * Returns the string "VolumetricLightScatteringPostProcess"
  71887. * @returns "VolumetricLightScatteringPostProcess"
  71888. */
  71889. getClassName(): string;
  71890. private _isReady;
  71891. /**
  71892. * Sets the new light position for light scattering effect
  71893. * @param position The new custom light position
  71894. */
  71895. setCustomMeshPosition(position: Vector3): void;
  71896. /**
  71897. * Returns the light position for light scattering effect
  71898. * @return Vector3 The custom light position
  71899. */
  71900. getCustomMeshPosition(): Vector3;
  71901. /**
  71902. * Disposes the internal assets and detaches the post-process from the camera
  71903. */
  71904. dispose(camera: Camera): void;
  71905. /**
  71906. * Returns the render target texture used by the post-process
  71907. * @return the render target texture used by the post-process
  71908. */
  71909. getPass(): RenderTargetTexture;
  71910. private _meshExcluded;
  71911. private _createPass;
  71912. private _updateMeshScreenCoordinates;
  71913. /**
  71914. * Creates a default mesh for the Volumeric Light Scattering post-process
  71915. * @param name The mesh name
  71916. * @param scene The scene where to create the mesh
  71917. * @return the default mesh
  71918. */
  71919. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  71920. }
  71921. }
  71922. declare module "babylonjs/PostProcesses/index" {
  71923. export * from "babylonjs/PostProcesses/anaglyphPostProcess";
  71924. export * from "babylonjs/PostProcesses/blackAndWhitePostProcess";
  71925. export * from "babylonjs/PostProcesses/bloomEffect";
  71926. export * from "babylonjs/PostProcesses/bloomMergePostProcess";
  71927. export * from "babylonjs/PostProcesses/blurPostProcess";
  71928. export * from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  71929. export * from "babylonjs/PostProcesses/circleOfConfusionPostProcess";
  71930. export * from "babylonjs/PostProcesses/colorCorrectionPostProcess";
  71931. export * from "babylonjs/PostProcesses/convolutionPostProcess";
  71932. export * from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  71933. export * from "babylonjs/PostProcesses/depthOfFieldEffect";
  71934. export * from "babylonjs/PostProcesses/depthOfFieldMergePostProcess";
  71935. export * from "babylonjs/PostProcesses/displayPassPostProcess";
  71936. export * from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  71937. export * from "babylonjs/PostProcesses/filterPostProcess";
  71938. export * from "babylonjs/PostProcesses/fxaaPostProcess";
  71939. export * from "babylonjs/PostProcesses/grainPostProcess";
  71940. export * from "babylonjs/PostProcesses/highlightsPostProcess";
  71941. export * from "babylonjs/PostProcesses/imageProcessingPostProcess";
  71942. export * from "babylonjs/PostProcesses/motionBlurPostProcess";
  71943. export * from "babylonjs/PostProcesses/passPostProcess";
  71944. export * from "babylonjs/PostProcesses/postProcess";
  71945. export * from "babylonjs/PostProcesses/postProcessManager";
  71946. export * from "babylonjs/PostProcesses/refractionPostProcess";
  71947. export * from "babylonjs/PostProcesses/RenderPipeline/index";
  71948. export * from "babylonjs/PostProcesses/sharpenPostProcess";
  71949. export * from "babylonjs/PostProcesses/stereoscopicInterlacePostProcess";
  71950. export * from "babylonjs/PostProcesses/tonemapPostProcess";
  71951. export * from "babylonjs/PostProcesses/volumetricLightScatteringPostProcess";
  71952. export * from "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess";
  71953. export * from "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess";
  71954. export * from "babylonjs/PostProcesses/screenSpaceReflectionPostProcess";
  71955. }
  71956. declare module "babylonjs/Probes/index" {
  71957. export * from "babylonjs/Probes/reflectionProbe";
  71958. }
  71959. declare module "babylonjs/Rendering/boundingBoxRenderer" {
  71960. import { Scene } from "babylonjs/scene";
  71961. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  71962. import { SmartArray } from "babylonjs/Misc/smartArray";
  71963. import { ISceneComponent } from "babylonjs/sceneComponent";
  71964. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  71965. import "babylonjs/Meshes/Builders/boxBuilder";
  71966. import "babylonjs/Shaders/color.fragment";
  71967. import "babylonjs/Shaders/color.vertex";
  71968. import { Color3 } from "babylonjs/Maths/math.color";
  71969. module "babylonjs/scene" {
  71970. interface Scene {
  71971. /** @hidden (Backing field) */
  71972. _boundingBoxRenderer: BoundingBoxRenderer;
  71973. /** @hidden (Backing field) */
  71974. _forceShowBoundingBoxes: boolean;
  71975. /**
  71976. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  71977. */
  71978. forceShowBoundingBoxes: boolean;
  71979. /**
  71980. * Gets the bounding box renderer associated with the scene
  71981. * @returns a BoundingBoxRenderer
  71982. */
  71983. getBoundingBoxRenderer(): BoundingBoxRenderer;
  71984. }
  71985. }
  71986. module "babylonjs/Meshes/abstractMesh" {
  71987. interface AbstractMesh {
  71988. /** @hidden (Backing field) */
  71989. _showBoundingBox: boolean;
  71990. /**
  71991. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  71992. */
  71993. showBoundingBox: boolean;
  71994. }
  71995. }
  71996. /**
  71997. * Component responsible of rendering the bounding box of the meshes in a scene.
  71998. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  71999. */
  72000. export class BoundingBoxRenderer implements ISceneComponent {
  72001. /**
  72002. * The component name helpfull to identify the component in the list of scene components.
  72003. */
  72004. readonly name: string;
  72005. /**
  72006. * The scene the component belongs to.
  72007. */
  72008. scene: Scene;
  72009. /**
  72010. * Color of the bounding box lines placed in front of an object
  72011. */
  72012. frontColor: Color3;
  72013. /**
  72014. * Color of the bounding box lines placed behind an object
  72015. */
  72016. backColor: Color3;
  72017. /**
  72018. * Defines if the renderer should show the back lines or not
  72019. */
  72020. showBackLines: boolean;
  72021. /**
  72022. * @hidden
  72023. */
  72024. renderList: SmartArray<BoundingBox>;
  72025. private _colorShader;
  72026. private _vertexBuffers;
  72027. private _indexBuffer;
  72028. private _fillIndexBuffer;
  72029. private _fillIndexData;
  72030. /**
  72031. * Instantiates a new bounding box renderer in a scene.
  72032. * @param scene the scene the renderer renders in
  72033. */
  72034. constructor(scene: Scene);
  72035. /**
  72036. * Registers the component in a given scene
  72037. */
  72038. register(): void;
  72039. private _evaluateSubMesh;
  72040. private _activeMesh;
  72041. private _prepareRessources;
  72042. private _createIndexBuffer;
  72043. /**
  72044. * Rebuilds the elements related to this component in case of
  72045. * context lost for instance.
  72046. */
  72047. rebuild(): void;
  72048. /**
  72049. * @hidden
  72050. */
  72051. reset(): void;
  72052. /**
  72053. * Render the bounding boxes of a specific rendering group
  72054. * @param renderingGroupId defines the rendering group to render
  72055. */
  72056. render(renderingGroupId: number): void;
  72057. /**
  72058. * In case of occlusion queries, we can render the occlusion bounding box through this method
  72059. * @param mesh Define the mesh to render the occlusion bounding box for
  72060. */
  72061. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  72062. /**
  72063. * Dispose and release the resources attached to this renderer.
  72064. */
  72065. dispose(): void;
  72066. }
  72067. }
  72068. declare module "babylonjs/Rendering/depthRendererSceneComponent" {
  72069. import { Nullable } from "babylonjs/types";
  72070. import { Scene } from "babylonjs/scene";
  72071. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  72072. import { Camera } from "babylonjs/Cameras/camera";
  72073. import { ISceneComponent } from "babylonjs/sceneComponent";
  72074. module "babylonjs/scene" {
  72075. interface Scene {
  72076. /** @hidden (Backing field) */
  72077. _depthRenderer: {
  72078. [id: string]: DepthRenderer;
  72079. };
  72080. /**
  72081. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  72082. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  72083. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  72084. * @returns the created depth renderer
  72085. */
  72086. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  72087. /**
  72088. * Disables a depth renderer for a given camera
  72089. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  72090. */
  72091. disableDepthRenderer(camera?: Nullable<Camera>): void;
  72092. }
  72093. }
  72094. /**
  72095. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  72096. * in several rendering techniques.
  72097. */
  72098. export class DepthRendererSceneComponent implements ISceneComponent {
  72099. /**
  72100. * The component name helpfull to identify the component in the list of scene components.
  72101. */
  72102. readonly name: string;
  72103. /**
  72104. * The scene the component belongs to.
  72105. */
  72106. scene: Scene;
  72107. /**
  72108. * Creates a new instance of the component for the given scene
  72109. * @param scene Defines the scene to register the component in
  72110. */
  72111. constructor(scene: Scene);
  72112. /**
  72113. * Registers the component in a given scene
  72114. */
  72115. register(): void;
  72116. /**
  72117. * Rebuilds the elements related to this component in case of
  72118. * context lost for instance.
  72119. */
  72120. rebuild(): void;
  72121. /**
  72122. * Disposes the component and the associated ressources
  72123. */
  72124. dispose(): void;
  72125. private _gatherRenderTargets;
  72126. private _gatherActiveCameraRenderTargets;
  72127. }
  72128. }
  72129. declare module "babylonjs/Shaders/outline.fragment" {
  72130. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  72131. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  72132. /** @hidden */
  72133. export var outlinePixelShader: {
  72134. name: string;
  72135. shader: string;
  72136. };
  72137. }
  72138. declare module "babylonjs/Shaders/outline.vertex" {
  72139. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  72140. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  72141. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  72142. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  72143. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  72144. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  72145. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  72146. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  72147. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  72148. /** @hidden */
  72149. export var outlineVertexShader: {
  72150. name: string;
  72151. shader: string;
  72152. };
  72153. }
  72154. declare module "babylonjs/Rendering/outlineRenderer" {
  72155. import { SubMesh } from "babylonjs/Meshes/subMesh";
  72156. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  72157. import { Scene } from "babylonjs/scene";
  72158. import { ISceneComponent } from "babylonjs/sceneComponent";
  72159. import "babylonjs/Shaders/outline.fragment";
  72160. import "babylonjs/Shaders/outline.vertex";
  72161. module "babylonjs/scene" {
  72162. interface Scene {
  72163. /** @hidden */
  72164. _outlineRenderer: OutlineRenderer;
  72165. /**
  72166. * Gets the outline renderer associated with the scene
  72167. * @returns a OutlineRenderer
  72168. */
  72169. getOutlineRenderer(): OutlineRenderer;
  72170. }
  72171. }
  72172. module "babylonjs/Meshes/abstractMesh" {
  72173. interface AbstractMesh {
  72174. /** @hidden (Backing field) */
  72175. _renderOutline: boolean;
  72176. /**
  72177. * Gets or sets a boolean indicating if the outline must be rendered as well
  72178. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  72179. */
  72180. renderOutline: boolean;
  72181. /** @hidden (Backing field) */
  72182. _renderOverlay: boolean;
  72183. /**
  72184. * Gets or sets a boolean indicating if the overlay must be rendered as well
  72185. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  72186. */
  72187. renderOverlay: boolean;
  72188. }
  72189. }
  72190. /**
  72191. * This class is responsible to draw bothe outline/overlay of meshes.
  72192. * It should not be used directly but through the available method on mesh.
  72193. */
  72194. export class OutlineRenderer implements ISceneComponent {
  72195. /**
  72196. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  72197. */
  72198. private static _StencilReference;
  72199. /**
  72200. * The name of the component. Each component must have a unique name.
  72201. */
  72202. name: string;
  72203. /**
  72204. * The scene the component belongs to.
  72205. */
  72206. scene: Scene;
  72207. /**
  72208. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  72209. */
  72210. zOffset: number;
  72211. private _engine;
  72212. private _effect;
  72213. private _cachedDefines;
  72214. private _savedDepthWrite;
  72215. /**
  72216. * Instantiates a new outline renderer. (There could be only one per scene).
  72217. * @param scene Defines the scene it belongs to
  72218. */
  72219. constructor(scene: Scene);
  72220. /**
  72221. * Register the component to one instance of a scene.
  72222. */
  72223. register(): void;
  72224. /**
  72225. * Rebuilds the elements related to this component in case of
  72226. * context lost for instance.
  72227. */
  72228. rebuild(): void;
  72229. /**
  72230. * Disposes the component and the associated ressources.
  72231. */
  72232. dispose(): void;
  72233. /**
  72234. * Renders the outline in the canvas.
  72235. * @param subMesh Defines the sumesh to render
  72236. * @param batch Defines the batch of meshes in case of instances
  72237. * @param useOverlay Defines if the rendering is for the overlay or the outline
  72238. */
  72239. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  72240. /**
  72241. * Returns whether or not the outline renderer is ready for a given submesh.
  72242. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  72243. * @param subMesh Defines the submesh to check readyness for
  72244. * @param useInstances Defines wheter wee are trying to render instances or not
  72245. * @returns true if ready otherwise false
  72246. */
  72247. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  72248. private _beforeRenderingMesh;
  72249. private _afterRenderingMesh;
  72250. }
  72251. }
  72252. declare module "babylonjs/Rendering/index" {
  72253. export * from "babylonjs/Rendering/boundingBoxRenderer";
  72254. export * from "babylonjs/Rendering/depthRenderer";
  72255. export * from "babylonjs/Rendering/depthRendererSceneComponent";
  72256. export * from "babylonjs/Rendering/edgesRenderer";
  72257. export * from "babylonjs/Rendering/geometryBufferRenderer";
  72258. export * from "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  72259. export * from "babylonjs/Rendering/outlineRenderer";
  72260. export * from "babylonjs/Rendering/renderingGroup";
  72261. export * from "babylonjs/Rendering/renderingManager";
  72262. export * from "babylonjs/Rendering/utilityLayerRenderer";
  72263. }
  72264. declare module "babylonjs/Sprites/ISprites" {
  72265. /**
  72266. * Defines the basic options interface of a Sprite Frame Source Size.
  72267. */
  72268. export interface ISpriteJSONSpriteSourceSize {
  72269. /**
  72270. * number of the original width of the Frame
  72271. */
  72272. w: number;
  72273. /**
  72274. * number of the original height of the Frame
  72275. */
  72276. h: number;
  72277. }
  72278. /**
  72279. * Defines the basic options interface of a Sprite Frame Data.
  72280. */
  72281. export interface ISpriteJSONSpriteFrameData {
  72282. /**
  72283. * number of the x offset of the Frame
  72284. */
  72285. x: number;
  72286. /**
  72287. * number of the y offset of the Frame
  72288. */
  72289. y: number;
  72290. /**
  72291. * number of the width of the Frame
  72292. */
  72293. w: number;
  72294. /**
  72295. * number of the height of the Frame
  72296. */
  72297. h: number;
  72298. }
  72299. /**
  72300. * Defines the basic options interface of a JSON Sprite.
  72301. */
  72302. export interface ISpriteJSONSprite {
  72303. /**
  72304. * string name of the Frame
  72305. */
  72306. filename: string;
  72307. /**
  72308. * ISpriteJSONSpriteFrame basic object of the frame data
  72309. */
  72310. frame: ISpriteJSONSpriteFrameData;
  72311. /**
  72312. * boolean to flag is the frame was rotated.
  72313. */
  72314. rotated: boolean;
  72315. /**
  72316. * boolean to flag is the frame was trimmed.
  72317. */
  72318. trimmed: boolean;
  72319. /**
  72320. * ISpriteJSONSpriteFrame basic object of the source data
  72321. */
  72322. spriteSourceSize: ISpriteJSONSpriteFrameData;
  72323. /**
  72324. * ISpriteJSONSpriteFrame basic object of the source data
  72325. */
  72326. sourceSize: ISpriteJSONSpriteSourceSize;
  72327. }
  72328. /**
  72329. * Defines the basic options interface of a JSON atlas.
  72330. */
  72331. export interface ISpriteJSONAtlas {
  72332. /**
  72333. * Array of objects that contain the frame data.
  72334. */
  72335. frames: Array<ISpriteJSONSprite>;
  72336. /**
  72337. * object basic object containing the sprite meta data.
  72338. */
  72339. meta?: object;
  72340. }
  72341. }
  72342. declare module "babylonjs/Shaders/spriteMap.fragment" {
  72343. /** @hidden */
  72344. export var spriteMapPixelShader: {
  72345. name: string;
  72346. shader: string;
  72347. };
  72348. }
  72349. declare module "babylonjs/Shaders/spriteMap.vertex" {
  72350. /** @hidden */
  72351. export var spriteMapVertexShader: {
  72352. name: string;
  72353. shader: string;
  72354. };
  72355. }
  72356. declare module "babylonjs/Sprites/spriteMap" {
  72357. import { IDisposable, Scene } from "babylonjs/scene";
  72358. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  72359. import { Texture } from "babylonjs/Materials/Textures/texture";
  72360. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  72361. import { ISpriteJSONSprite, ISpriteJSONAtlas } from "babylonjs/Sprites/ISprites";
  72362. import "babylonjs/Meshes/Builders/planeBuilder";
  72363. import "babylonjs/Shaders/spriteMap.fragment";
  72364. import "babylonjs/Shaders/spriteMap.vertex";
  72365. /**
  72366. * Defines the basic options interface of a SpriteMap
  72367. */
  72368. export interface ISpriteMapOptions {
  72369. /**
  72370. * Vector2 of the number of cells in the grid.
  72371. */
  72372. stageSize?: Vector2;
  72373. /**
  72374. * Vector2 of the size of the output plane in World Units.
  72375. */
  72376. outputSize?: Vector2;
  72377. /**
  72378. * Vector3 of the position of the output plane in World Units.
  72379. */
  72380. outputPosition?: Vector3;
  72381. /**
  72382. * Vector3 of the rotation of the output plane.
  72383. */
  72384. outputRotation?: Vector3;
  72385. /**
  72386. * number of layers that the system will reserve in resources.
  72387. */
  72388. layerCount?: number;
  72389. /**
  72390. * number of max animation frames a single cell will reserve in resources.
  72391. */
  72392. maxAnimationFrames?: number;
  72393. /**
  72394. * number cell index of the base tile when the system compiles.
  72395. */
  72396. baseTile?: number;
  72397. /**
  72398. * boolean flip the sprite after its been repositioned by the framing data.
  72399. */
  72400. flipU?: boolean;
  72401. /**
  72402. * Vector3 scalar of the global RGB values of the SpriteMap.
  72403. */
  72404. colorMultiply?: Vector3;
  72405. }
  72406. /**
  72407. * Defines the IDisposable interface in order to be cleanable from resources.
  72408. */
  72409. export interface ISpriteMap extends IDisposable {
  72410. /**
  72411. * String name of the SpriteMap.
  72412. */
  72413. name: string;
  72414. /**
  72415. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  72416. */
  72417. atlasJSON: ISpriteJSONAtlas;
  72418. /**
  72419. * Texture of the SpriteMap.
  72420. */
  72421. spriteSheet: Texture;
  72422. /**
  72423. * The parameters to initialize the SpriteMap with.
  72424. */
  72425. options: ISpriteMapOptions;
  72426. }
  72427. /**
  72428. * Class used to manage a grid restricted sprite deployment on an Output plane.
  72429. */
  72430. export class SpriteMap implements ISpriteMap {
  72431. /** The Name of the spriteMap */
  72432. name: string;
  72433. /** The JSON file with the frame and meta data */
  72434. atlasJSON: ISpriteJSONAtlas;
  72435. /** The systems Sprite Sheet Texture */
  72436. spriteSheet: Texture;
  72437. /** Arguments passed with the Constructor */
  72438. options: ISpriteMapOptions;
  72439. /** Public Sprite Storage array, parsed from atlasJSON */
  72440. sprites: Array<ISpriteJSONSprite>;
  72441. /** Returns the Number of Sprites in the System */
  72442. get spriteCount(): number;
  72443. /** Returns the Position of Output Plane*/
  72444. get position(): Vector3;
  72445. /** Returns the Position of Output Plane*/
  72446. set position(v: Vector3);
  72447. /** Returns the Rotation of Output Plane*/
  72448. get rotation(): Vector3;
  72449. /** Returns the Rotation of Output Plane*/
  72450. set rotation(v: Vector3);
  72451. /** Sets the AnimationMap*/
  72452. get animationMap(): RawTexture;
  72453. /** Sets the AnimationMap*/
  72454. set animationMap(v: RawTexture);
  72455. /** Scene that the SpriteMap was created in */
  72456. private _scene;
  72457. /** Texture Buffer of Float32 that holds tile frame data*/
  72458. private _frameMap;
  72459. /** Texture Buffers of Float32 that holds tileMap data*/
  72460. private _tileMaps;
  72461. /** Texture Buffer of Float32 that holds Animation Data*/
  72462. private _animationMap;
  72463. /** Custom ShaderMaterial Central to the System*/
  72464. private _material;
  72465. /** Custom ShaderMaterial Central to the System*/
  72466. private _output;
  72467. /** Systems Time Ticker*/
  72468. private _time;
  72469. /**
  72470. * Creates a new SpriteMap
  72471. * @param name defines the SpriteMaps Name
  72472. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  72473. * @param spriteSheet is the Texture that the Sprites are on.
  72474. * @param options a basic deployment configuration
  72475. * @param scene The Scene that the map is deployed on
  72476. */
  72477. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  72478. /**
  72479. * Returns tileID location
  72480. * @returns Vector2 the cell position ID
  72481. */
  72482. getTileID(): Vector2;
  72483. /**
  72484. * Gets the UV location of the mouse over the SpriteMap.
  72485. * @returns Vector2 the UV position of the mouse interaction
  72486. */
  72487. getMousePosition(): Vector2;
  72488. /**
  72489. * Creates the "frame" texture Buffer
  72490. * -------------------------------------
  72491. * Structure of frames
  72492. * "filename": "Falling-Water-2.png",
  72493. * "frame": {"x":69,"y":103,"w":24,"h":32},
  72494. * "rotated": true,
  72495. * "trimmed": true,
  72496. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  72497. * "sourceSize": {"w":32,"h":32}
  72498. * @returns RawTexture of the frameMap
  72499. */
  72500. private _createFrameBuffer;
  72501. /**
  72502. * Creates the tileMap texture Buffer
  72503. * @param buffer normally and array of numbers, or a false to generate from scratch
  72504. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  72505. * @returns RawTexture of the tileMap
  72506. */
  72507. private _createTileBuffer;
  72508. /**
  72509. * Modifies the data of the tileMaps
  72510. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  72511. * @param pos is the iVector2 Coordinates of the Tile
  72512. * @param tile The SpriteIndex of the new Tile
  72513. */
  72514. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  72515. /**
  72516. * Creates the animationMap texture Buffer
  72517. * @param buffer normally and array of numbers, or a false to generate from scratch
  72518. * @returns RawTexture of the animationMap
  72519. */
  72520. private _createTileAnimationBuffer;
  72521. /**
  72522. * Modifies the data of the animationMap
  72523. * @param cellID is the Index of the Sprite
  72524. * @param _frame is the target Animation frame
  72525. * @param toCell is the Target Index of the next frame of the animation
  72526. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  72527. * @param speed is a global scalar of the time variable on the map.
  72528. */
  72529. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  72530. /**
  72531. * Exports the .tilemaps file
  72532. */
  72533. saveTileMaps(): void;
  72534. /**
  72535. * Imports the .tilemaps file
  72536. * @param url of the .tilemaps file
  72537. */
  72538. loadTileMaps(url: string): void;
  72539. /**
  72540. * Release associated resources
  72541. */
  72542. dispose(): void;
  72543. }
  72544. }
  72545. declare module "babylonjs/Sprites/spritePackedManager" {
  72546. import { SpriteManager } from "babylonjs/Sprites/spriteManager";
  72547. import { Scene } from "babylonjs/scene";
  72548. /**
  72549. * Class used to manage multiple sprites of different sizes on the same spritesheet
  72550. * @see http://doc.babylonjs.com/babylon101/sprites
  72551. */
  72552. export class SpritePackedManager extends SpriteManager {
  72553. /** defines the packed manager's name */
  72554. name: string;
  72555. /**
  72556. * Creates a new sprite manager from a packed sprite sheet
  72557. * @param name defines the manager's name
  72558. * @param imgUrl defines the sprite sheet url
  72559. * @param capacity defines the maximum allowed number of sprites
  72560. * @param scene defines the hosting scene
  72561. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  72562. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  72563. * @param samplingMode defines the smapling mode to use with spritesheet
  72564. * @param fromPacked set to true; do not alter
  72565. */
  72566. constructor(
  72567. /** defines the packed manager's name */
  72568. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  72569. }
  72570. }
  72571. declare module "babylonjs/Sprites/index" {
  72572. export * from "babylonjs/Sprites/sprite";
  72573. export * from "babylonjs/Sprites/ISprites";
  72574. export * from "babylonjs/Sprites/spriteManager";
  72575. export * from "babylonjs/Sprites/spriteMap";
  72576. export * from "babylonjs/Sprites/spritePackedManager";
  72577. export * from "babylonjs/Sprites/spriteSceneComponent";
  72578. }
  72579. declare module "babylonjs/States/index" {
  72580. export * from "babylonjs/States/alphaCullingState";
  72581. export * from "babylonjs/States/depthCullingState";
  72582. export * from "babylonjs/States/stencilState";
  72583. }
  72584. declare module "babylonjs/Misc/assetsManager" {
  72585. import { Scene } from "babylonjs/scene";
  72586. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  72587. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  72588. import { Skeleton } from "babylonjs/Bones/skeleton";
  72589. import { Observable } from "babylonjs/Misc/observable";
  72590. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  72591. import { Texture } from "babylonjs/Materials/Textures/texture";
  72592. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  72593. import { HDRCubeTexture } from "babylonjs/Materials/Textures/hdrCubeTexture";
  72594. import { EquiRectangularCubeTexture } from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  72595. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  72596. /**
  72597. * Defines the list of states available for a task inside a AssetsManager
  72598. */
  72599. export enum AssetTaskState {
  72600. /**
  72601. * Initialization
  72602. */
  72603. INIT = 0,
  72604. /**
  72605. * Running
  72606. */
  72607. RUNNING = 1,
  72608. /**
  72609. * Done
  72610. */
  72611. DONE = 2,
  72612. /**
  72613. * Error
  72614. */
  72615. ERROR = 3
  72616. }
  72617. /**
  72618. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  72619. */
  72620. export abstract class AbstractAssetTask {
  72621. /**
  72622. * Task name
  72623. */ name: string;
  72624. /**
  72625. * Callback called when the task is successful
  72626. */
  72627. onSuccess: (task: any) => void;
  72628. /**
  72629. * Callback called when the task is not successful
  72630. */
  72631. onError: (task: any, message?: string, exception?: any) => void;
  72632. /**
  72633. * Creates a new AssetsManager
  72634. * @param name defines the name of the task
  72635. */
  72636. constructor(
  72637. /**
  72638. * Task name
  72639. */ name: string);
  72640. private _isCompleted;
  72641. private _taskState;
  72642. private _errorObject;
  72643. /**
  72644. * Get if the task is completed
  72645. */
  72646. get isCompleted(): boolean;
  72647. /**
  72648. * Gets the current state of the task
  72649. */
  72650. get taskState(): AssetTaskState;
  72651. /**
  72652. * Gets the current error object (if task is in error)
  72653. */
  72654. get errorObject(): {
  72655. message?: string;
  72656. exception?: any;
  72657. };
  72658. /**
  72659. * Internal only
  72660. * @hidden
  72661. */
  72662. _setErrorObject(message?: string, exception?: any): void;
  72663. /**
  72664. * Execute the current task
  72665. * @param scene defines the scene where you want your assets to be loaded
  72666. * @param onSuccess is a callback called when the task is successfully executed
  72667. * @param onError is a callback called if an error occurs
  72668. */
  72669. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  72670. /**
  72671. * Execute the current task
  72672. * @param scene defines the scene where you want your assets to be loaded
  72673. * @param onSuccess is a callback called when the task is successfully executed
  72674. * @param onError is a callback called if an error occurs
  72675. */
  72676. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  72677. /**
  72678. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  72679. * This can be used with failed tasks that have the reason for failure fixed.
  72680. */
  72681. reset(): void;
  72682. private onErrorCallback;
  72683. private onDoneCallback;
  72684. }
  72685. /**
  72686. * Define the interface used by progress events raised during assets loading
  72687. */
  72688. export interface IAssetsProgressEvent {
  72689. /**
  72690. * Defines the number of remaining tasks to process
  72691. */
  72692. remainingCount: number;
  72693. /**
  72694. * Defines the total number of tasks
  72695. */
  72696. totalCount: number;
  72697. /**
  72698. * Defines the task that was just processed
  72699. */
  72700. task: AbstractAssetTask;
  72701. }
  72702. /**
  72703. * Class used to share progress information about assets loading
  72704. */
  72705. export class AssetsProgressEvent implements IAssetsProgressEvent {
  72706. /**
  72707. * Defines the number of remaining tasks to process
  72708. */
  72709. remainingCount: number;
  72710. /**
  72711. * Defines the total number of tasks
  72712. */
  72713. totalCount: number;
  72714. /**
  72715. * Defines the task that was just processed
  72716. */
  72717. task: AbstractAssetTask;
  72718. /**
  72719. * Creates a AssetsProgressEvent
  72720. * @param remainingCount defines the number of remaining tasks to process
  72721. * @param totalCount defines the total number of tasks
  72722. * @param task defines the task that was just processed
  72723. */
  72724. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  72725. }
  72726. /**
  72727. * Define a task used by AssetsManager to load meshes
  72728. */
  72729. export class MeshAssetTask extends AbstractAssetTask {
  72730. /**
  72731. * Defines the name of the task
  72732. */
  72733. name: string;
  72734. /**
  72735. * Defines the list of mesh's names you want to load
  72736. */
  72737. meshesNames: any;
  72738. /**
  72739. * Defines the root url to use as a base to load your meshes and associated resources
  72740. */
  72741. rootUrl: string;
  72742. /**
  72743. * Defines the filename of the scene to load from
  72744. */
  72745. sceneFilename: string;
  72746. /**
  72747. * Gets the list of loaded meshes
  72748. */
  72749. loadedMeshes: Array<AbstractMesh>;
  72750. /**
  72751. * Gets the list of loaded particle systems
  72752. */
  72753. loadedParticleSystems: Array<IParticleSystem>;
  72754. /**
  72755. * Gets the list of loaded skeletons
  72756. */
  72757. loadedSkeletons: Array<Skeleton>;
  72758. /**
  72759. * Gets the list of loaded animation groups
  72760. */
  72761. loadedAnimationGroups: Array<AnimationGroup>;
  72762. /**
  72763. * Callback called when the task is successful
  72764. */
  72765. onSuccess: (task: MeshAssetTask) => void;
  72766. /**
  72767. * Callback called when the task is successful
  72768. */
  72769. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  72770. /**
  72771. * Creates a new MeshAssetTask
  72772. * @param name defines the name of the task
  72773. * @param meshesNames defines the list of mesh's names you want to load
  72774. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  72775. * @param sceneFilename defines the filename of the scene to load from
  72776. */
  72777. constructor(
  72778. /**
  72779. * Defines the name of the task
  72780. */
  72781. name: string,
  72782. /**
  72783. * Defines the list of mesh's names you want to load
  72784. */
  72785. meshesNames: any,
  72786. /**
  72787. * Defines the root url to use as a base to load your meshes and associated resources
  72788. */
  72789. rootUrl: string,
  72790. /**
  72791. * Defines the filename of the scene to load from
  72792. */
  72793. sceneFilename: string);
  72794. /**
  72795. * Execute the current task
  72796. * @param scene defines the scene where you want your assets to be loaded
  72797. * @param onSuccess is a callback called when the task is successfully executed
  72798. * @param onError is a callback called if an error occurs
  72799. */
  72800. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  72801. }
  72802. /**
  72803. * Define a task used by AssetsManager to load text content
  72804. */
  72805. export class TextFileAssetTask extends AbstractAssetTask {
  72806. /**
  72807. * Defines the name of the task
  72808. */
  72809. name: string;
  72810. /**
  72811. * Defines the location of the file to load
  72812. */
  72813. url: string;
  72814. /**
  72815. * Gets the loaded text string
  72816. */
  72817. text: string;
  72818. /**
  72819. * Callback called when the task is successful
  72820. */
  72821. onSuccess: (task: TextFileAssetTask) => void;
  72822. /**
  72823. * Callback called when the task is successful
  72824. */
  72825. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  72826. /**
  72827. * Creates a new TextFileAssetTask object
  72828. * @param name defines the name of the task
  72829. * @param url defines the location of the file to load
  72830. */
  72831. constructor(
  72832. /**
  72833. * Defines the name of the task
  72834. */
  72835. name: string,
  72836. /**
  72837. * Defines the location of the file to load
  72838. */
  72839. url: string);
  72840. /**
  72841. * Execute the current task
  72842. * @param scene defines the scene where you want your assets to be loaded
  72843. * @param onSuccess is a callback called when the task is successfully executed
  72844. * @param onError is a callback called if an error occurs
  72845. */
  72846. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  72847. }
  72848. /**
  72849. * Define a task used by AssetsManager to load binary data
  72850. */
  72851. export class BinaryFileAssetTask extends AbstractAssetTask {
  72852. /**
  72853. * Defines the name of the task
  72854. */
  72855. name: string;
  72856. /**
  72857. * Defines the location of the file to load
  72858. */
  72859. url: string;
  72860. /**
  72861. * Gets the lodaded data (as an array buffer)
  72862. */
  72863. data: ArrayBuffer;
  72864. /**
  72865. * Callback called when the task is successful
  72866. */
  72867. onSuccess: (task: BinaryFileAssetTask) => void;
  72868. /**
  72869. * Callback called when the task is successful
  72870. */
  72871. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  72872. /**
  72873. * Creates a new BinaryFileAssetTask object
  72874. * @param name defines the name of the new task
  72875. * @param url defines the location of the file to load
  72876. */
  72877. constructor(
  72878. /**
  72879. * Defines the name of the task
  72880. */
  72881. name: string,
  72882. /**
  72883. * Defines the location of the file to load
  72884. */
  72885. url: string);
  72886. /**
  72887. * Execute the current task
  72888. * @param scene defines the scene where you want your assets to be loaded
  72889. * @param onSuccess is a callback called when the task is successfully executed
  72890. * @param onError is a callback called if an error occurs
  72891. */
  72892. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  72893. }
  72894. /**
  72895. * Define a task used by AssetsManager to load images
  72896. */
  72897. export class ImageAssetTask extends AbstractAssetTask {
  72898. /**
  72899. * Defines the name of the task
  72900. */
  72901. name: string;
  72902. /**
  72903. * Defines the location of the image to load
  72904. */
  72905. url: string;
  72906. /**
  72907. * Gets the loaded images
  72908. */
  72909. image: HTMLImageElement;
  72910. /**
  72911. * Callback called when the task is successful
  72912. */
  72913. onSuccess: (task: ImageAssetTask) => void;
  72914. /**
  72915. * Callback called when the task is successful
  72916. */
  72917. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  72918. /**
  72919. * Creates a new ImageAssetTask
  72920. * @param name defines the name of the task
  72921. * @param url defines the location of the image to load
  72922. */
  72923. constructor(
  72924. /**
  72925. * Defines the name of the task
  72926. */
  72927. name: string,
  72928. /**
  72929. * Defines the location of the image to load
  72930. */
  72931. url: string);
  72932. /**
  72933. * Execute the current task
  72934. * @param scene defines the scene where you want your assets to be loaded
  72935. * @param onSuccess is a callback called when the task is successfully executed
  72936. * @param onError is a callback called if an error occurs
  72937. */
  72938. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  72939. }
  72940. /**
  72941. * Defines the interface used by texture loading tasks
  72942. */
  72943. export interface ITextureAssetTask<TEX extends BaseTexture> {
  72944. /**
  72945. * Gets the loaded texture
  72946. */
  72947. texture: TEX;
  72948. }
  72949. /**
  72950. * Define a task used by AssetsManager to load 2D textures
  72951. */
  72952. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  72953. /**
  72954. * Defines the name of the task
  72955. */
  72956. name: string;
  72957. /**
  72958. * Defines the location of the file to load
  72959. */
  72960. url: string;
  72961. /**
  72962. * Defines if mipmap should not be generated (default is false)
  72963. */
  72964. noMipmap?: boolean | undefined;
  72965. /**
  72966. * Defines if texture must be inverted on Y axis (default is true)
  72967. */
  72968. invertY: boolean;
  72969. /**
  72970. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  72971. */
  72972. samplingMode: number;
  72973. /**
  72974. * Gets the loaded texture
  72975. */
  72976. texture: Texture;
  72977. /**
  72978. * Callback called when the task is successful
  72979. */
  72980. onSuccess: (task: TextureAssetTask) => void;
  72981. /**
  72982. * Callback called when the task is successful
  72983. */
  72984. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  72985. /**
  72986. * Creates a new TextureAssetTask object
  72987. * @param name defines the name of the task
  72988. * @param url defines the location of the file to load
  72989. * @param noMipmap defines if mipmap should not be generated (default is false)
  72990. * @param invertY defines if texture must be inverted on Y axis (default is true)
  72991. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  72992. */
  72993. constructor(
  72994. /**
  72995. * Defines the name of the task
  72996. */
  72997. name: string,
  72998. /**
  72999. * Defines the location of the file to load
  73000. */
  73001. url: string,
  73002. /**
  73003. * Defines if mipmap should not be generated (default is false)
  73004. */
  73005. noMipmap?: boolean | undefined,
  73006. /**
  73007. * Defines if texture must be inverted on Y axis (default is true)
  73008. */
  73009. invertY?: boolean,
  73010. /**
  73011. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  73012. */
  73013. samplingMode?: number);
  73014. /**
  73015. * Execute the current task
  73016. * @param scene defines the scene where you want your assets to be loaded
  73017. * @param onSuccess is a callback called when the task is successfully executed
  73018. * @param onError is a callback called if an error occurs
  73019. */
  73020. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  73021. }
  73022. /**
  73023. * Define a task used by AssetsManager to load cube textures
  73024. */
  73025. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  73026. /**
  73027. * Defines the name of the task
  73028. */
  73029. name: string;
  73030. /**
  73031. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  73032. */
  73033. url: string;
  73034. /**
  73035. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  73036. */
  73037. extensions?: string[] | undefined;
  73038. /**
  73039. * Defines if mipmaps should not be generated (default is false)
  73040. */
  73041. noMipmap?: boolean | undefined;
  73042. /**
  73043. * Defines the explicit list of files (undefined by default)
  73044. */
  73045. files?: string[] | undefined;
  73046. /**
  73047. * Gets the loaded texture
  73048. */
  73049. texture: CubeTexture;
  73050. /**
  73051. * Callback called when the task is successful
  73052. */
  73053. onSuccess: (task: CubeTextureAssetTask) => void;
  73054. /**
  73055. * Callback called when the task is successful
  73056. */
  73057. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  73058. /**
  73059. * Creates a new CubeTextureAssetTask
  73060. * @param name defines the name of the task
  73061. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  73062. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  73063. * @param noMipmap defines if mipmaps should not be generated (default is false)
  73064. * @param files defines the explicit list of files (undefined by default)
  73065. */
  73066. constructor(
  73067. /**
  73068. * Defines the name of the task
  73069. */
  73070. name: string,
  73071. /**
  73072. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  73073. */
  73074. url: string,
  73075. /**
  73076. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  73077. */
  73078. extensions?: string[] | undefined,
  73079. /**
  73080. * Defines if mipmaps should not be generated (default is false)
  73081. */
  73082. noMipmap?: boolean | undefined,
  73083. /**
  73084. * Defines the explicit list of files (undefined by default)
  73085. */
  73086. files?: string[] | undefined);
  73087. /**
  73088. * Execute the current task
  73089. * @param scene defines the scene where you want your assets to be loaded
  73090. * @param onSuccess is a callback called when the task is successfully executed
  73091. * @param onError is a callback called if an error occurs
  73092. */
  73093. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  73094. }
  73095. /**
  73096. * Define a task used by AssetsManager to load HDR cube textures
  73097. */
  73098. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  73099. /**
  73100. * Defines the name of the task
  73101. */
  73102. name: string;
  73103. /**
  73104. * Defines the location of the file to load
  73105. */
  73106. url: string;
  73107. /**
  73108. * Defines the desired size (the more it increases the longer the generation will be)
  73109. */
  73110. size: number;
  73111. /**
  73112. * Defines if mipmaps should not be generated (default is false)
  73113. */
  73114. noMipmap: boolean;
  73115. /**
  73116. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  73117. */
  73118. generateHarmonics: boolean;
  73119. /**
  73120. * 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)
  73121. */
  73122. gammaSpace: boolean;
  73123. /**
  73124. * Internal Use Only
  73125. */
  73126. reserved: boolean;
  73127. /**
  73128. * Gets the loaded texture
  73129. */
  73130. texture: HDRCubeTexture;
  73131. /**
  73132. * Callback called when the task is successful
  73133. */
  73134. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  73135. /**
  73136. * Callback called when the task is successful
  73137. */
  73138. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  73139. /**
  73140. * Creates a new HDRCubeTextureAssetTask object
  73141. * @param name defines the name of the task
  73142. * @param url defines the location of the file to load
  73143. * @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.
  73144. * @param noMipmap defines if mipmaps should not be generated (default is false)
  73145. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  73146. * @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)
  73147. * @param reserved Internal use only
  73148. */
  73149. constructor(
  73150. /**
  73151. * Defines the name of the task
  73152. */
  73153. name: string,
  73154. /**
  73155. * Defines the location of the file to load
  73156. */
  73157. url: string,
  73158. /**
  73159. * Defines the desired size (the more it increases the longer the generation will be)
  73160. */
  73161. size: number,
  73162. /**
  73163. * Defines if mipmaps should not be generated (default is false)
  73164. */
  73165. noMipmap?: boolean,
  73166. /**
  73167. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  73168. */
  73169. generateHarmonics?: boolean,
  73170. /**
  73171. * 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)
  73172. */
  73173. gammaSpace?: boolean,
  73174. /**
  73175. * Internal Use Only
  73176. */
  73177. reserved?: boolean);
  73178. /**
  73179. * Execute the current task
  73180. * @param scene defines the scene where you want your assets to be loaded
  73181. * @param onSuccess is a callback called when the task is successfully executed
  73182. * @param onError is a callback called if an error occurs
  73183. */
  73184. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  73185. }
  73186. /**
  73187. * Define a task used by AssetsManager to load Equirectangular cube textures
  73188. */
  73189. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  73190. /**
  73191. * Defines the name of the task
  73192. */
  73193. name: string;
  73194. /**
  73195. * Defines the location of the file to load
  73196. */
  73197. url: string;
  73198. /**
  73199. * Defines the desired size (the more it increases the longer the generation will be)
  73200. */
  73201. size: number;
  73202. /**
  73203. * Defines if mipmaps should not be generated (default is false)
  73204. */
  73205. noMipmap: boolean;
  73206. /**
  73207. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  73208. * but the standard material would require them in Gamma space) (default is true)
  73209. */
  73210. gammaSpace: boolean;
  73211. /**
  73212. * Gets the loaded texture
  73213. */
  73214. texture: EquiRectangularCubeTexture;
  73215. /**
  73216. * Callback called when the task is successful
  73217. */
  73218. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  73219. /**
  73220. * Callback called when the task is successful
  73221. */
  73222. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  73223. /**
  73224. * Creates a new EquiRectangularCubeTextureAssetTask object
  73225. * @param name defines the name of the task
  73226. * @param url defines the location of the file to load
  73227. * @param size defines the desired size (the more it increases the longer the generation will be)
  73228. * If the size is omitted this implies you are using a preprocessed cubemap.
  73229. * @param noMipmap defines if mipmaps should not be generated (default is false)
  73230. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  73231. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  73232. * (default is true)
  73233. */
  73234. constructor(
  73235. /**
  73236. * Defines the name of the task
  73237. */
  73238. name: string,
  73239. /**
  73240. * Defines the location of the file to load
  73241. */
  73242. url: string,
  73243. /**
  73244. * Defines the desired size (the more it increases the longer the generation will be)
  73245. */
  73246. size: number,
  73247. /**
  73248. * Defines if mipmaps should not be generated (default is false)
  73249. */
  73250. noMipmap?: boolean,
  73251. /**
  73252. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  73253. * but the standard material would require them in Gamma space) (default is true)
  73254. */
  73255. gammaSpace?: boolean);
  73256. /**
  73257. * Execute the current task
  73258. * @param scene defines the scene where you want your assets to be loaded
  73259. * @param onSuccess is a callback called when the task is successfully executed
  73260. * @param onError is a callback called if an error occurs
  73261. */
  73262. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  73263. }
  73264. /**
  73265. * This class can be used to easily import assets into a scene
  73266. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  73267. */
  73268. export class AssetsManager {
  73269. private _scene;
  73270. private _isLoading;
  73271. protected _tasks: AbstractAssetTask[];
  73272. protected _waitingTasksCount: number;
  73273. protected _totalTasksCount: number;
  73274. /**
  73275. * Callback called when all tasks are processed
  73276. */
  73277. onFinish: (tasks: AbstractAssetTask[]) => void;
  73278. /**
  73279. * Callback called when a task is successful
  73280. */
  73281. onTaskSuccess: (task: AbstractAssetTask) => void;
  73282. /**
  73283. * Callback called when a task had an error
  73284. */
  73285. onTaskError: (task: AbstractAssetTask) => void;
  73286. /**
  73287. * Callback called when a task is done (whatever the result is)
  73288. */
  73289. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  73290. /**
  73291. * Observable called when all tasks are processed
  73292. */
  73293. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  73294. /**
  73295. * Observable called when a task had an error
  73296. */
  73297. onTaskErrorObservable: Observable<AbstractAssetTask>;
  73298. /**
  73299. * Observable called when all tasks were executed
  73300. */
  73301. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  73302. /**
  73303. * Observable called when a task is done (whatever the result is)
  73304. */
  73305. onProgressObservable: Observable<IAssetsProgressEvent>;
  73306. /**
  73307. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  73308. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  73309. */
  73310. useDefaultLoadingScreen: boolean;
  73311. /**
  73312. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  73313. * when all assets have been downloaded.
  73314. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  73315. */
  73316. autoHideLoadingUI: boolean;
  73317. /**
  73318. * Creates a new AssetsManager
  73319. * @param scene defines the scene to work on
  73320. */
  73321. constructor(scene: Scene);
  73322. /**
  73323. * Add a MeshAssetTask to the list of active tasks
  73324. * @param taskName defines the name of the new task
  73325. * @param meshesNames defines the name of meshes to load
  73326. * @param rootUrl defines the root url to use to locate files
  73327. * @param sceneFilename defines the filename of the scene file
  73328. * @returns a new MeshAssetTask object
  73329. */
  73330. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  73331. /**
  73332. * Add a TextFileAssetTask to the list of active tasks
  73333. * @param taskName defines the name of the new task
  73334. * @param url defines the url of the file to load
  73335. * @returns a new TextFileAssetTask object
  73336. */
  73337. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  73338. /**
  73339. * Add a BinaryFileAssetTask to the list of active tasks
  73340. * @param taskName defines the name of the new task
  73341. * @param url defines the url of the file to load
  73342. * @returns a new BinaryFileAssetTask object
  73343. */
  73344. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  73345. /**
  73346. * Add a ImageAssetTask to the list of active tasks
  73347. * @param taskName defines the name of the new task
  73348. * @param url defines the url of the file to load
  73349. * @returns a new ImageAssetTask object
  73350. */
  73351. addImageTask(taskName: string, url: string): ImageAssetTask;
  73352. /**
  73353. * Add a TextureAssetTask to the list of active tasks
  73354. * @param taskName defines the name of the new task
  73355. * @param url defines the url of the file to load
  73356. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  73357. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  73358. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  73359. * @returns a new TextureAssetTask object
  73360. */
  73361. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  73362. /**
  73363. * Add a CubeTextureAssetTask to the list of active tasks
  73364. * @param taskName defines the name of the new task
  73365. * @param url defines the url of the file to load
  73366. * @param extensions defines the extension to use to load the cube map (can be null)
  73367. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  73368. * @param files defines the list of files to load (can be null)
  73369. * @returns a new CubeTextureAssetTask object
  73370. */
  73371. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  73372. /**
  73373. *
  73374. * Add a HDRCubeTextureAssetTask to the list of active tasks
  73375. * @param taskName defines the name of the new task
  73376. * @param url defines the url of the file to load
  73377. * @param size defines the size you want for the cubemap (can be null)
  73378. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  73379. * @param generateHarmonics defines if you want to automatically generate (true by default)
  73380. * @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)
  73381. * @param reserved Internal use only
  73382. * @returns a new HDRCubeTextureAssetTask object
  73383. */
  73384. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  73385. /**
  73386. *
  73387. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  73388. * @param taskName defines the name of the new task
  73389. * @param url defines the url of the file to load
  73390. * @param size defines the size you want for the cubemap (can be null)
  73391. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  73392. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  73393. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  73394. * @returns a new EquiRectangularCubeTextureAssetTask object
  73395. */
  73396. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  73397. /**
  73398. * Remove a task from the assets manager.
  73399. * @param task the task to remove
  73400. */
  73401. removeTask(task: AbstractAssetTask): void;
  73402. private _decreaseWaitingTasksCount;
  73403. private _runTask;
  73404. /**
  73405. * Reset the AssetsManager and remove all tasks
  73406. * @return the current instance of the AssetsManager
  73407. */
  73408. reset(): AssetsManager;
  73409. /**
  73410. * Start the loading process
  73411. * @return the current instance of the AssetsManager
  73412. */
  73413. load(): AssetsManager;
  73414. /**
  73415. * Start the loading process as an async operation
  73416. * @return a promise returning the list of failed tasks
  73417. */
  73418. loadAsync(): Promise<void>;
  73419. }
  73420. }
  73421. declare module "babylonjs/Misc/deferred" {
  73422. /**
  73423. * Wrapper class for promise with external resolve and reject.
  73424. */
  73425. export class Deferred<T> {
  73426. /**
  73427. * The promise associated with this deferred object.
  73428. */
  73429. readonly promise: Promise<T>;
  73430. private _resolve;
  73431. private _reject;
  73432. /**
  73433. * The resolve method of the promise associated with this deferred object.
  73434. */
  73435. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  73436. /**
  73437. * The reject method of the promise associated with this deferred object.
  73438. */
  73439. get reject(): (reason?: any) => void;
  73440. /**
  73441. * Constructor for this deferred object.
  73442. */
  73443. constructor();
  73444. }
  73445. }
  73446. declare module "babylonjs/Misc/meshExploder" {
  73447. import { Mesh } from "babylonjs/Meshes/mesh";
  73448. /**
  73449. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  73450. */
  73451. export class MeshExploder {
  73452. private _centerMesh;
  73453. private _meshes;
  73454. private _meshesOrigins;
  73455. private _toCenterVectors;
  73456. private _scaledDirection;
  73457. private _newPosition;
  73458. private _centerPosition;
  73459. /**
  73460. * Explodes meshes from a center mesh.
  73461. * @param meshes The meshes to explode.
  73462. * @param centerMesh The mesh to be center of explosion.
  73463. */
  73464. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  73465. private _setCenterMesh;
  73466. /**
  73467. * Get class name
  73468. * @returns "MeshExploder"
  73469. */
  73470. getClassName(): string;
  73471. /**
  73472. * "Exploded meshes"
  73473. * @returns Array of meshes with the centerMesh at index 0.
  73474. */
  73475. getMeshes(): Array<Mesh>;
  73476. /**
  73477. * Explodes meshes giving a specific direction
  73478. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  73479. */
  73480. explode(direction?: number): void;
  73481. }
  73482. }
  73483. declare module "babylonjs/Misc/filesInput" {
  73484. import { Engine } from "babylonjs/Engines/engine";
  73485. import { Scene } from "babylonjs/scene";
  73486. import { SceneLoaderProgressEvent } from "babylonjs/Loading/sceneLoader";
  73487. /**
  73488. * Class used to help managing file picking and drag'n'drop
  73489. */
  73490. export class FilesInput {
  73491. /**
  73492. * List of files ready to be loaded
  73493. */
  73494. static get FilesToLoad(): {
  73495. [key: string]: File;
  73496. };
  73497. /**
  73498. * Callback called when a file is processed
  73499. */
  73500. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  73501. private _engine;
  73502. private _currentScene;
  73503. private _sceneLoadedCallback;
  73504. private _progressCallback;
  73505. private _additionalRenderLoopLogicCallback;
  73506. private _textureLoadingCallback;
  73507. private _startingProcessingFilesCallback;
  73508. private _onReloadCallback;
  73509. private _errorCallback;
  73510. private _elementToMonitor;
  73511. private _sceneFileToLoad;
  73512. private _filesToLoad;
  73513. /**
  73514. * Creates a new FilesInput
  73515. * @param engine defines the rendering engine
  73516. * @param scene defines the hosting scene
  73517. * @param sceneLoadedCallback callback called when scene is loaded
  73518. * @param progressCallback callback called to track progress
  73519. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  73520. * @param textureLoadingCallback callback called when a texture is loading
  73521. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  73522. * @param onReloadCallback callback called when a reload is requested
  73523. * @param errorCallback callback call if an error occurs
  73524. */
  73525. 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);
  73526. private _dragEnterHandler;
  73527. private _dragOverHandler;
  73528. private _dropHandler;
  73529. /**
  73530. * Calls this function to listen to drag'n'drop events on a specific DOM element
  73531. * @param elementToMonitor defines the DOM element to track
  73532. */
  73533. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  73534. /**
  73535. * Release all associated resources
  73536. */
  73537. dispose(): void;
  73538. private renderFunction;
  73539. private drag;
  73540. private drop;
  73541. private _traverseFolder;
  73542. private _processFiles;
  73543. /**
  73544. * Load files from a drop event
  73545. * @param event defines the drop event to use as source
  73546. */
  73547. loadFiles(event: any): void;
  73548. private _processReload;
  73549. /**
  73550. * Reload the current scene from the loaded files
  73551. */
  73552. reload(): void;
  73553. }
  73554. }
  73555. declare module "babylonjs/Misc/HighDynamicRange/index" {
  73556. export * from "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial";
  73557. export * from "babylonjs/Misc/HighDynamicRange/hdr";
  73558. export * from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  73559. }
  73560. declare module "babylonjs/Misc/sceneOptimizer" {
  73561. import { Scene, IDisposable } from "babylonjs/scene";
  73562. import { Observable } from "babylonjs/Misc/observable";
  73563. /**
  73564. * Defines the root class used to create scene optimization to use with SceneOptimizer
  73565. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  73566. */
  73567. export class SceneOptimization {
  73568. /**
  73569. * Defines the priority of this optimization (0 by default which means first in the list)
  73570. */
  73571. priority: number;
  73572. /**
  73573. * Gets a string describing the action executed by the current optimization
  73574. * @returns description string
  73575. */
  73576. getDescription(): string;
  73577. /**
  73578. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  73579. * @param scene defines the current scene where to apply this optimization
  73580. * @param optimizer defines the current optimizer
  73581. * @returns true if everything that can be done was applied
  73582. */
  73583. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  73584. /**
  73585. * Creates the SceneOptimization object
  73586. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  73587. * @param desc defines the description associated with the optimization
  73588. */
  73589. constructor(
  73590. /**
  73591. * Defines the priority of this optimization (0 by default which means first in the list)
  73592. */
  73593. priority?: number);
  73594. }
  73595. /**
  73596. * Defines an optimization used to reduce the size of render target textures
  73597. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  73598. */
  73599. export class TextureOptimization extends SceneOptimization {
  73600. /**
  73601. * Defines the priority of this optimization (0 by default which means first in the list)
  73602. */
  73603. priority: number;
  73604. /**
  73605. * 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
  73606. */
  73607. maximumSize: number;
  73608. /**
  73609. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  73610. */
  73611. step: number;
  73612. /**
  73613. * Gets a string describing the action executed by the current optimization
  73614. * @returns description string
  73615. */
  73616. getDescription(): string;
  73617. /**
  73618. * Creates the TextureOptimization object
  73619. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  73620. * @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
  73621. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  73622. */
  73623. constructor(
  73624. /**
  73625. * Defines the priority of this optimization (0 by default which means first in the list)
  73626. */
  73627. priority?: number,
  73628. /**
  73629. * 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
  73630. */
  73631. maximumSize?: number,
  73632. /**
  73633. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  73634. */
  73635. step?: number);
  73636. /**
  73637. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  73638. * @param scene defines the current scene where to apply this optimization
  73639. * @param optimizer defines the current optimizer
  73640. * @returns true if everything that can be done was applied
  73641. */
  73642. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  73643. }
  73644. /**
  73645. * Defines an optimization used to increase or decrease the rendering resolution
  73646. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  73647. */
  73648. export class HardwareScalingOptimization extends SceneOptimization {
  73649. /**
  73650. * Defines the priority of this optimization (0 by default which means first in the list)
  73651. */
  73652. priority: number;
  73653. /**
  73654. * Defines the maximum scale to use (2 by default)
  73655. */
  73656. maximumScale: number;
  73657. /**
  73658. * Defines the step to use between two passes (0.5 by default)
  73659. */
  73660. step: number;
  73661. private _currentScale;
  73662. private _directionOffset;
  73663. /**
  73664. * Gets a string describing the action executed by the current optimization
  73665. * @return description string
  73666. */
  73667. getDescription(): string;
  73668. /**
  73669. * Creates the HardwareScalingOptimization object
  73670. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  73671. * @param maximumScale defines the maximum scale to use (2 by default)
  73672. * @param step defines the step to use between two passes (0.5 by default)
  73673. */
  73674. constructor(
  73675. /**
  73676. * Defines the priority of this optimization (0 by default which means first in the list)
  73677. */
  73678. priority?: number,
  73679. /**
  73680. * Defines the maximum scale to use (2 by default)
  73681. */
  73682. maximumScale?: number,
  73683. /**
  73684. * Defines the step to use between two passes (0.5 by default)
  73685. */
  73686. step?: number);
  73687. /**
  73688. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  73689. * @param scene defines the current scene where to apply this optimization
  73690. * @param optimizer defines the current optimizer
  73691. * @returns true if everything that can be done was applied
  73692. */
  73693. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  73694. }
  73695. /**
  73696. * Defines an optimization used to remove shadows
  73697. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  73698. */
  73699. export class ShadowsOptimization extends SceneOptimization {
  73700. /**
  73701. * Gets a string describing the action executed by the current optimization
  73702. * @return description string
  73703. */
  73704. getDescription(): string;
  73705. /**
  73706. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  73707. * @param scene defines the current scene where to apply this optimization
  73708. * @param optimizer defines the current optimizer
  73709. * @returns true if everything that can be done was applied
  73710. */
  73711. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  73712. }
  73713. /**
  73714. * Defines an optimization used to turn post-processes off
  73715. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  73716. */
  73717. export class PostProcessesOptimization extends SceneOptimization {
  73718. /**
  73719. * Gets a string describing the action executed by the current optimization
  73720. * @return description string
  73721. */
  73722. getDescription(): string;
  73723. /**
  73724. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  73725. * @param scene defines the current scene where to apply this optimization
  73726. * @param optimizer defines the current optimizer
  73727. * @returns true if everything that can be done was applied
  73728. */
  73729. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  73730. }
  73731. /**
  73732. * Defines an optimization used to turn lens flares off
  73733. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  73734. */
  73735. export class LensFlaresOptimization extends SceneOptimization {
  73736. /**
  73737. * Gets a string describing the action executed by the current optimization
  73738. * @return description string
  73739. */
  73740. getDescription(): string;
  73741. /**
  73742. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  73743. * @param scene defines the current scene where to apply this optimization
  73744. * @param optimizer defines the current optimizer
  73745. * @returns true if everything that can be done was applied
  73746. */
  73747. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  73748. }
  73749. /**
  73750. * Defines an optimization based on user defined callback.
  73751. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  73752. */
  73753. export class CustomOptimization extends SceneOptimization {
  73754. /**
  73755. * Callback called to apply the custom optimization.
  73756. */
  73757. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  73758. /**
  73759. * Callback called to get custom description
  73760. */
  73761. onGetDescription: () => string;
  73762. /**
  73763. * Gets a string describing the action executed by the current optimization
  73764. * @returns description string
  73765. */
  73766. getDescription(): string;
  73767. /**
  73768. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  73769. * @param scene defines the current scene where to apply this optimization
  73770. * @param optimizer defines the current optimizer
  73771. * @returns true if everything that can be done was applied
  73772. */
  73773. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  73774. }
  73775. /**
  73776. * Defines an optimization used to turn particles off
  73777. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  73778. */
  73779. export class ParticlesOptimization extends SceneOptimization {
  73780. /**
  73781. * Gets a string describing the action executed by the current optimization
  73782. * @return description string
  73783. */
  73784. getDescription(): string;
  73785. /**
  73786. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  73787. * @param scene defines the current scene where to apply this optimization
  73788. * @param optimizer defines the current optimizer
  73789. * @returns true if everything that can be done was applied
  73790. */
  73791. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  73792. }
  73793. /**
  73794. * Defines an optimization used to turn render targets off
  73795. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  73796. */
  73797. export class RenderTargetsOptimization extends SceneOptimization {
  73798. /**
  73799. * Gets a string describing the action executed by the current optimization
  73800. * @return description string
  73801. */
  73802. getDescription(): string;
  73803. /**
  73804. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  73805. * @param scene defines the current scene where to apply this optimization
  73806. * @param optimizer defines the current optimizer
  73807. * @returns true if everything that can be done was applied
  73808. */
  73809. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  73810. }
  73811. /**
  73812. * Defines an optimization used to merge meshes with compatible materials
  73813. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  73814. */
  73815. export class MergeMeshesOptimization extends SceneOptimization {
  73816. private static _UpdateSelectionTree;
  73817. /**
  73818. * Gets or sets a boolean which defines if optimization octree has to be updated
  73819. */
  73820. static get UpdateSelectionTree(): boolean;
  73821. /**
  73822. * Gets or sets a boolean which defines if optimization octree has to be updated
  73823. */
  73824. static set UpdateSelectionTree(value: boolean);
  73825. /**
  73826. * Gets a string describing the action executed by the current optimization
  73827. * @return description string
  73828. */
  73829. getDescription(): string;
  73830. private _canBeMerged;
  73831. /**
  73832. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  73833. * @param scene defines the current scene where to apply this optimization
  73834. * @param optimizer defines the current optimizer
  73835. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  73836. * @returns true if everything that can be done was applied
  73837. */
  73838. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  73839. }
  73840. /**
  73841. * Defines a list of options used by SceneOptimizer
  73842. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  73843. */
  73844. export class SceneOptimizerOptions {
  73845. /**
  73846. * Defines the target frame rate to reach (60 by default)
  73847. */
  73848. targetFrameRate: number;
  73849. /**
  73850. * Defines the interval between two checkes (2000ms by default)
  73851. */
  73852. trackerDuration: number;
  73853. /**
  73854. * Gets the list of optimizations to apply
  73855. */
  73856. optimizations: SceneOptimization[];
  73857. /**
  73858. * Creates a new list of options used by SceneOptimizer
  73859. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  73860. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  73861. */
  73862. constructor(
  73863. /**
  73864. * Defines the target frame rate to reach (60 by default)
  73865. */
  73866. targetFrameRate?: number,
  73867. /**
  73868. * Defines the interval between two checkes (2000ms by default)
  73869. */
  73870. trackerDuration?: number);
  73871. /**
  73872. * Add a new optimization
  73873. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  73874. * @returns the current SceneOptimizerOptions
  73875. */
  73876. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  73877. /**
  73878. * Add a new custom optimization
  73879. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  73880. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  73881. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  73882. * @returns the current SceneOptimizerOptions
  73883. */
  73884. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  73885. /**
  73886. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  73887. * @param targetFrameRate defines the target frame rate (60 by default)
  73888. * @returns a SceneOptimizerOptions object
  73889. */
  73890. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  73891. /**
  73892. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  73893. * @param targetFrameRate defines the target frame rate (60 by default)
  73894. * @returns a SceneOptimizerOptions object
  73895. */
  73896. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  73897. /**
  73898. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  73899. * @param targetFrameRate defines the target frame rate (60 by default)
  73900. * @returns a SceneOptimizerOptions object
  73901. */
  73902. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  73903. }
  73904. /**
  73905. * Class used to run optimizations in order to reach a target frame rate
  73906. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  73907. */
  73908. export class SceneOptimizer implements IDisposable {
  73909. private _isRunning;
  73910. private _options;
  73911. private _scene;
  73912. private _currentPriorityLevel;
  73913. private _targetFrameRate;
  73914. private _trackerDuration;
  73915. private _currentFrameRate;
  73916. private _sceneDisposeObserver;
  73917. private _improvementMode;
  73918. /**
  73919. * Defines an observable called when the optimizer reaches the target frame rate
  73920. */
  73921. onSuccessObservable: Observable<SceneOptimizer>;
  73922. /**
  73923. * Defines an observable called when the optimizer enables an optimization
  73924. */
  73925. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  73926. /**
  73927. * Defines an observable called when the optimizer is not able to reach the target frame rate
  73928. */
  73929. onFailureObservable: Observable<SceneOptimizer>;
  73930. /**
  73931. * Gets a boolean indicating if the optimizer is in improvement mode
  73932. */
  73933. get isInImprovementMode(): boolean;
  73934. /**
  73935. * Gets the current priority level (0 at start)
  73936. */
  73937. get currentPriorityLevel(): number;
  73938. /**
  73939. * Gets the current frame rate checked by the SceneOptimizer
  73940. */
  73941. get currentFrameRate(): number;
  73942. /**
  73943. * Gets or sets the current target frame rate (60 by default)
  73944. */
  73945. get targetFrameRate(): number;
  73946. /**
  73947. * Gets or sets the current target frame rate (60 by default)
  73948. */
  73949. set targetFrameRate(value: number);
  73950. /**
  73951. * Gets or sets the current interval between two checks (every 2000ms by default)
  73952. */
  73953. get trackerDuration(): number;
  73954. /**
  73955. * Gets or sets the current interval between two checks (every 2000ms by default)
  73956. */
  73957. set trackerDuration(value: number);
  73958. /**
  73959. * Gets the list of active optimizations
  73960. */
  73961. get optimizations(): SceneOptimization[];
  73962. /**
  73963. * Creates a new SceneOptimizer
  73964. * @param scene defines the scene to work on
  73965. * @param options defines the options to use with the SceneOptimizer
  73966. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  73967. * @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)
  73968. */
  73969. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  73970. /**
  73971. * Stops the current optimizer
  73972. */
  73973. stop(): void;
  73974. /**
  73975. * Reset the optimizer to initial step (current priority level = 0)
  73976. */
  73977. reset(): void;
  73978. /**
  73979. * Start the optimizer. By default it will try to reach a specific framerate
  73980. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  73981. */
  73982. start(): void;
  73983. private _checkCurrentState;
  73984. /**
  73985. * Release all resources
  73986. */
  73987. dispose(): void;
  73988. /**
  73989. * Helper function to create a SceneOptimizer with one single line of code
  73990. * @param scene defines the scene to work on
  73991. * @param options defines the options to use with the SceneOptimizer
  73992. * @param onSuccess defines a callback to call on success
  73993. * @param onFailure defines a callback to call on failure
  73994. * @returns the new SceneOptimizer object
  73995. */
  73996. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  73997. }
  73998. }
  73999. declare module "babylonjs/Misc/sceneSerializer" {
  74000. import { Scene } from "babylonjs/scene";
  74001. /**
  74002. * Class used to serialize a scene into a string
  74003. */
  74004. export class SceneSerializer {
  74005. /**
  74006. * Clear cache used by a previous serialization
  74007. */
  74008. static ClearCache(): void;
  74009. /**
  74010. * Serialize a scene into a JSON compatible object
  74011. * @param scene defines the scene to serialize
  74012. * @returns a JSON compatible object
  74013. */
  74014. static Serialize(scene: Scene): any;
  74015. /**
  74016. * Serialize a mesh into a JSON compatible object
  74017. * @param toSerialize defines the mesh to serialize
  74018. * @param withParents defines if parents must be serialized as well
  74019. * @param withChildren defines if children must be serialized as well
  74020. * @returns a JSON compatible object
  74021. */
  74022. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  74023. }
  74024. }
  74025. declare module "babylonjs/Misc/textureTools" {
  74026. import { Texture } from "babylonjs/Materials/Textures/texture";
  74027. /**
  74028. * Class used to host texture specific utilities
  74029. */
  74030. export class TextureTools {
  74031. /**
  74032. * Uses the GPU to create a copy texture rescaled at a given size
  74033. * @param texture Texture to copy from
  74034. * @param width defines the desired width
  74035. * @param height defines the desired height
  74036. * @param useBilinearMode defines if bilinear mode has to be used
  74037. * @return the generated texture
  74038. */
  74039. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  74040. }
  74041. }
  74042. declare module "babylonjs/Misc/videoRecorder" {
  74043. import { Nullable } from "babylonjs/types";
  74044. import { Engine } from "babylonjs/Engines/engine";
  74045. /**
  74046. * This represents the different options available for the video capture.
  74047. */
  74048. export interface VideoRecorderOptions {
  74049. /** Defines the mime type of the video. */
  74050. mimeType: string;
  74051. /** Defines the FPS the video should be recorded at. */
  74052. fps: number;
  74053. /** Defines the chunk size for the recording data. */
  74054. recordChunckSize: number;
  74055. /** The audio tracks to attach to the recording. */
  74056. audioTracks?: MediaStreamTrack[];
  74057. }
  74058. /**
  74059. * This can help with recording videos from BabylonJS.
  74060. * This is based on the available WebRTC functionalities of the browser.
  74061. *
  74062. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  74063. */
  74064. export class VideoRecorder {
  74065. private static readonly _defaultOptions;
  74066. /**
  74067. * Returns whether or not the VideoRecorder is available in your browser.
  74068. * @param engine Defines the Babylon Engine.
  74069. * @returns true if supported otherwise false.
  74070. */
  74071. static IsSupported(engine: Engine): boolean;
  74072. private readonly _options;
  74073. private _canvas;
  74074. private _mediaRecorder;
  74075. private _recordedChunks;
  74076. private _fileName;
  74077. private _resolve;
  74078. private _reject;
  74079. /**
  74080. * True when a recording is already in progress.
  74081. */
  74082. get isRecording(): boolean;
  74083. /**
  74084. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  74085. * @param engine Defines the BabylonJS Engine you wish to record.
  74086. * @param options Defines options that can be used to customize the capture.
  74087. */
  74088. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  74089. /**
  74090. * Stops the current recording before the default capture timeout passed in the startRecording function.
  74091. */
  74092. stopRecording(): void;
  74093. /**
  74094. * Starts recording the canvas for a max duration specified in parameters.
  74095. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  74096. * If null no automatic download will start and you can rely on the promise to get the data back.
  74097. * @param maxDuration Defines the maximum recording time in seconds.
  74098. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  74099. * @return A promise callback at the end of the recording with the video data in Blob.
  74100. */
  74101. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  74102. /**
  74103. * Releases internal resources used during the recording.
  74104. */
  74105. dispose(): void;
  74106. private _handleDataAvailable;
  74107. private _handleError;
  74108. private _handleStop;
  74109. }
  74110. }
  74111. declare module "babylonjs/Misc/screenshotTools" {
  74112. import { Camera } from "babylonjs/Cameras/camera";
  74113. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  74114. import { Engine } from "babylonjs/Engines/engine";
  74115. /**
  74116. * Class containing a set of static utilities functions for screenshots
  74117. */
  74118. export class ScreenshotTools {
  74119. /**
  74120. * Captures a screenshot of the current rendering
  74121. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  74122. * @param engine defines the rendering engine
  74123. * @param camera defines the source camera
  74124. * @param size This parameter can be set to a single number or to an object with the
  74125. * following (optional) properties: precision, width, height. If a single number is passed,
  74126. * it will be used for both width and height. If an object is passed, the screenshot size
  74127. * will be derived from the parameters. The precision property is a multiplier allowing
  74128. * rendering at a higher or lower resolution
  74129. * @param successCallback defines the callback receives a single parameter which contains the
  74130. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  74131. * src parameter of an <img> to display it
  74132. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  74133. * Check your browser for supported MIME types
  74134. */
  74135. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  74136. /**
  74137. * Captures a screenshot of the current rendering
  74138. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  74139. * @param engine defines the rendering engine
  74140. * @param camera defines the source camera
  74141. * @param size This parameter can be set to a single number or to an object with the
  74142. * following (optional) properties: precision, width, height. If a single number is passed,
  74143. * it will be used for both width and height. If an object is passed, the screenshot size
  74144. * will be derived from the parameters. The precision property is a multiplier allowing
  74145. * rendering at a higher or lower resolution
  74146. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  74147. * Check your browser for supported MIME types
  74148. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  74149. * to the src parameter of an <img> to display it
  74150. */
  74151. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  74152. /**
  74153. * Generates an image screenshot from the specified camera.
  74154. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  74155. * @param engine The engine to use for rendering
  74156. * @param camera The camera to use for rendering
  74157. * @param size This parameter can be set to a single number or to an object with the
  74158. * following (optional) properties: precision, width, height. If a single number is passed,
  74159. * it will be used for both width and height. If an object is passed, the screenshot size
  74160. * will be derived from the parameters. The precision property is a multiplier allowing
  74161. * rendering at a higher or lower resolution
  74162. * @param successCallback The callback receives a single parameter which contains the
  74163. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  74164. * src parameter of an <img> to display it
  74165. * @param mimeType The MIME type of the screenshot image (default: image/png).
  74166. * Check your browser for supported MIME types
  74167. * @param samples Texture samples (default: 1)
  74168. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  74169. * @param fileName A name for for the downloaded file.
  74170. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  74171. */
  74172. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): void;
  74173. /**
  74174. * Generates an image screenshot from the specified camera.
  74175. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  74176. * @param engine The engine to use for rendering
  74177. * @param camera The camera to use for rendering
  74178. * @param size This parameter can be set to a single number or to an object with the
  74179. * following (optional) properties: precision, width, height. If a single number is passed,
  74180. * it will be used for both width and height. If an object is passed, the screenshot size
  74181. * will be derived from the parameters. The precision property is a multiplier allowing
  74182. * rendering at a higher or lower resolution
  74183. * @param mimeType The MIME type of the screenshot image (default: image/png).
  74184. * Check your browser for supported MIME types
  74185. * @param samples Texture samples (default: 1)
  74186. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  74187. * @param fileName A name for for the downloaded file.
  74188. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  74189. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  74190. * to the src parameter of an <img> to display it
  74191. */
  74192. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): Promise<string>;
  74193. /**
  74194. * Gets height and width for screenshot size
  74195. * @private
  74196. */
  74197. private static _getScreenshotSize;
  74198. }
  74199. }
  74200. declare module "babylonjs/Misc/dataReader" {
  74201. /**
  74202. * Interface for a data buffer
  74203. */
  74204. export interface IDataBuffer {
  74205. /**
  74206. * Reads bytes from the data buffer.
  74207. * @param byteOffset The byte offset to read
  74208. * @param byteLength The byte length to read
  74209. * @returns A promise that resolves when the bytes are read
  74210. */
  74211. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  74212. /**
  74213. * The byte length of the buffer.
  74214. */
  74215. readonly byteLength: number;
  74216. }
  74217. /**
  74218. * Utility class for reading from a data buffer
  74219. */
  74220. export class DataReader {
  74221. /**
  74222. * The data buffer associated with this data reader.
  74223. */
  74224. readonly buffer: IDataBuffer;
  74225. /**
  74226. * The current byte offset from the beginning of the data buffer.
  74227. */
  74228. byteOffset: number;
  74229. private _dataView;
  74230. private _dataByteOffset;
  74231. /**
  74232. * Constructor
  74233. * @param buffer The buffer to read
  74234. */
  74235. constructor(buffer: IDataBuffer);
  74236. /**
  74237. * Loads the given byte length.
  74238. * @param byteLength The byte length to load
  74239. * @returns A promise that resolves when the load is complete
  74240. */
  74241. loadAsync(byteLength: number): Promise<void>;
  74242. /**
  74243. * Read a unsigned 32-bit integer from the currently loaded data range.
  74244. * @returns The 32-bit integer read
  74245. */
  74246. readUint32(): number;
  74247. /**
  74248. * Read a byte array from the currently loaded data range.
  74249. * @param byteLength The byte length to read
  74250. * @returns The byte array read
  74251. */
  74252. readUint8Array(byteLength: number): Uint8Array;
  74253. /**
  74254. * Read a string from the currently loaded data range.
  74255. * @param byteLength The byte length to read
  74256. * @returns The string read
  74257. */
  74258. readString(byteLength: number): string;
  74259. /**
  74260. * Skips the given byte length the currently loaded data range.
  74261. * @param byteLength The byte length to skip
  74262. */
  74263. skipBytes(byteLength: number): void;
  74264. }
  74265. }
  74266. declare module "babylonjs/Misc/dataStorage" {
  74267. /**
  74268. * Class for storing data to local storage if available or in-memory storage otherwise
  74269. */
  74270. export class DataStorage {
  74271. private static _Storage;
  74272. private static _GetStorage;
  74273. /**
  74274. * Reads a string from the data storage
  74275. * @param key The key to read
  74276. * @param defaultValue The value if the key doesn't exist
  74277. * @returns The string value
  74278. */
  74279. static ReadString(key: string, defaultValue: string): string;
  74280. /**
  74281. * Writes a string to the data storage
  74282. * @param key The key to write
  74283. * @param value The value to write
  74284. */
  74285. static WriteString(key: string, value: string): void;
  74286. /**
  74287. * Reads a boolean from the data storage
  74288. * @param key The key to read
  74289. * @param defaultValue The value if the key doesn't exist
  74290. * @returns The boolean value
  74291. */
  74292. static ReadBoolean(key: string, defaultValue: boolean): boolean;
  74293. /**
  74294. * Writes a boolean to the data storage
  74295. * @param key The key to write
  74296. * @param value The value to write
  74297. */
  74298. static WriteBoolean(key: string, value: boolean): void;
  74299. /**
  74300. * Reads a number from the data storage
  74301. * @param key The key to read
  74302. * @param defaultValue The value if the key doesn't exist
  74303. * @returns The number value
  74304. */
  74305. static ReadNumber(key: string, defaultValue: number): number;
  74306. /**
  74307. * Writes a number to the data storage
  74308. * @param key The key to write
  74309. * @param value The value to write
  74310. */
  74311. static WriteNumber(key: string, value: number): void;
  74312. }
  74313. }
  74314. declare module "babylonjs/Misc/index" {
  74315. export * from "babylonjs/Misc/andOrNotEvaluator";
  74316. export * from "babylonjs/Misc/assetsManager";
  74317. export * from "babylonjs/Misc/basis";
  74318. export * from "babylonjs/Misc/dds";
  74319. export * from "babylonjs/Misc/decorators";
  74320. export * from "babylonjs/Misc/deferred";
  74321. export * from "babylonjs/Misc/environmentTextureTools";
  74322. export * from "babylonjs/Misc/meshExploder";
  74323. export * from "babylonjs/Misc/filesInput";
  74324. export * from "babylonjs/Misc/HighDynamicRange/index";
  74325. export * from "babylonjs/Misc/khronosTextureContainer";
  74326. export * from "babylonjs/Misc/observable";
  74327. export * from "babylonjs/Misc/performanceMonitor";
  74328. export * from "babylonjs/Misc/promise";
  74329. export * from "babylonjs/Misc/sceneOptimizer";
  74330. export * from "babylonjs/Misc/sceneSerializer";
  74331. export * from "babylonjs/Misc/smartArray";
  74332. export * from "babylonjs/Misc/stringDictionary";
  74333. export * from "babylonjs/Misc/tags";
  74334. export * from "babylonjs/Misc/textureTools";
  74335. export * from "babylonjs/Misc/tga";
  74336. export * from "babylonjs/Misc/tools";
  74337. export * from "babylonjs/Misc/videoRecorder";
  74338. export * from "babylonjs/Misc/virtualJoystick";
  74339. export * from "babylonjs/Misc/workerPool";
  74340. export * from "babylonjs/Misc/logger";
  74341. export * from "babylonjs/Misc/typeStore";
  74342. export * from "babylonjs/Misc/filesInputStore";
  74343. export * from "babylonjs/Misc/deepCopier";
  74344. export * from "babylonjs/Misc/pivotTools";
  74345. export * from "babylonjs/Misc/precisionDate";
  74346. export * from "babylonjs/Misc/screenshotTools";
  74347. export * from "babylonjs/Misc/typeStore";
  74348. export * from "babylonjs/Misc/webRequest";
  74349. export * from "babylonjs/Misc/iInspectable";
  74350. export * from "babylonjs/Misc/brdfTextureTools";
  74351. export * from "babylonjs/Misc/rgbdTextureTools";
  74352. export * from "babylonjs/Misc/gradients";
  74353. export * from "babylonjs/Misc/perfCounter";
  74354. export * from "babylonjs/Misc/fileRequest";
  74355. export * from "babylonjs/Misc/customAnimationFrameRequester";
  74356. export * from "babylonjs/Misc/retryStrategy";
  74357. export * from "babylonjs/Misc/interfaces/screenshotSize";
  74358. export * from "babylonjs/Misc/canvasGenerator";
  74359. export * from "babylonjs/Misc/fileTools";
  74360. export * from "babylonjs/Misc/stringTools";
  74361. export * from "babylonjs/Misc/dataReader";
  74362. export * from "babylonjs/Misc/minMaxReducer";
  74363. export * from "babylonjs/Misc/depthReducer";
  74364. export * from "babylonjs/Misc/dataStorage";
  74365. }
  74366. declare module "babylonjs/XR/features/WebXRHitTestLegacy" {
  74367. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  74368. import { Observable } from "babylonjs/Misc/observable";
  74369. import { Matrix } from "babylonjs/Maths/math.vector";
  74370. import { TransformNode } from "babylonjs/Meshes/transformNode";
  74371. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  74372. /**
  74373. * Options used for hit testing
  74374. */
  74375. export interface IWebXRLegacyHitTestOptions {
  74376. /**
  74377. * Only test when user interacted with the scene. Default - hit test every frame
  74378. */
  74379. testOnPointerDownOnly?: boolean;
  74380. /**
  74381. * The node to use to transform the local results to world coordinates
  74382. */
  74383. worldParentNode?: TransformNode;
  74384. }
  74385. /**
  74386. * Interface defining the babylon result of raycasting/hit-test
  74387. */
  74388. export interface IWebXRLegacyHitResult {
  74389. /**
  74390. * Transformation matrix that can be applied to a node that will put it in the hit point location
  74391. */
  74392. transformationMatrix: Matrix;
  74393. /**
  74394. * The native hit test result
  74395. */
  74396. xrHitResult: XRHitResult | XRHitTestResult;
  74397. }
  74398. /**
  74399. * The currently-working hit-test module.
  74400. * Hit test (or Ray-casting) is used to interact with the real world.
  74401. * For further information read here - https://github.com/immersive-web/hit-test
  74402. */
  74403. export class WebXRHitTestLegacy extends WebXRAbstractFeature {
  74404. /**
  74405. * options to use when constructing this feature
  74406. */
  74407. readonly options: IWebXRLegacyHitTestOptions;
  74408. private _direction;
  74409. private _mat;
  74410. private _onSelectEnabled;
  74411. private _origin;
  74412. /**
  74413. * The module's name
  74414. */
  74415. static readonly Name: string;
  74416. /**
  74417. * The (Babylon) version of this module.
  74418. * This is an integer representing the implementation version.
  74419. * This number does not correspond to the WebXR specs version
  74420. */
  74421. static readonly Version: number;
  74422. /**
  74423. * Populated with the last native XR Hit Results
  74424. */
  74425. lastNativeXRHitResults: XRHitResult[];
  74426. /**
  74427. * Triggered when new babylon (transformed) hit test results are available
  74428. */
  74429. onHitTestResultObservable: Observable<IWebXRLegacyHitResult[]>;
  74430. /**
  74431. * Creates a new instance of the (legacy version) hit test feature
  74432. * @param _xrSessionManager an instance of WebXRSessionManager
  74433. * @param options options to use when constructing this feature
  74434. */
  74435. constructor(_xrSessionManager: WebXRSessionManager,
  74436. /**
  74437. * options to use when constructing this feature
  74438. */
  74439. options?: IWebXRLegacyHitTestOptions);
  74440. /**
  74441. * execute a hit test with an XR Ray
  74442. *
  74443. * @param xrSession a native xrSession that will execute this hit test
  74444. * @param xrRay the ray (position and direction) to use for ray-casting
  74445. * @param referenceSpace native XR reference space to use for the hit-test
  74446. * @param filter filter function that will filter the results
  74447. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  74448. */
  74449. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  74450. /**
  74451. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  74452. * @param event the (select) event to use to select with
  74453. * @param referenceSpace the reference space to use for this hit test
  74454. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  74455. */
  74456. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  74457. /**
  74458. * attach this feature
  74459. * Will usually be called by the features manager
  74460. *
  74461. * @returns true if successful.
  74462. */
  74463. attach(): boolean;
  74464. /**
  74465. * detach this feature.
  74466. * Will usually be called by the features manager
  74467. *
  74468. * @returns true if successful.
  74469. */
  74470. detach(): boolean;
  74471. /**
  74472. * Dispose this feature and all of the resources attached
  74473. */
  74474. dispose(): void;
  74475. protected _onXRFrame(frame: XRFrame): void;
  74476. private _onHitTestResults;
  74477. private _onSelect;
  74478. }
  74479. }
  74480. declare module "babylonjs/XR/features/WebXRPlaneDetector" {
  74481. import { TransformNode } from "babylonjs/Meshes/transformNode";
  74482. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  74483. import { Observable } from "babylonjs/Misc/observable";
  74484. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  74485. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  74486. /**
  74487. * Options used in the plane detector module
  74488. */
  74489. export interface IWebXRPlaneDetectorOptions {
  74490. /**
  74491. * The node to use to transform the local results to world coordinates
  74492. */
  74493. worldParentNode?: TransformNode;
  74494. }
  74495. /**
  74496. * A babylon interface for a WebXR plane.
  74497. * A Plane is actually a polygon, built from N points in space
  74498. *
  74499. * Supported in chrome 79, not supported in canary 81 ATM
  74500. */
  74501. export interface IWebXRPlane {
  74502. /**
  74503. * a babylon-assigned ID for this polygon
  74504. */
  74505. id: number;
  74506. /**
  74507. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  74508. */
  74509. polygonDefinition: Array<Vector3>;
  74510. /**
  74511. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  74512. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  74513. */
  74514. transformationMatrix: Matrix;
  74515. /**
  74516. * the native xr-plane object
  74517. */
  74518. xrPlane: XRPlane;
  74519. }
  74520. /**
  74521. * The plane detector is used to detect planes in the real world when in AR
  74522. * For more information see https://github.com/immersive-web/real-world-geometry/
  74523. */
  74524. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  74525. private _options;
  74526. private _detectedPlanes;
  74527. private _enabled;
  74528. private _lastFrameDetected;
  74529. /**
  74530. * The module's name
  74531. */
  74532. static readonly Name: string;
  74533. /**
  74534. * The (Babylon) version of this module.
  74535. * This is an integer representing the implementation version.
  74536. * This number does not correspond to the WebXR specs version
  74537. */
  74538. static readonly Version: number;
  74539. /**
  74540. * Observers registered here will be executed when a new plane was added to the session
  74541. */
  74542. onPlaneAddedObservable: Observable<IWebXRPlane>;
  74543. /**
  74544. * Observers registered here will be executed when a plane is no longer detected in the session
  74545. */
  74546. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  74547. /**
  74548. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  74549. * This can execute N times every frame
  74550. */
  74551. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  74552. /**
  74553. * construct a new Plane Detector
  74554. * @param _xrSessionManager an instance of xr Session manager
  74555. * @param _options configuration to use when constructing this feature
  74556. */
  74557. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  74558. /**
  74559. * Dispose this feature and all of the resources attached
  74560. */
  74561. dispose(): void;
  74562. protected _onXRFrame(frame: XRFrame): void;
  74563. private _init;
  74564. private _updatePlaneWithXRPlane;
  74565. /**
  74566. * avoiding using Array.find for global support.
  74567. * @param xrPlane the plane to find in the array
  74568. */
  74569. private findIndexInPlaneArray;
  74570. }
  74571. }
  74572. declare module "babylonjs/XR/features/WebXRAnchorSystem" {
  74573. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  74574. import { Observable } from "babylonjs/Misc/observable";
  74575. import { Matrix } from "babylonjs/Maths/math.vector";
  74576. import { TransformNode } from "babylonjs/Meshes/transformNode";
  74577. import { WebXRPlaneDetector } from "babylonjs/XR/features/WebXRPlaneDetector";
  74578. import { WebXRHitTestLegacy } from "babylonjs/XR/features/WebXRHitTestLegacy";
  74579. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  74580. /**
  74581. * Configuration options of the anchor system
  74582. */
  74583. export interface IWebXRAnchorSystemOptions {
  74584. /**
  74585. * Should a new anchor be added every time a select event is triggered
  74586. */
  74587. addAnchorOnSelect?: boolean;
  74588. /**
  74589. * should the anchor system use plane detection.
  74590. * If set to true, the plane-detection feature should be set using setPlaneDetector
  74591. */
  74592. usePlaneDetection?: boolean;
  74593. /**
  74594. * a node that will be used to convert local to world coordinates
  74595. */
  74596. worldParentNode?: TransformNode;
  74597. }
  74598. /**
  74599. * A babylon container for an XR Anchor
  74600. */
  74601. export interface IWebXRAnchor {
  74602. /**
  74603. * A babylon-assigned ID for this anchor
  74604. */
  74605. id: number;
  74606. /**
  74607. * Transformation matrix to apply to an object attached to this anchor
  74608. */
  74609. transformationMatrix: Matrix;
  74610. /**
  74611. * The native anchor object
  74612. */
  74613. xrAnchor: XRAnchor;
  74614. }
  74615. /**
  74616. * An implementation of the anchor system of WebXR.
  74617. * Note that the current documented implementation is not available in any browser. Future implementations
  74618. * will use the frame to create an anchor and not the session or a detected plane
  74619. * For further information see https://github.com/immersive-web/anchors/
  74620. */
  74621. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  74622. private _options;
  74623. private _enabled;
  74624. private _hitTestModule;
  74625. private _lastFrameDetected;
  74626. private _onSelect;
  74627. private _planeDetector;
  74628. private _trackedAnchors;
  74629. /**
  74630. * The module's name
  74631. */
  74632. static readonly Name: string;
  74633. /**
  74634. * The (Babylon) version of this module.
  74635. * This is an integer representing the implementation version.
  74636. * This number does not correspond to the WebXR specs version
  74637. */
  74638. static readonly Version: number;
  74639. /**
  74640. * Observers registered here will be executed when a new anchor was added to the session
  74641. */
  74642. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  74643. /**
  74644. * Observers registered here will be executed when an anchor was removed from the session
  74645. */
  74646. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  74647. /**
  74648. * Observers registered here will be executed when an existing anchor updates
  74649. * This can execute N times every frame
  74650. */
  74651. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  74652. /**
  74653. * constructs a new anchor system
  74654. * @param _xrSessionManager an instance of WebXRSessionManager
  74655. * @param _options configuration object for this feature
  74656. */
  74657. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  74658. /**
  74659. * Add anchor at a specific XR point.
  74660. *
  74661. * @param xrRigidTransformation xr-coordinates where a new anchor should be added
  74662. * @param anchorCreator the object o use to create an anchor with. either a session or a plane
  74663. * @returns a promise the fulfills when the anchor was created
  74664. */
  74665. addAnchorAtRigidTransformation(xrRigidTransformation: XRRigidTransform, anchorCreator?: XRAnchorCreator): Promise<XRAnchor>;
  74666. /**
  74667. * attach this feature
  74668. * Will usually be called by the features manager
  74669. *
  74670. * @returns true if successful.
  74671. */
  74672. attach(): boolean;
  74673. /**
  74674. * detach this feature.
  74675. * Will usually be called by the features manager
  74676. *
  74677. * @returns true if successful.
  74678. */
  74679. detach(): boolean;
  74680. /**
  74681. * Dispose this feature and all of the resources attached
  74682. */
  74683. dispose(): void;
  74684. /**
  74685. * If set, it will improve performance by using the current hit-test results instead of executing a new hit-test
  74686. * @param hitTestModule the hit-test module to use.
  74687. */
  74688. setHitTestModule(hitTestModule: WebXRHitTestLegacy): void;
  74689. /**
  74690. * set the plane detector to use in order to create anchors from frames
  74691. * @param planeDetector the plane-detector module to use
  74692. * @param enable enable plane-anchors. default is true
  74693. */
  74694. setPlaneDetector(planeDetector: WebXRPlaneDetector, enable?: boolean): void;
  74695. protected _onXRFrame(frame: XRFrame): void;
  74696. /**
  74697. * avoiding using Array.find for global support.
  74698. * @param xrAnchor the plane to find in the array
  74699. */
  74700. private _findIndexInAnchorArray;
  74701. private _updateAnchorWithXRFrame;
  74702. }
  74703. }
  74704. declare module "babylonjs/XR/features/WebXRBackgroundRemover" {
  74705. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  74706. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  74707. import { Observable } from "babylonjs/Misc/observable";
  74708. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  74709. /**
  74710. * Options interface for the background remover plugin
  74711. */
  74712. export interface IWebXRBackgroundRemoverOptions {
  74713. /**
  74714. * Further background meshes to disable when entering AR
  74715. */
  74716. backgroundMeshes?: AbstractMesh[];
  74717. /**
  74718. * flags to configure the removal of the environment helper.
  74719. * If not set, the entire background will be removed. If set, flags should be set as well.
  74720. */
  74721. environmentHelperRemovalFlags?: {
  74722. /**
  74723. * Should the skybox be removed (default false)
  74724. */
  74725. skyBox?: boolean;
  74726. /**
  74727. * Should the ground be removed (default false)
  74728. */
  74729. ground?: boolean;
  74730. };
  74731. /**
  74732. * don't disable the environment helper
  74733. */
  74734. ignoreEnvironmentHelper?: boolean;
  74735. }
  74736. /**
  74737. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  74738. */
  74739. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  74740. /**
  74741. * read-only options to be used in this module
  74742. */
  74743. readonly options: IWebXRBackgroundRemoverOptions;
  74744. /**
  74745. * The module's name
  74746. */
  74747. static readonly Name: string;
  74748. /**
  74749. * The (Babylon) version of this module.
  74750. * This is an integer representing the implementation version.
  74751. * This number does not correspond to the WebXR specs version
  74752. */
  74753. static readonly Version: number;
  74754. /**
  74755. * registered observers will be triggered when the background state changes
  74756. */
  74757. onBackgroundStateChangedObservable: Observable<boolean>;
  74758. /**
  74759. * constructs a new background remover module
  74760. * @param _xrSessionManager the session manager for this module
  74761. * @param options read-only options to be used in this module
  74762. */
  74763. constructor(_xrSessionManager: WebXRSessionManager,
  74764. /**
  74765. * read-only options to be used in this module
  74766. */
  74767. options?: IWebXRBackgroundRemoverOptions);
  74768. /**
  74769. * attach this feature
  74770. * Will usually be called by the features manager
  74771. *
  74772. * @returns true if successful.
  74773. */
  74774. attach(): boolean;
  74775. /**
  74776. * detach this feature.
  74777. * Will usually be called by the features manager
  74778. *
  74779. * @returns true if successful.
  74780. */
  74781. detach(): boolean;
  74782. /**
  74783. * Dispose this feature and all of the resources attached
  74784. */
  74785. dispose(): void;
  74786. protected _onXRFrame(_xrFrame: XRFrame): void;
  74787. private _setBackgroundState;
  74788. }
  74789. }
  74790. declare module "babylonjs/XR/features/WebXRControllerPhysics" {
  74791. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  74792. import { WebXRInputSource } from "babylonjs/XR/webXRInputSource";
  74793. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  74794. import { WebXRInput } from "babylonjs/XR/webXRInput";
  74795. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  74796. import { Nullable } from "babylonjs/types";
  74797. /**
  74798. * Options for the controller physics feature
  74799. */
  74800. export class IWebXRControllerPhysicsOptions {
  74801. /**
  74802. * Should the headset get its own impostor
  74803. */
  74804. enableHeadsetImpostor?: boolean;
  74805. /**
  74806. * Optional parameters for the headset impostor
  74807. */
  74808. headsetImpostorParams?: {
  74809. /**
  74810. * The type of impostor to create. Default is sphere
  74811. */
  74812. impostorType: number;
  74813. /**
  74814. * the size of the impostor. Defaults to 10cm
  74815. */
  74816. impostorSize?: number | {
  74817. width: number;
  74818. height: number;
  74819. depth: number;
  74820. };
  74821. /**
  74822. * Friction definitions
  74823. */
  74824. friction?: number;
  74825. /**
  74826. * Restitution
  74827. */
  74828. restitution?: number;
  74829. };
  74830. /**
  74831. * The physics properties of the future impostors
  74832. */
  74833. physicsProperties?: {
  74834. /**
  74835. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  74836. * Note that this requires a physics engine that supports mesh impostors!
  74837. */
  74838. useControllerMesh?: boolean;
  74839. /**
  74840. * The type of impostor to create. Default is sphere
  74841. */
  74842. impostorType?: number;
  74843. /**
  74844. * the size of the impostor. Defaults to 10cm
  74845. */
  74846. impostorSize?: number | {
  74847. width: number;
  74848. height: number;
  74849. depth: number;
  74850. };
  74851. /**
  74852. * Friction definitions
  74853. */
  74854. friction?: number;
  74855. /**
  74856. * Restitution
  74857. */
  74858. restitution?: number;
  74859. };
  74860. /**
  74861. * the xr input to use with this pointer selection
  74862. */
  74863. xrInput: WebXRInput;
  74864. }
  74865. /**
  74866. * Add physics impostor to your webxr controllers,
  74867. * including naive calculation of their linear and angular velocity
  74868. */
  74869. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  74870. private readonly _options;
  74871. private _attachController;
  74872. private _controllers;
  74873. private _debugMode;
  74874. private _delta;
  74875. private _headsetImpostor?;
  74876. private _headsetMesh?;
  74877. private _lastTimestamp;
  74878. private _tmpQuaternion;
  74879. private _tmpVector;
  74880. /**
  74881. * The module's name
  74882. */
  74883. static readonly Name: string;
  74884. /**
  74885. * The (Babylon) version of this module.
  74886. * This is an integer representing the implementation version.
  74887. * This number does not correspond to the webxr specs version
  74888. */
  74889. static readonly Version: number;
  74890. /**
  74891. * Construct a new Controller Physics Feature
  74892. * @param _xrSessionManager the corresponding xr session manager
  74893. * @param _options options to create this feature with
  74894. */
  74895. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  74896. /**
  74897. * @hidden
  74898. * enable debugging - will show console outputs and the impostor mesh
  74899. */
  74900. _enablePhysicsDebug(): void;
  74901. /**
  74902. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  74903. * @param xrController the controller to add
  74904. */
  74905. addController(xrController: WebXRInputSource): void;
  74906. /**
  74907. * attach this feature
  74908. * Will usually be called by the features manager
  74909. *
  74910. * @returns true if successful.
  74911. */
  74912. attach(): boolean;
  74913. /**
  74914. * detach this feature.
  74915. * Will usually be called by the features manager
  74916. *
  74917. * @returns true if successful.
  74918. */
  74919. detach(): boolean;
  74920. /**
  74921. * Get the headset impostor, if enabled
  74922. * @returns the impostor
  74923. */
  74924. getHeadsetImpostor(): PhysicsImpostor | undefined;
  74925. /**
  74926. * Get the physics impostor of a specific controller.
  74927. * The impostor is not attached to a mesh because a mesh for each controller is not obligatory
  74928. * @param controller the controller or the controller id of which to get the impostor
  74929. * @returns the impostor or null
  74930. */
  74931. getImpostorForController(controller: WebXRInputSource | string): Nullable<PhysicsImpostor>;
  74932. /**
  74933. * Update the physics properties provided in the constructor
  74934. * @param newProperties the new properties object
  74935. */
  74936. setPhysicsProperties(newProperties: {
  74937. impostorType?: number;
  74938. impostorSize?: number | {
  74939. width: number;
  74940. height: number;
  74941. depth: number;
  74942. };
  74943. friction?: number;
  74944. restitution?: number;
  74945. }): void;
  74946. protected _onXRFrame(_xrFrame: any): void;
  74947. private _detachController;
  74948. }
  74949. }
  74950. declare module "babylonjs/XR/features/WebXRHitTest" {
  74951. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  74952. import { Observable } from "babylonjs/Misc/observable";
  74953. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  74954. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  74955. import { IWebXRLegacyHitTestOptions, IWebXRLegacyHitResult } from "babylonjs/XR/features/WebXRHitTestLegacy";
  74956. /**
  74957. * Options used for hit testing (version 2)
  74958. */
  74959. export interface IWebXRHitTestOptions extends IWebXRLegacyHitTestOptions {
  74960. /**
  74961. * Do not create a permanent hit test. Will usually be used when only
  74962. * transient inputs are needed.
  74963. */
  74964. disablePermanentHitTest?: boolean;
  74965. /**
  74966. * Enable transient (for example touch-based) hit test inspections
  74967. */
  74968. enableTransientHitTest?: boolean;
  74969. /**
  74970. * Offset ray for the permanent hit test
  74971. */
  74972. offsetRay?: Vector3;
  74973. /**
  74974. * Offset ray for the transient hit test
  74975. */
  74976. transientOffsetRay?: Vector3;
  74977. /**
  74978. * Instead of using viewer space for hit tests, use the reference space defined in the session manager
  74979. */
  74980. useReferenceSpace?: boolean;
  74981. }
  74982. /**
  74983. * Interface defining the babylon result of hit-test
  74984. */
  74985. export interface IWebXRHitResult extends IWebXRLegacyHitResult {
  74986. /**
  74987. * The input source that generated this hit test (if transient)
  74988. */
  74989. inputSource?: XRInputSource;
  74990. /**
  74991. * Is this a transient hit test
  74992. */
  74993. isTransient?: boolean;
  74994. /**
  74995. * Position of the hit test result
  74996. */
  74997. position: Vector3;
  74998. /**
  74999. * Rotation of the hit test result
  75000. */
  75001. rotationQuaternion: Quaternion;
  75002. }
  75003. /**
  75004. * The currently-working hit-test module.
  75005. * Hit test (or Ray-casting) is used to interact with the real world.
  75006. * For further information read here - https://github.com/immersive-web/hit-test
  75007. *
  75008. * Tested on chrome (mobile) 80.
  75009. */
  75010. export class WebXRHitTest extends WebXRAbstractFeature {
  75011. /**
  75012. * options to use when constructing this feature
  75013. */
  75014. readonly options: IWebXRHitTestOptions;
  75015. private _tmpMat;
  75016. private _tmpPos;
  75017. private _tmpQuat;
  75018. private _transientXrHitTestSource;
  75019. private _xrHitTestSource;
  75020. private initHitTestSource;
  75021. /**
  75022. * The module's name
  75023. */
  75024. static readonly Name: string;
  75025. /**
  75026. * The (Babylon) version of this module.
  75027. * This is an integer representing the implementation version.
  75028. * This number does not correspond to the WebXR specs version
  75029. */
  75030. static readonly Version: number;
  75031. /**
  75032. * When set to true, each hit test will have its own position/rotation objects
  75033. * When set to false, position and rotation objects will be reused for each hit test. It is expected that
  75034. * the developers will clone them or copy them as they see fit.
  75035. */
  75036. autoCloneTransformation: boolean;
  75037. /**
  75038. * Populated with the last native XR Hit Results
  75039. */
  75040. lastNativeXRHitResults: XRHitResult[];
  75041. /**
  75042. * Triggered when new babylon (transformed) hit test results are available
  75043. */
  75044. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  75045. /**
  75046. * Use this to temporarily pause hit test checks.
  75047. */
  75048. paused: boolean;
  75049. /**
  75050. * Creates a new instance of the hit test feature
  75051. * @param _xrSessionManager an instance of WebXRSessionManager
  75052. * @param options options to use when constructing this feature
  75053. */
  75054. constructor(_xrSessionManager: WebXRSessionManager,
  75055. /**
  75056. * options to use when constructing this feature
  75057. */
  75058. options?: IWebXRHitTestOptions);
  75059. /**
  75060. * attach this feature
  75061. * Will usually be called by the features manager
  75062. *
  75063. * @returns true if successful.
  75064. */
  75065. attach(): boolean;
  75066. /**
  75067. * detach this feature.
  75068. * Will usually be called by the features manager
  75069. *
  75070. * @returns true if successful.
  75071. */
  75072. detach(): boolean;
  75073. /**
  75074. * Dispose this feature and all of the resources attached
  75075. */
  75076. dispose(): void;
  75077. protected _onXRFrame(frame: XRFrame): void;
  75078. private _processWebXRHitTestResult;
  75079. }
  75080. }
  75081. declare module "babylonjs/XR/features/index" {
  75082. export * from "babylonjs/XR/features/WebXRHitTestLegacy";
  75083. export * from "babylonjs/XR/features/WebXRAnchorSystem";
  75084. export * from "babylonjs/XR/features/WebXRPlaneDetector";
  75085. export * from "babylonjs/XR/features/WebXRBackgroundRemover";
  75086. export * from "babylonjs/XR/features/WebXRControllerTeleportation";
  75087. export * from "babylonjs/XR/features/WebXRControllerPointerSelection";
  75088. export * from "babylonjs/XR/features/WebXRControllerPhysics";
  75089. export * from "babylonjs/XR/features/WebXRHitTest";
  75090. }
  75091. declare module "babylonjs/XR/motionController/webXRMicrosoftMixedRealityController" {
  75092. import { WebXRAbstractMotionController, IMinimalMotionControllerObject, MotionControllerHandedness } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  75093. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  75094. import { Scene } from "babylonjs/scene";
  75095. /**
  75096. * The motion controller class for all microsoft mixed reality controllers
  75097. */
  75098. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  75099. protected readonly _mapping: {
  75100. defaultButton: {
  75101. valueNodeName: string;
  75102. unpressedNodeName: string;
  75103. pressedNodeName: string;
  75104. };
  75105. defaultAxis: {
  75106. valueNodeName: string;
  75107. minNodeName: string;
  75108. maxNodeName: string;
  75109. };
  75110. buttons: {
  75111. "xr-standard-trigger": {
  75112. rootNodeName: string;
  75113. componentProperty: string;
  75114. states: string[];
  75115. };
  75116. "xr-standard-squeeze": {
  75117. rootNodeName: string;
  75118. componentProperty: string;
  75119. states: string[];
  75120. };
  75121. "xr-standard-touchpad": {
  75122. rootNodeName: string;
  75123. labelAnchorNodeName: string;
  75124. touchPointNodeName: string;
  75125. };
  75126. "xr-standard-thumbstick": {
  75127. rootNodeName: string;
  75128. componentProperty: string;
  75129. states: string[];
  75130. };
  75131. };
  75132. axes: {
  75133. "xr-standard-touchpad": {
  75134. "x-axis": {
  75135. rootNodeName: string;
  75136. };
  75137. "y-axis": {
  75138. rootNodeName: string;
  75139. };
  75140. };
  75141. "xr-standard-thumbstick": {
  75142. "x-axis": {
  75143. rootNodeName: string;
  75144. };
  75145. "y-axis": {
  75146. rootNodeName: string;
  75147. };
  75148. };
  75149. };
  75150. };
  75151. /**
  75152. * The base url used to load the left and right controller models
  75153. */
  75154. static MODEL_BASE_URL: string;
  75155. /**
  75156. * The name of the left controller model file
  75157. */
  75158. static MODEL_LEFT_FILENAME: string;
  75159. /**
  75160. * The name of the right controller model file
  75161. */
  75162. static MODEL_RIGHT_FILENAME: string;
  75163. profileId: string;
  75164. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  75165. protected _getFilenameAndPath(): {
  75166. filename: string;
  75167. path: string;
  75168. };
  75169. protected _getModelLoadingConstraints(): boolean;
  75170. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  75171. protected _setRootMesh(meshes: AbstractMesh[]): void;
  75172. protected _updateModel(): void;
  75173. }
  75174. }
  75175. declare module "babylonjs/XR/motionController/webXROculusTouchMotionController" {
  75176. import { WebXRAbstractMotionController, IMinimalMotionControllerObject, MotionControllerHandedness } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  75177. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  75178. import { Scene } from "babylonjs/scene";
  75179. /**
  75180. * The motion controller class for oculus touch (quest, rift).
  75181. * This class supports legacy mapping as well the standard xr mapping
  75182. */
  75183. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  75184. private _forceLegacyControllers;
  75185. private _modelRootNode;
  75186. /**
  75187. * The base url used to load the left and right controller models
  75188. */
  75189. static MODEL_BASE_URL: string;
  75190. /**
  75191. * The name of the left controller model file
  75192. */
  75193. static MODEL_LEFT_FILENAME: string;
  75194. /**
  75195. * The name of the right controller model file
  75196. */
  75197. static MODEL_RIGHT_FILENAME: string;
  75198. /**
  75199. * Base Url for the Quest controller model.
  75200. */
  75201. static QUEST_MODEL_BASE_URL: string;
  75202. profileId: string;
  75203. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  75204. protected _getFilenameAndPath(): {
  75205. filename: string;
  75206. path: string;
  75207. };
  75208. protected _getModelLoadingConstraints(): boolean;
  75209. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  75210. protected _setRootMesh(meshes: AbstractMesh[]): void;
  75211. protected _updateModel(): void;
  75212. /**
  75213. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  75214. * between the touch and touch 2.
  75215. */
  75216. private _isQuest;
  75217. }
  75218. }
  75219. declare module "babylonjs/XR/motionController/webXRHTCViveMotionController" {
  75220. import { IMinimalMotionControllerObject, MotionControllerHandedness, WebXRAbstractMotionController } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  75221. import { Scene } from "babylonjs/scene";
  75222. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  75223. /**
  75224. * The motion controller class for the standard HTC-Vive controllers
  75225. */
  75226. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  75227. private _modelRootNode;
  75228. /**
  75229. * The base url used to load the left and right controller models
  75230. */
  75231. static MODEL_BASE_URL: string;
  75232. /**
  75233. * File name for the controller model.
  75234. */
  75235. static MODEL_FILENAME: string;
  75236. profileId: string;
  75237. /**
  75238. * Create a new Vive motion controller object
  75239. * @param scene the scene to use to create this controller
  75240. * @param gamepadObject the corresponding gamepad object
  75241. * @param handedness the handedness of the controller
  75242. */
  75243. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  75244. protected _getFilenameAndPath(): {
  75245. filename: string;
  75246. path: string;
  75247. };
  75248. protected _getModelLoadingConstraints(): boolean;
  75249. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  75250. protected _setRootMesh(meshes: AbstractMesh[]): void;
  75251. protected _updateModel(): void;
  75252. }
  75253. }
  75254. declare module "babylonjs/XR/motionController/index" {
  75255. export * from "babylonjs/XR/motionController/webXRAbstractMotionController";
  75256. export * from "babylonjs/XR/motionController/webXRControllerComponent";
  75257. export * from "babylonjs/XR/motionController/webXRGenericMotionController";
  75258. export * from "babylonjs/XR/motionController/webXRMicrosoftMixedRealityController";
  75259. export * from "babylonjs/XR/motionController/webXRMotionControllerManager";
  75260. export * from "babylonjs/XR/motionController/webXROculusTouchMotionController";
  75261. export * from "babylonjs/XR/motionController/webXRHTCViveMotionController";
  75262. export * from "babylonjs/XR/motionController/webXRProfiledMotionController";
  75263. }
  75264. declare module "babylonjs/XR/index" {
  75265. export * from "babylonjs/XR/webXRCamera";
  75266. export * from "babylonjs/XR/webXREnterExitUI";
  75267. export * from "babylonjs/XR/webXRExperienceHelper";
  75268. export * from "babylonjs/XR/webXRInput";
  75269. export * from "babylonjs/XR/webXRInputSource";
  75270. export * from "babylonjs/XR/webXRManagedOutputCanvas";
  75271. export * from "babylonjs/XR/webXRTypes";
  75272. export * from "babylonjs/XR/webXRSessionManager";
  75273. export * from "babylonjs/XR/webXRDefaultExperience";
  75274. export * from "babylonjs/XR/webXRFeaturesManager";
  75275. export * from "babylonjs/XR/features/index";
  75276. export * from "babylonjs/XR/motionController/index";
  75277. }
  75278. declare module "babylonjs/index" {
  75279. export * from "babylonjs/abstractScene";
  75280. export * from "babylonjs/Actions/index";
  75281. export * from "babylonjs/Animations/index";
  75282. export * from "babylonjs/assetContainer";
  75283. export * from "babylonjs/Audio/index";
  75284. export * from "babylonjs/Behaviors/index";
  75285. export * from "babylonjs/Bones/index";
  75286. export * from "babylonjs/Cameras/index";
  75287. export * from "babylonjs/Collisions/index";
  75288. export * from "babylonjs/Culling/index";
  75289. export * from "babylonjs/Debug/index";
  75290. export * from "babylonjs/DeviceInput/index";
  75291. export * from "babylonjs/Engines/index";
  75292. export * from "babylonjs/Events/index";
  75293. export * from "babylonjs/Gamepads/index";
  75294. export * from "babylonjs/Gizmos/index";
  75295. export * from "babylonjs/Helpers/index";
  75296. export * from "babylonjs/Instrumentation/index";
  75297. export * from "babylonjs/Layers/index";
  75298. export * from "babylonjs/LensFlares/index";
  75299. export * from "babylonjs/Lights/index";
  75300. export * from "babylonjs/Loading/index";
  75301. export * from "babylonjs/Materials/index";
  75302. export * from "babylonjs/Maths/index";
  75303. export * from "babylonjs/Meshes/index";
  75304. export * from "babylonjs/Morph/index";
  75305. export * from "babylonjs/Navigation/index";
  75306. export * from "babylonjs/node";
  75307. export * from "babylonjs/Offline/index";
  75308. export * from "babylonjs/Particles/index";
  75309. export * from "babylonjs/Physics/index";
  75310. export * from "babylonjs/PostProcesses/index";
  75311. export * from "babylonjs/Probes/index";
  75312. export * from "babylonjs/Rendering/index";
  75313. export * from "babylonjs/scene";
  75314. export * from "babylonjs/sceneComponent";
  75315. export * from "babylonjs/Sprites/index";
  75316. export * from "babylonjs/States/index";
  75317. export * from "babylonjs/Misc/index";
  75318. export * from "babylonjs/XR/index";
  75319. export * from "babylonjs/types";
  75320. }
  75321. declare module "babylonjs/Animations/pathCursor" {
  75322. import { Vector3 } from "babylonjs/Maths/math.vector";
  75323. import { Path2 } from "babylonjs/Maths/math.path";
  75324. /**
  75325. * A cursor which tracks a point on a path
  75326. */
  75327. export class PathCursor {
  75328. private path;
  75329. /**
  75330. * Stores path cursor callbacks for when an onchange event is triggered
  75331. */
  75332. private _onchange;
  75333. /**
  75334. * The value of the path cursor
  75335. */
  75336. value: number;
  75337. /**
  75338. * The animation array of the path cursor
  75339. */
  75340. animations: Animation[];
  75341. /**
  75342. * Initializes the path cursor
  75343. * @param path The path to track
  75344. */
  75345. constructor(path: Path2);
  75346. /**
  75347. * Gets the cursor point on the path
  75348. * @returns A point on the path cursor at the cursor location
  75349. */
  75350. getPoint(): Vector3;
  75351. /**
  75352. * Moves the cursor ahead by the step amount
  75353. * @param step The amount to move the cursor forward
  75354. * @returns This path cursor
  75355. */
  75356. moveAhead(step?: number): PathCursor;
  75357. /**
  75358. * Moves the cursor behind by the step amount
  75359. * @param step The amount to move the cursor back
  75360. * @returns This path cursor
  75361. */
  75362. moveBack(step?: number): PathCursor;
  75363. /**
  75364. * Moves the cursor by the step amount
  75365. * If the step amount is greater than one, an exception is thrown
  75366. * @param step The amount to move the cursor
  75367. * @returns This path cursor
  75368. */
  75369. move(step: number): PathCursor;
  75370. /**
  75371. * Ensures that the value is limited between zero and one
  75372. * @returns This path cursor
  75373. */
  75374. private ensureLimits;
  75375. /**
  75376. * Runs onchange callbacks on change (used by the animation engine)
  75377. * @returns This path cursor
  75378. */
  75379. private raiseOnChange;
  75380. /**
  75381. * Executes a function on change
  75382. * @param f A path cursor onchange callback
  75383. * @returns This path cursor
  75384. */
  75385. onchange(f: (cursor: PathCursor) => void): PathCursor;
  75386. }
  75387. }
  75388. declare module "babylonjs/Engines/Processors/Expressions/Operators/index" {
  75389. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator";
  75390. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator";
  75391. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator";
  75392. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator";
  75393. }
  75394. declare module "babylonjs/Engines/Processors/Expressions/index" {
  75395. export * from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  75396. export * from "babylonjs/Engines/Processors/Expressions/Operators/index";
  75397. }
  75398. declare module "babylonjs/Engines/Processors/index" {
  75399. export * from "babylonjs/Engines/Processors/iShaderProcessor";
  75400. export * from "babylonjs/Engines/Processors/Expressions/index";
  75401. export * from "babylonjs/Engines/Processors/shaderCodeConditionNode";
  75402. export * from "babylonjs/Engines/Processors/shaderCodeCursor";
  75403. export * from "babylonjs/Engines/Processors/shaderCodeNode";
  75404. export * from "babylonjs/Engines/Processors/shaderCodeTestNode";
  75405. export * from "babylonjs/Engines/Processors/shaderProcessingOptions";
  75406. export * from "babylonjs/Engines/Processors/shaderProcessor";
  75407. }
  75408. declare module "babylonjs/Legacy/legacy" {
  75409. import * as Babylon from "babylonjs/index";
  75410. export * from "babylonjs/index";
  75411. }
  75412. declare module "babylonjs/Shaders/blur.fragment" {
  75413. /** @hidden */
  75414. export var blurPixelShader: {
  75415. name: string;
  75416. shader: string;
  75417. };
  75418. }
  75419. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertexDeclaration" {
  75420. /** @hidden */
  75421. export var pointCloudVertexDeclaration: {
  75422. name: string;
  75423. shader: string;
  75424. };
  75425. }
  75426. declare module "babylonjs" {
  75427. export * from "babylonjs/Legacy/legacy";
  75428. }
  75429. declare module BABYLON {
  75430. /** Alias type for value that can be null */
  75431. export type Nullable<T> = T | null;
  75432. /**
  75433. * Alias type for number that are floats
  75434. * @ignorenaming
  75435. */
  75436. export type float = number;
  75437. /**
  75438. * Alias type for number that are doubles.
  75439. * @ignorenaming
  75440. */
  75441. export type double = number;
  75442. /**
  75443. * Alias type for number that are integer
  75444. * @ignorenaming
  75445. */
  75446. export type int = number;
  75447. /** Alias type for number array or Float32Array */
  75448. export type FloatArray = number[] | Float32Array;
  75449. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  75450. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  75451. /**
  75452. * Alias for types that can be used by a Buffer or VertexBuffer.
  75453. */
  75454. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  75455. /**
  75456. * Alias type for primitive types
  75457. * @ignorenaming
  75458. */
  75459. type Primitive = undefined | null | boolean | string | number | Function;
  75460. /**
  75461. * Type modifier to make all the properties of an object Readonly
  75462. */
  75463. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  75464. /**
  75465. * Type modifier to make all the properties of an object Readonly recursively
  75466. */
  75467. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  75468. /**
  75469. * Type modifier to make object properties readonly.
  75470. */
  75471. export type DeepImmutableObject<T> = {
  75472. readonly [K in keyof T]: DeepImmutable<T[K]>;
  75473. };
  75474. /** @hidden */
  75475. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  75476. }
  75477. }
  75478. declare module BABYLON {
  75479. /**
  75480. * A class serves as a medium between the observable and its observers
  75481. */
  75482. export class EventState {
  75483. /**
  75484. * Create a new EventState
  75485. * @param mask defines the mask associated with this state
  75486. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  75487. * @param target defines the original target of the state
  75488. * @param currentTarget defines the current target of the state
  75489. */
  75490. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  75491. /**
  75492. * Initialize the current event state
  75493. * @param mask defines the mask associated with this state
  75494. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  75495. * @param target defines the original target of the state
  75496. * @param currentTarget defines the current target of the state
  75497. * @returns the current event state
  75498. */
  75499. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  75500. /**
  75501. * An Observer can set this property to true to prevent subsequent observers of being notified
  75502. */
  75503. skipNextObservers: boolean;
  75504. /**
  75505. * Get the mask value that were used to trigger the event corresponding to this EventState object
  75506. */
  75507. mask: number;
  75508. /**
  75509. * The object that originally notified the event
  75510. */
  75511. target?: any;
  75512. /**
  75513. * The current object in the bubbling phase
  75514. */
  75515. currentTarget?: any;
  75516. /**
  75517. * This will be populated with the return value of the last function that was executed.
  75518. * If it is the first function in the callback chain it will be the event data.
  75519. */
  75520. lastReturnValue?: any;
  75521. }
  75522. /**
  75523. * Represent an Observer registered to a given Observable object.
  75524. */
  75525. export class Observer<T> {
  75526. /**
  75527. * Defines the callback to call when the observer is notified
  75528. */
  75529. callback: (eventData: T, eventState: EventState) => void;
  75530. /**
  75531. * Defines the mask of the observer (used to filter notifications)
  75532. */
  75533. mask: number;
  75534. /**
  75535. * Defines the current scope used to restore the JS context
  75536. */
  75537. scope: any;
  75538. /** @hidden */
  75539. _willBeUnregistered: boolean;
  75540. /**
  75541. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  75542. */
  75543. unregisterOnNextCall: boolean;
  75544. /**
  75545. * Creates a new observer
  75546. * @param callback defines the callback to call when the observer is notified
  75547. * @param mask defines the mask of the observer (used to filter notifications)
  75548. * @param scope defines the current scope used to restore the JS context
  75549. */
  75550. constructor(
  75551. /**
  75552. * Defines the callback to call when the observer is notified
  75553. */
  75554. callback: (eventData: T, eventState: EventState) => void,
  75555. /**
  75556. * Defines the mask of the observer (used to filter notifications)
  75557. */
  75558. mask: number,
  75559. /**
  75560. * Defines the current scope used to restore the JS context
  75561. */
  75562. scope?: any);
  75563. }
  75564. /**
  75565. * Represent a list of observers registered to multiple Observables object.
  75566. */
  75567. export class MultiObserver<T> {
  75568. private _observers;
  75569. private _observables;
  75570. /**
  75571. * Release associated resources
  75572. */
  75573. dispose(): void;
  75574. /**
  75575. * Raise a callback when one of the observable will notify
  75576. * @param observables defines a list of observables to watch
  75577. * @param callback defines the callback to call on notification
  75578. * @param mask defines the mask used to filter notifications
  75579. * @param scope defines the current scope used to restore the JS context
  75580. * @returns the new MultiObserver
  75581. */
  75582. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  75583. }
  75584. /**
  75585. * The Observable class is a simple implementation of the Observable pattern.
  75586. *
  75587. * 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.
  75588. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  75589. * 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).
  75590. * 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.
  75591. */
  75592. export class Observable<T> {
  75593. private _observers;
  75594. private _eventState;
  75595. private _onObserverAdded;
  75596. /**
  75597. * Gets the list of observers
  75598. */
  75599. get observers(): Array<Observer<T>>;
  75600. /**
  75601. * Creates a new observable
  75602. * @param onObserverAdded defines a callback to call when a new observer is added
  75603. */
  75604. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  75605. /**
  75606. * Create a new Observer with the specified callback
  75607. * @param callback the callback that will be executed for that Observer
  75608. * @param mask the mask used to filter observers
  75609. * @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.
  75610. * @param scope optional scope for the callback to be called from
  75611. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  75612. * @returns the new observer created for the callback
  75613. */
  75614. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  75615. /**
  75616. * Create a new Observer with the specified callback and unregisters after the next notification
  75617. * @param callback the callback that will be executed for that Observer
  75618. * @returns the new observer created for the callback
  75619. */
  75620. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  75621. /**
  75622. * Remove an Observer from the Observable object
  75623. * @param observer the instance of the Observer to remove
  75624. * @returns false if it doesn't belong to this Observable
  75625. */
  75626. remove(observer: Nullable<Observer<T>>): boolean;
  75627. /**
  75628. * Remove a callback from the Observable object
  75629. * @param callback the callback to remove
  75630. * @param scope optional scope. If used only the callbacks with this scope will be removed
  75631. * @returns false if it doesn't belong to this Observable
  75632. */
  75633. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  75634. private _deferUnregister;
  75635. private _remove;
  75636. /**
  75637. * Moves the observable to the top of the observer list making it get called first when notified
  75638. * @param observer the observer to move
  75639. */
  75640. makeObserverTopPriority(observer: Observer<T>): void;
  75641. /**
  75642. * Moves the observable to the bottom of the observer list making it get called last when notified
  75643. * @param observer the observer to move
  75644. */
  75645. makeObserverBottomPriority(observer: Observer<T>): void;
  75646. /**
  75647. * Notify all Observers by calling their respective callback with the given data
  75648. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  75649. * @param eventData defines the data to send to all observers
  75650. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  75651. * @param target defines the original target of the state
  75652. * @param currentTarget defines the current target of the state
  75653. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  75654. */
  75655. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  75656. /**
  75657. * Calling this will execute each callback, expecting it to be a promise or return a value.
  75658. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  75659. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  75660. * and it is crucial that all callbacks will be executed.
  75661. * The order of the callbacks is kept, callbacks are not executed parallel.
  75662. *
  75663. * @param eventData The data to be sent to each callback
  75664. * @param mask is used to filter observers defaults to -1
  75665. * @param target defines the callback target (see EventState)
  75666. * @param currentTarget defines he current object in the bubbling phase
  75667. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  75668. */
  75669. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  75670. /**
  75671. * Notify a specific observer
  75672. * @param observer defines the observer to notify
  75673. * @param eventData defines the data to be sent to each callback
  75674. * @param mask is used to filter observers defaults to -1
  75675. */
  75676. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  75677. /**
  75678. * Gets a boolean indicating if the observable has at least one observer
  75679. * @returns true is the Observable has at least one Observer registered
  75680. */
  75681. hasObservers(): boolean;
  75682. /**
  75683. * Clear the list of observers
  75684. */
  75685. clear(): void;
  75686. /**
  75687. * Clone the current observable
  75688. * @returns a new observable
  75689. */
  75690. clone(): Observable<T>;
  75691. /**
  75692. * Does this observable handles observer registered with a given mask
  75693. * @param mask defines the mask to be tested
  75694. * @return whether or not one observer registered with the given mask is handeled
  75695. **/
  75696. hasSpecificMask(mask?: number): boolean;
  75697. }
  75698. }
  75699. declare module BABYLON {
  75700. /**
  75701. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  75702. * Babylon.js
  75703. */
  75704. export class DomManagement {
  75705. /**
  75706. * Checks if the window object exists
  75707. * @returns true if the window object exists
  75708. */
  75709. static IsWindowObjectExist(): boolean;
  75710. /**
  75711. * Checks if the navigator object exists
  75712. * @returns true if the navigator object exists
  75713. */
  75714. static IsNavigatorAvailable(): boolean;
  75715. /**
  75716. * Check if the document object exists
  75717. * @returns true if the document object exists
  75718. */
  75719. static IsDocumentAvailable(): boolean;
  75720. /**
  75721. * Extracts text content from a DOM element hierarchy
  75722. * @param element defines the root element
  75723. * @returns a string
  75724. */
  75725. static GetDOMTextContent(element: HTMLElement): string;
  75726. }
  75727. }
  75728. declare module BABYLON {
  75729. /**
  75730. * Logger used througouht the application to allow configuration of
  75731. * the log level required for the messages.
  75732. */
  75733. export class Logger {
  75734. /**
  75735. * No log
  75736. */
  75737. static readonly NoneLogLevel: number;
  75738. /**
  75739. * Only message logs
  75740. */
  75741. static readonly MessageLogLevel: number;
  75742. /**
  75743. * Only warning logs
  75744. */
  75745. static readonly WarningLogLevel: number;
  75746. /**
  75747. * Only error logs
  75748. */
  75749. static readonly ErrorLogLevel: number;
  75750. /**
  75751. * All logs
  75752. */
  75753. static readonly AllLogLevel: number;
  75754. private static _LogCache;
  75755. /**
  75756. * Gets a value indicating the number of loading errors
  75757. * @ignorenaming
  75758. */
  75759. static errorsCount: number;
  75760. /**
  75761. * Callback called when a new log is added
  75762. */
  75763. static OnNewCacheEntry: (entry: string) => void;
  75764. private static _AddLogEntry;
  75765. private static _FormatMessage;
  75766. private static _LogDisabled;
  75767. private static _LogEnabled;
  75768. private static _WarnDisabled;
  75769. private static _WarnEnabled;
  75770. private static _ErrorDisabled;
  75771. private static _ErrorEnabled;
  75772. /**
  75773. * Log a message to the console
  75774. */
  75775. static Log: (message: string) => void;
  75776. /**
  75777. * Write a warning message to the console
  75778. */
  75779. static Warn: (message: string) => void;
  75780. /**
  75781. * Write an error message to the console
  75782. */
  75783. static Error: (message: string) => void;
  75784. /**
  75785. * Gets current log cache (list of logs)
  75786. */
  75787. static get LogCache(): string;
  75788. /**
  75789. * Clears the log cache
  75790. */
  75791. static ClearLogCache(): void;
  75792. /**
  75793. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  75794. */
  75795. static set LogLevels(level: number);
  75796. }
  75797. }
  75798. declare module BABYLON {
  75799. /** @hidden */
  75800. export class _TypeStore {
  75801. /** @hidden */
  75802. static RegisteredTypes: {
  75803. [key: string]: Object;
  75804. };
  75805. /** @hidden */
  75806. static GetClass(fqdn: string): any;
  75807. }
  75808. }
  75809. declare module BABYLON {
  75810. /**
  75811. * Helper to manipulate strings
  75812. */
  75813. export class StringTools {
  75814. /**
  75815. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  75816. * @param str Source string
  75817. * @param suffix Suffix to search for in the source string
  75818. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  75819. */
  75820. static EndsWith(str: string, suffix: string): boolean;
  75821. /**
  75822. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  75823. * @param str Source string
  75824. * @param suffix Suffix to search for in the source string
  75825. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  75826. */
  75827. static StartsWith(str: string, suffix: string): boolean;
  75828. /**
  75829. * Decodes a buffer into a string
  75830. * @param buffer The buffer to decode
  75831. * @returns The decoded string
  75832. */
  75833. static Decode(buffer: Uint8Array | Uint16Array): string;
  75834. /**
  75835. * Encode a buffer to a base64 string
  75836. * @param buffer defines the buffer to encode
  75837. * @returns the encoded string
  75838. */
  75839. static EncodeArrayBufferToBase64(buffer: ArrayBuffer | ArrayBufferView): string;
  75840. /**
  75841. * Converts a number to string and pads with preceeding zeroes until it is of specified length.
  75842. * @param num the number to convert and pad
  75843. * @param length the expected length of the string
  75844. * @returns the padded string
  75845. */
  75846. static PadNumber(num: number, length: number): string;
  75847. }
  75848. }
  75849. declare module BABYLON {
  75850. /**
  75851. * Class containing a set of static utilities functions for deep copy.
  75852. */
  75853. export class DeepCopier {
  75854. /**
  75855. * Tries to copy an object by duplicating every property
  75856. * @param source defines the source object
  75857. * @param destination defines the target object
  75858. * @param doNotCopyList defines a list of properties to avoid
  75859. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  75860. */
  75861. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  75862. }
  75863. }
  75864. declare module BABYLON {
  75865. /**
  75866. * Class containing a set of static utilities functions for precision date
  75867. */
  75868. export class PrecisionDate {
  75869. /**
  75870. * Gets either window.performance.now() if supported or Date.now() else
  75871. */
  75872. static get Now(): number;
  75873. }
  75874. }
  75875. declare module BABYLON {
  75876. /** @hidden */
  75877. export class _DevTools {
  75878. static WarnImport(name: string): string;
  75879. }
  75880. }
  75881. declare module BABYLON {
  75882. /**
  75883. * Interface used to define the mechanism to get data from the network
  75884. */
  75885. export interface IWebRequest {
  75886. /**
  75887. * Returns client's response url
  75888. */
  75889. responseURL: string;
  75890. /**
  75891. * Returns client's status
  75892. */
  75893. status: number;
  75894. /**
  75895. * Returns client's status as a text
  75896. */
  75897. statusText: string;
  75898. }
  75899. }
  75900. declare module BABYLON {
  75901. /**
  75902. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  75903. */
  75904. export class WebRequest implements IWebRequest {
  75905. private _xhr;
  75906. /**
  75907. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  75908. * i.e. when loading files, where the server/service expects an Authorization header
  75909. */
  75910. static CustomRequestHeaders: {
  75911. [key: string]: string;
  75912. };
  75913. /**
  75914. * Add callback functions in this array to update all the requests before they get sent to the network
  75915. */
  75916. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  75917. private _injectCustomRequestHeaders;
  75918. /**
  75919. * Gets or sets a function to be called when loading progress changes
  75920. */
  75921. get onprogress(): ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  75922. set onprogress(value: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null);
  75923. /**
  75924. * Returns client's state
  75925. */
  75926. get readyState(): number;
  75927. /**
  75928. * Returns client's status
  75929. */
  75930. get status(): number;
  75931. /**
  75932. * Returns client's status as a text
  75933. */
  75934. get statusText(): string;
  75935. /**
  75936. * Returns client's response
  75937. */
  75938. get response(): any;
  75939. /**
  75940. * Returns client's response url
  75941. */
  75942. get responseURL(): string;
  75943. /**
  75944. * Returns client's response as text
  75945. */
  75946. get responseText(): string;
  75947. /**
  75948. * Gets or sets the expected response type
  75949. */
  75950. get responseType(): XMLHttpRequestResponseType;
  75951. set responseType(value: XMLHttpRequestResponseType);
  75952. /** @hidden */
  75953. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  75954. /** @hidden */
  75955. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  75956. /**
  75957. * Cancels any network activity
  75958. */
  75959. abort(): void;
  75960. /**
  75961. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  75962. * @param body defines an optional request body
  75963. */
  75964. send(body?: Document | BodyInit | null): void;
  75965. /**
  75966. * Sets the request method, request URL
  75967. * @param method defines the method to use (GET, POST, etc..)
  75968. * @param url defines the url to connect with
  75969. */
  75970. open(method: string, url: string): void;
  75971. /**
  75972. * Sets the value of a request header.
  75973. * @param name The name of the header whose value is to be set
  75974. * @param value The value to set as the body of the header
  75975. */
  75976. setRequestHeader(name: string, value: string): void;
  75977. /**
  75978. * Get the string containing the text of a particular header's value.
  75979. * @param name The name of the header
  75980. * @returns The string containing the text of the given header name
  75981. */
  75982. getResponseHeader(name: string): Nullable<string>;
  75983. }
  75984. }
  75985. declare module BABYLON {
  75986. /**
  75987. * File request interface
  75988. */
  75989. export interface IFileRequest {
  75990. /**
  75991. * Raised when the request is complete (success or error).
  75992. */
  75993. onCompleteObservable: Observable<IFileRequest>;
  75994. /**
  75995. * Aborts the request for a file.
  75996. */
  75997. abort: () => void;
  75998. }
  75999. }
  76000. declare module BABYLON {
  76001. /**
  76002. * Define options used to create a render target texture
  76003. */
  76004. export class RenderTargetCreationOptions {
  76005. /**
  76006. * Specifies is mipmaps must be generated
  76007. */
  76008. generateMipMaps?: boolean;
  76009. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  76010. generateDepthBuffer?: boolean;
  76011. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  76012. generateStencilBuffer?: boolean;
  76013. /** Defines texture type (int by default) */
  76014. type?: number;
  76015. /** Defines sampling mode (trilinear by default) */
  76016. samplingMode?: number;
  76017. /** Defines format (RGBA by default) */
  76018. format?: number;
  76019. }
  76020. }
  76021. declare module BABYLON {
  76022. /** Defines the cross module used constants to avoid circular dependncies */
  76023. export class Constants {
  76024. /** Defines that alpha blending is disabled */
  76025. static readonly ALPHA_DISABLE: number;
  76026. /** Defines that alpha blending is SRC ALPHA * SRC + DEST */
  76027. static readonly ALPHA_ADD: number;
  76028. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  76029. static readonly ALPHA_COMBINE: number;
  76030. /** Defines that alpha blending is DEST - SRC * DEST */
  76031. static readonly ALPHA_SUBTRACT: number;
  76032. /** Defines that alpha blending is SRC * DEST */
  76033. static readonly ALPHA_MULTIPLY: number;
  76034. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC) * DEST */
  76035. static readonly ALPHA_MAXIMIZED: number;
  76036. /** Defines that alpha blending is SRC + DEST */
  76037. static readonly ALPHA_ONEONE: number;
  76038. /** Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST */
  76039. static readonly ALPHA_PREMULTIPLIED: number;
  76040. /**
  76041. * Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST
  76042. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  76043. */
  76044. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  76045. /** Defines that alpha blending is CST * SRC + (1 - CST) * DEST */
  76046. static readonly ALPHA_INTERPOLATE: number;
  76047. /**
  76048. * Defines that alpha blending is SRC + (1 - SRC) * DEST
  76049. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  76050. */
  76051. static readonly ALPHA_SCREENMODE: number;
  76052. /**
  76053. * Defines that alpha blending is SRC + DST
  76054. * Alpha will be set to SRC ALPHA + DST ALPHA
  76055. */
  76056. static readonly ALPHA_ONEONE_ONEONE: number;
  76057. /**
  76058. * Defines that alpha blending is SRC * DST ALPHA + DST
  76059. * Alpha will be set to 0
  76060. */
  76061. static readonly ALPHA_ALPHATOCOLOR: number;
  76062. /**
  76063. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  76064. */
  76065. static readonly ALPHA_REVERSEONEMINUS: number;
  76066. /**
  76067. * Defines that alpha blending is SRC + DST * (1 - SRC ALPHA)
  76068. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  76069. */
  76070. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  76071. /**
  76072. * Defines that alpha blending is SRC + DST
  76073. * Alpha will be set to SRC ALPHA
  76074. */
  76075. static readonly ALPHA_ONEONE_ONEZERO: number;
  76076. /**
  76077. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  76078. * Alpha will be set to DST ALPHA
  76079. */
  76080. static readonly ALPHA_EXCLUSION: number;
  76081. /** Defines that alpha blending equation a SUM */
  76082. static readonly ALPHA_EQUATION_ADD: number;
  76083. /** Defines that alpha blending equation a SUBSTRACTION */
  76084. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  76085. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  76086. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  76087. /** Defines that alpha blending equation a MAX operation */
  76088. static readonly ALPHA_EQUATION_MAX: number;
  76089. /** Defines that alpha blending equation a MIN operation */
  76090. static readonly ALPHA_EQUATION_MIN: number;
  76091. /**
  76092. * Defines that alpha blending equation a DARKEN operation:
  76093. * It takes the min of the src and sums the alpha channels.
  76094. */
  76095. static readonly ALPHA_EQUATION_DARKEN: number;
  76096. /** Defines that the ressource is not delayed*/
  76097. static readonly DELAYLOADSTATE_NONE: number;
  76098. /** Defines that the ressource was successfully delay loaded */
  76099. static readonly DELAYLOADSTATE_LOADED: number;
  76100. /** Defines that the ressource is currently delay loading */
  76101. static readonly DELAYLOADSTATE_LOADING: number;
  76102. /** Defines that the ressource is delayed and has not started loading */
  76103. static readonly DELAYLOADSTATE_NOTLOADED: number;
  76104. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  76105. static readonly NEVER: number;
  76106. /** 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 */
  76107. static readonly ALWAYS: number;
  76108. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  76109. static readonly LESS: number;
  76110. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  76111. static readonly EQUAL: number;
  76112. /** 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 */
  76113. static readonly LEQUAL: number;
  76114. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  76115. static readonly GREATER: number;
  76116. /** 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 */
  76117. static readonly GEQUAL: number;
  76118. /** 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 */
  76119. static readonly NOTEQUAL: number;
  76120. /** Passed to stencilOperation to specify that stencil value must be kept */
  76121. static readonly KEEP: number;
  76122. /** Passed to stencilOperation to specify that stencil value must be replaced */
  76123. static readonly REPLACE: number;
  76124. /** Passed to stencilOperation to specify that stencil value must be incremented */
  76125. static readonly INCR: number;
  76126. /** Passed to stencilOperation to specify that stencil value must be decremented */
  76127. static readonly DECR: number;
  76128. /** Passed to stencilOperation to specify that stencil value must be inverted */
  76129. static readonly INVERT: number;
  76130. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  76131. static readonly INCR_WRAP: number;
  76132. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  76133. static readonly DECR_WRAP: number;
  76134. /** Texture is not repeating outside of 0..1 UVs */
  76135. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  76136. /** Texture is repeating outside of 0..1 UVs */
  76137. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  76138. /** Texture is repeating and mirrored */
  76139. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  76140. /** ALPHA */
  76141. static readonly TEXTUREFORMAT_ALPHA: number;
  76142. /** LUMINANCE */
  76143. static readonly TEXTUREFORMAT_LUMINANCE: number;
  76144. /** LUMINANCE_ALPHA */
  76145. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  76146. /** RGB */
  76147. static readonly TEXTUREFORMAT_RGB: number;
  76148. /** RGBA */
  76149. static readonly TEXTUREFORMAT_RGBA: number;
  76150. /** RED */
  76151. static readonly TEXTUREFORMAT_RED: number;
  76152. /** RED (2nd reference) */
  76153. static readonly TEXTUREFORMAT_R: number;
  76154. /** RG */
  76155. static readonly TEXTUREFORMAT_RG: number;
  76156. /** RED_INTEGER */
  76157. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  76158. /** RED_INTEGER (2nd reference) */
  76159. static readonly TEXTUREFORMAT_R_INTEGER: number;
  76160. /** RG_INTEGER */
  76161. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  76162. /** RGB_INTEGER */
  76163. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  76164. /** RGBA_INTEGER */
  76165. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  76166. /** UNSIGNED_BYTE */
  76167. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  76168. /** UNSIGNED_BYTE (2nd reference) */
  76169. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  76170. /** FLOAT */
  76171. static readonly TEXTURETYPE_FLOAT: number;
  76172. /** HALF_FLOAT */
  76173. static readonly TEXTURETYPE_HALF_FLOAT: number;
  76174. /** BYTE */
  76175. static readonly TEXTURETYPE_BYTE: number;
  76176. /** SHORT */
  76177. static readonly TEXTURETYPE_SHORT: number;
  76178. /** UNSIGNED_SHORT */
  76179. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  76180. /** INT */
  76181. static readonly TEXTURETYPE_INT: number;
  76182. /** UNSIGNED_INT */
  76183. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  76184. /** UNSIGNED_SHORT_4_4_4_4 */
  76185. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  76186. /** UNSIGNED_SHORT_5_5_5_1 */
  76187. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  76188. /** UNSIGNED_SHORT_5_6_5 */
  76189. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  76190. /** UNSIGNED_INT_2_10_10_10_REV */
  76191. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  76192. /** UNSIGNED_INT_24_8 */
  76193. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  76194. /** UNSIGNED_INT_10F_11F_11F_REV */
  76195. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  76196. /** UNSIGNED_INT_5_9_9_9_REV */
  76197. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  76198. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  76199. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  76200. /** nearest is mag = nearest and min = nearest and no mip */
  76201. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  76202. /** mag = nearest and min = nearest and mip = none */
  76203. static readonly TEXTURE_NEAREST_NEAREST: number;
  76204. /** Bilinear is mag = linear and min = linear and no mip */
  76205. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  76206. /** mag = linear and min = linear and mip = none */
  76207. static readonly TEXTURE_LINEAR_LINEAR: number;
  76208. /** Trilinear is mag = linear and min = linear and mip = linear */
  76209. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  76210. /** Trilinear is mag = linear and min = linear and mip = linear */
  76211. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  76212. /** mag = nearest and min = nearest and mip = nearest */
  76213. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  76214. /** mag = nearest and min = linear and mip = nearest */
  76215. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  76216. /** mag = nearest and min = linear and mip = linear */
  76217. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  76218. /** mag = nearest and min = linear and mip = none */
  76219. static readonly TEXTURE_NEAREST_LINEAR: number;
  76220. /** nearest is mag = nearest and min = nearest and mip = linear */
  76221. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  76222. /** mag = linear and min = nearest and mip = nearest */
  76223. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  76224. /** mag = linear and min = nearest and mip = linear */
  76225. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  76226. /** Bilinear is mag = linear and min = linear and mip = nearest */
  76227. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  76228. /** mag = linear and min = nearest and mip = none */
  76229. static readonly TEXTURE_LINEAR_NEAREST: number;
  76230. /** Explicit coordinates mode */
  76231. static readonly TEXTURE_EXPLICIT_MODE: number;
  76232. /** Spherical coordinates mode */
  76233. static readonly TEXTURE_SPHERICAL_MODE: number;
  76234. /** Planar coordinates mode */
  76235. static readonly TEXTURE_PLANAR_MODE: number;
  76236. /** Cubic coordinates mode */
  76237. static readonly TEXTURE_CUBIC_MODE: number;
  76238. /** Projection coordinates mode */
  76239. static readonly TEXTURE_PROJECTION_MODE: number;
  76240. /** Skybox coordinates mode */
  76241. static readonly TEXTURE_SKYBOX_MODE: number;
  76242. /** Inverse Cubic coordinates mode */
  76243. static readonly TEXTURE_INVCUBIC_MODE: number;
  76244. /** Equirectangular coordinates mode */
  76245. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  76246. /** Equirectangular Fixed coordinates mode */
  76247. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  76248. /** Equirectangular Fixed Mirrored coordinates mode */
  76249. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  76250. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  76251. static readonly SCALEMODE_FLOOR: number;
  76252. /** Defines that texture rescaling will look for the nearest power of 2 size */
  76253. static readonly SCALEMODE_NEAREST: number;
  76254. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  76255. static readonly SCALEMODE_CEILING: number;
  76256. /**
  76257. * The dirty texture flag value
  76258. */
  76259. static readonly MATERIAL_TextureDirtyFlag: number;
  76260. /**
  76261. * The dirty light flag value
  76262. */
  76263. static readonly MATERIAL_LightDirtyFlag: number;
  76264. /**
  76265. * The dirty fresnel flag value
  76266. */
  76267. static readonly MATERIAL_FresnelDirtyFlag: number;
  76268. /**
  76269. * The dirty attribute flag value
  76270. */
  76271. static readonly MATERIAL_AttributesDirtyFlag: number;
  76272. /**
  76273. * The dirty misc flag value
  76274. */
  76275. static readonly MATERIAL_MiscDirtyFlag: number;
  76276. /**
  76277. * The all dirty flag value
  76278. */
  76279. static readonly MATERIAL_AllDirtyFlag: number;
  76280. /**
  76281. * Returns the triangle fill mode
  76282. */
  76283. static readonly MATERIAL_TriangleFillMode: number;
  76284. /**
  76285. * Returns the wireframe mode
  76286. */
  76287. static readonly MATERIAL_WireFrameFillMode: number;
  76288. /**
  76289. * Returns the point fill mode
  76290. */
  76291. static readonly MATERIAL_PointFillMode: number;
  76292. /**
  76293. * Returns the point list draw mode
  76294. */
  76295. static readonly MATERIAL_PointListDrawMode: number;
  76296. /**
  76297. * Returns the line list draw mode
  76298. */
  76299. static readonly MATERIAL_LineListDrawMode: number;
  76300. /**
  76301. * Returns the line loop draw mode
  76302. */
  76303. static readonly MATERIAL_LineLoopDrawMode: number;
  76304. /**
  76305. * Returns the line strip draw mode
  76306. */
  76307. static readonly MATERIAL_LineStripDrawMode: number;
  76308. /**
  76309. * Returns the triangle strip draw mode
  76310. */
  76311. static readonly MATERIAL_TriangleStripDrawMode: number;
  76312. /**
  76313. * Returns the triangle fan draw mode
  76314. */
  76315. static readonly MATERIAL_TriangleFanDrawMode: number;
  76316. /**
  76317. * Stores the clock-wise side orientation
  76318. */
  76319. static readonly MATERIAL_ClockWiseSideOrientation: number;
  76320. /**
  76321. * Stores the counter clock-wise side orientation
  76322. */
  76323. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  76324. /**
  76325. * Nothing
  76326. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76327. */
  76328. static readonly ACTION_NothingTrigger: number;
  76329. /**
  76330. * On pick
  76331. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76332. */
  76333. static readonly ACTION_OnPickTrigger: number;
  76334. /**
  76335. * On left pick
  76336. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76337. */
  76338. static readonly ACTION_OnLeftPickTrigger: number;
  76339. /**
  76340. * On right pick
  76341. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76342. */
  76343. static readonly ACTION_OnRightPickTrigger: number;
  76344. /**
  76345. * On center pick
  76346. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76347. */
  76348. static readonly ACTION_OnCenterPickTrigger: number;
  76349. /**
  76350. * On pick down
  76351. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76352. */
  76353. static readonly ACTION_OnPickDownTrigger: number;
  76354. /**
  76355. * On double pick
  76356. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76357. */
  76358. static readonly ACTION_OnDoublePickTrigger: number;
  76359. /**
  76360. * On pick up
  76361. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76362. */
  76363. static readonly ACTION_OnPickUpTrigger: number;
  76364. /**
  76365. * On pick out.
  76366. * This trigger will only be raised if you also declared a OnPickDown
  76367. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76368. */
  76369. static readonly ACTION_OnPickOutTrigger: number;
  76370. /**
  76371. * On long press
  76372. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76373. */
  76374. static readonly ACTION_OnLongPressTrigger: number;
  76375. /**
  76376. * On pointer over
  76377. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76378. */
  76379. static readonly ACTION_OnPointerOverTrigger: number;
  76380. /**
  76381. * On pointer out
  76382. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76383. */
  76384. static readonly ACTION_OnPointerOutTrigger: number;
  76385. /**
  76386. * On every frame
  76387. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76388. */
  76389. static readonly ACTION_OnEveryFrameTrigger: number;
  76390. /**
  76391. * On intersection enter
  76392. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76393. */
  76394. static readonly ACTION_OnIntersectionEnterTrigger: number;
  76395. /**
  76396. * On intersection exit
  76397. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76398. */
  76399. static readonly ACTION_OnIntersectionExitTrigger: number;
  76400. /**
  76401. * On key down
  76402. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76403. */
  76404. static readonly ACTION_OnKeyDownTrigger: number;
  76405. /**
  76406. * On key up
  76407. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76408. */
  76409. static readonly ACTION_OnKeyUpTrigger: number;
  76410. /**
  76411. * Billboard mode will only apply to Y axis
  76412. */
  76413. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  76414. /**
  76415. * Billboard mode will apply to all axes
  76416. */
  76417. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  76418. /**
  76419. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  76420. */
  76421. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  76422. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  76423. * Test order :
  76424. * Is the bounding sphere outside the frustum ?
  76425. * If not, are the bounding box vertices outside the frustum ?
  76426. * It not, then the cullable object is in the frustum.
  76427. */
  76428. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  76429. /** Culling strategy : Bounding Sphere Only.
  76430. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  76431. * It's also less accurate than the standard because some not visible objects can still be selected.
  76432. * Test : is the bounding sphere outside the frustum ?
  76433. * If not, then the cullable object is in the frustum.
  76434. */
  76435. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  76436. /** Culling strategy : Optimistic Inclusion.
  76437. * This in an inclusion test first, then the standard exclusion test.
  76438. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  76439. * 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.
  76440. * Anyway, it's as accurate as the standard strategy.
  76441. * Test :
  76442. * Is the cullable object bounding sphere center in the frustum ?
  76443. * If not, apply the default culling strategy.
  76444. */
  76445. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  76446. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  76447. * This in an inclusion test first, then the bounding sphere only exclusion test.
  76448. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  76449. * 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.
  76450. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  76451. * Test :
  76452. * Is the cullable object bounding sphere center in the frustum ?
  76453. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  76454. */
  76455. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  76456. /**
  76457. * No logging while loading
  76458. */
  76459. static readonly SCENELOADER_NO_LOGGING: number;
  76460. /**
  76461. * Minimal logging while loading
  76462. */
  76463. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  76464. /**
  76465. * Summary logging while loading
  76466. */
  76467. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  76468. /**
  76469. * Detailled logging while loading
  76470. */
  76471. static readonly SCENELOADER_DETAILED_LOGGING: number;
  76472. }
  76473. }
  76474. declare module BABYLON {
  76475. /**
  76476. * This represents the required contract to create a new type of texture loader.
  76477. */
  76478. export interface IInternalTextureLoader {
  76479. /**
  76480. * Defines wether the loader supports cascade loading the different faces.
  76481. */
  76482. supportCascades: boolean;
  76483. /**
  76484. * This returns if the loader support the current file information.
  76485. * @param extension defines the file extension of the file being loaded
  76486. * @returns true if the loader can load the specified file
  76487. */
  76488. canLoad(extension: string): boolean;
  76489. /**
  76490. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  76491. * @param data contains the texture data
  76492. * @param texture defines the BabylonJS internal texture
  76493. * @param createPolynomials will be true if polynomials have been requested
  76494. * @param onLoad defines the callback to trigger once the texture is ready
  76495. * @param onError defines the callback to trigger in case of error
  76496. */
  76497. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  76498. /**
  76499. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  76500. * @param data contains the texture data
  76501. * @param texture defines the BabylonJS internal texture
  76502. * @param callback defines the method to call once ready to upload
  76503. */
  76504. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  76505. }
  76506. }
  76507. declare module BABYLON {
  76508. /**
  76509. * Class used to store and describe the pipeline context associated with an effect
  76510. */
  76511. export interface IPipelineContext {
  76512. /**
  76513. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  76514. */
  76515. isAsync: boolean;
  76516. /**
  76517. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  76518. */
  76519. isReady: boolean;
  76520. /** @hidden */
  76521. _getVertexShaderCode(): string | null;
  76522. /** @hidden */
  76523. _getFragmentShaderCode(): string | null;
  76524. /** @hidden */
  76525. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  76526. }
  76527. }
  76528. declare module BABYLON {
  76529. /**
  76530. * Class used to store gfx data (like WebGLBuffer)
  76531. */
  76532. export class DataBuffer {
  76533. /**
  76534. * Gets or sets the number of objects referencing this buffer
  76535. */
  76536. references: number;
  76537. /** Gets or sets the size of the underlying buffer */
  76538. capacity: number;
  76539. /**
  76540. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  76541. */
  76542. is32Bits: boolean;
  76543. /**
  76544. * Gets the underlying buffer
  76545. */
  76546. get underlyingResource(): any;
  76547. }
  76548. }
  76549. declare module BABYLON {
  76550. /** @hidden */
  76551. export interface IShaderProcessor {
  76552. attributeProcessor?: (attribute: string) => string;
  76553. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  76554. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  76555. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  76556. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  76557. lineProcessor?: (line: string, isFragment: boolean) => string;
  76558. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  76559. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  76560. }
  76561. }
  76562. declare module BABYLON {
  76563. /** @hidden */
  76564. export interface ProcessingOptions {
  76565. defines: string[];
  76566. indexParameters: any;
  76567. isFragment: boolean;
  76568. shouldUseHighPrecisionShader: boolean;
  76569. supportsUniformBuffers: boolean;
  76570. shadersRepository: string;
  76571. includesShadersStore: {
  76572. [key: string]: string;
  76573. };
  76574. processor?: IShaderProcessor;
  76575. version: string;
  76576. platformName: string;
  76577. lookForClosingBracketForUniformBuffer?: boolean;
  76578. }
  76579. }
  76580. declare module BABYLON {
  76581. /** @hidden */
  76582. export class ShaderCodeNode {
  76583. line: string;
  76584. children: ShaderCodeNode[];
  76585. additionalDefineKey?: string;
  76586. additionalDefineValue?: string;
  76587. isValid(preprocessors: {
  76588. [key: string]: string;
  76589. }): boolean;
  76590. process(preprocessors: {
  76591. [key: string]: string;
  76592. }, options: ProcessingOptions): string;
  76593. }
  76594. }
  76595. declare module BABYLON {
  76596. /** @hidden */
  76597. export class ShaderCodeCursor {
  76598. private _lines;
  76599. lineIndex: number;
  76600. get currentLine(): string;
  76601. get canRead(): boolean;
  76602. set lines(value: string[]);
  76603. }
  76604. }
  76605. declare module BABYLON {
  76606. /** @hidden */
  76607. export class ShaderCodeConditionNode extends ShaderCodeNode {
  76608. process(preprocessors: {
  76609. [key: string]: string;
  76610. }, options: ProcessingOptions): string;
  76611. }
  76612. }
  76613. declare module BABYLON {
  76614. /** @hidden */
  76615. export class ShaderDefineExpression {
  76616. isTrue(preprocessors: {
  76617. [key: string]: string;
  76618. }): boolean;
  76619. private static _OperatorPriority;
  76620. private static _Stack;
  76621. static postfixToInfix(postfix: string[]): string;
  76622. static infixToPostfix(infix: string): string[];
  76623. }
  76624. }
  76625. declare module BABYLON {
  76626. /** @hidden */
  76627. export class ShaderCodeTestNode extends ShaderCodeNode {
  76628. testExpression: ShaderDefineExpression;
  76629. isValid(preprocessors: {
  76630. [key: string]: string;
  76631. }): boolean;
  76632. }
  76633. }
  76634. declare module BABYLON {
  76635. /** @hidden */
  76636. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  76637. define: string;
  76638. not: boolean;
  76639. constructor(define: string, not?: boolean);
  76640. isTrue(preprocessors: {
  76641. [key: string]: string;
  76642. }): boolean;
  76643. }
  76644. }
  76645. declare module BABYLON {
  76646. /** @hidden */
  76647. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  76648. leftOperand: ShaderDefineExpression;
  76649. rightOperand: ShaderDefineExpression;
  76650. isTrue(preprocessors: {
  76651. [key: string]: string;
  76652. }): boolean;
  76653. }
  76654. }
  76655. declare module BABYLON {
  76656. /** @hidden */
  76657. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  76658. leftOperand: ShaderDefineExpression;
  76659. rightOperand: ShaderDefineExpression;
  76660. isTrue(preprocessors: {
  76661. [key: string]: string;
  76662. }): boolean;
  76663. }
  76664. }
  76665. declare module BABYLON {
  76666. /** @hidden */
  76667. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  76668. define: string;
  76669. operand: string;
  76670. testValue: string;
  76671. constructor(define: string, operand: string, testValue: string);
  76672. isTrue(preprocessors: {
  76673. [key: string]: string;
  76674. }): boolean;
  76675. }
  76676. }
  76677. declare module BABYLON {
  76678. /**
  76679. * Class used to enable access to offline support
  76680. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  76681. */
  76682. export interface IOfflineProvider {
  76683. /**
  76684. * Gets a boolean indicating if scene must be saved in the database
  76685. */
  76686. enableSceneOffline: boolean;
  76687. /**
  76688. * Gets a boolean indicating if textures must be saved in the database
  76689. */
  76690. enableTexturesOffline: boolean;
  76691. /**
  76692. * Open the offline support and make it available
  76693. * @param successCallback defines the callback to call on success
  76694. * @param errorCallback defines the callback to call on error
  76695. */
  76696. open(successCallback: () => void, errorCallback: () => void): void;
  76697. /**
  76698. * Loads an image from the offline support
  76699. * @param url defines the url to load from
  76700. * @param image defines the target DOM image
  76701. */
  76702. loadImage(url: string, image: HTMLImageElement): void;
  76703. /**
  76704. * Loads a file from offline support
  76705. * @param url defines the URL to load from
  76706. * @param sceneLoaded defines a callback to call on success
  76707. * @param progressCallBack defines a callback to call when progress changed
  76708. * @param errorCallback defines a callback to call on error
  76709. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  76710. */
  76711. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  76712. }
  76713. }
  76714. declare module BABYLON {
  76715. /**
  76716. * Class used to help managing file picking and drag'n'drop
  76717. * File Storage
  76718. */
  76719. export class FilesInputStore {
  76720. /**
  76721. * List of files ready to be loaded
  76722. */
  76723. static FilesToLoad: {
  76724. [key: string]: File;
  76725. };
  76726. }
  76727. }
  76728. declare module BABYLON {
  76729. /**
  76730. * Class used to define a retry strategy when error happens while loading assets
  76731. */
  76732. export class RetryStrategy {
  76733. /**
  76734. * Function used to defines an exponential back off strategy
  76735. * @param maxRetries defines the maximum number of retries (3 by default)
  76736. * @param baseInterval defines the interval between retries
  76737. * @returns the strategy function to use
  76738. */
  76739. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  76740. }
  76741. }
  76742. declare module BABYLON {
  76743. /**
  76744. * @ignore
  76745. * Application error to support additional information when loading a file
  76746. */
  76747. export abstract class BaseError extends Error {
  76748. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  76749. }
  76750. }
  76751. declare module BABYLON {
  76752. /** @ignore */
  76753. export class LoadFileError extends BaseError {
  76754. request?: WebRequest;
  76755. file?: File;
  76756. /**
  76757. * Creates a new LoadFileError
  76758. * @param message defines the message of the error
  76759. * @param request defines the optional web request
  76760. * @param file defines the optional file
  76761. */
  76762. constructor(message: string, object?: WebRequest | File);
  76763. }
  76764. /** @ignore */
  76765. export class RequestFileError extends BaseError {
  76766. request: WebRequest;
  76767. /**
  76768. * Creates a new LoadFileError
  76769. * @param message defines the message of the error
  76770. * @param request defines the optional web request
  76771. */
  76772. constructor(message: string, request: WebRequest);
  76773. }
  76774. /** @ignore */
  76775. export class ReadFileError extends BaseError {
  76776. file: File;
  76777. /**
  76778. * Creates a new ReadFileError
  76779. * @param message defines the message of the error
  76780. * @param file defines the optional file
  76781. */
  76782. constructor(message: string, file: File);
  76783. }
  76784. /**
  76785. * @hidden
  76786. */
  76787. export class FileTools {
  76788. /**
  76789. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  76790. */
  76791. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  76792. /**
  76793. * Gets or sets the base URL to use to load assets
  76794. */
  76795. static BaseUrl: string;
  76796. /**
  76797. * Default behaviour for cors in the application.
  76798. * It can be a string if the expected behavior is identical in the entire app.
  76799. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  76800. */
  76801. static CorsBehavior: string | ((url: string | string[]) => string);
  76802. /**
  76803. * Gets or sets a function used to pre-process url before using them to load assets
  76804. */
  76805. static PreprocessUrl: (url: string) => string;
  76806. /**
  76807. * Removes unwanted characters from an url
  76808. * @param url defines the url to clean
  76809. * @returns the cleaned url
  76810. */
  76811. private static _CleanUrl;
  76812. /**
  76813. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  76814. * @param url define the url we are trying
  76815. * @param element define the dom element where to configure the cors policy
  76816. */
  76817. static SetCorsBehavior(url: string | string[], element: {
  76818. crossOrigin: string | null;
  76819. }): void;
  76820. /**
  76821. * Loads an image as an HTMLImageElement.
  76822. * @param input url string, ArrayBuffer, or Blob to load
  76823. * @param onLoad callback called when the image successfully loads
  76824. * @param onError callback called when the image fails to load
  76825. * @param offlineProvider offline provider for caching
  76826. * @param mimeType optional mime type
  76827. * @returns the HTMLImageElement of the loaded image
  76828. */
  76829. 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>;
  76830. /**
  76831. * Reads a file from a File object
  76832. * @param file defines the file to load
  76833. * @param onSuccess defines the callback to call when data is loaded
  76834. * @param onProgress defines the callback to call during loading process
  76835. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  76836. * @param onError defines the callback to call when an error occurs
  76837. * @returns a file request object
  76838. */
  76839. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  76840. /**
  76841. * Loads a file from a url
  76842. * @param url url to load
  76843. * @param onSuccess callback called when the file successfully loads
  76844. * @param onProgress callback called while file is loading (if the server supports this mode)
  76845. * @param offlineProvider defines the offline provider for caching
  76846. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  76847. * @param onError callback called when the file fails to load
  76848. * @returns a file request object
  76849. */
  76850. 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;
  76851. /**
  76852. * Loads a file
  76853. * @param url url to load
  76854. * @param onSuccess callback called when the file successfully loads
  76855. * @param onProgress callback called while file is loading (if the server supports this mode)
  76856. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  76857. * @param onError callback called when the file fails to load
  76858. * @param onOpened callback called when the web request is opened
  76859. * @returns a file request object
  76860. */
  76861. 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;
  76862. /**
  76863. * Checks if the loaded document was accessed via `file:`-Protocol.
  76864. * @returns boolean
  76865. */
  76866. static IsFileURL(): boolean;
  76867. }
  76868. }
  76869. declare module BABYLON {
  76870. /** @hidden */
  76871. export class ShaderProcessor {
  76872. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  76873. private static _ProcessPrecision;
  76874. private static _ExtractOperation;
  76875. private static _BuildSubExpression;
  76876. private static _BuildExpression;
  76877. private static _MoveCursorWithinIf;
  76878. private static _MoveCursor;
  76879. private static _EvaluatePreProcessors;
  76880. private static _PreparePreProcessors;
  76881. private static _ProcessShaderConversion;
  76882. private static _ProcessIncludes;
  76883. /**
  76884. * Loads a file from a url
  76885. * @param url url to load
  76886. * @param onSuccess callback called when the file successfully loads
  76887. * @param onProgress callback called while file is loading (if the server supports this mode)
  76888. * @param offlineProvider defines the offline provider for caching
  76889. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  76890. * @param onError callback called when the file fails to load
  76891. * @returns a file request object
  76892. * @hidden
  76893. */
  76894. 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;
  76895. }
  76896. }
  76897. declare module BABYLON {
  76898. /**
  76899. * @hidden
  76900. */
  76901. export interface IColor4Like {
  76902. r: float;
  76903. g: float;
  76904. b: float;
  76905. a: float;
  76906. }
  76907. /**
  76908. * @hidden
  76909. */
  76910. export interface IColor3Like {
  76911. r: float;
  76912. g: float;
  76913. b: float;
  76914. }
  76915. /**
  76916. * @hidden
  76917. */
  76918. export interface IVector4Like {
  76919. x: float;
  76920. y: float;
  76921. z: float;
  76922. w: float;
  76923. }
  76924. /**
  76925. * @hidden
  76926. */
  76927. export interface IVector3Like {
  76928. x: float;
  76929. y: float;
  76930. z: float;
  76931. }
  76932. /**
  76933. * @hidden
  76934. */
  76935. export interface IVector2Like {
  76936. x: float;
  76937. y: float;
  76938. }
  76939. /**
  76940. * @hidden
  76941. */
  76942. export interface IMatrixLike {
  76943. toArray(): DeepImmutable<Float32Array>;
  76944. updateFlag: int;
  76945. }
  76946. /**
  76947. * @hidden
  76948. */
  76949. export interface IViewportLike {
  76950. x: float;
  76951. y: float;
  76952. width: float;
  76953. height: float;
  76954. }
  76955. /**
  76956. * @hidden
  76957. */
  76958. export interface IPlaneLike {
  76959. normal: IVector3Like;
  76960. d: float;
  76961. normalize(): void;
  76962. }
  76963. }
  76964. declare module BABYLON {
  76965. /**
  76966. * Interface used to define common properties for effect fallbacks
  76967. */
  76968. export interface IEffectFallbacks {
  76969. /**
  76970. * Removes the defines that should be removed when falling back.
  76971. * @param currentDefines defines the current define statements for the shader.
  76972. * @param effect defines the current effect we try to compile
  76973. * @returns The resulting defines with defines of the current rank removed.
  76974. */
  76975. reduce(currentDefines: string, effect: Effect): string;
  76976. /**
  76977. * Removes the fallback from the bound mesh.
  76978. */
  76979. unBindMesh(): void;
  76980. /**
  76981. * Checks to see if more fallbacks are still availible.
  76982. */
  76983. hasMoreFallbacks: boolean;
  76984. }
  76985. }
  76986. declare module BABYLON {
  76987. /**
  76988. * Class used to evalaute queries containing `and` and `or` operators
  76989. */
  76990. export class AndOrNotEvaluator {
  76991. /**
  76992. * Evaluate a query
  76993. * @param query defines the query to evaluate
  76994. * @param evaluateCallback defines the callback used to filter result
  76995. * @returns true if the query matches
  76996. */
  76997. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  76998. private static _HandleParenthesisContent;
  76999. private static _SimplifyNegation;
  77000. }
  77001. }
  77002. declare module BABYLON {
  77003. /**
  77004. * Class used to store custom tags
  77005. */
  77006. export class Tags {
  77007. /**
  77008. * Adds support for tags on the given object
  77009. * @param obj defines the object to use
  77010. */
  77011. static EnableFor(obj: any): void;
  77012. /**
  77013. * Removes tags support
  77014. * @param obj defines the object to use
  77015. */
  77016. static DisableFor(obj: any): void;
  77017. /**
  77018. * Gets a boolean indicating if the given object has tags
  77019. * @param obj defines the object to use
  77020. * @returns a boolean
  77021. */
  77022. static HasTags(obj: any): boolean;
  77023. /**
  77024. * Gets the tags available on a given object
  77025. * @param obj defines the object to use
  77026. * @param asString defines if the tags must be returned as a string instead of an array of strings
  77027. * @returns the tags
  77028. */
  77029. static GetTags(obj: any, asString?: boolean): any;
  77030. /**
  77031. * Adds tags to an object
  77032. * @param obj defines the object to use
  77033. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  77034. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  77035. */
  77036. static AddTagsTo(obj: any, tagsString: string): void;
  77037. /**
  77038. * @hidden
  77039. */
  77040. static _AddTagTo(obj: any, tag: string): void;
  77041. /**
  77042. * Removes specific tags from a specific object
  77043. * @param obj defines the object to use
  77044. * @param tagsString defines the tags to remove
  77045. */
  77046. static RemoveTagsFrom(obj: any, tagsString: string): void;
  77047. /**
  77048. * @hidden
  77049. */
  77050. static _RemoveTagFrom(obj: any, tag: string): void;
  77051. /**
  77052. * Defines if tags hosted on an object match a given query
  77053. * @param obj defines the object to use
  77054. * @param tagsQuery defines the tag query
  77055. * @returns a boolean
  77056. */
  77057. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  77058. }
  77059. }
  77060. declare module BABYLON {
  77061. /**
  77062. * Scalar computation library
  77063. */
  77064. export class Scalar {
  77065. /**
  77066. * Two pi constants convenient for computation.
  77067. */
  77068. static TwoPi: number;
  77069. /**
  77070. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  77071. * @param a number
  77072. * @param b number
  77073. * @param epsilon (default = 1.401298E-45)
  77074. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  77075. */
  77076. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  77077. /**
  77078. * Returns a string : the upper case translation of the number i to hexadecimal.
  77079. * @param i number
  77080. * @returns the upper case translation of the number i to hexadecimal.
  77081. */
  77082. static ToHex(i: number): string;
  77083. /**
  77084. * Returns -1 if value is negative and +1 is value is positive.
  77085. * @param value the value
  77086. * @returns the value itself if it's equal to zero.
  77087. */
  77088. static Sign(value: number): number;
  77089. /**
  77090. * Returns the value itself if it's between min and max.
  77091. * Returns min if the value is lower than min.
  77092. * Returns max if the value is greater than max.
  77093. * @param value the value to clmap
  77094. * @param min the min value to clamp to (default: 0)
  77095. * @param max the max value to clamp to (default: 1)
  77096. * @returns the clamped value
  77097. */
  77098. static Clamp(value: number, min?: number, max?: number): number;
  77099. /**
  77100. * the log2 of value.
  77101. * @param value the value to compute log2 of
  77102. * @returns the log2 of value.
  77103. */
  77104. static Log2(value: number): number;
  77105. /**
  77106. * Loops the value, so that it is never larger than length and never smaller than 0.
  77107. *
  77108. * This is similar to the modulo operator but it works with floating point numbers.
  77109. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  77110. * With t = 5 and length = 2.5, the result would be 0.0.
  77111. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  77112. * @param value the value
  77113. * @param length the length
  77114. * @returns the looped value
  77115. */
  77116. static Repeat(value: number, length: number): number;
  77117. /**
  77118. * Normalize the value between 0.0 and 1.0 using min and max values
  77119. * @param value value to normalize
  77120. * @param min max to normalize between
  77121. * @param max min to normalize between
  77122. * @returns the normalized value
  77123. */
  77124. static Normalize(value: number, min: number, max: number): number;
  77125. /**
  77126. * Denormalize the value from 0.0 and 1.0 using min and max values
  77127. * @param normalized value to denormalize
  77128. * @param min max to denormalize between
  77129. * @param max min to denormalize between
  77130. * @returns the denormalized value
  77131. */
  77132. static Denormalize(normalized: number, min: number, max: number): number;
  77133. /**
  77134. * Calculates the shortest difference between two given angles given in degrees.
  77135. * @param current current angle in degrees
  77136. * @param target target angle in degrees
  77137. * @returns the delta
  77138. */
  77139. static DeltaAngle(current: number, target: number): number;
  77140. /**
  77141. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  77142. * @param tx value
  77143. * @param length length
  77144. * @returns The returned value will move back and forth between 0 and length
  77145. */
  77146. static PingPong(tx: number, length: number): number;
  77147. /**
  77148. * Interpolates between min and max with smoothing at the limits.
  77149. *
  77150. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  77151. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  77152. * @param from from
  77153. * @param to to
  77154. * @param tx value
  77155. * @returns the smooth stepped value
  77156. */
  77157. static SmoothStep(from: number, to: number, tx: number): number;
  77158. /**
  77159. * Moves a value current towards target.
  77160. *
  77161. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  77162. * Negative values of maxDelta pushes the value away from target.
  77163. * @param current current value
  77164. * @param target target value
  77165. * @param maxDelta max distance to move
  77166. * @returns resulting value
  77167. */
  77168. static MoveTowards(current: number, target: number, maxDelta: number): number;
  77169. /**
  77170. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  77171. *
  77172. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  77173. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  77174. * @param current current value
  77175. * @param target target value
  77176. * @param maxDelta max distance to move
  77177. * @returns resulting angle
  77178. */
  77179. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  77180. /**
  77181. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  77182. * @param start start value
  77183. * @param end target value
  77184. * @param amount amount to lerp between
  77185. * @returns the lerped value
  77186. */
  77187. static Lerp(start: number, end: number, amount: number): number;
  77188. /**
  77189. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  77190. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  77191. * @param start start value
  77192. * @param end target value
  77193. * @param amount amount to lerp between
  77194. * @returns the lerped value
  77195. */
  77196. static LerpAngle(start: number, end: number, amount: number): number;
  77197. /**
  77198. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  77199. * @param a start value
  77200. * @param b target value
  77201. * @param value value between a and b
  77202. * @returns the inverseLerp value
  77203. */
  77204. static InverseLerp(a: number, b: number, value: number): number;
  77205. /**
  77206. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  77207. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  77208. * @param value1 spline value
  77209. * @param tangent1 spline value
  77210. * @param value2 spline value
  77211. * @param tangent2 spline value
  77212. * @param amount input value
  77213. * @returns hermite result
  77214. */
  77215. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  77216. /**
  77217. * Returns a random float number between and min and max values
  77218. * @param min min value of random
  77219. * @param max max value of random
  77220. * @returns random value
  77221. */
  77222. static RandomRange(min: number, max: number): number;
  77223. /**
  77224. * This function returns percentage of a number in a given range.
  77225. *
  77226. * RangeToPercent(40,20,60) will return 0.5 (50%)
  77227. * RangeToPercent(34,0,100) will return 0.34 (34%)
  77228. * @param number to convert to percentage
  77229. * @param min min range
  77230. * @param max max range
  77231. * @returns the percentage
  77232. */
  77233. static RangeToPercent(number: number, min: number, max: number): number;
  77234. /**
  77235. * This function returns number that corresponds to the percentage in a given range.
  77236. *
  77237. * PercentToRange(0.34,0,100) will return 34.
  77238. * @param percent to convert to number
  77239. * @param min min range
  77240. * @param max max range
  77241. * @returns the number
  77242. */
  77243. static PercentToRange(percent: number, min: number, max: number): number;
  77244. /**
  77245. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  77246. * @param angle The angle to normalize in radian.
  77247. * @return The converted angle.
  77248. */
  77249. static NormalizeRadians(angle: number): number;
  77250. }
  77251. }
  77252. declare module BABYLON {
  77253. /**
  77254. * Constant used to convert a value to gamma space
  77255. * @ignorenaming
  77256. */
  77257. export const ToGammaSpace: number;
  77258. /**
  77259. * Constant used to convert a value to linear space
  77260. * @ignorenaming
  77261. */
  77262. export const ToLinearSpace = 2.2;
  77263. /**
  77264. * Constant used to define the minimal number value in Babylon.js
  77265. * @ignorenaming
  77266. */
  77267. let Epsilon: number;
  77268. }
  77269. declare module BABYLON {
  77270. /**
  77271. * Class used to represent a viewport on screen
  77272. */
  77273. export class Viewport {
  77274. /** viewport left coordinate */
  77275. x: number;
  77276. /** viewport top coordinate */
  77277. y: number;
  77278. /**viewport width */
  77279. width: number;
  77280. /** viewport height */
  77281. height: number;
  77282. /**
  77283. * Creates a Viewport object located at (x, y) and sized (width, height)
  77284. * @param x defines viewport left coordinate
  77285. * @param y defines viewport top coordinate
  77286. * @param width defines the viewport width
  77287. * @param height defines the viewport height
  77288. */
  77289. constructor(
  77290. /** viewport left coordinate */
  77291. x: number,
  77292. /** viewport top coordinate */
  77293. y: number,
  77294. /**viewport width */
  77295. width: number,
  77296. /** viewport height */
  77297. height: number);
  77298. /**
  77299. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  77300. * @param renderWidth defines the rendering width
  77301. * @param renderHeight defines the rendering height
  77302. * @returns a new Viewport
  77303. */
  77304. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  77305. /**
  77306. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  77307. * @param renderWidth defines the rendering width
  77308. * @param renderHeight defines the rendering height
  77309. * @param ref defines the target viewport
  77310. * @returns the current viewport
  77311. */
  77312. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  77313. /**
  77314. * Returns a new Viewport copied from the current one
  77315. * @returns a new Viewport
  77316. */
  77317. clone(): Viewport;
  77318. }
  77319. }
  77320. declare module BABYLON {
  77321. /**
  77322. * Class containing a set of static utilities functions for arrays.
  77323. */
  77324. export class ArrayTools {
  77325. /**
  77326. * Returns an array of the given size filled with element built from the given constructor and the paramters
  77327. * @param size the number of element to construct and put in the array
  77328. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  77329. * @returns a new array filled with new objects
  77330. */
  77331. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  77332. }
  77333. }
  77334. declare module BABYLON {
  77335. /**
  77336. * Represens a plane by the equation ax + by + cz + d = 0
  77337. */
  77338. export class Plane {
  77339. private static _TmpMatrix;
  77340. /**
  77341. * Normal of the plane (a,b,c)
  77342. */
  77343. normal: Vector3;
  77344. /**
  77345. * d component of the plane
  77346. */
  77347. d: number;
  77348. /**
  77349. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  77350. * @param a a component of the plane
  77351. * @param b b component of the plane
  77352. * @param c c component of the plane
  77353. * @param d d component of the plane
  77354. */
  77355. constructor(a: number, b: number, c: number, d: number);
  77356. /**
  77357. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  77358. */
  77359. asArray(): number[];
  77360. /**
  77361. * @returns a new plane copied from the current Plane.
  77362. */
  77363. clone(): Plane;
  77364. /**
  77365. * @returns the string "Plane".
  77366. */
  77367. getClassName(): string;
  77368. /**
  77369. * @returns the Plane hash code.
  77370. */
  77371. getHashCode(): number;
  77372. /**
  77373. * Normalize the current Plane in place.
  77374. * @returns the updated Plane.
  77375. */
  77376. normalize(): Plane;
  77377. /**
  77378. * Applies a transformation the plane and returns the result
  77379. * @param transformation the transformation matrix to be applied to the plane
  77380. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  77381. */
  77382. transform(transformation: DeepImmutable<Matrix>): Plane;
  77383. /**
  77384. * Compute the dot product between the point and the plane normal
  77385. * @param point point to calculate the dot product with
  77386. * @returns the dot product (float) of the point coordinates and the plane normal.
  77387. */
  77388. dotCoordinate(point: DeepImmutable<Vector3>): number;
  77389. /**
  77390. * Updates the current Plane from the plane defined by the three given points.
  77391. * @param point1 one of the points used to contruct the plane
  77392. * @param point2 one of the points used to contruct the plane
  77393. * @param point3 one of the points used to contruct the plane
  77394. * @returns the updated Plane.
  77395. */
  77396. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  77397. /**
  77398. * Checks if the plane is facing a given direction
  77399. * @param direction the direction to check if the plane is facing
  77400. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  77401. * @returns True is the vector "direction" is the same side than the plane normal.
  77402. */
  77403. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  77404. /**
  77405. * Calculates the distance to a point
  77406. * @param point point to calculate distance to
  77407. * @returns the signed distance (float) from the given point to the Plane.
  77408. */
  77409. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  77410. /**
  77411. * Creates a plane from an array
  77412. * @param array the array to create a plane from
  77413. * @returns a new Plane from the given array.
  77414. */
  77415. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  77416. /**
  77417. * Creates a plane from three points
  77418. * @param point1 point used to create the plane
  77419. * @param point2 point used to create the plane
  77420. * @param point3 point used to create the plane
  77421. * @returns a new Plane defined by the three given points.
  77422. */
  77423. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  77424. /**
  77425. * Creates a plane from an origin point and a normal
  77426. * @param origin origin of the plane to be constructed
  77427. * @param normal normal of the plane to be constructed
  77428. * @returns a new Plane the normal vector to this plane at the given origin point.
  77429. * Note : the vector "normal" is updated because normalized.
  77430. */
  77431. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  77432. /**
  77433. * Calculates the distance from a plane and a point
  77434. * @param origin origin of the plane to be constructed
  77435. * @param normal normal of the plane to be constructed
  77436. * @param point point to calculate distance to
  77437. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  77438. */
  77439. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  77440. }
  77441. }
  77442. declare module BABYLON {
  77443. /**
  77444. * Class representing a vector containing 2 coordinates
  77445. */
  77446. export class Vector2 {
  77447. /** defines the first coordinate */
  77448. x: number;
  77449. /** defines the second coordinate */
  77450. y: number;
  77451. /**
  77452. * Creates a new Vector2 from the given x and y coordinates
  77453. * @param x defines the first coordinate
  77454. * @param y defines the second coordinate
  77455. */
  77456. constructor(
  77457. /** defines the first coordinate */
  77458. x?: number,
  77459. /** defines the second coordinate */
  77460. y?: number);
  77461. /**
  77462. * Gets a string with the Vector2 coordinates
  77463. * @returns a string with the Vector2 coordinates
  77464. */
  77465. toString(): string;
  77466. /**
  77467. * Gets class name
  77468. * @returns the string "Vector2"
  77469. */
  77470. getClassName(): string;
  77471. /**
  77472. * Gets current vector hash code
  77473. * @returns the Vector2 hash code as a number
  77474. */
  77475. getHashCode(): number;
  77476. /**
  77477. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  77478. * @param array defines the source array
  77479. * @param index defines the offset in source array
  77480. * @returns the current Vector2
  77481. */
  77482. toArray(array: FloatArray, index?: number): Vector2;
  77483. /**
  77484. * Copy the current vector to an array
  77485. * @returns a new array with 2 elements: the Vector2 coordinates.
  77486. */
  77487. asArray(): number[];
  77488. /**
  77489. * Sets the Vector2 coordinates with the given Vector2 coordinates
  77490. * @param source defines the source Vector2
  77491. * @returns the current updated Vector2
  77492. */
  77493. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  77494. /**
  77495. * Sets the Vector2 coordinates with the given floats
  77496. * @param x defines the first coordinate
  77497. * @param y defines the second coordinate
  77498. * @returns the current updated Vector2
  77499. */
  77500. copyFromFloats(x: number, y: number): Vector2;
  77501. /**
  77502. * Sets the Vector2 coordinates with the given floats
  77503. * @param x defines the first coordinate
  77504. * @param y defines the second coordinate
  77505. * @returns the current updated Vector2
  77506. */
  77507. set(x: number, y: number): Vector2;
  77508. /**
  77509. * Add another vector with the current one
  77510. * @param otherVector defines the other vector
  77511. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  77512. */
  77513. add(otherVector: DeepImmutable<Vector2>): Vector2;
  77514. /**
  77515. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  77516. * @param otherVector defines the other vector
  77517. * @param result defines the target vector
  77518. * @returns the unmodified current Vector2
  77519. */
  77520. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  77521. /**
  77522. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  77523. * @param otherVector defines the other vector
  77524. * @returns the current updated Vector2
  77525. */
  77526. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  77527. /**
  77528. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  77529. * @param otherVector defines the other vector
  77530. * @returns a new Vector2
  77531. */
  77532. addVector3(otherVector: Vector3): Vector2;
  77533. /**
  77534. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  77535. * @param otherVector defines the other vector
  77536. * @returns a new Vector2
  77537. */
  77538. subtract(otherVector: Vector2): Vector2;
  77539. /**
  77540. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  77541. * @param otherVector defines the other vector
  77542. * @param result defines the target vector
  77543. * @returns the unmodified current Vector2
  77544. */
  77545. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  77546. /**
  77547. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  77548. * @param otherVector defines the other vector
  77549. * @returns the current updated Vector2
  77550. */
  77551. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  77552. /**
  77553. * Multiplies in place the current Vector2 coordinates by the given ones
  77554. * @param otherVector defines the other vector
  77555. * @returns the current updated Vector2
  77556. */
  77557. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  77558. /**
  77559. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  77560. * @param otherVector defines the other vector
  77561. * @returns a new Vector2
  77562. */
  77563. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  77564. /**
  77565. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  77566. * @param otherVector defines the other vector
  77567. * @param result defines the target vector
  77568. * @returns the unmodified current Vector2
  77569. */
  77570. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  77571. /**
  77572. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  77573. * @param x defines the first coordinate
  77574. * @param y defines the second coordinate
  77575. * @returns a new Vector2
  77576. */
  77577. multiplyByFloats(x: number, y: number): Vector2;
  77578. /**
  77579. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  77580. * @param otherVector defines the other vector
  77581. * @returns a new Vector2
  77582. */
  77583. divide(otherVector: Vector2): Vector2;
  77584. /**
  77585. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  77586. * @param otherVector defines the other vector
  77587. * @param result defines the target vector
  77588. * @returns the unmodified current Vector2
  77589. */
  77590. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  77591. /**
  77592. * Divides the current Vector2 coordinates by the given ones
  77593. * @param otherVector defines the other vector
  77594. * @returns the current updated Vector2
  77595. */
  77596. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  77597. /**
  77598. * Gets a new Vector2 with current Vector2 negated coordinates
  77599. * @returns a new Vector2
  77600. */
  77601. negate(): Vector2;
  77602. /**
  77603. * Negate this vector in place
  77604. * @returns this
  77605. */
  77606. negateInPlace(): Vector2;
  77607. /**
  77608. * Negate the current Vector2 and stores the result in the given vector "result" coordinates
  77609. * @param result defines the Vector3 object where to store the result
  77610. * @returns the current Vector2
  77611. */
  77612. negateToRef(result: Vector2): Vector2;
  77613. /**
  77614. * Multiply the Vector2 coordinates by scale
  77615. * @param scale defines the scaling factor
  77616. * @returns the current updated Vector2
  77617. */
  77618. scaleInPlace(scale: number): Vector2;
  77619. /**
  77620. * Returns a new Vector2 scaled by "scale" from the current Vector2
  77621. * @param scale defines the scaling factor
  77622. * @returns a new Vector2
  77623. */
  77624. scale(scale: number): Vector2;
  77625. /**
  77626. * Scale the current Vector2 values by a factor to a given Vector2
  77627. * @param scale defines the scale factor
  77628. * @param result defines the Vector2 object where to store the result
  77629. * @returns the unmodified current Vector2
  77630. */
  77631. scaleToRef(scale: number, result: Vector2): Vector2;
  77632. /**
  77633. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  77634. * @param scale defines the scale factor
  77635. * @param result defines the Vector2 object where to store the result
  77636. * @returns the unmodified current Vector2
  77637. */
  77638. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  77639. /**
  77640. * Gets a boolean if two vectors are equals
  77641. * @param otherVector defines the other vector
  77642. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  77643. */
  77644. equals(otherVector: DeepImmutable<Vector2>): boolean;
  77645. /**
  77646. * Gets a boolean if two vectors are equals (using an epsilon value)
  77647. * @param otherVector defines the other vector
  77648. * @param epsilon defines the minimal distance to consider equality
  77649. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  77650. */
  77651. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  77652. /**
  77653. * Gets a new Vector2 from current Vector2 floored values
  77654. * @returns a new Vector2
  77655. */
  77656. floor(): Vector2;
  77657. /**
  77658. * Gets a new Vector2 from current Vector2 floored values
  77659. * @returns a new Vector2
  77660. */
  77661. fract(): Vector2;
  77662. /**
  77663. * Gets the length of the vector
  77664. * @returns the vector length (float)
  77665. */
  77666. length(): number;
  77667. /**
  77668. * Gets the vector squared length
  77669. * @returns the vector squared length (float)
  77670. */
  77671. lengthSquared(): number;
  77672. /**
  77673. * Normalize the vector
  77674. * @returns the current updated Vector2
  77675. */
  77676. normalize(): Vector2;
  77677. /**
  77678. * Gets a new Vector2 copied from the Vector2
  77679. * @returns a new Vector2
  77680. */
  77681. clone(): Vector2;
  77682. /**
  77683. * Gets a new Vector2(0, 0)
  77684. * @returns a new Vector2
  77685. */
  77686. static Zero(): Vector2;
  77687. /**
  77688. * Gets a new Vector2(1, 1)
  77689. * @returns a new Vector2
  77690. */
  77691. static One(): Vector2;
  77692. /**
  77693. * Gets a new Vector2 set from the given index element of the given array
  77694. * @param array defines the data source
  77695. * @param offset defines the offset in the data source
  77696. * @returns a new Vector2
  77697. */
  77698. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  77699. /**
  77700. * Sets "result" from the given index element of the given array
  77701. * @param array defines the data source
  77702. * @param offset defines the offset in the data source
  77703. * @param result defines the target vector
  77704. */
  77705. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  77706. /**
  77707. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  77708. * @param value1 defines 1st point of control
  77709. * @param value2 defines 2nd point of control
  77710. * @param value3 defines 3rd point of control
  77711. * @param value4 defines 4th point of control
  77712. * @param amount defines the interpolation factor
  77713. * @returns a new Vector2
  77714. */
  77715. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  77716. /**
  77717. * 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".
  77718. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  77719. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  77720. * @param value defines the value to clamp
  77721. * @param min defines the lower limit
  77722. * @param max defines the upper limit
  77723. * @returns a new Vector2
  77724. */
  77725. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  77726. /**
  77727. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  77728. * @param value1 defines the 1st control point
  77729. * @param tangent1 defines the outgoing tangent
  77730. * @param value2 defines the 2nd control point
  77731. * @param tangent2 defines the incoming tangent
  77732. * @param amount defines the interpolation factor
  77733. * @returns a new Vector2
  77734. */
  77735. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  77736. /**
  77737. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  77738. * @param start defines the start vector
  77739. * @param end defines the end vector
  77740. * @param amount defines the interpolation factor
  77741. * @returns a new Vector2
  77742. */
  77743. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  77744. /**
  77745. * Gets the dot product of the vector "left" and the vector "right"
  77746. * @param left defines first vector
  77747. * @param right defines second vector
  77748. * @returns the dot product (float)
  77749. */
  77750. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  77751. /**
  77752. * Returns a new Vector2 equal to the normalized given vector
  77753. * @param vector defines the vector to normalize
  77754. * @returns a new Vector2
  77755. */
  77756. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  77757. /**
  77758. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  77759. * @param left defines 1st vector
  77760. * @param right defines 2nd vector
  77761. * @returns a new Vector2
  77762. */
  77763. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  77764. /**
  77765. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  77766. * @param left defines 1st vector
  77767. * @param right defines 2nd vector
  77768. * @returns a new Vector2
  77769. */
  77770. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  77771. /**
  77772. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  77773. * @param vector defines the vector to transform
  77774. * @param transformation defines the matrix to apply
  77775. * @returns a new Vector2
  77776. */
  77777. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  77778. /**
  77779. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  77780. * @param vector defines the vector to transform
  77781. * @param transformation defines the matrix to apply
  77782. * @param result defines the target vector
  77783. */
  77784. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  77785. /**
  77786. * Determines if a given vector is included in a triangle
  77787. * @param p defines the vector to test
  77788. * @param p0 defines 1st triangle point
  77789. * @param p1 defines 2nd triangle point
  77790. * @param p2 defines 3rd triangle point
  77791. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  77792. */
  77793. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  77794. /**
  77795. * Gets the distance between the vectors "value1" and "value2"
  77796. * @param value1 defines first vector
  77797. * @param value2 defines second vector
  77798. * @returns the distance between vectors
  77799. */
  77800. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  77801. /**
  77802. * Returns the squared distance between the vectors "value1" and "value2"
  77803. * @param value1 defines first vector
  77804. * @param value2 defines second vector
  77805. * @returns the squared distance between vectors
  77806. */
  77807. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  77808. /**
  77809. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  77810. * @param value1 defines first vector
  77811. * @param value2 defines second vector
  77812. * @returns a new Vector2
  77813. */
  77814. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  77815. /**
  77816. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  77817. * @param p defines the middle point
  77818. * @param segA defines one point of the segment
  77819. * @param segB defines the other point of the segment
  77820. * @returns the shortest distance
  77821. */
  77822. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  77823. }
  77824. /**
  77825. * Class used to store (x,y,z) vector representation
  77826. * A Vector3 is the main object used in 3D geometry
  77827. * It can represent etiher the coordinates of a point the space, either a direction
  77828. * Reminder: js uses a left handed forward facing system
  77829. */
  77830. export class Vector3 {
  77831. /**
  77832. * Defines the first coordinates (on X axis)
  77833. */
  77834. x: number;
  77835. /**
  77836. * Defines the second coordinates (on Y axis)
  77837. */
  77838. y: number;
  77839. /**
  77840. * Defines the third coordinates (on Z axis)
  77841. */
  77842. z: number;
  77843. private static _UpReadOnly;
  77844. private static _ZeroReadOnly;
  77845. /**
  77846. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  77847. * @param x defines the first coordinates (on X axis)
  77848. * @param y defines the second coordinates (on Y axis)
  77849. * @param z defines the third coordinates (on Z axis)
  77850. */
  77851. constructor(
  77852. /**
  77853. * Defines the first coordinates (on X axis)
  77854. */
  77855. x?: number,
  77856. /**
  77857. * Defines the second coordinates (on Y axis)
  77858. */
  77859. y?: number,
  77860. /**
  77861. * Defines the third coordinates (on Z axis)
  77862. */
  77863. z?: number);
  77864. /**
  77865. * Creates a string representation of the Vector3
  77866. * @returns a string with the Vector3 coordinates.
  77867. */
  77868. toString(): string;
  77869. /**
  77870. * Gets the class name
  77871. * @returns the string "Vector3"
  77872. */
  77873. getClassName(): string;
  77874. /**
  77875. * Creates the Vector3 hash code
  77876. * @returns a number which tends to be unique between Vector3 instances
  77877. */
  77878. getHashCode(): number;
  77879. /**
  77880. * Creates an array containing three elements : the coordinates of the Vector3
  77881. * @returns a new array of numbers
  77882. */
  77883. asArray(): number[];
  77884. /**
  77885. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  77886. * @param array defines the destination array
  77887. * @param index defines the offset in the destination array
  77888. * @returns the current Vector3
  77889. */
  77890. toArray(array: FloatArray, index?: number): Vector3;
  77891. /**
  77892. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  77893. * @returns a new Quaternion object, computed from the Vector3 coordinates
  77894. */
  77895. toQuaternion(): Quaternion;
  77896. /**
  77897. * Adds the given vector to the current Vector3
  77898. * @param otherVector defines the second operand
  77899. * @returns the current updated Vector3
  77900. */
  77901. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  77902. /**
  77903. * Adds the given coordinates to the current Vector3
  77904. * @param x defines the x coordinate of the operand
  77905. * @param y defines the y coordinate of the operand
  77906. * @param z defines the z coordinate of the operand
  77907. * @returns the current updated Vector3
  77908. */
  77909. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  77910. /**
  77911. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  77912. * @param otherVector defines the second operand
  77913. * @returns the resulting Vector3
  77914. */
  77915. add(otherVector: DeepImmutable<Vector3>): Vector3;
  77916. /**
  77917. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  77918. * @param otherVector defines the second operand
  77919. * @param result defines the Vector3 object where to store the result
  77920. * @returns the current Vector3
  77921. */
  77922. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  77923. /**
  77924. * Subtract the given vector from the current Vector3
  77925. * @param otherVector defines the second operand
  77926. * @returns the current updated Vector3
  77927. */
  77928. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  77929. /**
  77930. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  77931. * @param otherVector defines the second operand
  77932. * @returns the resulting Vector3
  77933. */
  77934. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  77935. /**
  77936. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  77937. * @param otherVector defines the second operand
  77938. * @param result defines the Vector3 object where to store the result
  77939. * @returns the current Vector3
  77940. */
  77941. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  77942. /**
  77943. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  77944. * @param x defines the x coordinate of the operand
  77945. * @param y defines the y coordinate of the operand
  77946. * @param z defines the z coordinate of the operand
  77947. * @returns the resulting Vector3
  77948. */
  77949. subtractFromFloats(x: number, y: number, z: number): Vector3;
  77950. /**
  77951. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  77952. * @param x defines the x coordinate of the operand
  77953. * @param y defines the y coordinate of the operand
  77954. * @param z defines the z coordinate of the operand
  77955. * @param result defines the Vector3 object where to store the result
  77956. * @returns the current Vector3
  77957. */
  77958. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  77959. /**
  77960. * Gets a new Vector3 set with the current Vector3 negated coordinates
  77961. * @returns a new Vector3
  77962. */
  77963. negate(): Vector3;
  77964. /**
  77965. * Negate this vector in place
  77966. * @returns this
  77967. */
  77968. negateInPlace(): Vector3;
  77969. /**
  77970. * Negate the current Vector3 and stores the result in the given vector "result" coordinates
  77971. * @param result defines the Vector3 object where to store the result
  77972. * @returns the current Vector3
  77973. */
  77974. negateToRef(result: Vector3): Vector3;
  77975. /**
  77976. * Multiplies the Vector3 coordinates by the float "scale"
  77977. * @param scale defines the multiplier factor
  77978. * @returns the current updated Vector3
  77979. */
  77980. scaleInPlace(scale: number): Vector3;
  77981. /**
  77982. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  77983. * @param scale defines the multiplier factor
  77984. * @returns a new Vector3
  77985. */
  77986. scale(scale: number): Vector3;
  77987. /**
  77988. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  77989. * @param scale defines the multiplier factor
  77990. * @param result defines the Vector3 object where to store the result
  77991. * @returns the current Vector3
  77992. */
  77993. scaleToRef(scale: number, result: Vector3): Vector3;
  77994. /**
  77995. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  77996. * @param scale defines the scale factor
  77997. * @param result defines the Vector3 object where to store the result
  77998. * @returns the unmodified current Vector3
  77999. */
  78000. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  78001. /**
  78002. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  78003. * @param origin defines the origin of the projection ray
  78004. * @param plane defines the plane to project to
  78005. * @returns the projected vector3
  78006. */
  78007. projectOnPlane(plane: Plane, origin: Vector3): Vector3;
  78008. /**
  78009. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  78010. * @param origin defines the origin of the projection ray
  78011. * @param plane defines the plane to project to
  78012. * @param result defines the Vector3 where to store the result
  78013. */
  78014. projectOnPlaneToRef(plane: Plane, origin: Vector3, result: Vector3): void;
  78015. /**
  78016. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  78017. * @param otherVector defines the second operand
  78018. * @returns true if both vectors are equals
  78019. */
  78020. equals(otherVector: DeepImmutable<Vector3>): boolean;
  78021. /**
  78022. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  78023. * @param otherVector defines the second operand
  78024. * @param epsilon defines the minimal distance to define values as equals
  78025. * @returns true if both vectors are distant less than epsilon
  78026. */
  78027. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  78028. /**
  78029. * Returns true if the current Vector3 coordinates equals the given floats
  78030. * @param x defines the x coordinate of the operand
  78031. * @param y defines the y coordinate of the operand
  78032. * @param z defines the z coordinate of the operand
  78033. * @returns true if both vectors are equals
  78034. */
  78035. equalsToFloats(x: number, y: number, z: number): boolean;
  78036. /**
  78037. * Multiplies the current Vector3 coordinates by the given ones
  78038. * @param otherVector defines the second operand
  78039. * @returns the current updated Vector3
  78040. */
  78041. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  78042. /**
  78043. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  78044. * @param otherVector defines the second operand
  78045. * @returns the new Vector3
  78046. */
  78047. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  78048. /**
  78049. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  78050. * @param otherVector defines the second operand
  78051. * @param result defines the Vector3 object where to store the result
  78052. * @returns the current Vector3
  78053. */
  78054. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  78055. /**
  78056. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  78057. * @param x defines the x coordinate of the operand
  78058. * @param y defines the y coordinate of the operand
  78059. * @param z defines the z coordinate of the operand
  78060. * @returns the new Vector3
  78061. */
  78062. multiplyByFloats(x: number, y: number, z: number): Vector3;
  78063. /**
  78064. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  78065. * @param otherVector defines the second operand
  78066. * @returns the new Vector3
  78067. */
  78068. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  78069. /**
  78070. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  78071. * @param otherVector defines the second operand
  78072. * @param result defines the Vector3 object where to store the result
  78073. * @returns the current Vector3
  78074. */
  78075. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  78076. /**
  78077. * Divides the current Vector3 coordinates by the given ones.
  78078. * @param otherVector defines the second operand
  78079. * @returns the current updated Vector3
  78080. */
  78081. divideInPlace(otherVector: Vector3): Vector3;
  78082. /**
  78083. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  78084. * @param other defines the second operand
  78085. * @returns the current updated Vector3
  78086. */
  78087. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  78088. /**
  78089. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  78090. * @param other defines the second operand
  78091. * @returns the current updated Vector3
  78092. */
  78093. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  78094. /**
  78095. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  78096. * @param x defines the x coordinate of the operand
  78097. * @param y defines the y coordinate of the operand
  78098. * @param z defines the z coordinate of the operand
  78099. * @returns the current updated Vector3
  78100. */
  78101. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  78102. /**
  78103. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  78104. * @param x defines the x coordinate of the operand
  78105. * @param y defines the y coordinate of the operand
  78106. * @param z defines the z coordinate of the operand
  78107. * @returns the current updated Vector3
  78108. */
  78109. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  78110. /**
  78111. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  78112. * Check if is non uniform within a certain amount of decimal places to account for this
  78113. * @param epsilon the amount the values can differ
  78114. * @returns if the the vector is non uniform to a certain number of decimal places
  78115. */
  78116. isNonUniformWithinEpsilon(epsilon: number): boolean;
  78117. /**
  78118. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  78119. */
  78120. get isNonUniform(): boolean;
  78121. /**
  78122. * Gets a new Vector3 from current Vector3 floored values
  78123. * @returns a new Vector3
  78124. */
  78125. floor(): Vector3;
  78126. /**
  78127. * Gets a new Vector3 from current Vector3 floored values
  78128. * @returns a new Vector3
  78129. */
  78130. fract(): Vector3;
  78131. /**
  78132. * Gets the length of the Vector3
  78133. * @returns the length of the Vector3
  78134. */
  78135. length(): number;
  78136. /**
  78137. * Gets the squared length of the Vector3
  78138. * @returns squared length of the Vector3
  78139. */
  78140. lengthSquared(): number;
  78141. /**
  78142. * Normalize the current Vector3.
  78143. * Please note that this is an in place operation.
  78144. * @returns the current updated Vector3
  78145. */
  78146. normalize(): Vector3;
  78147. /**
  78148. * Reorders the x y z properties of the vector in place
  78149. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  78150. * @returns the current updated vector
  78151. */
  78152. reorderInPlace(order: string): this;
  78153. /**
  78154. * Rotates the vector around 0,0,0 by a quaternion
  78155. * @param quaternion the rotation quaternion
  78156. * @param result vector to store the result
  78157. * @returns the resulting vector
  78158. */
  78159. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  78160. /**
  78161. * Rotates a vector around a given point
  78162. * @param quaternion the rotation quaternion
  78163. * @param point the point to rotate around
  78164. * @param result vector to store the result
  78165. * @returns the resulting vector
  78166. */
  78167. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  78168. /**
  78169. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  78170. * The cross product is then orthogonal to both current and "other"
  78171. * @param other defines the right operand
  78172. * @returns the cross product
  78173. */
  78174. cross(other: Vector3): Vector3;
  78175. /**
  78176. * Normalize the current Vector3 with the given input length.
  78177. * Please note that this is an in place operation.
  78178. * @param len the length of the vector
  78179. * @returns the current updated Vector3
  78180. */
  78181. normalizeFromLength(len: number): Vector3;
  78182. /**
  78183. * Normalize the current Vector3 to a new vector
  78184. * @returns the new Vector3
  78185. */
  78186. normalizeToNew(): Vector3;
  78187. /**
  78188. * Normalize the current Vector3 to the reference
  78189. * @param reference define the Vector3 to update
  78190. * @returns the updated Vector3
  78191. */
  78192. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  78193. /**
  78194. * Creates a new Vector3 copied from the current Vector3
  78195. * @returns the new Vector3
  78196. */
  78197. clone(): Vector3;
  78198. /**
  78199. * Copies the given vector coordinates to the current Vector3 ones
  78200. * @param source defines the source Vector3
  78201. * @returns the current updated Vector3
  78202. */
  78203. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  78204. /**
  78205. * Copies the given floats to the current Vector3 coordinates
  78206. * @param x defines the x coordinate of the operand
  78207. * @param y defines the y coordinate of the operand
  78208. * @param z defines the z coordinate of the operand
  78209. * @returns the current updated Vector3
  78210. */
  78211. copyFromFloats(x: number, y: number, z: number): Vector3;
  78212. /**
  78213. * Copies the given floats to the current Vector3 coordinates
  78214. * @param x defines the x coordinate of the operand
  78215. * @param y defines the y coordinate of the operand
  78216. * @param z defines the z coordinate of the operand
  78217. * @returns the current updated Vector3
  78218. */
  78219. set(x: number, y: number, z: number): Vector3;
  78220. /**
  78221. * Copies the given float to the current Vector3 coordinates
  78222. * @param v defines the x, y and z coordinates of the operand
  78223. * @returns the current updated Vector3
  78224. */
  78225. setAll(v: number): Vector3;
  78226. /**
  78227. * Get the clip factor between two vectors
  78228. * @param vector0 defines the first operand
  78229. * @param vector1 defines the second operand
  78230. * @param axis defines the axis to use
  78231. * @param size defines the size along the axis
  78232. * @returns the clip factor
  78233. */
  78234. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  78235. /**
  78236. * Get angle between two vectors
  78237. * @param vector0 angle between vector0 and vector1
  78238. * @param vector1 angle between vector0 and vector1
  78239. * @param normal direction of the normal
  78240. * @return the angle between vector0 and vector1
  78241. */
  78242. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  78243. /**
  78244. * Returns a new Vector3 set from the index "offset" of the given array
  78245. * @param array defines the source array
  78246. * @param offset defines the offset in the source array
  78247. * @returns the new Vector3
  78248. */
  78249. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  78250. /**
  78251. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  78252. * @param array defines the source array
  78253. * @param offset defines the offset in the source array
  78254. * @returns the new Vector3
  78255. * @deprecated Please use FromArray instead.
  78256. */
  78257. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  78258. /**
  78259. * Sets the given vector "result" with the element values from the index "offset" of the given array
  78260. * @param array defines the source array
  78261. * @param offset defines the offset in the source array
  78262. * @param result defines the Vector3 where to store the result
  78263. */
  78264. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  78265. /**
  78266. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  78267. * @param array defines the source array
  78268. * @param offset defines the offset in the source array
  78269. * @param result defines the Vector3 where to store the result
  78270. * @deprecated Please use FromArrayToRef instead.
  78271. */
  78272. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  78273. /**
  78274. * Sets the given vector "result" with the given floats.
  78275. * @param x defines the x coordinate of the source
  78276. * @param y defines the y coordinate of the source
  78277. * @param z defines the z coordinate of the source
  78278. * @param result defines the Vector3 where to store the result
  78279. */
  78280. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  78281. /**
  78282. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  78283. * @returns a new empty Vector3
  78284. */
  78285. static Zero(): Vector3;
  78286. /**
  78287. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  78288. * @returns a new unit Vector3
  78289. */
  78290. static One(): Vector3;
  78291. /**
  78292. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  78293. * @returns a new up Vector3
  78294. */
  78295. static Up(): Vector3;
  78296. /**
  78297. * Gets a up Vector3 that must not be updated
  78298. */
  78299. static get UpReadOnly(): DeepImmutable<Vector3>;
  78300. /**
  78301. * Gets a zero Vector3 that must not be updated
  78302. */
  78303. static get ZeroReadOnly(): DeepImmutable<Vector3>;
  78304. /**
  78305. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  78306. * @returns a new down Vector3
  78307. */
  78308. static Down(): Vector3;
  78309. /**
  78310. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  78311. * @param rightHandedSystem is the scene right-handed (negative z)
  78312. * @returns a new forward Vector3
  78313. */
  78314. static Forward(rightHandedSystem?: boolean): Vector3;
  78315. /**
  78316. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  78317. * @param rightHandedSystem is the scene right-handed (negative-z)
  78318. * @returns a new forward Vector3
  78319. */
  78320. static Backward(rightHandedSystem?: boolean): Vector3;
  78321. /**
  78322. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  78323. * @returns a new right Vector3
  78324. */
  78325. static Right(): Vector3;
  78326. /**
  78327. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  78328. * @returns a new left Vector3
  78329. */
  78330. static Left(): Vector3;
  78331. /**
  78332. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  78333. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  78334. * @param vector defines the Vector3 to transform
  78335. * @param transformation defines the transformation matrix
  78336. * @returns the transformed Vector3
  78337. */
  78338. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  78339. /**
  78340. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  78341. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  78342. * @param vector defines the Vector3 to transform
  78343. * @param transformation defines the transformation matrix
  78344. * @param result defines the Vector3 where to store the result
  78345. */
  78346. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  78347. /**
  78348. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  78349. * This method computes tranformed coordinates only, not transformed direction vectors
  78350. * @param x define the x coordinate of the source vector
  78351. * @param y define the y coordinate of the source vector
  78352. * @param z define the z coordinate of the source vector
  78353. * @param transformation defines the transformation matrix
  78354. * @param result defines the Vector3 where to store the result
  78355. */
  78356. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  78357. /**
  78358. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  78359. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  78360. * @param vector defines the Vector3 to transform
  78361. * @param transformation defines the transformation matrix
  78362. * @returns the new Vector3
  78363. */
  78364. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  78365. /**
  78366. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  78367. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  78368. * @param vector defines the Vector3 to transform
  78369. * @param transformation defines the transformation matrix
  78370. * @param result defines the Vector3 where to store the result
  78371. */
  78372. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  78373. /**
  78374. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  78375. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  78376. * @param x define the x coordinate of the source vector
  78377. * @param y define the y coordinate of the source vector
  78378. * @param z define the z coordinate of the source vector
  78379. * @param transformation defines the transformation matrix
  78380. * @param result defines the Vector3 where to store the result
  78381. */
  78382. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  78383. /**
  78384. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  78385. * @param value1 defines the first control point
  78386. * @param value2 defines the second control point
  78387. * @param value3 defines the third control point
  78388. * @param value4 defines the fourth control point
  78389. * @param amount defines the amount on the spline to use
  78390. * @returns the new Vector3
  78391. */
  78392. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  78393. /**
  78394. * 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"
  78395. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  78396. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  78397. * @param value defines the current value
  78398. * @param min defines the lower range value
  78399. * @param max defines the upper range value
  78400. * @returns the new Vector3
  78401. */
  78402. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  78403. /**
  78404. * 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"
  78405. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  78406. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  78407. * @param value defines the current value
  78408. * @param min defines the lower range value
  78409. * @param max defines the upper range value
  78410. * @param result defines the Vector3 where to store the result
  78411. */
  78412. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  78413. /**
  78414. * Checks if a given vector is inside a specific range
  78415. * @param v defines the vector to test
  78416. * @param min defines the minimum range
  78417. * @param max defines the maximum range
  78418. */
  78419. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  78420. /**
  78421. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  78422. * @param value1 defines the first control point
  78423. * @param tangent1 defines the first tangent vector
  78424. * @param value2 defines the second control point
  78425. * @param tangent2 defines the second tangent vector
  78426. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  78427. * @returns the new Vector3
  78428. */
  78429. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  78430. /**
  78431. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  78432. * @param start defines the start value
  78433. * @param end defines the end value
  78434. * @param amount max defines amount between both (between 0 and 1)
  78435. * @returns the new Vector3
  78436. */
  78437. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  78438. /**
  78439. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  78440. * @param start defines the start value
  78441. * @param end defines the end value
  78442. * @param amount max defines amount between both (between 0 and 1)
  78443. * @param result defines the Vector3 where to store the result
  78444. */
  78445. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  78446. /**
  78447. * Returns the dot product (float) between the vectors "left" and "right"
  78448. * @param left defines the left operand
  78449. * @param right defines the right operand
  78450. * @returns the dot product
  78451. */
  78452. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  78453. /**
  78454. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  78455. * The cross product is then orthogonal to both "left" and "right"
  78456. * @param left defines the left operand
  78457. * @param right defines the right operand
  78458. * @returns the cross product
  78459. */
  78460. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  78461. /**
  78462. * Sets the given vector "result" with the cross product of "left" and "right"
  78463. * The cross product is then orthogonal to both "left" and "right"
  78464. * @param left defines the left operand
  78465. * @param right defines the right operand
  78466. * @param result defines the Vector3 where to store the result
  78467. */
  78468. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  78469. /**
  78470. * Returns a new Vector3 as the normalization of the given vector
  78471. * @param vector defines the Vector3 to normalize
  78472. * @returns the new Vector3
  78473. */
  78474. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  78475. /**
  78476. * Sets the given vector "result" with the normalization of the given first vector
  78477. * @param vector defines the Vector3 to normalize
  78478. * @param result defines the Vector3 where to store the result
  78479. */
  78480. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  78481. /**
  78482. * Project a Vector3 onto screen space
  78483. * @param vector defines the Vector3 to project
  78484. * @param world defines the world matrix to use
  78485. * @param transform defines the transform (view x projection) matrix to use
  78486. * @param viewport defines the screen viewport to use
  78487. * @returns the new Vector3
  78488. */
  78489. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  78490. /** @hidden */
  78491. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  78492. /**
  78493. * Unproject from screen space to object space
  78494. * @param source defines the screen space Vector3 to use
  78495. * @param viewportWidth defines the current width of the viewport
  78496. * @param viewportHeight defines the current height of the viewport
  78497. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  78498. * @param transform defines the transform (view x projection) matrix to use
  78499. * @returns the new Vector3
  78500. */
  78501. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  78502. /**
  78503. * Unproject from screen space to object space
  78504. * @param source defines the screen space Vector3 to use
  78505. * @param viewportWidth defines the current width of the viewport
  78506. * @param viewportHeight defines the current height of the viewport
  78507. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  78508. * @param view defines the view matrix to use
  78509. * @param projection defines the projection matrix to use
  78510. * @returns the new Vector3
  78511. */
  78512. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  78513. /**
  78514. * Unproject from screen space to object space
  78515. * @param source defines the screen space Vector3 to use
  78516. * @param viewportWidth defines the current width of the viewport
  78517. * @param viewportHeight defines the current height of the viewport
  78518. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  78519. * @param view defines the view matrix to use
  78520. * @param projection defines the projection matrix to use
  78521. * @param result defines the Vector3 where to store the result
  78522. */
  78523. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  78524. /**
  78525. * Unproject from screen space to object space
  78526. * @param sourceX defines the screen space x coordinate to use
  78527. * @param sourceY defines the screen space y coordinate to use
  78528. * @param sourceZ defines the screen space z coordinate to use
  78529. * @param viewportWidth defines the current width of the viewport
  78530. * @param viewportHeight defines the current height of the viewport
  78531. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  78532. * @param view defines the view matrix to use
  78533. * @param projection defines the projection matrix to use
  78534. * @param result defines the Vector3 where to store the result
  78535. */
  78536. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  78537. /**
  78538. * Gets the minimal coordinate values between two Vector3
  78539. * @param left defines the first operand
  78540. * @param right defines the second operand
  78541. * @returns the new Vector3
  78542. */
  78543. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  78544. /**
  78545. * Gets the maximal coordinate values between two Vector3
  78546. * @param left defines the first operand
  78547. * @param right defines the second operand
  78548. * @returns the new Vector3
  78549. */
  78550. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  78551. /**
  78552. * Returns the distance between the vectors "value1" and "value2"
  78553. * @param value1 defines the first operand
  78554. * @param value2 defines the second operand
  78555. * @returns the distance
  78556. */
  78557. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  78558. /**
  78559. * Returns the squared distance between the vectors "value1" and "value2"
  78560. * @param value1 defines the first operand
  78561. * @param value2 defines the second operand
  78562. * @returns the squared distance
  78563. */
  78564. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  78565. /**
  78566. * Returns a new Vector3 located at the center between "value1" and "value2"
  78567. * @param value1 defines the first operand
  78568. * @param value2 defines the second operand
  78569. * @returns the new Vector3
  78570. */
  78571. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  78572. /**
  78573. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  78574. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  78575. * to something in order to rotate it from its local system to the given target system
  78576. * Note: axis1, axis2 and axis3 are normalized during this operation
  78577. * @param axis1 defines the first axis
  78578. * @param axis2 defines the second axis
  78579. * @param axis3 defines the third axis
  78580. * @returns a new Vector3
  78581. */
  78582. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  78583. /**
  78584. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  78585. * @param axis1 defines the first axis
  78586. * @param axis2 defines the second axis
  78587. * @param axis3 defines the third axis
  78588. * @param ref defines the Vector3 where to store the result
  78589. */
  78590. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  78591. }
  78592. /**
  78593. * Vector4 class created for EulerAngle class conversion to Quaternion
  78594. */
  78595. export class Vector4 {
  78596. /** x value of the vector */
  78597. x: number;
  78598. /** y value of the vector */
  78599. y: number;
  78600. /** z value of the vector */
  78601. z: number;
  78602. /** w value of the vector */
  78603. w: number;
  78604. /**
  78605. * Creates a Vector4 object from the given floats.
  78606. * @param x x value of the vector
  78607. * @param y y value of the vector
  78608. * @param z z value of the vector
  78609. * @param w w value of the vector
  78610. */
  78611. constructor(
  78612. /** x value of the vector */
  78613. x: number,
  78614. /** y value of the vector */
  78615. y: number,
  78616. /** z value of the vector */
  78617. z: number,
  78618. /** w value of the vector */
  78619. w: number);
  78620. /**
  78621. * Returns the string with the Vector4 coordinates.
  78622. * @returns a string containing all the vector values
  78623. */
  78624. toString(): string;
  78625. /**
  78626. * Returns the string "Vector4".
  78627. * @returns "Vector4"
  78628. */
  78629. getClassName(): string;
  78630. /**
  78631. * Returns the Vector4 hash code.
  78632. * @returns a unique hash code
  78633. */
  78634. getHashCode(): number;
  78635. /**
  78636. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  78637. * @returns the resulting array
  78638. */
  78639. asArray(): number[];
  78640. /**
  78641. * Populates the given array from the given index with the Vector4 coordinates.
  78642. * @param array array to populate
  78643. * @param index index of the array to start at (default: 0)
  78644. * @returns the Vector4.
  78645. */
  78646. toArray(array: FloatArray, index?: number): Vector4;
  78647. /**
  78648. * Adds the given vector to the current Vector4.
  78649. * @param otherVector the vector to add
  78650. * @returns the updated Vector4.
  78651. */
  78652. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  78653. /**
  78654. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  78655. * @param otherVector the vector to add
  78656. * @returns the resulting vector
  78657. */
  78658. add(otherVector: DeepImmutable<Vector4>): Vector4;
  78659. /**
  78660. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  78661. * @param otherVector the vector to add
  78662. * @param result the vector to store the result
  78663. * @returns the current Vector4.
  78664. */
  78665. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  78666. /**
  78667. * Subtract in place the given vector from the current Vector4.
  78668. * @param otherVector the vector to subtract
  78669. * @returns the updated Vector4.
  78670. */
  78671. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  78672. /**
  78673. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  78674. * @param otherVector the vector to add
  78675. * @returns the new vector with the result
  78676. */
  78677. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  78678. /**
  78679. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  78680. * @param otherVector the vector to subtract
  78681. * @param result the vector to store the result
  78682. * @returns the current Vector4.
  78683. */
  78684. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  78685. /**
  78686. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  78687. */
  78688. /**
  78689. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  78690. * @param x value to subtract
  78691. * @param y value to subtract
  78692. * @param z value to subtract
  78693. * @param w value to subtract
  78694. * @returns new vector containing the result
  78695. */
  78696. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  78697. /**
  78698. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  78699. * @param x value to subtract
  78700. * @param y value to subtract
  78701. * @param z value to subtract
  78702. * @param w value to subtract
  78703. * @param result the vector to store the result in
  78704. * @returns the current Vector4.
  78705. */
  78706. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  78707. /**
  78708. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  78709. * @returns a new vector with the negated values
  78710. */
  78711. negate(): Vector4;
  78712. /**
  78713. * Negate this vector in place
  78714. * @returns this
  78715. */
  78716. negateInPlace(): Vector4;
  78717. /**
  78718. * Negate the current Vector4 and stores the result in the given vector "result" coordinates
  78719. * @param result defines the Vector3 object where to store the result
  78720. * @returns the current Vector4
  78721. */
  78722. negateToRef(result: Vector4): Vector4;
  78723. /**
  78724. * Multiplies the current Vector4 coordinates by scale (float).
  78725. * @param scale the number to scale with
  78726. * @returns the updated Vector4.
  78727. */
  78728. scaleInPlace(scale: number): Vector4;
  78729. /**
  78730. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  78731. * @param scale the number to scale with
  78732. * @returns a new vector with the result
  78733. */
  78734. scale(scale: number): Vector4;
  78735. /**
  78736. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  78737. * @param scale the number to scale with
  78738. * @param result a vector to store the result in
  78739. * @returns the current Vector4.
  78740. */
  78741. scaleToRef(scale: number, result: Vector4): Vector4;
  78742. /**
  78743. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  78744. * @param scale defines the scale factor
  78745. * @param result defines the Vector4 object where to store the result
  78746. * @returns the unmodified current Vector4
  78747. */
  78748. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  78749. /**
  78750. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  78751. * @param otherVector the vector to compare against
  78752. * @returns true if they are equal
  78753. */
  78754. equals(otherVector: DeepImmutable<Vector4>): boolean;
  78755. /**
  78756. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  78757. * @param otherVector vector to compare against
  78758. * @param epsilon (Default: very small number)
  78759. * @returns true if they are equal
  78760. */
  78761. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  78762. /**
  78763. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  78764. * @param x x value to compare against
  78765. * @param y y value to compare against
  78766. * @param z z value to compare against
  78767. * @param w w value to compare against
  78768. * @returns true if equal
  78769. */
  78770. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  78771. /**
  78772. * Multiplies in place the current Vector4 by the given one.
  78773. * @param otherVector vector to multiple with
  78774. * @returns the updated Vector4.
  78775. */
  78776. multiplyInPlace(otherVector: Vector4): Vector4;
  78777. /**
  78778. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  78779. * @param otherVector vector to multiple with
  78780. * @returns resulting new vector
  78781. */
  78782. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  78783. /**
  78784. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  78785. * @param otherVector vector to multiple with
  78786. * @param result vector to store the result
  78787. * @returns the current Vector4.
  78788. */
  78789. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  78790. /**
  78791. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  78792. * @param x x value multiply with
  78793. * @param y y value multiply with
  78794. * @param z z value multiply with
  78795. * @param w w value multiply with
  78796. * @returns resulting new vector
  78797. */
  78798. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  78799. /**
  78800. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  78801. * @param otherVector vector to devide with
  78802. * @returns resulting new vector
  78803. */
  78804. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  78805. /**
  78806. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  78807. * @param otherVector vector to devide with
  78808. * @param result vector to store the result
  78809. * @returns the current Vector4.
  78810. */
  78811. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  78812. /**
  78813. * Divides the current Vector3 coordinates by the given ones.
  78814. * @param otherVector vector to devide with
  78815. * @returns the updated Vector3.
  78816. */
  78817. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  78818. /**
  78819. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  78820. * @param other defines the second operand
  78821. * @returns the current updated Vector4
  78822. */
  78823. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  78824. /**
  78825. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  78826. * @param other defines the second operand
  78827. * @returns the current updated Vector4
  78828. */
  78829. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  78830. /**
  78831. * Gets a new Vector4 from current Vector4 floored values
  78832. * @returns a new Vector4
  78833. */
  78834. floor(): Vector4;
  78835. /**
  78836. * Gets a new Vector4 from current Vector3 floored values
  78837. * @returns a new Vector4
  78838. */
  78839. fract(): Vector4;
  78840. /**
  78841. * Returns the Vector4 length (float).
  78842. * @returns the length
  78843. */
  78844. length(): number;
  78845. /**
  78846. * Returns the Vector4 squared length (float).
  78847. * @returns the length squared
  78848. */
  78849. lengthSquared(): number;
  78850. /**
  78851. * Normalizes in place the Vector4.
  78852. * @returns the updated Vector4.
  78853. */
  78854. normalize(): Vector4;
  78855. /**
  78856. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  78857. * @returns this converted to a new vector3
  78858. */
  78859. toVector3(): Vector3;
  78860. /**
  78861. * Returns a new Vector4 copied from the current one.
  78862. * @returns the new cloned vector
  78863. */
  78864. clone(): Vector4;
  78865. /**
  78866. * Updates the current Vector4 with the given one coordinates.
  78867. * @param source the source vector to copy from
  78868. * @returns the updated Vector4.
  78869. */
  78870. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  78871. /**
  78872. * Updates the current Vector4 coordinates with the given floats.
  78873. * @param x float to copy from
  78874. * @param y float to copy from
  78875. * @param z float to copy from
  78876. * @param w float to copy from
  78877. * @returns the updated Vector4.
  78878. */
  78879. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  78880. /**
  78881. * Updates the current Vector4 coordinates with the given floats.
  78882. * @param x float to set from
  78883. * @param y float to set from
  78884. * @param z float to set from
  78885. * @param w float to set from
  78886. * @returns the updated Vector4.
  78887. */
  78888. set(x: number, y: number, z: number, w: number): Vector4;
  78889. /**
  78890. * Copies the given float to the current Vector3 coordinates
  78891. * @param v defines the x, y, z and w coordinates of the operand
  78892. * @returns the current updated Vector3
  78893. */
  78894. setAll(v: number): Vector4;
  78895. /**
  78896. * Returns a new Vector4 set from the starting index of the given array.
  78897. * @param array the array to pull values from
  78898. * @param offset the offset into the array to start at
  78899. * @returns the new vector
  78900. */
  78901. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  78902. /**
  78903. * Updates the given vector "result" from the starting index of the given array.
  78904. * @param array the array to pull values from
  78905. * @param offset the offset into the array to start at
  78906. * @param result the vector to store the result in
  78907. */
  78908. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  78909. /**
  78910. * Updates the given vector "result" from the starting index of the given Float32Array.
  78911. * @param array the array to pull values from
  78912. * @param offset the offset into the array to start at
  78913. * @param result the vector to store the result in
  78914. */
  78915. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  78916. /**
  78917. * Updates the given vector "result" coordinates from the given floats.
  78918. * @param x float to set from
  78919. * @param y float to set from
  78920. * @param z float to set from
  78921. * @param w float to set from
  78922. * @param result the vector to the floats in
  78923. */
  78924. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  78925. /**
  78926. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  78927. * @returns the new vector
  78928. */
  78929. static Zero(): Vector4;
  78930. /**
  78931. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  78932. * @returns the new vector
  78933. */
  78934. static One(): Vector4;
  78935. /**
  78936. * Returns a new normalized Vector4 from the given one.
  78937. * @param vector the vector to normalize
  78938. * @returns the vector
  78939. */
  78940. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  78941. /**
  78942. * Updates the given vector "result" from the normalization of the given one.
  78943. * @param vector the vector to normalize
  78944. * @param result the vector to store the result in
  78945. */
  78946. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  78947. /**
  78948. * Returns a vector with the minimum values from the left and right vectors
  78949. * @param left left vector to minimize
  78950. * @param right right vector to minimize
  78951. * @returns a new vector with the minimum of the left and right vector values
  78952. */
  78953. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  78954. /**
  78955. * Returns a vector with the maximum values from the left and right vectors
  78956. * @param left left vector to maximize
  78957. * @param right right vector to maximize
  78958. * @returns a new vector with the maximum of the left and right vector values
  78959. */
  78960. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  78961. /**
  78962. * Returns the distance (float) between the vectors "value1" and "value2".
  78963. * @param value1 value to calulate the distance between
  78964. * @param value2 value to calulate the distance between
  78965. * @return the distance between the two vectors
  78966. */
  78967. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  78968. /**
  78969. * Returns the squared distance (float) between the vectors "value1" and "value2".
  78970. * @param value1 value to calulate the distance between
  78971. * @param value2 value to calulate the distance between
  78972. * @return the distance between the two vectors squared
  78973. */
  78974. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  78975. /**
  78976. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  78977. * @param value1 value to calulate the center between
  78978. * @param value2 value to calulate the center between
  78979. * @return the center between the two vectors
  78980. */
  78981. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  78982. /**
  78983. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  78984. * This methods computes transformed normalized direction vectors only.
  78985. * @param vector the vector to transform
  78986. * @param transformation the transformation matrix to apply
  78987. * @returns the new vector
  78988. */
  78989. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  78990. /**
  78991. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  78992. * This methods computes transformed normalized direction vectors only.
  78993. * @param vector the vector to transform
  78994. * @param transformation the transformation matrix to apply
  78995. * @param result the vector to store the result in
  78996. */
  78997. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  78998. /**
  78999. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  79000. * This methods computes transformed normalized direction vectors only.
  79001. * @param x value to transform
  79002. * @param y value to transform
  79003. * @param z value to transform
  79004. * @param w value to transform
  79005. * @param transformation the transformation matrix to apply
  79006. * @param result the vector to store the results in
  79007. */
  79008. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  79009. /**
  79010. * Creates a new Vector4 from a Vector3
  79011. * @param source defines the source data
  79012. * @param w defines the 4th component (default is 0)
  79013. * @returns a new Vector4
  79014. */
  79015. static FromVector3(source: Vector3, w?: number): Vector4;
  79016. }
  79017. /**
  79018. * Class used to store quaternion data
  79019. * @see https://en.wikipedia.org/wiki/Quaternion
  79020. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  79021. */
  79022. export class Quaternion {
  79023. /** defines the first component (0 by default) */
  79024. x: number;
  79025. /** defines the second component (0 by default) */
  79026. y: number;
  79027. /** defines the third component (0 by default) */
  79028. z: number;
  79029. /** defines the fourth component (1.0 by default) */
  79030. w: number;
  79031. /**
  79032. * Creates a new Quaternion from the given floats
  79033. * @param x defines the first component (0 by default)
  79034. * @param y defines the second component (0 by default)
  79035. * @param z defines the third component (0 by default)
  79036. * @param w defines the fourth component (1.0 by default)
  79037. */
  79038. constructor(
  79039. /** defines the first component (0 by default) */
  79040. x?: number,
  79041. /** defines the second component (0 by default) */
  79042. y?: number,
  79043. /** defines the third component (0 by default) */
  79044. z?: number,
  79045. /** defines the fourth component (1.0 by default) */
  79046. w?: number);
  79047. /**
  79048. * Gets a string representation for the current quaternion
  79049. * @returns a string with the Quaternion coordinates
  79050. */
  79051. toString(): string;
  79052. /**
  79053. * Gets the class name of the quaternion
  79054. * @returns the string "Quaternion"
  79055. */
  79056. getClassName(): string;
  79057. /**
  79058. * Gets a hash code for this quaternion
  79059. * @returns the quaternion hash code
  79060. */
  79061. getHashCode(): number;
  79062. /**
  79063. * Copy the quaternion to an array
  79064. * @returns a new array populated with 4 elements from the quaternion coordinates
  79065. */
  79066. asArray(): number[];
  79067. /**
  79068. * Check if two quaternions are equals
  79069. * @param otherQuaternion defines the second operand
  79070. * @return true if the current quaternion and the given one coordinates are strictly equals
  79071. */
  79072. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  79073. /**
  79074. * Gets a boolean if two quaternions are equals (using an epsilon value)
  79075. * @param otherQuaternion defines the other quaternion
  79076. * @param epsilon defines the minimal distance to consider equality
  79077. * @returns true if the given quaternion coordinates are close to the current ones by a distance of epsilon.
  79078. */
  79079. equalsWithEpsilon(otherQuaternion: DeepImmutable<Quaternion>, epsilon?: number): boolean;
  79080. /**
  79081. * Clone the current quaternion
  79082. * @returns a new quaternion copied from the current one
  79083. */
  79084. clone(): Quaternion;
  79085. /**
  79086. * Copy a quaternion to the current one
  79087. * @param other defines the other quaternion
  79088. * @returns the updated current quaternion
  79089. */
  79090. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  79091. /**
  79092. * Updates the current quaternion with the given float coordinates
  79093. * @param x defines the x coordinate
  79094. * @param y defines the y coordinate
  79095. * @param z defines the z coordinate
  79096. * @param w defines the w coordinate
  79097. * @returns the updated current quaternion
  79098. */
  79099. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  79100. /**
  79101. * Updates the current quaternion from the given float coordinates
  79102. * @param x defines the x coordinate
  79103. * @param y defines the y coordinate
  79104. * @param z defines the z coordinate
  79105. * @param w defines the w coordinate
  79106. * @returns the updated current quaternion
  79107. */
  79108. set(x: number, y: number, z: number, w: number): Quaternion;
  79109. /**
  79110. * Adds two quaternions
  79111. * @param other defines the second operand
  79112. * @returns a new quaternion as the addition result of the given one and the current quaternion
  79113. */
  79114. add(other: DeepImmutable<Quaternion>): Quaternion;
  79115. /**
  79116. * Add a quaternion to the current one
  79117. * @param other defines the quaternion to add
  79118. * @returns the current quaternion
  79119. */
  79120. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  79121. /**
  79122. * Subtract two quaternions
  79123. * @param other defines the second operand
  79124. * @returns a new quaternion as the subtraction result of the given one from the current one
  79125. */
  79126. subtract(other: Quaternion): Quaternion;
  79127. /**
  79128. * Multiplies the current quaternion by a scale factor
  79129. * @param value defines the scale factor
  79130. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  79131. */
  79132. scale(value: number): Quaternion;
  79133. /**
  79134. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  79135. * @param scale defines the scale factor
  79136. * @param result defines the Quaternion object where to store the result
  79137. * @returns the unmodified current quaternion
  79138. */
  79139. scaleToRef(scale: number, result: Quaternion): Quaternion;
  79140. /**
  79141. * Multiplies in place the current quaternion by a scale factor
  79142. * @param value defines the scale factor
  79143. * @returns the current modified quaternion
  79144. */
  79145. scaleInPlace(value: number): Quaternion;
  79146. /**
  79147. * Scale the current quaternion values by a factor and add the result to a given quaternion
  79148. * @param scale defines the scale factor
  79149. * @param result defines the Quaternion object where to store the result
  79150. * @returns the unmodified current quaternion
  79151. */
  79152. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  79153. /**
  79154. * Multiplies two quaternions
  79155. * @param q1 defines the second operand
  79156. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  79157. */
  79158. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  79159. /**
  79160. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  79161. * @param q1 defines the second operand
  79162. * @param result defines the target quaternion
  79163. * @returns the current quaternion
  79164. */
  79165. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  79166. /**
  79167. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  79168. * @param q1 defines the second operand
  79169. * @returns the currentupdated quaternion
  79170. */
  79171. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  79172. /**
  79173. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  79174. * @param ref defines the target quaternion
  79175. * @returns the current quaternion
  79176. */
  79177. conjugateToRef(ref: Quaternion): Quaternion;
  79178. /**
  79179. * Conjugates in place (1-q) the current quaternion
  79180. * @returns the current updated quaternion
  79181. */
  79182. conjugateInPlace(): Quaternion;
  79183. /**
  79184. * Conjugates in place (1-q) the current quaternion
  79185. * @returns a new quaternion
  79186. */
  79187. conjugate(): Quaternion;
  79188. /**
  79189. * Gets length of current quaternion
  79190. * @returns the quaternion length (float)
  79191. */
  79192. length(): number;
  79193. /**
  79194. * Normalize in place the current quaternion
  79195. * @returns the current updated quaternion
  79196. */
  79197. normalize(): Quaternion;
  79198. /**
  79199. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  79200. * @param order is a reserved parameter and is ignore for now
  79201. * @returns a new Vector3 containing the Euler angles
  79202. */
  79203. toEulerAngles(order?: string): Vector3;
  79204. /**
  79205. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  79206. * @param result defines the vector which will be filled with the Euler angles
  79207. * @param order is a reserved parameter and is ignore for now
  79208. * @returns the current unchanged quaternion
  79209. */
  79210. toEulerAnglesToRef(result: Vector3): Quaternion;
  79211. /**
  79212. * Updates the given rotation matrix with the current quaternion values
  79213. * @param result defines the target matrix
  79214. * @returns the current unchanged quaternion
  79215. */
  79216. toRotationMatrix(result: Matrix): Quaternion;
  79217. /**
  79218. * Updates the current quaternion from the given rotation matrix values
  79219. * @param matrix defines the source matrix
  79220. * @returns the current updated quaternion
  79221. */
  79222. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  79223. /**
  79224. * Creates a new quaternion from a rotation matrix
  79225. * @param matrix defines the source matrix
  79226. * @returns a new quaternion created from the given rotation matrix values
  79227. */
  79228. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  79229. /**
  79230. * Updates the given quaternion with the given rotation matrix values
  79231. * @param matrix defines the source matrix
  79232. * @param result defines the target quaternion
  79233. */
  79234. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  79235. /**
  79236. * Returns the dot product (float) between the quaternions "left" and "right"
  79237. * @param left defines the left operand
  79238. * @param right defines the right operand
  79239. * @returns the dot product
  79240. */
  79241. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  79242. /**
  79243. * Checks if the two quaternions are close to each other
  79244. * @param quat0 defines the first quaternion to check
  79245. * @param quat1 defines the second quaternion to check
  79246. * @returns true if the two quaternions are close to each other
  79247. */
  79248. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  79249. /**
  79250. * Creates an empty quaternion
  79251. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  79252. */
  79253. static Zero(): Quaternion;
  79254. /**
  79255. * Inverse a given quaternion
  79256. * @param q defines the source quaternion
  79257. * @returns a new quaternion as the inverted current quaternion
  79258. */
  79259. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  79260. /**
  79261. * Inverse a given quaternion
  79262. * @param q defines the source quaternion
  79263. * @param result the quaternion the result will be stored in
  79264. * @returns the result quaternion
  79265. */
  79266. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  79267. /**
  79268. * Creates an identity quaternion
  79269. * @returns the identity quaternion
  79270. */
  79271. static Identity(): Quaternion;
  79272. /**
  79273. * Gets a boolean indicating if the given quaternion is identity
  79274. * @param quaternion defines the quaternion to check
  79275. * @returns true if the quaternion is identity
  79276. */
  79277. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  79278. /**
  79279. * Creates a quaternion from a rotation around an axis
  79280. * @param axis defines the axis to use
  79281. * @param angle defines the angle to use
  79282. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  79283. */
  79284. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  79285. /**
  79286. * Creates a rotation around an axis and stores it into the given quaternion
  79287. * @param axis defines the axis to use
  79288. * @param angle defines the angle to use
  79289. * @param result defines the target quaternion
  79290. * @returns the target quaternion
  79291. */
  79292. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  79293. /**
  79294. * Creates a new quaternion from data stored into an array
  79295. * @param array defines the data source
  79296. * @param offset defines the offset in the source array where the data starts
  79297. * @returns a new quaternion
  79298. */
  79299. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  79300. /**
  79301. * Updates the given quaternion "result" from the starting index of the given array.
  79302. * @param array the array to pull values from
  79303. * @param offset the offset into the array to start at
  79304. * @param result the quaternion to store the result in
  79305. */
  79306. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Quaternion): void;
  79307. /**
  79308. * Create a quaternion from Euler rotation angles
  79309. * @param x Pitch
  79310. * @param y Yaw
  79311. * @param z Roll
  79312. * @returns the new Quaternion
  79313. */
  79314. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  79315. /**
  79316. * Updates a quaternion from Euler rotation angles
  79317. * @param x Pitch
  79318. * @param y Yaw
  79319. * @param z Roll
  79320. * @param result the quaternion to store the result
  79321. * @returns the updated quaternion
  79322. */
  79323. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  79324. /**
  79325. * Create a quaternion from Euler rotation vector
  79326. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  79327. * @returns the new Quaternion
  79328. */
  79329. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  79330. /**
  79331. * Updates a quaternion from Euler rotation vector
  79332. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  79333. * @param result the quaternion to store the result
  79334. * @returns the updated quaternion
  79335. */
  79336. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  79337. /**
  79338. * Creates a new quaternion from the given Euler float angles (y, x, z)
  79339. * @param yaw defines the rotation around Y axis
  79340. * @param pitch defines the rotation around X axis
  79341. * @param roll defines the rotation around Z axis
  79342. * @returns the new quaternion
  79343. */
  79344. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  79345. /**
  79346. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  79347. * @param yaw defines the rotation around Y axis
  79348. * @param pitch defines the rotation around X axis
  79349. * @param roll defines the rotation around Z axis
  79350. * @param result defines the target quaternion
  79351. */
  79352. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  79353. /**
  79354. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  79355. * @param alpha defines the rotation around first axis
  79356. * @param beta defines the rotation around second axis
  79357. * @param gamma defines the rotation around third axis
  79358. * @returns the new quaternion
  79359. */
  79360. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  79361. /**
  79362. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  79363. * @param alpha defines the rotation around first axis
  79364. * @param beta defines the rotation around second axis
  79365. * @param gamma defines the rotation around third axis
  79366. * @param result defines the target quaternion
  79367. */
  79368. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  79369. /**
  79370. * 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)
  79371. * @param axis1 defines the first axis
  79372. * @param axis2 defines the second axis
  79373. * @param axis3 defines the third axis
  79374. * @returns the new quaternion
  79375. */
  79376. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  79377. /**
  79378. * 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
  79379. * @param axis1 defines the first axis
  79380. * @param axis2 defines the second axis
  79381. * @param axis3 defines the third axis
  79382. * @param ref defines the target quaternion
  79383. */
  79384. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  79385. /**
  79386. * Interpolates between two quaternions
  79387. * @param left defines first quaternion
  79388. * @param right defines second quaternion
  79389. * @param amount defines the gradient to use
  79390. * @returns the new interpolated quaternion
  79391. */
  79392. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  79393. /**
  79394. * Interpolates between two quaternions and stores it into a target quaternion
  79395. * @param left defines first quaternion
  79396. * @param right defines second quaternion
  79397. * @param amount defines the gradient to use
  79398. * @param result defines the target quaternion
  79399. */
  79400. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  79401. /**
  79402. * Interpolate between two quaternions using Hermite interpolation
  79403. * @param value1 defines first quaternion
  79404. * @param tangent1 defines the incoming tangent
  79405. * @param value2 defines second quaternion
  79406. * @param tangent2 defines the outgoing tangent
  79407. * @param amount defines the target quaternion
  79408. * @returns the new interpolated quaternion
  79409. */
  79410. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  79411. }
  79412. /**
  79413. * Class used to store matrix data (4x4)
  79414. */
  79415. export class Matrix {
  79416. private static _updateFlagSeed;
  79417. private static _identityReadOnly;
  79418. private _isIdentity;
  79419. private _isIdentityDirty;
  79420. private _isIdentity3x2;
  79421. private _isIdentity3x2Dirty;
  79422. /**
  79423. * Gets the update flag of the matrix which is an unique number for the matrix.
  79424. * It will be incremented every time the matrix data change.
  79425. * You can use it to speed the comparison between two versions of the same matrix.
  79426. */
  79427. updateFlag: number;
  79428. private readonly _m;
  79429. /**
  79430. * Gets the internal data of the matrix
  79431. */
  79432. get m(): DeepImmutable<Float32Array>;
  79433. /** @hidden */
  79434. _markAsUpdated(): void;
  79435. /** @hidden */
  79436. private _updateIdentityStatus;
  79437. /**
  79438. * Creates an empty matrix (filled with zeros)
  79439. */
  79440. constructor();
  79441. /**
  79442. * Check if the current matrix is identity
  79443. * @returns true is the matrix is the identity matrix
  79444. */
  79445. isIdentity(): boolean;
  79446. /**
  79447. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  79448. * @returns true is the matrix is the identity matrix
  79449. */
  79450. isIdentityAs3x2(): boolean;
  79451. /**
  79452. * Gets the determinant of the matrix
  79453. * @returns the matrix determinant
  79454. */
  79455. determinant(): number;
  79456. /**
  79457. * Returns the matrix as a Float32Array
  79458. * @returns the matrix underlying array
  79459. */
  79460. toArray(): DeepImmutable<Float32Array>;
  79461. /**
  79462. * Returns the matrix as a Float32Array
  79463. * @returns the matrix underlying array.
  79464. */
  79465. asArray(): DeepImmutable<Float32Array>;
  79466. /**
  79467. * Inverts the current matrix in place
  79468. * @returns the current inverted matrix
  79469. */
  79470. invert(): Matrix;
  79471. /**
  79472. * Sets all the matrix elements to zero
  79473. * @returns the current matrix
  79474. */
  79475. reset(): Matrix;
  79476. /**
  79477. * Adds the current matrix with a second one
  79478. * @param other defines the matrix to add
  79479. * @returns a new matrix as the addition of the current matrix and the given one
  79480. */
  79481. add(other: DeepImmutable<Matrix>): Matrix;
  79482. /**
  79483. * Sets the given matrix "result" to the addition of the current matrix and the given one
  79484. * @param other defines the matrix to add
  79485. * @param result defines the target matrix
  79486. * @returns the current matrix
  79487. */
  79488. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  79489. /**
  79490. * Adds in place the given matrix to the current matrix
  79491. * @param other defines the second operand
  79492. * @returns the current updated matrix
  79493. */
  79494. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  79495. /**
  79496. * Sets the given matrix to the current inverted Matrix
  79497. * @param other defines the target matrix
  79498. * @returns the unmodified current matrix
  79499. */
  79500. invertToRef(other: Matrix): Matrix;
  79501. /**
  79502. * add a value at the specified position in the current Matrix
  79503. * @param index the index of the value within the matrix. between 0 and 15.
  79504. * @param value the value to be added
  79505. * @returns the current updated matrix
  79506. */
  79507. addAtIndex(index: number, value: number): Matrix;
  79508. /**
  79509. * mutiply the specified position in the current Matrix by a value
  79510. * @param index the index of the value within the matrix. between 0 and 15.
  79511. * @param value the value to be added
  79512. * @returns the current updated matrix
  79513. */
  79514. multiplyAtIndex(index: number, value: number): Matrix;
  79515. /**
  79516. * Inserts the translation vector (using 3 floats) in the current matrix
  79517. * @param x defines the 1st component of the translation
  79518. * @param y defines the 2nd component of the translation
  79519. * @param z defines the 3rd component of the translation
  79520. * @returns the current updated matrix
  79521. */
  79522. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  79523. /**
  79524. * Adds the translation vector (using 3 floats) in the current matrix
  79525. * @param x defines the 1st component of the translation
  79526. * @param y defines the 2nd component of the translation
  79527. * @param z defines the 3rd component of the translation
  79528. * @returns the current updated matrix
  79529. */
  79530. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  79531. /**
  79532. * Inserts the translation vector in the current matrix
  79533. * @param vector3 defines the translation to insert
  79534. * @returns the current updated matrix
  79535. */
  79536. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  79537. /**
  79538. * Gets the translation value of the current matrix
  79539. * @returns a new Vector3 as the extracted translation from the matrix
  79540. */
  79541. getTranslation(): Vector3;
  79542. /**
  79543. * Fill a Vector3 with the extracted translation from the matrix
  79544. * @param result defines the Vector3 where to store the translation
  79545. * @returns the current matrix
  79546. */
  79547. getTranslationToRef(result: Vector3): Matrix;
  79548. /**
  79549. * Remove rotation and scaling part from the matrix
  79550. * @returns the updated matrix
  79551. */
  79552. removeRotationAndScaling(): Matrix;
  79553. /**
  79554. * Multiply two matrices
  79555. * @param other defines the second operand
  79556. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  79557. */
  79558. multiply(other: DeepImmutable<Matrix>): Matrix;
  79559. /**
  79560. * Copy the current matrix from the given one
  79561. * @param other defines the source matrix
  79562. * @returns the current updated matrix
  79563. */
  79564. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  79565. /**
  79566. * Populates the given array from the starting index with the current matrix values
  79567. * @param array defines the target array
  79568. * @param offset defines the offset in the target array where to start storing values
  79569. * @returns the current matrix
  79570. */
  79571. copyToArray(array: Float32Array, offset?: number): Matrix;
  79572. /**
  79573. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  79574. * @param other defines the second operand
  79575. * @param result defines the matrix where to store the multiplication
  79576. * @returns the current matrix
  79577. */
  79578. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  79579. /**
  79580. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  79581. * @param other defines the second operand
  79582. * @param result defines the array where to store the multiplication
  79583. * @param offset defines the offset in the target array where to start storing values
  79584. * @returns the current matrix
  79585. */
  79586. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  79587. /**
  79588. * Check equality between this matrix and a second one
  79589. * @param value defines the second matrix to compare
  79590. * @returns true is the current matrix and the given one values are strictly equal
  79591. */
  79592. equals(value: DeepImmutable<Matrix>): boolean;
  79593. /**
  79594. * Clone the current matrix
  79595. * @returns a new matrix from the current matrix
  79596. */
  79597. clone(): Matrix;
  79598. /**
  79599. * Returns the name of the current matrix class
  79600. * @returns the string "Matrix"
  79601. */
  79602. getClassName(): string;
  79603. /**
  79604. * Gets the hash code of the current matrix
  79605. * @returns the hash code
  79606. */
  79607. getHashCode(): number;
  79608. /**
  79609. * Decomposes the current Matrix into a translation, rotation and scaling components
  79610. * @param scale defines the scale vector3 given as a reference to update
  79611. * @param rotation defines the rotation quaternion given as a reference to update
  79612. * @param translation defines the translation vector3 given as a reference to update
  79613. * @returns true if operation was successful
  79614. */
  79615. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  79616. /**
  79617. * Gets specific row of the matrix
  79618. * @param index defines the number of the row to get
  79619. * @returns the index-th row of the current matrix as a new Vector4
  79620. */
  79621. getRow(index: number): Nullable<Vector4>;
  79622. /**
  79623. * Sets the index-th row of the current matrix to the vector4 values
  79624. * @param index defines the number of the row to set
  79625. * @param row defines the target vector4
  79626. * @returns the updated current matrix
  79627. */
  79628. setRow(index: number, row: Vector4): Matrix;
  79629. /**
  79630. * Compute the transpose of the matrix
  79631. * @returns the new transposed matrix
  79632. */
  79633. transpose(): Matrix;
  79634. /**
  79635. * Compute the transpose of the matrix and store it in a given matrix
  79636. * @param result defines the target matrix
  79637. * @returns the current matrix
  79638. */
  79639. transposeToRef(result: Matrix): Matrix;
  79640. /**
  79641. * Sets the index-th row of the current matrix with the given 4 x float values
  79642. * @param index defines the row index
  79643. * @param x defines the x component to set
  79644. * @param y defines the y component to set
  79645. * @param z defines the z component to set
  79646. * @param w defines the w component to set
  79647. * @returns the updated current matrix
  79648. */
  79649. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  79650. /**
  79651. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  79652. * @param scale defines the scale factor
  79653. * @returns a new matrix
  79654. */
  79655. scale(scale: number): Matrix;
  79656. /**
  79657. * Scale the current matrix values by a factor to a given result matrix
  79658. * @param scale defines the scale factor
  79659. * @param result defines the matrix to store the result
  79660. * @returns the current matrix
  79661. */
  79662. scaleToRef(scale: number, result: Matrix): Matrix;
  79663. /**
  79664. * Scale the current matrix values by a factor and add the result to a given matrix
  79665. * @param scale defines the scale factor
  79666. * @param result defines the Matrix to store the result
  79667. * @returns the current matrix
  79668. */
  79669. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  79670. /**
  79671. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  79672. * @param ref matrix to store the result
  79673. */
  79674. toNormalMatrix(ref: Matrix): void;
  79675. /**
  79676. * Gets only rotation part of the current matrix
  79677. * @returns a new matrix sets to the extracted rotation matrix from the current one
  79678. */
  79679. getRotationMatrix(): Matrix;
  79680. /**
  79681. * Extracts the rotation matrix from the current one and sets it as the given "result"
  79682. * @param result defines the target matrix to store data to
  79683. * @returns the current matrix
  79684. */
  79685. getRotationMatrixToRef(result: Matrix): Matrix;
  79686. /**
  79687. * Toggles model matrix from being right handed to left handed in place and vice versa
  79688. */
  79689. toggleModelMatrixHandInPlace(): void;
  79690. /**
  79691. * Toggles projection matrix from being right handed to left handed in place and vice versa
  79692. */
  79693. toggleProjectionMatrixHandInPlace(): void;
  79694. /**
  79695. * Creates a matrix from an array
  79696. * @param array defines the source array
  79697. * @param offset defines an offset in the source array
  79698. * @returns a new Matrix set from the starting index of the given array
  79699. */
  79700. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  79701. /**
  79702. * Copy the content of an array into a given matrix
  79703. * @param array defines the source array
  79704. * @param offset defines an offset in the source array
  79705. * @param result defines the target matrix
  79706. */
  79707. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  79708. /**
  79709. * Stores an array into a matrix after having multiplied each component by a given factor
  79710. * @param array defines the source array
  79711. * @param offset defines the offset in the source array
  79712. * @param scale defines the scaling factor
  79713. * @param result defines the target matrix
  79714. */
  79715. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  79716. /**
  79717. * Gets an identity matrix that must not be updated
  79718. */
  79719. static get IdentityReadOnly(): DeepImmutable<Matrix>;
  79720. /**
  79721. * Stores a list of values (16) inside a given matrix
  79722. * @param initialM11 defines 1st value of 1st row
  79723. * @param initialM12 defines 2nd value of 1st row
  79724. * @param initialM13 defines 3rd value of 1st row
  79725. * @param initialM14 defines 4th value of 1st row
  79726. * @param initialM21 defines 1st value of 2nd row
  79727. * @param initialM22 defines 2nd value of 2nd row
  79728. * @param initialM23 defines 3rd value of 2nd row
  79729. * @param initialM24 defines 4th value of 2nd row
  79730. * @param initialM31 defines 1st value of 3rd row
  79731. * @param initialM32 defines 2nd value of 3rd row
  79732. * @param initialM33 defines 3rd value of 3rd row
  79733. * @param initialM34 defines 4th value of 3rd row
  79734. * @param initialM41 defines 1st value of 4th row
  79735. * @param initialM42 defines 2nd value of 4th row
  79736. * @param initialM43 defines 3rd value of 4th row
  79737. * @param initialM44 defines 4th value of 4th row
  79738. * @param result defines the target matrix
  79739. */
  79740. 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;
  79741. /**
  79742. * Creates new matrix from a list of values (16)
  79743. * @param initialM11 defines 1st value of 1st row
  79744. * @param initialM12 defines 2nd value of 1st row
  79745. * @param initialM13 defines 3rd value of 1st row
  79746. * @param initialM14 defines 4th value of 1st row
  79747. * @param initialM21 defines 1st value of 2nd row
  79748. * @param initialM22 defines 2nd value of 2nd row
  79749. * @param initialM23 defines 3rd value of 2nd row
  79750. * @param initialM24 defines 4th value of 2nd row
  79751. * @param initialM31 defines 1st value of 3rd row
  79752. * @param initialM32 defines 2nd value of 3rd row
  79753. * @param initialM33 defines 3rd value of 3rd row
  79754. * @param initialM34 defines 4th value of 3rd row
  79755. * @param initialM41 defines 1st value of 4th row
  79756. * @param initialM42 defines 2nd value of 4th row
  79757. * @param initialM43 defines 3rd value of 4th row
  79758. * @param initialM44 defines 4th value of 4th row
  79759. * @returns the new matrix
  79760. */
  79761. 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;
  79762. /**
  79763. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  79764. * @param scale defines the scale vector3
  79765. * @param rotation defines the rotation quaternion
  79766. * @param translation defines the translation vector3
  79767. * @returns a new matrix
  79768. */
  79769. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  79770. /**
  79771. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  79772. * @param scale defines the scale vector3
  79773. * @param rotation defines the rotation quaternion
  79774. * @param translation defines the translation vector3
  79775. * @param result defines the target matrix
  79776. */
  79777. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  79778. /**
  79779. * Creates a new identity matrix
  79780. * @returns a new identity matrix
  79781. */
  79782. static Identity(): Matrix;
  79783. /**
  79784. * Creates a new identity matrix and stores the result in a given matrix
  79785. * @param result defines the target matrix
  79786. */
  79787. static IdentityToRef(result: Matrix): void;
  79788. /**
  79789. * Creates a new zero matrix
  79790. * @returns a new zero matrix
  79791. */
  79792. static Zero(): Matrix;
  79793. /**
  79794. * Creates a new rotation matrix for "angle" radians around the X axis
  79795. * @param angle defines the angle (in radians) to use
  79796. * @return the new matrix
  79797. */
  79798. static RotationX(angle: number): Matrix;
  79799. /**
  79800. * Creates a new matrix as the invert of a given matrix
  79801. * @param source defines the source matrix
  79802. * @returns the new matrix
  79803. */
  79804. static Invert(source: DeepImmutable<Matrix>): Matrix;
  79805. /**
  79806. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  79807. * @param angle defines the angle (in radians) to use
  79808. * @param result defines the target matrix
  79809. */
  79810. static RotationXToRef(angle: number, result: Matrix): void;
  79811. /**
  79812. * Creates a new rotation matrix for "angle" radians around the Y axis
  79813. * @param angle defines the angle (in radians) to use
  79814. * @return the new matrix
  79815. */
  79816. static RotationY(angle: number): Matrix;
  79817. /**
  79818. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  79819. * @param angle defines the angle (in radians) to use
  79820. * @param result defines the target matrix
  79821. */
  79822. static RotationYToRef(angle: number, result: Matrix): void;
  79823. /**
  79824. * Creates a new rotation matrix for "angle" radians around the Z axis
  79825. * @param angle defines the angle (in radians) to use
  79826. * @return the new matrix
  79827. */
  79828. static RotationZ(angle: number): Matrix;
  79829. /**
  79830. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  79831. * @param angle defines the angle (in radians) to use
  79832. * @param result defines the target matrix
  79833. */
  79834. static RotationZToRef(angle: number, result: Matrix): void;
  79835. /**
  79836. * Creates a new rotation matrix for "angle" radians around the given axis
  79837. * @param axis defines the axis to use
  79838. * @param angle defines the angle (in radians) to use
  79839. * @return the new matrix
  79840. */
  79841. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  79842. /**
  79843. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  79844. * @param axis defines the axis to use
  79845. * @param angle defines the angle (in radians) to use
  79846. * @param result defines the target matrix
  79847. */
  79848. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  79849. /**
  79850. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  79851. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  79852. * @param from defines the vector to align
  79853. * @param to defines the vector to align to
  79854. * @param result defines the target matrix
  79855. */
  79856. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  79857. /**
  79858. * Creates a rotation matrix
  79859. * @param yaw defines the yaw angle in radians (Y axis)
  79860. * @param pitch defines the pitch angle in radians (X axis)
  79861. * @param roll defines the roll angle in radians (X axis)
  79862. * @returns the new rotation matrix
  79863. */
  79864. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  79865. /**
  79866. * Creates a rotation matrix and stores it in a given matrix
  79867. * @param yaw defines the yaw angle in radians (Y axis)
  79868. * @param pitch defines the pitch angle in radians (X axis)
  79869. * @param roll defines the roll angle in radians (X axis)
  79870. * @param result defines the target matrix
  79871. */
  79872. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  79873. /**
  79874. * Creates a scaling matrix
  79875. * @param x defines the scale factor on X axis
  79876. * @param y defines the scale factor on Y axis
  79877. * @param z defines the scale factor on Z axis
  79878. * @returns the new matrix
  79879. */
  79880. static Scaling(x: number, y: number, z: number): Matrix;
  79881. /**
  79882. * Creates a scaling matrix and stores it in a given matrix
  79883. * @param x defines the scale factor on X axis
  79884. * @param y defines the scale factor on Y axis
  79885. * @param z defines the scale factor on Z axis
  79886. * @param result defines the target matrix
  79887. */
  79888. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  79889. /**
  79890. * Creates a translation matrix
  79891. * @param x defines the translation on X axis
  79892. * @param y defines the translation on Y axis
  79893. * @param z defines the translationon Z axis
  79894. * @returns the new matrix
  79895. */
  79896. static Translation(x: number, y: number, z: number): Matrix;
  79897. /**
  79898. * Creates a translation matrix and stores it in a given matrix
  79899. * @param x defines the translation on X axis
  79900. * @param y defines the translation on Y axis
  79901. * @param z defines the translationon Z axis
  79902. * @param result defines the target matrix
  79903. */
  79904. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  79905. /**
  79906. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  79907. * @param startValue defines the start value
  79908. * @param endValue defines the end value
  79909. * @param gradient defines the gradient factor
  79910. * @returns the new matrix
  79911. */
  79912. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  79913. /**
  79914. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  79915. * @param startValue defines the start value
  79916. * @param endValue defines the end value
  79917. * @param gradient defines the gradient factor
  79918. * @param result defines the Matrix object where to store data
  79919. */
  79920. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  79921. /**
  79922. * Builds a new matrix whose values are computed by:
  79923. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  79924. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  79925. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  79926. * @param startValue defines the first matrix
  79927. * @param endValue defines the second matrix
  79928. * @param gradient defines the gradient between the two matrices
  79929. * @returns the new matrix
  79930. */
  79931. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  79932. /**
  79933. * Update a matrix to values which are computed by:
  79934. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  79935. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  79936. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  79937. * @param startValue defines the first matrix
  79938. * @param endValue defines the second matrix
  79939. * @param gradient defines the gradient between the two matrices
  79940. * @param result defines the target matrix
  79941. */
  79942. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  79943. /**
  79944. * 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"
  79945. * This function works in left handed mode
  79946. * @param eye defines the final position of the entity
  79947. * @param target defines where the entity should look at
  79948. * @param up defines the up vector for the entity
  79949. * @returns the new matrix
  79950. */
  79951. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  79952. /**
  79953. * 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".
  79954. * This function works in left handed mode
  79955. * @param eye defines the final position of the entity
  79956. * @param target defines where the entity should look at
  79957. * @param up defines the up vector for the entity
  79958. * @param result defines the target matrix
  79959. */
  79960. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  79961. /**
  79962. * 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"
  79963. * This function works in right handed mode
  79964. * @param eye defines the final position of the entity
  79965. * @param target defines where the entity should look at
  79966. * @param up defines the up vector for the entity
  79967. * @returns the new matrix
  79968. */
  79969. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  79970. /**
  79971. * 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".
  79972. * This function works in right handed mode
  79973. * @param eye defines the final position of the entity
  79974. * @param target defines where the entity should look at
  79975. * @param up defines the up vector for the entity
  79976. * @param result defines the target matrix
  79977. */
  79978. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  79979. /**
  79980. * Create a left-handed orthographic projection matrix
  79981. * @param width defines the viewport width
  79982. * @param height defines the viewport height
  79983. * @param znear defines the near clip plane
  79984. * @param zfar defines the far clip plane
  79985. * @returns a new matrix as a left-handed orthographic projection matrix
  79986. */
  79987. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  79988. /**
  79989. * Store a left-handed orthographic projection to a given matrix
  79990. * @param width defines the viewport width
  79991. * @param height defines the viewport height
  79992. * @param znear defines the near clip plane
  79993. * @param zfar defines the far clip plane
  79994. * @param result defines the target matrix
  79995. */
  79996. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  79997. /**
  79998. * Create a left-handed orthographic projection matrix
  79999. * @param left defines the viewport left coordinate
  80000. * @param right defines the viewport right coordinate
  80001. * @param bottom defines the viewport bottom coordinate
  80002. * @param top defines the viewport top coordinate
  80003. * @param znear defines the near clip plane
  80004. * @param zfar defines the far clip plane
  80005. * @returns a new matrix as a left-handed orthographic projection matrix
  80006. */
  80007. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  80008. /**
  80009. * Stores a left-handed orthographic projection into a given matrix
  80010. * @param left defines the viewport left coordinate
  80011. * @param right defines the viewport right coordinate
  80012. * @param bottom defines the viewport bottom coordinate
  80013. * @param top defines the viewport top coordinate
  80014. * @param znear defines the near clip plane
  80015. * @param zfar defines the far clip plane
  80016. * @param result defines the target matrix
  80017. */
  80018. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  80019. /**
  80020. * Creates a right-handed orthographic projection matrix
  80021. * @param left defines the viewport left coordinate
  80022. * @param right defines the viewport right coordinate
  80023. * @param bottom defines the viewport bottom coordinate
  80024. * @param top defines the viewport top coordinate
  80025. * @param znear defines the near clip plane
  80026. * @param zfar defines the far clip plane
  80027. * @returns a new matrix as a right-handed orthographic projection matrix
  80028. */
  80029. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  80030. /**
  80031. * Stores a right-handed orthographic projection into a given matrix
  80032. * @param left defines the viewport left coordinate
  80033. * @param right defines the viewport right coordinate
  80034. * @param bottom defines the viewport bottom coordinate
  80035. * @param top defines the viewport top coordinate
  80036. * @param znear defines the near clip plane
  80037. * @param zfar defines the far clip plane
  80038. * @param result defines the target matrix
  80039. */
  80040. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  80041. /**
  80042. * Creates a left-handed perspective projection matrix
  80043. * @param width defines the viewport width
  80044. * @param height defines the viewport height
  80045. * @param znear defines the near clip plane
  80046. * @param zfar defines the far clip plane
  80047. * @returns a new matrix as a left-handed perspective projection matrix
  80048. */
  80049. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  80050. /**
  80051. * Creates a left-handed perspective projection matrix
  80052. * @param fov defines the horizontal field of view
  80053. * @param aspect defines the aspect ratio
  80054. * @param znear defines the near clip plane
  80055. * @param zfar defines the far clip plane
  80056. * @returns a new matrix as a left-handed perspective projection matrix
  80057. */
  80058. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  80059. /**
  80060. * Stores a left-handed perspective projection into a given matrix
  80061. * @param fov defines the horizontal field of view
  80062. * @param aspect defines the aspect ratio
  80063. * @param znear defines the near clip plane
  80064. * @param zfar defines the far clip plane
  80065. * @param result defines the target matrix
  80066. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  80067. */
  80068. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  80069. /**
  80070. * Stores a left-handed perspective projection into a given matrix with depth reversed
  80071. * @param fov defines the horizontal field of view
  80072. * @param aspect defines the aspect ratio
  80073. * @param znear defines the near clip plane
  80074. * @param zfar not used as infinity is used as far clip
  80075. * @param result defines the target matrix
  80076. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  80077. */
  80078. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  80079. /**
  80080. * Creates a right-handed perspective projection matrix
  80081. * @param fov defines the horizontal field of view
  80082. * @param aspect defines the aspect ratio
  80083. * @param znear defines the near clip plane
  80084. * @param zfar defines the far clip plane
  80085. * @returns a new matrix as a right-handed perspective projection matrix
  80086. */
  80087. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  80088. /**
  80089. * Stores a right-handed perspective projection into a given matrix
  80090. * @param fov defines the horizontal field of view
  80091. * @param aspect defines the aspect ratio
  80092. * @param znear defines the near clip plane
  80093. * @param zfar defines the far clip plane
  80094. * @param result defines the target matrix
  80095. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  80096. */
  80097. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  80098. /**
  80099. * Stores a right-handed perspective projection into a given matrix
  80100. * @param fov defines the horizontal field of view
  80101. * @param aspect defines the aspect ratio
  80102. * @param znear defines the near clip plane
  80103. * @param zfar not used as infinity is used as far clip
  80104. * @param result defines the target matrix
  80105. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  80106. */
  80107. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  80108. /**
  80109. * Stores a perspective projection for WebVR info a given matrix
  80110. * @param fov defines the field of view
  80111. * @param znear defines the near clip plane
  80112. * @param zfar defines the far clip plane
  80113. * @param result defines the target matrix
  80114. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  80115. */
  80116. static PerspectiveFovWebVRToRef(fov: {
  80117. upDegrees: number;
  80118. downDegrees: number;
  80119. leftDegrees: number;
  80120. rightDegrees: number;
  80121. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  80122. /**
  80123. * Computes a complete transformation matrix
  80124. * @param viewport defines the viewport to use
  80125. * @param world defines the world matrix
  80126. * @param view defines the view matrix
  80127. * @param projection defines the projection matrix
  80128. * @param zmin defines the near clip plane
  80129. * @param zmax defines the far clip plane
  80130. * @returns the transformation matrix
  80131. */
  80132. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  80133. /**
  80134. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  80135. * @param matrix defines the matrix to use
  80136. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  80137. */
  80138. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  80139. /**
  80140. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  80141. * @param matrix defines the matrix to use
  80142. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  80143. */
  80144. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  80145. /**
  80146. * Compute the transpose of a given matrix
  80147. * @param matrix defines the matrix to transpose
  80148. * @returns the new matrix
  80149. */
  80150. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  80151. /**
  80152. * Compute the transpose of a matrix and store it in a target matrix
  80153. * @param matrix defines the matrix to transpose
  80154. * @param result defines the target matrix
  80155. */
  80156. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  80157. /**
  80158. * Computes a reflection matrix from a plane
  80159. * @param plane defines the reflection plane
  80160. * @returns a new matrix
  80161. */
  80162. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  80163. /**
  80164. * Computes a reflection matrix from a plane
  80165. * @param plane defines the reflection plane
  80166. * @param result defines the target matrix
  80167. */
  80168. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  80169. /**
  80170. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  80171. * @param xaxis defines the value of the 1st axis
  80172. * @param yaxis defines the value of the 2nd axis
  80173. * @param zaxis defines the value of the 3rd axis
  80174. * @param result defines the target matrix
  80175. */
  80176. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  80177. /**
  80178. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  80179. * @param quat defines the quaternion to use
  80180. * @param result defines the target matrix
  80181. */
  80182. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  80183. }
  80184. /**
  80185. * @hidden
  80186. */
  80187. export class TmpVectors {
  80188. static Vector2: Vector2[];
  80189. static Vector3: Vector3[];
  80190. static Vector4: Vector4[];
  80191. static Quaternion: Quaternion[];
  80192. static Matrix: Matrix[];
  80193. }
  80194. }
  80195. declare module BABYLON {
  80196. /**
  80197. * Defines potential orientation for back face culling
  80198. */
  80199. export enum Orientation {
  80200. /**
  80201. * Clockwise
  80202. */
  80203. CW = 0,
  80204. /** Counter clockwise */
  80205. CCW = 1
  80206. }
  80207. /** Class used to represent a Bezier curve */
  80208. export class BezierCurve {
  80209. /**
  80210. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  80211. * @param t defines the time
  80212. * @param x1 defines the left coordinate on X axis
  80213. * @param y1 defines the left coordinate on Y axis
  80214. * @param x2 defines the right coordinate on X axis
  80215. * @param y2 defines the right coordinate on Y axis
  80216. * @returns the interpolated value
  80217. */
  80218. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  80219. }
  80220. /**
  80221. * Defines angle representation
  80222. */
  80223. export class Angle {
  80224. private _radians;
  80225. /**
  80226. * Creates an Angle object of "radians" radians (float).
  80227. * @param radians the angle in radians
  80228. */
  80229. constructor(radians: number);
  80230. /**
  80231. * Get value in degrees
  80232. * @returns the Angle value in degrees (float)
  80233. */
  80234. degrees(): number;
  80235. /**
  80236. * Get value in radians
  80237. * @returns the Angle value in radians (float)
  80238. */
  80239. radians(): number;
  80240. /**
  80241. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  80242. * @param a defines first vector
  80243. * @param b defines second vector
  80244. * @returns a new Angle
  80245. */
  80246. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  80247. /**
  80248. * Gets a new Angle object from the given float in radians
  80249. * @param radians defines the angle value in radians
  80250. * @returns a new Angle
  80251. */
  80252. static FromRadians(radians: number): Angle;
  80253. /**
  80254. * Gets a new Angle object from the given float in degrees
  80255. * @param degrees defines the angle value in degrees
  80256. * @returns a new Angle
  80257. */
  80258. static FromDegrees(degrees: number): Angle;
  80259. }
  80260. /**
  80261. * This represents an arc in a 2d space.
  80262. */
  80263. export class Arc2 {
  80264. /** Defines the start point of the arc */
  80265. startPoint: Vector2;
  80266. /** Defines the mid point of the arc */
  80267. midPoint: Vector2;
  80268. /** Defines the end point of the arc */
  80269. endPoint: Vector2;
  80270. /**
  80271. * Defines the center point of the arc.
  80272. */
  80273. centerPoint: Vector2;
  80274. /**
  80275. * Defines the radius of the arc.
  80276. */
  80277. radius: number;
  80278. /**
  80279. * Defines the angle of the arc (from mid point to end point).
  80280. */
  80281. angle: Angle;
  80282. /**
  80283. * Defines the start angle of the arc (from start point to middle point).
  80284. */
  80285. startAngle: Angle;
  80286. /**
  80287. * Defines the orientation of the arc (clock wise/counter clock wise).
  80288. */
  80289. orientation: Orientation;
  80290. /**
  80291. * Creates an Arc object from the three given points : start, middle and end.
  80292. * @param startPoint Defines the start point of the arc
  80293. * @param midPoint Defines the midlle point of the arc
  80294. * @param endPoint Defines the end point of the arc
  80295. */
  80296. constructor(
  80297. /** Defines the start point of the arc */
  80298. startPoint: Vector2,
  80299. /** Defines the mid point of the arc */
  80300. midPoint: Vector2,
  80301. /** Defines the end point of the arc */
  80302. endPoint: Vector2);
  80303. }
  80304. /**
  80305. * Represents a 2D path made up of multiple 2D points
  80306. */
  80307. export class Path2 {
  80308. private _points;
  80309. private _length;
  80310. /**
  80311. * If the path start and end point are the same
  80312. */
  80313. closed: boolean;
  80314. /**
  80315. * Creates a Path2 object from the starting 2D coordinates x and y.
  80316. * @param x the starting points x value
  80317. * @param y the starting points y value
  80318. */
  80319. constructor(x: number, y: number);
  80320. /**
  80321. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  80322. * @param x the added points x value
  80323. * @param y the added points y value
  80324. * @returns the updated Path2.
  80325. */
  80326. addLineTo(x: number, y: number): Path2;
  80327. /**
  80328. * 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.
  80329. * @param midX middle point x value
  80330. * @param midY middle point y value
  80331. * @param endX end point x value
  80332. * @param endY end point y value
  80333. * @param numberOfSegments (default: 36)
  80334. * @returns the updated Path2.
  80335. */
  80336. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  80337. /**
  80338. * Closes the Path2.
  80339. * @returns the Path2.
  80340. */
  80341. close(): Path2;
  80342. /**
  80343. * Gets the sum of the distance between each sequential point in the path
  80344. * @returns the Path2 total length (float).
  80345. */
  80346. length(): number;
  80347. /**
  80348. * Gets the points which construct the path
  80349. * @returns the Path2 internal array of points.
  80350. */
  80351. getPoints(): Vector2[];
  80352. /**
  80353. * Retreives the point at the distance aways from the starting point
  80354. * @param normalizedLengthPosition the length along the path to retreive the point from
  80355. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  80356. */
  80357. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  80358. /**
  80359. * Creates a new path starting from an x and y position
  80360. * @param x starting x value
  80361. * @param y starting y value
  80362. * @returns a new Path2 starting at the coordinates (x, y).
  80363. */
  80364. static StartingAt(x: number, y: number): Path2;
  80365. }
  80366. /**
  80367. * Represents a 3D path made up of multiple 3D points
  80368. */
  80369. export class Path3D {
  80370. /**
  80371. * an array of Vector3, the curve axis of the Path3D
  80372. */
  80373. path: Vector3[];
  80374. private _curve;
  80375. private _distances;
  80376. private _tangents;
  80377. private _normals;
  80378. private _binormals;
  80379. private _raw;
  80380. private _alignTangentsWithPath;
  80381. private readonly _pointAtData;
  80382. /**
  80383. * new Path3D(path, normal, raw)
  80384. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  80385. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  80386. * @param path an array of Vector3, the curve axis of the Path3D
  80387. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  80388. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  80389. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  80390. */
  80391. constructor(
  80392. /**
  80393. * an array of Vector3, the curve axis of the Path3D
  80394. */
  80395. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  80396. /**
  80397. * Returns the Path3D array of successive Vector3 designing its curve.
  80398. * @returns the Path3D array of successive Vector3 designing its curve.
  80399. */
  80400. getCurve(): Vector3[];
  80401. /**
  80402. * Returns the Path3D array of successive Vector3 designing its curve.
  80403. * @returns the Path3D array of successive Vector3 designing its curve.
  80404. */
  80405. getPoints(): Vector3[];
  80406. /**
  80407. * @returns the computed length (float) of the path.
  80408. */
  80409. length(): number;
  80410. /**
  80411. * Returns an array populated with tangent vectors on each Path3D curve point.
  80412. * @returns an array populated with tangent vectors on each Path3D curve point.
  80413. */
  80414. getTangents(): Vector3[];
  80415. /**
  80416. * Returns an array populated with normal vectors on each Path3D curve point.
  80417. * @returns an array populated with normal vectors on each Path3D curve point.
  80418. */
  80419. getNormals(): Vector3[];
  80420. /**
  80421. * Returns an array populated with binormal vectors on each Path3D curve point.
  80422. * @returns an array populated with binormal vectors on each Path3D curve point.
  80423. */
  80424. getBinormals(): Vector3[];
  80425. /**
  80426. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  80427. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  80428. */
  80429. getDistances(): number[];
  80430. /**
  80431. * Returns an interpolated point along this path
  80432. * @param position the position of the point along this path, from 0.0 to 1.0
  80433. * @returns a new Vector3 as the point
  80434. */
  80435. getPointAt(position: number): Vector3;
  80436. /**
  80437. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  80438. * @param position the position of the point along this path, from 0.0 to 1.0
  80439. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  80440. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  80441. */
  80442. getTangentAt(position: number, interpolated?: boolean): Vector3;
  80443. /**
  80444. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  80445. * @param position the position of the point along this path, from 0.0 to 1.0
  80446. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  80447. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  80448. */
  80449. getNormalAt(position: number, interpolated?: boolean): Vector3;
  80450. /**
  80451. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  80452. * @param position the position of the point along this path, from 0.0 to 1.0
  80453. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  80454. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  80455. */
  80456. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  80457. /**
  80458. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  80459. * @param position the position of the point along this path, from 0.0 to 1.0
  80460. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  80461. */
  80462. getDistanceAt(position: number): number;
  80463. /**
  80464. * Returns the array index of the previous point of an interpolated point along this path
  80465. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  80466. * @returns the array index
  80467. */
  80468. getPreviousPointIndexAt(position: number): number;
  80469. /**
  80470. * 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)
  80471. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  80472. * @returns the sub position
  80473. */
  80474. getSubPositionAt(position: number): number;
  80475. /**
  80476. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  80477. * @param target the vector of which to get the closest position to
  80478. * @returns the position of the closest virtual point on this path to the target vector
  80479. */
  80480. getClosestPositionTo(target: Vector3): number;
  80481. /**
  80482. * Returns a sub path (slice) of this path
  80483. * @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
  80484. * @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
  80485. * @returns a sub path (slice) of this path
  80486. */
  80487. slice(start?: number, end?: number): Path3D;
  80488. /**
  80489. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  80490. * @param path path which all values are copied into the curves points
  80491. * @param firstNormal which should be projected onto the curve
  80492. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  80493. * @returns the same object updated.
  80494. */
  80495. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  80496. private _compute;
  80497. private _getFirstNonNullVector;
  80498. private _getLastNonNullVector;
  80499. private _normalVector;
  80500. /**
  80501. * Updates the point at data for an interpolated point along this curve
  80502. * @param position the position of the point along this curve, from 0.0 to 1.0
  80503. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  80504. * @returns the (updated) point at data
  80505. */
  80506. private _updatePointAtData;
  80507. /**
  80508. * Updates the point at data from the specified parameters
  80509. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  80510. * @param point the interpolated point
  80511. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  80512. */
  80513. private _setPointAtData;
  80514. /**
  80515. * Updates the point at interpolation matrix for the tangents, normals and binormals
  80516. */
  80517. private _updateInterpolationMatrix;
  80518. }
  80519. /**
  80520. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  80521. * A Curve3 is designed from a series of successive Vector3.
  80522. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  80523. */
  80524. export class Curve3 {
  80525. private _points;
  80526. private _length;
  80527. /**
  80528. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  80529. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  80530. * @param v1 (Vector3) the control point
  80531. * @param v2 (Vector3) the end point of the Quadratic Bezier
  80532. * @param nbPoints (integer) the wanted number of points in the curve
  80533. * @returns the created Curve3
  80534. */
  80535. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  80536. /**
  80537. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  80538. * @param v0 (Vector3) the origin point of the Cubic Bezier
  80539. * @param v1 (Vector3) the first control point
  80540. * @param v2 (Vector3) the second control point
  80541. * @param v3 (Vector3) the end point of the Cubic Bezier
  80542. * @param nbPoints (integer) the wanted number of points in the curve
  80543. * @returns the created Curve3
  80544. */
  80545. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  80546. /**
  80547. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  80548. * @param p1 (Vector3) the origin point of the Hermite Spline
  80549. * @param t1 (Vector3) the tangent vector at the origin point
  80550. * @param p2 (Vector3) the end point of the Hermite Spline
  80551. * @param t2 (Vector3) the tangent vector at the end point
  80552. * @param nbPoints (integer) the wanted number of points in the curve
  80553. * @returns the created Curve3
  80554. */
  80555. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  80556. /**
  80557. * Returns a Curve3 object along a CatmullRom Spline curve :
  80558. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  80559. * @param nbPoints (integer) the wanted number of points between each curve control points
  80560. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  80561. * @returns the created Curve3
  80562. */
  80563. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  80564. /**
  80565. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  80566. * A Curve3 is designed from a series of successive Vector3.
  80567. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  80568. * @param points points which make up the curve
  80569. */
  80570. constructor(points: Vector3[]);
  80571. /**
  80572. * @returns the Curve3 stored array of successive Vector3
  80573. */
  80574. getPoints(): Vector3[];
  80575. /**
  80576. * @returns the computed length (float) of the curve.
  80577. */
  80578. length(): number;
  80579. /**
  80580. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  80581. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  80582. * curveA and curveB keep unchanged.
  80583. * @param curve the curve to continue from this curve
  80584. * @returns the newly constructed curve
  80585. */
  80586. continue(curve: DeepImmutable<Curve3>): Curve3;
  80587. private _computeLength;
  80588. }
  80589. }
  80590. declare module BABYLON {
  80591. /**
  80592. * This represents the main contract an easing function should follow.
  80593. * Easing functions are used throughout the animation system.
  80594. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  80595. */
  80596. export interface IEasingFunction {
  80597. /**
  80598. * Given an input gradient between 0 and 1, this returns the corrseponding value
  80599. * of the easing function.
  80600. * The link below provides some of the most common examples of easing functions.
  80601. * @see https://easings.net/
  80602. * @param gradient Defines the value between 0 and 1 we want the easing value for
  80603. * @returns the corresponding value on the curve defined by the easing function
  80604. */
  80605. ease(gradient: number): number;
  80606. }
  80607. /**
  80608. * Base class used for every default easing function.
  80609. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  80610. */
  80611. export class EasingFunction implements IEasingFunction {
  80612. /**
  80613. * Interpolation follows the mathematical formula associated with the easing function.
  80614. */
  80615. static readonly EASINGMODE_EASEIN: number;
  80616. /**
  80617. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  80618. */
  80619. static readonly EASINGMODE_EASEOUT: number;
  80620. /**
  80621. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  80622. */
  80623. static readonly EASINGMODE_EASEINOUT: number;
  80624. private _easingMode;
  80625. /**
  80626. * Sets the easing mode of the current function.
  80627. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  80628. */
  80629. setEasingMode(easingMode: number): void;
  80630. /**
  80631. * Gets the current easing mode.
  80632. * @returns the easing mode
  80633. */
  80634. getEasingMode(): number;
  80635. /**
  80636. * @hidden
  80637. */
  80638. easeInCore(gradient: number): number;
  80639. /**
  80640. * Given an input gradient between 0 and 1, this returns the corresponding value
  80641. * of the easing function.
  80642. * @param gradient Defines the value between 0 and 1 we want the easing value for
  80643. * @returns the corresponding value on the curve defined by the easing function
  80644. */
  80645. ease(gradient: number): number;
  80646. }
  80647. /**
  80648. * Easing function with a circle shape (see link below).
  80649. * @see https://easings.net/#easeInCirc
  80650. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  80651. */
  80652. export class CircleEase extends EasingFunction implements IEasingFunction {
  80653. /** @hidden */
  80654. easeInCore(gradient: number): number;
  80655. }
  80656. /**
  80657. * Easing function with a ease back shape (see link below).
  80658. * @see https://easings.net/#easeInBack
  80659. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  80660. */
  80661. export class BackEase extends EasingFunction implements IEasingFunction {
  80662. /** Defines the amplitude of the function */
  80663. amplitude: number;
  80664. /**
  80665. * Instantiates a back ease easing
  80666. * @see https://easings.net/#easeInBack
  80667. * @param amplitude Defines the amplitude of the function
  80668. */
  80669. constructor(
  80670. /** Defines the amplitude of the function */
  80671. amplitude?: number);
  80672. /** @hidden */
  80673. easeInCore(gradient: number): number;
  80674. }
  80675. /**
  80676. * Easing function with a bouncing shape (see link below).
  80677. * @see https://easings.net/#easeInBounce
  80678. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  80679. */
  80680. export class BounceEase extends EasingFunction implements IEasingFunction {
  80681. /** Defines the number of bounces */
  80682. bounces: number;
  80683. /** Defines the amplitude of the bounce */
  80684. bounciness: number;
  80685. /**
  80686. * Instantiates a bounce easing
  80687. * @see https://easings.net/#easeInBounce
  80688. * @param bounces Defines the number of bounces
  80689. * @param bounciness Defines the amplitude of the bounce
  80690. */
  80691. constructor(
  80692. /** Defines the number of bounces */
  80693. bounces?: number,
  80694. /** Defines the amplitude of the bounce */
  80695. bounciness?: number);
  80696. /** @hidden */
  80697. easeInCore(gradient: number): number;
  80698. }
  80699. /**
  80700. * Easing function with a power of 3 shape (see link below).
  80701. * @see https://easings.net/#easeInCubic
  80702. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  80703. */
  80704. export class CubicEase extends EasingFunction implements IEasingFunction {
  80705. /** @hidden */
  80706. easeInCore(gradient: number): number;
  80707. }
  80708. /**
  80709. * Easing function with an elastic shape (see link below).
  80710. * @see https://easings.net/#easeInElastic
  80711. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  80712. */
  80713. export class ElasticEase extends EasingFunction implements IEasingFunction {
  80714. /** Defines the number of oscillations*/
  80715. oscillations: number;
  80716. /** Defines the amplitude of the oscillations*/
  80717. springiness: number;
  80718. /**
  80719. * Instantiates an elastic easing function
  80720. * @see https://easings.net/#easeInElastic
  80721. * @param oscillations Defines the number of oscillations
  80722. * @param springiness Defines the amplitude of the oscillations
  80723. */
  80724. constructor(
  80725. /** Defines the number of oscillations*/
  80726. oscillations?: number,
  80727. /** Defines the amplitude of the oscillations*/
  80728. springiness?: number);
  80729. /** @hidden */
  80730. easeInCore(gradient: number): number;
  80731. }
  80732. /**
  80733. * Easing function with an exponential shape (see link below).
  80734. * @see https://easings.net/#easeInExpo
  80735. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  80736. */
  80737. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  80738. /** Defines the exponent of the function */
  80739. exponent: number;
  80740. /**
  80741. * Instantiates an exponential easing function
  80742. * @see https://easings.net/#easeInExpo
  80743. * @param exponent Defines the exponent of the function
  80744. */
  80745. constructor(
  80746. /** Defines the exponent of the function */
  80747. exponent?: number);
  80748. /** @hidden */
  80749. easeInCore(gradient: number): number;
  80750. }
  80751. /**
  80752. * Easing function with a power shape (see link below).
  80753. * @see https://easings.net/#easeInQuad
  80754. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  80755. */
  80756. export class PowerEase extends EasingFunction implements IEasingFunction {
  80757. /** Defines the power of the function */
  80758. power: number;
  80759. /**
  80760. * Instantiates an power base easing function
  80761. * @see https://easings.net/#easeInQuad
  80762. * @param power Defines the power of the function
  80763. */
  80764. constructor(
  80765. /** Defines the power of the function */
  80766. power?: number);
  80767. /** @hidden */
  80768. easeInCore(gradient: number): number;
  80769. }
  80770. /**
  80771. * Easing function with a power of 2 shape (see link below).
  80772. * @see https://easings.net/#easeInQuad
  80773. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  80774. */
  80775. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  80776. /** @hidden */
  80777. easeInCore(gradient: number): number;
  80778. }
  80779. /**
  80780. * Easing function with a power of 4 shape (see link below).
  80781. * @see https://easings.net/#easeInQuart
  80782. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  80783. */
  80784. export class QuarticEase extends EasingFunction implements IEasingFunction {
  80785. /** @hidden */
  80786. easeInCore(gradient: number): number;
  80787. }
  80788. /**
  80789. * Easing function with a power of 5 shape (see link below).
  80790. * @see https://easings.net/#easeInQuint
  80791. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  80792. */
  80793. export class QuinticEase extends EasingFunction implements IEasingFunction {
  80794. /** @hidden */
  80795. easeInCore(gradient: number): number;
  80796. }
  80797. /**
  80798. * Easing function with a sin shape (see link below).
  80799. * @see https://easings.net/#easeInSine
  80800. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  80801. */
  80802. export class SineEase extends EasingFunction implements IEasingFunction {
  80803. /** @hidden */
  80804. easeInCore(gradient: number): number;
  80805. }
  80806. /**
  80807. * Easing function with a bezier shape (see link below).
  80808. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  80809. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  80810. */
  80811. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  80812. /** Defines the x component of the start tangent in the bezier curve */
  80813. x1: number;
  80814. /** Defines the y component of the start tangent in the bezier curve */
  80815. y1: number;
  80816. /** Defines the x component of the end tangent in the bezier curve */
  80817. x2: number;
  80818. /** Defines the y component of the end tangent in the bezier curve */
  80819. y2: number;
  80820. /**
  80821. * Instantiates a bezier function
  80822. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  80823. * @param x1 Defines the x component of the start tangent in the bezier curve
  80824. * @param y1 Defines the y component of the start tangent in the bezier curve
  80825. * @param x2 Defines the x component of the end tangent in the bezier curve
  80826. * @param y2 Defines the y component of the end tangent in the bezier curve
  80827. */
  80828. constructor(
  80829. /** Defines the x component of the start tangent in the bezier curve */
  80830. x1?: number,
  80831. /** Defines the y component of the start tangent in the bezier curve */
  80832. y1?: number,
  80833. /** Defines the x component of the end tangent in the bezier curve */
  80834. x2?: number,
  80835. /** Defines the y component of the end tangent in the bezier curve */
  80836. y2?: number);
  80837. /** @hidden */
  80838. easeInCore(gradient: number): number;
  80839. }
  80840. }
  80841. declare module BABYLON {
  80842. /**
  80843. * Class used to hold a RBG color
  80844. */
  80845. export class Color3 {
  80846. /**
  80847. * Defines the red component (between 0 and 1, default is 0)
  80848. */
  80849. r: number;
  80850. /**
  80851. * Defines the green component (between 0 and 1, default is 0)
  80852. */
  80853. g: number;
  80854. /**
  80855. * Defines the blue component (between 0 and 1, default is 0)
  80856. */
  80857. b: number;
  80858. /**
  80859. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  80860. * @param r defines the red component (between 0 and 1, default is 0)
  80861. * @param g defines the green component (between 0 and 1, default is 0)
  80862. * @param b defines the blue component (between 0 and 1, default is 0)
  80863. */
  80864. constructor(
  80865. /**
  80866. * Defines the red component (between 0 and 1, default is 0)
  80867. */
  80868. r?: number,
  80869. /**
  80870. * Defines the green component (between 0 and 1, default is 0)
  80871. */
  80872. g?: number,
  80873. /**
  80874. * Defines the blue component (between 0 and 1, default is 0)
  80875. */
  80876. b?: number);
  80877. /**
  80878. * Creates a string with the Color3 current values
  80879. * @returns the string representation of the Color3 object
  80880. */
  80881. toString(): string;
  80882. /**
  80883. * Returns the string "Color3"
  80884. * @returns "Color3"
  80885. */
  80886. getClassName(): string;
  80887. /**
  80888. * Compute the Color3 hash code
  80889. * @returns an unique number that can be used to hash Color3 objects
  80890. */
  80891. getHashCode(): number;
  80892. /**
  80893. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  80894. * @param array defines the array where to store the r,g,b components
  80895. * @param index defines an optional index in the target array to define where to start storing values
  80896. * @returns the current Color3 object
  80897. */
  80898. toArray(array: FloatArray, index?: number): Color3;
  80899. /**
  80900. * Returns a new Color4 object from the current Color3 and the given alpha
  80901. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  80902. * @returns a new Color4 object
  80903. */
  80904. toColor4(alpha?: number): Color4;
  80905. /**
  80906. * Returns a new array populated with 3 numeric elements : red, green and blue values
  80907. * @returns the new array
  80908. */
  80909. asArray(): number[];
  80910. /**
  80911. * Returns the luminance value
  80912. * @returns a float value
  80913. */
  80914. toLuminance(): number;
  80915. /**
  80916. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  80917. * @param otherColor defines the second operand
  80918. * @returns the new Color3 object
  80919. */
  80920. multiply(otherColor: DeepImmutable<Color3>): Color3;
  80921. /**
  80922. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  80923. * @param otherColor defines the second operand
  80924. * @param result defines the Color3 object where to store the result
  80925. * @returns the current Color3
  80926. */
  80927. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  80928. /**
  80929. * Determines equality between Color3 objects
  80930. * @param otherColor defines the second operand
  80931. * @returns true if the rgb values are equal to the given ones
  80932. */
  80933. equals(otherColor: DeepImmutable<Color3>): boolean;
  80934. /**
  80935. * Determines equality between the current Color3 object and a set of r,b,g values
  80936. * @param r defines the red component to check
  80937. * @param g defines the green component to check
  80938. * @param b defines the blue component to check
  80939. * @returns true if the rgb values are equal to the given ones
  80940. */
  80941. equalsFloats(r: number, g: number, b: number): boolean;
  80942. /**
  80943. * Multiplies in place each rgb value by scale
  80944. * @param scale defines the scaling factor
  80945. * @returns the updated Color3
  80946. */
  80947. scale(scale: number): Color3;
  80948. /**
  80949. * Multiplies the rgb values by scale and stores the result into "result"
  80950. * @param scale defines the scaling factor
  80951. * @param result defines the Color3 object where to store the result
  80952. * @returns the unmodified current Color3
  80953. */
  80954. scaleToRef(scale: number, result: Color3): Color3;
  80955. /**
  80956. * Scale the current Color3 values by a factor and add the result to a given Color3
  80957. * @param scale defines the scale factor
  80958. * @param result defines color to store the result into
  80959. * @returns the unmodified current Color3
  80960. */
  80961. scaleAndAddToRef(scale: number, result: Color3): Color3;
  80962. /**
  80963. * Clamps the rgb values by the min and max values and stores the result into "result"
  80964. * @param min defines minimum clamping value (default is 0)
  80965. * @param max defines maximum clamping value (default is 1)
  80966. * @param result defines color to store the result into
  80967. * @returns the original Color3
  80968. */
  80969. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  80970. /**
  80971. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  80972. * @param otherColor defines the second operand
  80973. * @returns the new Color3
  80974. */
  80975. add(otherColor: DeepImmutable<Color3>): Color3;
  80976. /**
  80977. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  80978. * @param otherColor defines the second operand
  80979. * @param result defines Color3 object to store the result into
  80980. * @returns the unmodified current Color3
  80981. */
  80982. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  80983. /**
  80984. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  80985. * @param otherColor defines the second operand
  80986. * @returns the new Color3
  80987. */
  80988. subtract(otherColor: DeepImmutable<Color3>): Color3;
  80989. /**
  80990. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  80991. * @param otherColor defines the second operand
  80992. * @param result defines Color3 object to store the result into
  80993. * @returns the unmodified current Color3
  80994. */
  80995. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  80996. /**
  80997. * Copy the current object
  80998. * @returns a new Color3 copied the current one
  80999. */
  81000. clone(): Color3;
  81001. /**
  81002. * Copies the rgb values from the source in the current Color3
  81003. * @param source defines the source Color3 object
  81004. * @returns the updated Color3 object
  81005. */
  81006. copyFrom(source: DeepImmutable<Color3>): Color3;
  81007. /**
  81008. * Updates the Color3 rgb values from the given floats
  81009. * @param r defines the red component to read from
  81010. * @param g defines the green component to read from
  81011. * @param b defines the blue component to read from
  81012. * @returns the current Color3 object
  81013. */
  81014. copyFromFloats(r: number, g: number, b: number): Color3;
  81015. /**
  81016. * Updates the Color3 rgb values from the given floats
  81017. * @param r defines the red component to read from
  81018. * @param g defines the green component to read from
  81019. * @param b defines the blue component to read from
  81020. * @returns the current Color3 object
  81021. */
  81022. set(r: number, g: number, b: number): Color3;
  81023. /**
  81024. * Compute the Color3 hexadecimal code as a string
  81025. * @returns a string containing the hexadecimal representation of the Color3 object
  81026. */
  81027. toHexString(): string;
  81028. /**
  81029. * Computes a new Color3 converted from the current one to linear space
  81030. * @returns a new Color3 object
  81031. */
  81032. toLinearSpace(): Color3;
  81033. /**
  81034. * Converts current color in rgb space to HSV values
  81035. * @returns a new color3 representing the HSV values
  81036. */
  81037. toHSV(): Color3;
  81038. /**
  81039. * Converts current color in rgb space to HSV values
  81040. * @param result defines the Color3 where to store the HSV values
  81041. */
  81042. toHSVToRef(result: Color3): void;
  81043. /**
  81044. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  81045. * @param convertedColor defines the Color3 object where to store the linear space version
  81046. * @returns the unmodified Color3
  81047. */
  81048. toLinearSpaceToRef(convertedColor: Color3): Color3;
  81049. /**
  81050. * Computes a new Color3 converted from the current one to gamma space
  81051. * @returns a new Color3 object
  81052. */
  81053. toGammaSpace(): Color3;
  81054. /**
  81055. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  81056. * @param convertedColor defines the Color3 object where to store the gamma space version
  81057. * @returns the unmodified Color3
  81058. */
  81059. toGammaSpaceToRef(convertedColor: Color3): Color3;
  81060. private static _BlackReadOnly;
  81061. /**
  81062. * Convert Hue, saturation and value to a Color3 (RGB)
  81063. * @param hue defines the hue
  81064. * @param saturation defines the saturation
  81065. * @param value defines the value
  81066. * @param result defines the Color3 where to store the RGB values
  81067. */
  81068. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  81069. /**
  81070. * Creates a new Color3 from the string containing valid hexadecimal values
  81071. * @param hex defines a string containing valid hexadecimal values
  81072. * @returns a new Color3 object
  81073. */
  81074. static FromHexString(hex: string): Color3;
  81075. /**
  81076. * Creates a new Color3 from the starting index of the given array
  81077. * @param array defines the source array
  81078. * @param offset defines an offset in the source array
  81079. * @returns a new Color3 object
  81080. */
  81081. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  81082. /**
  81083. * Creates a new Color3 from integer values (< 256)
  81084. * @param r defines the red component to read from (value between 0 and 255)
  81085. * @param g defines the green component to read from (value between 0 and 255)
  81086. * @param b defines the blue component to read from (value between 0 and 255)
  81087. * @returns a new Color3 object
  81088. */
  81089. static FromInts(r: number, g: number, b: number): Color3;
  81090. /**
  81091. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  81092. * @param start defines the start Color3 value
  81093. * @param end defines the end Color3 value
  81094. * @param amount defines the gradient value between start and end
  81095. * @returns a new Color3 object
  81096. */
  81097. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  81098. /**
  81099. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  81100. * @param left defines the start value
  81101. * @param right defines the end value
  81102. * @param amount defines the gradient factor
  81103. * @param result defines the Color3 object where to store the result
  81104. */
  81105. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  81106. /**
  81107. * Returns a Color3 value containing a red color
  81108. * @returns a new Color3 object
  81109. */
  81110. static Red(): Color3;
  81111. /**
  81112. * Returns a Color3 value containing a green color
  81113. * @returns a new Color3 object
  81114. */
  81115. static Green(): Color3;
  81116. /**
  81117. * Returns a Color3 value containing a blue color
  81118. * @returns a new Color3 object
  81119. */
  81120. static Blue(): Color3;
  81121. /**
  81122. * Returns a Color3 value containing a black color
  81123. * @returns a new Color3 object
  81124. */
  81125. static Black(): Color3;
  81126. /**
  81127. * Gets a Color3 value containing a black color that must not be updated
  81128. */
  81129. static get BlackReadOnly(): DeepImmutable<Color3>;
  81130. /**
  81131. * Returns a Color3 value containing a white color
  81132. * @returns a new Color3 object
  81133. */
  81134. static White(): Color3;
  81135. /**
  81136. * Returns a Color3 value containing a purple color
  81137. * @returns a new Color3 object
  81138. */
  81139. static Purple(): Color3;
  81140. /**
  81141. * Returns a Color3 value containing a magenta color
  81142. * @returns a new Color3 object
  81143. */
  81144. static Magenta(): Color3;
  81145. /**
  81146. * Returns a Color3 value containing a yellow color
  81147. * @returns a new Color3 object
  81148. */
  81149. static Yellow(): Color3;
  81150. /**
  81151. * Returns a Color3 value containing a gray color
  81152. * @returns a new Color3 object
  81153. */
  81154. static Gray(): Color3;
  81155. /**
  81156. * Returns a Color3 value containing a teal color
  81157. * @returns a new Color3 object
  81158. */
  81159. static Teal(): Color3;
  81160. /**
  81161. * Returns a Color3 value containing a random color
  81162. * @returns a new Color3 object
  81163. */
  81164. static Random(): Color3;
  81165. }
  81166. /**
  81167. * Class used to hold a RBGA color
  81168. */
  81169. export class Color4 {
  81170. /**
  81171. * Defines the red component (between 0 and 1, default is 0)
  81172. */
  81173. r: number;
  81174. /**
  81175. * Defines the green component (between 0 and 1, default is 0)
  81176. */
  81177. g: number;
  81178. /**
  81179. * Defines the blue component (between 0 and 1, default is 0)
  81180. */
  81181. b: number;
  81182. /**
  81183. * Defines the alpha component (between 0 and 1, default is 1)
  81184. */
  81185. a: number;
  81186. /**
  81187. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  81188. * @param r defines the red component (between 0 and 1, default is 0)
  81189. * @param g defines the green component (between 0 and 1, default is 0)
  81190. * @param b defines the blue component (between 0 and 1, default is 0)
  81191. * @param a defines the alpha component (between 0 and 1, default is 1)
  81192. */
  81193. constructor(
  81194. /**
  81195. * Defines the red component (between 0 and 1, default is 0)
  81196. */
  81197. r?: number,
  81198. /**
  81199. * Defines the green component (between 0 and 1, default is 0)
  81200. */
  81201. g?: number,
  81202. /**
  81203. * Defines the blue component (between 0 and 1, default is 0)
  81204. */
  81205. b?: number,
  81206. /**
  81207. * Defines the alpha component (between 0 and 1, default is 1)
  81208. */
  81209. a?: number);
  81210. /**
  81211. * Adds in place the given Color4 values to the current Color4 object
  81212. * @param right defines the second operand
  81213. * @returns the current updated Color4 object
  81214. */
  81215. addInPlace(right: DeepImmutable<Color4>): Color4;
  81216. /**
  81217. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  81218. * @returns the new array
  81219. */
  81220. asArray(): number[];
  81221. /**
  81222. * Stores from the starting index in the given array the Color4 successive values
  81223. * @param array defines the array where to store the r,g,b components
  81224. * @param index defines an optional index in the target array to define where to start storing values
  81225. * @returns the current Color4 object
  81226. */
  81227. toArray(array: number[], index?: number): Color4;
  81228. /**
  81229. * Determines equality between Color4 objects
  81230. * @param otherColor defines the second operand
  81231. * @returns true if the rgba values are equal to the given ones
  81232. */
  81233. equals(otherColor: DeepImmutable<Color4>): boolean;
  81234. /**
  81235. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  81236. * @param right defines the second operand
  81237. * @returns a new Color4 object
  81238. */
  81239. add(right: DeepImmutable<Color4>): Color4;
  81240. /**
  81241. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  81242. * @param right defines the second operand
  81243. * @returns a new Color4 object
  81244. */
  81245. subtract(right: DeepImmutable<Color4>): Color4;
  81246. /**
  81247. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  81248. * @param right defines the second operand
  81249. * @param result defines the Color4 object where to store the result
  81250. * @returns the current Color4 object
  81251. */
  81252. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  81253. /**
  81254. * Creates a new Color4 with the current Color4 values multiplied by scale
  81255. * @param scale defines the scaling factor to apply
  81256. * @returns a new Color4 object
  81257. */
  81258. scale(scale: number): Color4;
  81259. /**
  81260. * Multiplies the current Color4 values by scale and stores the result in "result"
  81261. * @param scale defines the scaling factor to apply
  81262. * @param result defines the Color4 object where to store the result
  81263. * @returns the current unmodified Color4
  81264. */
  81265. scaleToRef(scale: number, result: Color4): Color4;
  81266. /**
  81267. * Scale the current Color4 values by a factor and add the result to a given Color4
  81268. * @param scale defines the scale factor
  81269. * @param result defines the Color4 object where to store the result
  81270. * @returns the unmodified current Color4
  81271. */
  81272. scaleAndAddToRef(scale: number, result: Color4): Color4;
  81273. /**
  81274. * Clamps the rgb values by the min and max values and stores the result into "result"
  81275. * @param min defines minimum clamping value (default is 0)
  81276. * @param max defines maximum clamping value (default is 1)
  81277. * @param result defines color to store the result into.
  81278. * @returns the cuurent Color4
  81279. */
  81280. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  81281. /**
  81282. * Multipy an Color4 value by another and return a new Color4 object
  81283. * @param color defines the Color4 value to multiply by
  81284. * @returns a new Color4 object
  81285. */
  81286. multiply(color: Color4): Color4;
  81287. /**
  81288. * Multipy a Color4 value by another and push the result in a reference value
  81289. * @param color defines the Color4 value to multiply by
  81290. * @param result defines the Color4 to fill the result in
  81291. * @returns the result Color4
  81292. */
  81293. multiplyToRef(color: Color4, result: Color4): Color4;
  81294. /**
  81295. * Creates a string with the Color4 current values
  81296. * @returns the string representation of the Color4 object
  81297. */
  81298. toString(): string;
  81299. /**
  81300. * Returns the string "Color4"
  81301. * @returns "Color4"
  81302. */
  81303. getClassName(): string;
  81304. /**
  81305. * Compute the Color4 hash code
  81306. * @returns an unique number that can be used to hash Color4 objects
  81307. */
  81308. getHashCode(): number;
  81309. /**
  81310. * Creates a new Color4 copied from the current one
  81311. * @returns a new Color4 object
  81312. */
  81313. clone(): Color4;
  81314. /**
  81315. * Copies the given Color4 values into the current one
  81316. * @param source defines the source Color4 object
  81317. * @returns the current updated Color4 object
  81318. */
  81319. copyFrom(source: Color4): Color4;
  81320. /**
  81321. * Copies the given float values into the current one
  81322. * @param r defines the red component to read from
  81323. * @param g defines the green component to read from
  81324. * @param b defines the blue component to read from
  81325. * @param a defines the alpha component to read from
  81326. * @returns the current updated Color4 object
  81327. */
  81328. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  81329. /**
  81330. * Copies the given float values into the current one
  81331. * @param r defines the red component to read from
  81332. * @param g defines the green component to read from
  81333. * @param b defines the blue component to read from
  81334. * @param a defines the alpha component to read from
  81335. * @returns the current updated Color4 object
  81336. */
  81337. set(r: number, g: number, b: number, a: number): Color4;
  81338. /**
  81339. * Compute the Color4 hexadecimal code as a string
  81340. * @param returnAsColor3 defines if the string should only contains RGB values (off by default)
  81341. * @returns a string containing the hexadecimal representation of the Color4 object
  81342. */
  81343. toHexString(returnAsColor3?: boolean): string;
  81344. /**
  81345. * Computes a new Color4 converted from the current one to linear space
  81346. * @returns a new Color4 object
  81347. */
  81348. toLinearSpace(): Color4;
  81349. /**
  81350. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  81351. * @param convertedColor defines the Color4 object where to store the linear space version
  81352. * @returns the unmodified Color4
  81353. */
  81354. toLinearSpaceToRef(convertedColor: Color4): Color4;
  81355. /**
  81356. * Computes a new Color4 converted from the current one to gamma space
  81357. * @returns a new Color4 object
  81358. */
  81359. toGammaSpace(): Color4;
  81360. /**
  81361. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  81362. * @param convertedColor defines the Color4 object where to store the gamma space version
  81363. * @returns the unmodified Color4
  81364. */
  81365. toGammaSpaceToRef(convertedColor: Color4): Color4;
  81366. /**
  81367. * Creates a new Color4 from the string containing valid hexadecimal values
  81368. * @param hex defines a string containing valid hexadecimal values
  81369. * @returns a new Color4 object
  81370. */
  81371. static FromHexString(hex: string): Color4;
  81372. /**
  81373. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  81374. * @param left defines the start value
  81375. * @param right defines the end value
  81376. * @param amount defines the gradient factor
  81377. * @returns a new Color4 object
  81378. */
  81379. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  81380. /**
  81381. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  81382. * @param left defines the start value
  81383. * @param right defines the end value
  81384. * @param amount defines the gradient factor
  81385. * @param result defines the Color4 object where to store data
  81386. */
  81387. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  81388. /**
  81389. * Creates a new Color4 from a Color3 and an alpha value
  81390. * @param color3 defines the source Color3 to read from
  81391. * @param alpha defines the alpha component (1.0 by default)
  81392. * @returns a new Color4 object
  81393. */
  81394. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  81395. /**
  81396. * Creates a new Color4 from the starting index element of the given array
  81397. * @param array defines the source array to read from
  81398. * @param offset defines the offset in the source array
  81399. * @returns a new Color4 object
  81400. */
  81401. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  81402. /**
  81403. * Creates a new Color3 from integer values (< 256)
  81404. * @param r defines the red component to read from (value between 0 and 255)
  81405. * @param g defines the green component to read from (value between 0 and 255)
  81406. * @param b defines the blue component to read from (value between 0 and 255)
  81407. * @param a defines the alpha component to read from (value between 0 and 255)
  81408. * @returns a new Color3 object
  81409. */
  81410. static FromInts(r: number, g: number, b: number, a: number): Color4;
  81411. /**
  81412. * Check the content of a given array and convert it to an array containing RGBA data
  81413. * If the original array was already containing count * 4 values then it is returned directly
  81414. * @param colors defines the array to check
  81415. * @param count defines the number of RGBA data to expect
  81416. * @returns an array containing count * 4 values (RGBA)
  81417. */
  81418. static CheckColors4(colors: number[], count: number): number[];
  81419. }
  81420. /**
  81421. * @hidden
  81422. */
  81423. export class TmpColors {
  81424. static Color3: Color3[];
  81425. static Color4: Color4[];
  81426. }
  81427. }
  81428. declare module BABYLON {
  81429. /**
  81430. * Defines an interface which represents an animation key frame
  81431. */
  81432. export interface IAnimationKey {
  81433. /**
  81434. * Frame of the key frame
  81435. */
  81436. frame: number;
  81437. /**
  81438. * Value at the specifies key frame
  81439. */
  81440. value: any;
  81441. /**
  81442. * The input tangent for the cubic hermite spline
  81443. */
  81444. inTangent?: any;
  81445. /**
  81446. * The output tangent for the cubic hermite spline
  81447. */
  81448. outTangent?: any;
  81449. /**
  81450. * The animation interpolation type
  81451. */
  81452. interpolation?: AnimationKeyInterpolation;
  81453. }
  81454. /**
  81455. * Enum for the animation key frame interpolation type
  81456. */
  81457. export enum AnimationKeyInterpolation {
  81458. /**
  81459. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  81460. */
  81461. STEP = 1
  81462. }
  81463. }
  81464. declare module BABYLON {
  81465. /**
  81466. * Represents the range of an animation
  81467. */
  81468. export class AnimationRange {
  81469. /**The name of the animation range**/
  81470. name: string;
  81471. /**The starting frame of the animation */
  81472. from: number;
  81473. /**The ending frame of the animation*/
  81474. to: number;
  81475. /**
  81476. * Initializes the range of an animation
  81477. * @param name The name of the animation range
  81478. * @param from The starting frame of the animation
  81479. * @param to The ending frame of the animation
  81480. */
  81481. constructor(
  81482. /**The name of the animation range**/
  81483. name: string,
  81484. /**The starting frame of the animation */
  81485. from: number,
  81486. /**The ending frame of the animation*/
  81487. to: number);
  81488. /**
  81489. * Makes a copy of the animation range
  81490. * @returns A copy of the animation range
  81491. */
  81492. clone(): AnimationRange;
  81493. }
  81494. }
  81495. declare module BABYLON {
  81496. /**
  81497. * Composed of a frame, and an action function
  81498. */
  81499. export class AnimationEvent {
  81500. /** The frame for which the event is triggered **/
  81501. frame: number;
  81502. /** The event to perform when triggered **/
  81503. action: (currentFrame: number) => void;
  81504. /** Specifies if the event should be triggered only once**/
  81505. onlyOnce?: boolean | undefined;
  81506. /**
  81507. * Specifies if the animation event is done
  81508. */
  81509. isDone: boolean;
  81510. /**
  81511. * Initializes the animation event
  81512. * @param frame The frame for which the event is triggered
  81513. * @param action The event to perform when triggered
  81514. * @param onlyOnce Specifies if the event should be triggered only once
  81515. */
  81516. constructor(
  81517. /** The frame for which the event is triggered **/
  81518. frame: number,
  81519. /** The event to perform when triggered **/
  81520. action: (currentFrame: number) => void,
  81521. /** Specifies if the event should be triggered only once**/
  81522. onlyOnce?: boolean | undefined);
  81523. /** @hidden */
  81524. _clone(): AnimationEvent;
  81525. }
  81526. }
  81527. declare module BABYLON {
  81528. /**
  81529. * Interface used to define a behavior
  81530. */
  81531. export interface Behavior<T> {
  81532. /** gets or sets behavior's name */
  81533. name: string;
  81534. /**
  81535. * Function called when the behavior needs to be initialized (after attaching it to a target)
  81536. */
  81537. init(): void;
  81538. /**
  81539. * Called when the behavior is attached to a target
  81540. * @param target defines the target where the behavior is attached to
  81541. */
  81542. attach(target: T): void;
  81543. /**
  81544. * Called when the behavior is detached from its target
  81545. */
  81546. detach(): void;
  81547. }
  81548. /**
  81549. * Interface implemented by classes supporting behaviors
  81550. */
  81551. export interface IBehaviorAware<T> {
  81552. /**
  81553. * Attach a behavior
  81554. * @param behavior defines the behavior to attach
  81555. * @returns the current host
  81556. */
  81557. addBehavior(behavior: Behavior<T>): T;
  81558. /**
  81559. * Remove a behavior from the current object
  81560. * @param behavior defines the behavior to detach
  81561. * @returns the current host
  81562. */
  81563. removeBehavior(behavior: Behavior<T>): T;
  81564. /**
  81565. * Gets a behavior using its name to search
  81566. * @param name defines the name to search
  81567. * @returns the behavior or null if not found
  81568. */
  81569. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  81570. }
  81571. }
  81572. declare module BABYLON {
  81573. /**
  81574. * Defines an array and its length.
  81575. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  81576. */
  81577. export interface ISmartArrayLike<T> {
  81578. /**
  81579. * The data of the array.
  81580. */
  81581. data: Array<T>;
  81582. /**
  81583. * The active length of the array.
  81584. */
  81585. length: number;
  81586. }
  81587. /**
  81588. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  81589. */
  81590. export class SmartArray<T> implements ISmartArrayLike<T> {
  81591. /**
  81592. * The full set of data from the array.
  81593. */
  81594. data: Array<T>;
  81595. /**
  81596. * The active length of the array.
  81597. */
  81598. length: number;
  81599. protected _id: number;
  81600. /**
  81601. * Instantiates a Smart Array.
  81602. * @param capacity defines the default capacity of the array.
  81603. */
  81604. constructor(capacity: number);
  81605. /**
  81606. * Pushes a value at the end of the active data.
  81607. * @param value defines the object to push in the array.
  81608. */
  81609. push(value: T): void;
  81610. /**
  81611. * Iterates over the active data and apply the lambda to them.
  81612. * @param func defines the action to apply on each value.
  81613. */
  81614. forEach(func: (content: T) => void): void;
  81615. /**
  81616. * Sorts the full sets of data.
  81617. * @param compareFn defines the comparison function to apply.
  81618. */
  81619. sort(compareFn: (a: T, b: T) => number): void;
  81620. /**
  81621. * Resets the active data to an empty array.
  81622. */
  81623. reset(): void;
  81624. /**
  81625. * Releases all the data from the array as well as the array.
  81626. */
  81627. dispose(): void;
  81628. /**
  81629. * Concats the active data with a given array.
  81630. * @param array defines the data to concatenate with.
  81631. */
  81632. concat(array: any): void;
  81633. /**
  81634. * Returns the position of a value in the active data.
  81635. * @param value defines the value to find the index for
  81636. * @returns the index if found in the active data otherwise -1
  81637. */
  81638. indexOf(value: T): number;
  81639. /**
  81640. * Returns whether an element is part of the active data.
  81641. * @param value defines the value to look for
  81642. * @returns true if found in the active data otherwise false
  81643. */
  81644. contains(value: T): boolean;
  81645. private static _GlobalId;
  81646. }
  81647. /**
  81648. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  81649. * The data in this array can only be present once
  81650. */
  81651. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  81652. private _duplicateId;
  81653. /**
  81654. * Pushes a value at the end of the active data.
  81655. * THIS DOES NOT PREVENT DUPPLICATE DATA
  81656. * @param value defines the object to push in the array.
  81657. */
  81658. push(value: T): void;
  81659. /**
  81660. * Pushes a value at the end of the active data.
  81661. * If the data is already present, it won t be added again
  81662. * @param value defines the object to push in the array.
  81663. * @returns true if added false if it was already present
  81664. */
  81665. pushNoDuplicate(value: T): boolean;
  81666. /**
  81667. * Resets the active data to an empty array.
  81668. */
  81669. reset(): void;
  81670. /**
  81671. * Concats the active data with a given array.
  81672. * This ensures no dupplicate will be present in the result.
  81673. * @param array defines the data to concatenate with.
  81674. */
  81675. concatWithNoDuplicate(array: any): void;
  81676. }
  81677. }
  81678. declare module BABYLON {
  81679. /**
  81680. * @ignore
  81681. * This is a list of all the different input types that are available in the application.
  81682. * Fo instance: ArcRotateCameraGamepadInput...
  81683. */
  81684. export var CameraInputTypes: {};
  81685. /**
  81686. * This is the contract to implement in order to create a new input class.
  81687. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  81688. */
  81689. export interface ICameraInput<TCamera extends Camera> {
  81690. /**
  81691. * Defines the camera the input is attached to.
  81692. */
  81693. camera: Nullable<TCamera>;
  81694. /**
  81695. * Gets the class name of the current intput.
  81696. * @returns the class name
  81697. */
  81698. getClassName(): string;
  81699. /**
  81700. * Get the friendly name associated with the input class.
  81701. * @returns the input friendly name
  81702. */
  81703. getSimpleName(): string;
  81704. /**
  81705. * Attach the input controls to a specific dom element to get the input from.
  81706. * @param element Defines the element the controls should be listened from
  81707. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  81708. */
  81709. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  81710. /**
  81711. * Detach the current controls from the specified dom element.
  81712. * @param element Defines the element to stop listening the inputs from
  81713. */
  81714. detachControl(element: Nullable<HTMLElement>): void;
  81715. /**
  81716. * Update the current camera state depending on the inputs that have been used this frame.
  81717. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  81718. */
  81719. checkInputs?: () => void;
  81720. }
  81721. /**
  81722. * Represents a map of input types to input instance or input index to input instance.
  81723. */
  81724. export interface CameraInputsMap<TCamera extends Camera> {
  81725. /**
  81726. * Accessor to the input by input type.
  81727. */
  81728. [name: string]: ICameraInput<TCamera>;
  81729. /**
  81730. * Accessor to the input by input index.
  81731. */
  81732. [idx: number]: ICameraInput<TCamera>;
  81733. }
  81734. /**
  81735. * This represents the input manager used within a camera.
  81736. * It helps dealing with all the different kind of input attached to a camera.
  81737. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  81738. */
  81739. export class CameraInputsManager<TCamera extends Camera> {
  81740. /**
  81741. * Defines the list of inputs attahed to the camera.
  81742. */
  81743. attached: CameraInputsMap<TCamera>;
  81744. /**
  81745. * Defines the dom element the camera is collecting inputs from.
  81746. * This is null if the controls have not been attached.
  81747. */
  81748. attachedElement: Nullable<HTMLElement>;
  81749. /**
  81750. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  81751. */
  81752. noPreventDefault: boolean;
  81753. /**
  81754. * Defined the camera the input manager belongs to.
  81755. */
  81756. camera: TCamera;
  81757. /**
  81758. * Update the current camera state depending on the inputs that have been used this frame.
  81759. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  81760. */
  81761. checkInputs: () => void;
  81762. /**
  81763. * Instantiate a new Camera Input Manager.
  81764. * @param camera Defines the camera the input manager blongs to
  81765. */
  81766. constructor(camera: TCamera);
  81767. /**
  81768. * Add an input method to a camera
  81769. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  81770. * @param input camera input method
  81771. */
  81772. add(input: ICameraInput<TCamera>): void;
  81773. /**
  81774. * Remove a specific input method from a camera
  81775. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  81776. * @param inputToRemove camera input method
  81777. */
  81778. remove(inputToRemove: ICameraInput<TCamera>): void;
  81779. /**
  81780. * Remove a specific input type from a camera
  81781. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  81782. * @param inputType the type of the input to remove
  81783. */
  81784. removeByType(inputType: string): void;
  81785. private _addCheckInputs;
  81786. /**
  81787. * Attach the input controls to the currently attached dom element to listen the events from.
  81788. * @param input Defines the input to attach
  81789. */
  81790. attachInput(input: ICameraInput<TCamera>): void;
  81791. /**
  81792. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  81793. * @param element Defines the dom element to collect the events from
  81794. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  81795. */
  81796. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  81797. /**
  81798. * Detach the current manager inputs controls from a specific dom element.
  81799. * @param element Defines the dom element to collect the events from
  81800. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  81801. */
  81802. detachElement(element: HTMLElement, disconnect?: boolean): void;
  81803. /**
  81804. * Rebuild the dynamic inputCheck function from the current list of
  81805. * defined inputs in the manager.
  81806. */
  81807. rebuildInputCheck(): void;
  81808. /**
  81809. * Remove all attached input methods from a camera
  81810. */
  81811. clear(): void;
  81812. /**
  81813. * Serialize the current input manager attached to a camera.
  81814. * This ensures than once parsed,
  81815. * the input associated to the camera will be identical to the current ones
  81816. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  81817. */
  81818. serialize(serializedCamera: any): void;
  81819. /**
  81820. * Parses an input manager serialized JSON to restore the previous list of inputs
  81821. * and states associated to a camera.
  81822. * @param parsedCamera Defines the JSON to parse
  81823. */
  81824. parse(parsedCamera: any): void;
  81825. }
  81826. }
  81827. declare module BABYLON {
  81828. /**
  81829. * Class used to store data that will be store in GPU memory
  81830. */
  81831. export class Buffer {
  81832. private _engine;
  81833. private _buffer;
  81834. /** @hidden */
  81835. _data: Nullable<DataArray>;
  81836. private _updatable;
  81837. private _instanced;
  81838. private _divisor;
  81839. /**
  81840. * Gets the byte stride.
  81841. */
  81842. readonly byteStride: number;
  81843. /**
  81844. * Constructor
  81845. * @param engine the engine
  81846. * @param data the data to use for this buffer
  81847. * @param updatable whether the data is updatable
  81848. * @param stride the stride (optional)
  81849. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  81850. * @param instanced whether the buffer is instanced (optional)
  81851. * @param useBytes set to true if the stride in in bytes (optional)
  81852. * @param divisor sets an optional divisor for instances (1 by default)
  81853. */
  81854. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  81855. /**
  81856. * Create a new VertexBuffer based on the current buffer
  81857. * @param kind defines the vertex buffer kind (position, normal, etc.)
  81858. * @param offset defines offset in the buffer (0 by default)
  81859. * @param size defines the size in floats of attributes (position is 3 for instance)
  81860. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  81861. * @param instanced defines if the vertex buffer contains indexed data
  81862. * @param useBytes defines if the offset and stride are in bytes *
  81863. * @param divisor sets an optional divisor for instances (1 by default)
  81864. * @returns the new vertex buffer
  81865. */
  81866. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  81867. /**
  81868. * Gets a boolean indicating if the Buffer is updatable?
  81869. * @returns true if the buffer is updatable
  81870. */
  81871. isUpdatable(): boolean;
  81872. /**
  81873. * Gets current buffer's data
  81874. * @returns a DataArray or null
  81875. */
  81876. getData(): Nullable<DataArray>;
  81877. /**
  81878. * Gets underlying native buffer
  81879. * @returns underlying native buffer
  81880. */
  81881. getBuffer(): Nullable<DataBuffer>;
  81882. /**
  81883. * Gets the stride in float32 units (i.e. byte stride / 4).
  81884. * May not be an integer if the byte stride is not divisible by 4.
  81885. * @returns the stride in float32 units
  81886. * @deprecated Please use byteStride instead.
  81887. */
  81888. getStrideSize(): number;
  81889. /**
  81890. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  81891. * @param data defines the data to store
  81892. */
  81893. create(data?: Nullable<DataArray>): void;
  81894. /** @hidden */
  81895. _rebuild(): void;
  81896. /**
  81897. * Update current buffer data
  81898. * @param data defines the data to store
  81899. */
  81900. update(data: DataArray): void;
  81901. /**
  81902. * Updates the data directly.
  81903. * @param data the new data
  81904. * @param offset the new offset
  81905. * @param vertexCount the vertex count (optional)
  81906. * @param useBytes set to true if the offset is in bytes
  81907. */
  81908. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  81909. /**
  81910. * Release all resources
  81911. */
  81912. dispose(): void;
  81913. }
  81914. /**
  81915. * Specialized buffer used to store vertex data
  81916. */
  81917. export class VertexBuffer {
  81918. /** @hidden */
  81919. _buffer: Buffer;
  81920. private _kind;
  81921. private _size;
  81922. private _ownsBuffer;
  81923. private _instanced;
  81924. private _instanceDivisor;
  81925. /**
  81926. * The byte type.
  81927. */
  81928. static readonly BYTE: number;
  81929. /**
  81930. * The unsigned byte type.
  81931. */
  81932. static readonly UNSIGNED_BYTE: number;
  81933. /**
  81934. * The short type.
  81935. */
  81936. static readonly SHORT: number;
  81937. /**
  81938. * The unsigned short type.
  81939. */
  81940. static readonly UNSIGNED_SHORT: number;
  81941. /**
  81942. * The integer type.
  81943. */
  81944. static readonly INT: number;
  81945. /**
  81946. * The unsigned integer type.
  81947. */
  81948. static readonly UNSIGNED_INT: number;
  81949. /**
  81950. * The float type.
  81951. */
  81952. static readonly FLOAT: number;
  81953. /**
  81954. * Gets or sets the instance divisor when in instanced mode
  81955. */
  81956. get instanceDivisor(): number;
  81957. set instanceDivisor(value: number);
  81958. /**
  81959. * Gets the byte stride.
  81960. */
  81961. readonly byteStride: number;
  81962. /**
  81963. * Gets the byte offset.
  81964. */
  81965. readonly byteOffset: number;
  81966. /**
  81967. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  81968. */
  81969. readonly normalized: boolean;
  81970. /**
  81971. * Gets the data type of each component in the array.
  81972. */
  81973. readonly type: number;
  81974. /**
  81975. * Constructor
  81976. * @param engine the engine
  81977. * @param data the data to use for this vertex buffer
  81978. * @param kind the vertex buffer kind
  81979. * @param updatable whether the data is updatable
  81980. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  81981. * @param stride the stride (optional)
  81982. * @param instanced whether the buffer is instanced (optional)
  81983. * @param offset the offset of the data (optional)
  81984. * @param size the number of components (optional)
  81985. * @param type the type of the component (optional)
  81986. * @param normalized whether the data contains normalized data (optional)
  81987. * @param useBytes set to true if stride and offset are in bytes (optional)
  81988. * @param divisor defines the instance divisor to use (1 by default)
  81989. */
  81990. 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);
  81991. /** @hidden */
  81992. _rebuild(): void;
  81993. /**
  81994. * Returns the kind of the VertexBuffer (string)
  81995. * @returns a string
  81996. */
  81997. getKind(): string;
  81998. /**
  81999. * Gets a boolean indicating if the VertexBuffer is updatable?
  82000. * @returns true if the buffer is updatable
  82001. */
  82002. isUpdatable(): boolean;
  82003. /**
  82004. * Gets current buffer's data
  82005. * @returns a DataArray or null
  82006. */
  82007. getData(): Nullable<DataArray>;
  82008. /**
  82009. * Gets underlying native buffer
  82010. * @returns underlying native buffer
  82011. */
  82012. getBuffer(): Nullable<DataBuffer>;
  82013. /**
  82014. * Gets the stride in float32 units (i.e. byte stride / 4).
  82015. * May not be an integer if the byte stride is not divisible by 4.
  82016. * @returns the stride in float32 units
  82017. * @deprecated Please use byteStride instead.
  82018. */
  82019. getStrideSize(): number;
  82020. /**
  82021. * Returns the offset as a multiple of the type byte length.
  82022. * @returns the offset in bytes
  82023. * @deprecated Please use byteOffset instead.
  82024. */
  82025. getOffset(): number;
  82026. /**
  82027. * Returns the number of components per vertex attribute (integer)
  82028. * @returns the size in float
  82029. */
  82030. getSize(): number;
  82031. /**
  82032. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  82033. * @returns true if this buffer is instanced
  82034. */
  82035. getIsInstanced(): boolean;
  82036. /**
  82037. * Returns the instancing divisor, zero for non-instanced (integer).
  82038. * @returns a number
  82039. */
  82040. getInstanceDivisor(): number;
  82041. /**
  82042. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  82043. * @param data defines the data to store
  82044. */
  82045. create(data?: DataArray): void;
  82046. /**
  82047. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  82048. * This function will create a new buffer if the current one is not updatable
  82049. * @param data defines the data to store
  82050. */
  82051. update(data: DataArray): void;
  82052. /**
  82053. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  82054. * Returns the directly updated WebGLBuffer.
  82055. * @param data the new data
  82056. * @param offset the new offset
  82057. * @param useBytes set to true if the offset is in bytes
  82058. */
  82059. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  82060. /**
  82061. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  82062. */
  82063. dispose(): void;
  82064. /**
  82065. * Enumerates each value of this vertex buffer as numbers.
  82066. * @param count the number of values to enumerate
  82067. * @param callback the callback function called for each value
  82068. */
  82069. forEach(count: number, callback: (value: number, index: number) => void): void;
  82070. /**
  82071. * Positions
  82072. */
  82073. static readonly PositionKind: string;
  82074. /**
  82075. * Normals
  82076. */
  82077. static readonly NormalKind: string;
  82078. /**
  82079. * Tangents
  82080. */
  82081. static readonly TangentKind: string;
  82082. /**
  82083. * Texture coordinates
  82084. */
  82085. static readonly UVKind: string;
  82086. /**
  82087. * Texture coordinates 2
  82088. */
  82089. static readonly UV2Kind: string;
  82090. /**
  82091. * Texture coordinates 3
  82092. */
  82093. static readonly UV3Kind: string;
  82094. /**
  82095. * Texture coordinates 4
  82096. */
  82097. static readonly UV4Kind: string;
  82098. /**
  82099. * Texture coordinates 5
  82100. */
  82101. static readonly UV5Kind: string;
  82102. /**
  82103. * Texture coordinates 6
  82104. */
  82105. static readonly UV6Kind: string;
  82106. /**
  82107. * Colors
  82108. */
  82109. static readonly ColorKind: string;
  82110. /**
  82111. * Matrix indices (for bones)
  82112. */
  82113. static readonly MatricesIndicesKind: string;
  82114. /**
  82115. * Matrix weights (for bones)
  82116. */
  82117. static readonly MatricesWeightsKind: string;
  82118. /**
  82119. * Additional matrix indices (for bones)
  82120. */
  82121. static readonly MatricesIndicesExtraKind: string;
  82122. /**
  82123. * Additional matrix weights (for bones)
  82124. */
  82125. static readonly MatricesWeightsExtraKind: string;
  82126. /**
  82127. * Deduces the stride given a kind.
  82128. * @param kind The kind string to deduce
  82129. * @returns The deduced stride
  82130. */
  82131. static DeduceStride(kind: string): number;
  82132. /**
  82133. * Gets the byte length of the given type.
  82134. * @param type the type
  82135. * @returns the number of bytes
  82136. */
  82137. static GetTypeByteLength(type: number): number;
  82138. /**
  82139. * Enumerates each value of the given parameters as numbers.
  82140. * @param data the data to enumerate
  82141. * @param byteOffset the byte offset of the data
  82142. * @param byteStride the byte stride of the data
  82143. * @param componentCount the number of components per element
  82144. * @param componentType the type of the component
  82145. * @param count the number of values to enumerate
  82146. * @param normalized whether the data is normalized
  82147. * @param callback the callback function called for each value
  82148. */
  82149. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  82150. private static _GetFloatValue;
  82151. }
  82152. }
  82153. declare module BABYLON {
  82154. /**
  82155. * @hidden
  82156. */
  82157. export class IntersectionInfo {
  82158. bu: Nullable<number>;
  82159. bv: Nullable<number>;
  82160. distance: number;
  82161. faceId: number;
  82162. subMeshId: number;
  82163. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  82164. }
  82165. }
  82166. declare module BABYLON {
  82167. /**
  82168. * Class used to store bounding sphere information
  82169. */
  82170. export class BoundingSphere {
  82171. /**
  82172. * Gets the center of the bounding sphere in local space
  82173. */
  82174. readonly center: Vector3;
  82175. /**
  82176. * Radius of the bounding sphere in local space
  82177. */
  82178. radius: number;
  82179. /**
  82180. * Gets the center of the bounding sphere in world space
  82181. */
  82182. readonly centerWorld: Vector3;
  82183. /**
  82184. * Radius of the bounding sphere in world space
  82185. */
  82186. radiusWorld: number;
  82187. /**
  82188. * Gets the minimum vector in local space
  82189. */
  82190. readonly minimum: Vector3;
  82191. /**
  82192. * Gets the maximum vector in local space
  82193. */
  82194. readonly maximum: Vector3;
  82195. private _worldMatrix;
  82196. private static readonly TmpVector3;
  82197. /**
  82198. * Creates a new bounding sphere
  82199. * @param min defines the minimum vector (in local space)
  82200. * @param max defines the maximum vector (in local space)
  82201. * @param worldMatrix defines the new world matrix
  82202. */
  82203. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  82204. /**
  82205. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  82206. * @param min defines the new minimum vector (in local space)
  82207. * @param max defines the new maximum vector (in local space)
  82208. * @param worldMatrix defines the new world matrix
  82209. */
  82210. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  82211. /**
  82212. * Scale the current bounding sphere by applying a scale factor
  82213. * @param factor defines the scale factor to apply
  82214. * @returns the current bounding box
  82215. */
  82216. scale(factor: number): BoundingSphere;
  82217. /**
  82218. * Gets the world matrix of the bounding box
  82219. * @returns a matrix
  82220. */
  82221. getWorldMatrix(): DeepImmutable<Matrix>;
  82222. /** @hidden */
  82223. _update(worldMatrix: DeepImmutable<Matrix>): void;
  82224. /**
  82225. * Tests if the bounding sphere is intersecting the frustum planes
  82226. * @param frustumPlanes defines the frustum planes to test
  82227. * @returns true if there is an intersection
  82228. */
  82229. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  82230. /**
  82231. * Tests if the bounding sphere center is in between the frustum planes.
  82232. * Used for optimistic fast inclusion.
  82233. * @param frustumPlanes defines the frustum planes to test
  82234. * @returns true if the sphere center is in between the frustum planes
  82235. */
  82236. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  82237. /**
  82238. * Tests if a point is inside the bounding sphere
  82239. * @param point defines the point to test
  82240. * @returns true if the point is inside the bounding sphere
  82241. */
  82242. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  82243. /**
  82244. * Checks if two sphere intersct
  82245. * @param sphere0 sphere 0
  82246. * @param sphere1 sphere 1
  82247. * @returns true if the speres intersect
  82248. */
  82249. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  82250. }
  82251. }
  82252. declare module BABYLON {
  82253. /**
  82254. * Class used to store bounding box information
  82255. */
  82256. export class BoundingBox implements ICullable {
  82257. /**
  82258. * Gets the 8 vectors representing the bounding box in local space
  82259. */
  82260. readonly vectors: Vector3[];
  82261. /**
  82262. * Gets the center of the bounding box in local space
  82263. */
  82264. readonly center: Vector3;
  82265. /**
  82266. * Gets the center of the bounding box in world space
  82267. */
  82268. readonly centerWorld: Vector3;
  82269. /**
  82270. * Gets the extend size in local space
  82271. */
  82272. readonly extendSize: Vector3;
  82273. /**
  82274. * Gets the extend size in world space
  82275. */
  82276. readonly extendSizeWorld: Vector3;
  82277. /**
  82278. * Gets the OBB (object bounding box) directions
  82279. */
  82280. readonly directions: Vector3[];
  82281. /**
  82282. * Gets the 8 vectors representing the bounding box in world space
  82283. */
  82284. readonly vectorsWorld: Vector3[];
  82285. /**
  82286. * Gets the minimum vector in world space
  82287. */
  82288. readonly minimumWorld: Vector3;
  82289. /**
  82290. * Gets the maximum vector in world space
  82291. */
  82292. readonly maximumWorld: Vector3;
  82293. /**
  82294. * Gets the minimum vector in local space
  82295. */
  82296. readonly minimum: Vector3;
  82297. /**
  82298. * Gets the maximum vector in local space
  82299. */
  82300. readonly maximum: Vector3;
  82301. private _worldMatrix;
  82302. private static readonly TmpVector3;
  82303. /**
  82304. * @hidden
  82305. */
  82306. _tag: number;
  82307. /**
  82308. * Creates a new bounding box
  82309. * @param min defines the minimum vector (in local space)
  82310. * @param max defines the maximum vector (in local space)
  82311. * @param worldMatrix defines the new world matrix
  82312. */
  82313. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  82314. /**
  82315. * Recreates the entire bounding box from scratch as if we call the constructor in place
  82316. * @param min defines the new minimum vector (in local space)
  82317. * @param max defines the new maximum vector (in local space)
  82318. * @param worldMatrix defines the new world matrix
  82319. */
  82320. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  82321. /**
  82322. * Scale the current bounding box by applying a scale factor
  82323. * @param factor defines the scale factor to apply
  82324. * @returns the current bounding box
  82325. */
  82326. scale(factor: number): BoundingBox;
  82327. /**
  82328. * Gets the world matrix of the bounding box
  82329. * @returns a matrix
  82330. */
  82331. getWorldMatrix(): DeepImmutable<Matrix>;
  82332. /** @hidden */
  82333. _update(world: DeepImmutable<Matrix>): void;
  82334. /**
  82335. * Tests if the bounding box is intersecting the frustum planes
  82336. * @param frustumPlanes defines the frustum planes to test
  82337. * @returns true if there is an intersection
  82338. */
  82339. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  82340. /**
  82341. * Tests if the bounding box is entirely inside the frustum planes
  82342. * @param frustumPlanes defines the frustum planes to test
  82343. * @returns true if there is an inclusion
  82344. */
  82345. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  82346. /**
  82347. * Tests if a point is inside the bounding box
  82348. * @param point defines the point to test
  82349. * @returns true if the point is inside the bounding box
  82350. */
  82351. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  82352. /**
  82353. * Tests if the bounding box intersects with a bounding sphere
  82354. * @param sphere defines the sphere to test
  82355. * @returns true if there is an intersection
  82356. */
  82357. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  82358. /**
  82359. * Tests if the bounding box intersects with a box defined by a min and max vectors
  82360. * @param min defines the min vector to use
  82361. * @param max defines the max vector to use
  82362. * @returns true if there is an intersection
  82363. */
  82364. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  82365. /**
  82366. * Tests if two bounding boxes are intersections
  82367. * @param box0 defines the first box to test
  82368. * @param box1 defines the second box to test
  82369. * @returns true if there is an intersection
  82370. */
  82371. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  82372. /**
  82373. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  82374. * @param minPoint defines the minimum vector of the bounding box
  82375. * @param maxPoint defines the maximum vector of the bounding box
  82376. * @param sphereCenter defines the sphere center
  82377. * @param sphereRadius defines the sphere radius
  82378. * @returns true if there is an intersection
  82379. */
  82380. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  82381. /**
  82382. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  82383. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  82384. * @param frustumPlanes defines the frustum planes to test
  82385. * @return true if there is an inclusion
  82386. */
  82387. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  82388. /**
  82389. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  82390. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  82391. * @param frustumPlanes defines the frustum planes to test
  82392. * @return true if there is an intersection
  82393. */
  82394. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  82395. }
  82396. }
  82397. declare module BABYLON {
  82398. /** @hidden */
  82399. export class Collider {
  82400. /** Define if a collision was found */
  82401. collisionFound: boolean;
  82402. /**
  82403. * Define last intersection point in local space
  82404. */
  82405. intersectionPoint: Vector3;
  82406. /**
  82407. * Define last collided mesh
  82408. */
  82409. collidedMesh: Nullable<AbstractMesh>;
  82410. private _collisionPoint;
  82411. private _planeIntersectionPoint;
  82412. private _tempVector;
  82413. private _tempVector2;
  82414. private _tempVector3;
  82415. private _tempVector4;
  82416. private _edge;
  82417. private _baseToVertex;
  82418. private _destinationPoint;
  82419. private _slidePlaneNormal;
  82420. private _displacementVector;
  82421. /** @hidden */
  82422. _radius: Vector3;
  82423. /** @hidden */
  82424. _retry: number;
  82425. private _velocity;
  82426. private _basePoint;
  82427. private _epsilon;
  82428. /** @hidden */
  82429. _velocityWorldLength: number;
  82430. /** @hidden */
  82431. _basePointWorld: Vector3;
  82432. private _velocityWorld;
  82433. private _normalizedVelocity;
  82434. /** @hidden */
  82435. _initialVelocity: Vector3;
  82436. /** @hidden */
  82437. _initialPosition: Vector3;
  82438. private _nearestDistance;
  82439. private _collisionMask;
  82440. get collisionMask(): number;
  82441. set collisionMask(mask: number);
  82442. /**
  82443. * Gets the plane normal used to compute the sliding response (in local space)
  82444. */
  82445. get slidePlaneNormal(): Vector3;
  82446. /** @hidden */
  82447. _initialize(source: Vector3, dir: Vector3, e: number): void;
  82448. /** @hidden */
  82449. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  82450. /** @hidden */
  82451. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  82452. /** @hidden */
  82453. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  82454. /** @hidden */
  82455. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  82456. /** @hidden */
  82457. _getResponse(pos: Vector3, vel: Vector3): void;
  82458. }
  82459. }
  82460. declare module BABYLON {
  82461. /**
  82462. * Interface for cullable objects
  82463. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  82464. */
  82465. export interface ICullable {
  82466. /**
  82467. * Checks if the object or part of the object is in the frustum
  82468. * @param frustumPlanes Camera near/planes
  82469. * @returns true if the object is in frustum otherwise false
  82470. */
  82471. isInFrustum(frustumPlanes: Plane[]): boolean;
  82472. /**
  82473. * Checks if a cullable object (mesh...) is in the camera frustum
  82474. * Unlike isInFrustum this cheks the full bounding box
  82475. * @param frustumPlanes Camera near/planes
  82476. * @returns true if the object is in frustum otherwise false
  82477. */
  82478. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  82479. }
  82480. /**
  82481. * Info for a bounding data of a mesh
  82482. */
  82483. export class BoundingInfo implements ICullable {
  82484. /**
  82485. * Bounding box for the mesh
  82486. */
  82487. readonly boundingBox: BoundingBox;
  82488. /**
  82489. * Bounding sphere for the mesh
  82490. */
  82491. readonly boundingSphere: BoundingSphere;
  82492. private _isLocked;
  82493. private static readonly TmpVector3;
  82494. /**
  82495. * Constructs bounding info
  82496. * @param minimum min vector of the bounding box/sphere
  82497. * @param maximum max vector of the bounding box/sphere
  82498. * @param worldMatrix defines the new world matrix
  82499. */
  82500. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  82501. /**
  82502. * Recreates the entire bounding info from scratch as if we call the constructor in place
  82503. * @param min defines the new minimum vector (in local space)
  82504. * @param max defines the new maximum vector (in local space)
  82505. * @param worldMatrix defines the new world matrix
  82506. */
  82507. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  82508. /**
  82509. * min vector of the bounding box/sphere
  82510. */
  82511. get minimum(): Vector3;
  82512. /**
  82513. * max vector of the bounding box/sphere
  82514. */
  82515. get maximum(): Vector3;
  82516. /**
  82517. * If the info is locked and won't be updated to avoid perf overhead
  82518. */
  82519. get isLocked(): boolean;
  82520. set isLocked(value: boolean);
  82521. /**
  82522. * Updates the bounding sphere and box
  82523. * @param world world matrix to be used to update
  82524. */
  82525. update(world: DeepImmutable<Matrix>): void;
  82526. /**
  82527. * Recreate the bounding info to be centered around a specific point given a specific extend.
  82528. * @param center New center of the bounding info
  82529. * @param extend New extend of the bounding info
  82530. * @returns the current bounding info
  82531. */
  82532. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  82533. /**
  82534. * Scale the current bounding info by applying a scale factor
  82535. * @param factor defines the scale factor to apply
  82536. * @returns the current bounding info
  82537. */
  82538. scale(factor: number): BoundingInfo;
  82539. /**
  82540. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  82541. * @param frustumPlanes defines the frustum to test
  82542. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  82543. * @returns true if the bounding info is in the frustum planes
  82544. */
  82545. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  82546. /**
  82547. * Gets the world distance between the min and max points of the bounding box
  82548. */
  82549. get diagonalLength(): number;
  82550. /**
  82551. * Checks if a cullable object (mesh...) is in the camera frustum
  82552. * Unlike isInFrustum this cheks the full bounding box
  82553. * @param frustumPlanes Camera near/planes
  82554. * @returns true if the object is in frustum otherwise false
  82555. */
  82556. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  82557. /** @hidden */
  82558. _checkCollision(collider: Collider): boolean;
  82559. /**
  82560. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  82561. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  82562. * @param point the point to check intersection with
  82563. * @returns if the point intersects
  82564. */
  82565. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  82566. /**
  82567. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  82568. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  82569. * @param boundingInfo the bounding info to check intersection with
  82570. * @param precise if the intersection should be done using OBB
  82571. * @returns if the bounding info intersects
  82572. */
  82573. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  82574. }
  82575. }
  82576. declare module BABYLON {
  82577. /**
  82578. * Extracts minimum and maximum values from a list of indexed positions
  82579. * @param positions defines the positions to use
  82580. * @param indices defines the indices to the positions
  82581. * @param indexStart defines the start index
  82582. * @param indexCount defines the end index
  82583. * @param bias defines bias value to add to the result
  82584. * @return minimum and maximum values
  82585. */
  82586. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  82587. minimum: Vector3;
  82588. maximum: Vector3;
  82589. };
  82590. /**
  82591. * Extracts minimum and maximum values from a list of positions
  82592. * @param positions defines the positions to use
  82593. * @param start defines the start index in the positions array
  82594. * @param count defines the number of positions to handle
  82595. * @param bias defines bias value to add to the result
  82596. * @param stride defines the stride size to use (distance between two positions in the positions array)
  82597. * @return minimum and maximum values
  82598. */
  82599. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  82600. minimum: Vector3;
  82601. maximum: Vector3;
  82602. };
  82603. }
  82604. declare module BABYLON {
  82605. /** @hidden */
  82606. export class WebGLDataBuffer extends DataBuffer {
  82607. private _buffer;
  82608. constructor(resource: WebGLBuffer);
  82609. get underlyingResource(): any;
  82610. }
  82611. }
  82612. declare module BABYLON {
  82613. /** @hidden */
  82614. export class WebGLPipelineContext implements IPipelineContext {
  82615. engine: ThinEngine;
  82616. program: Nullable<WebGLProgram>;
  82617. context?: WebGLRenderingContext;
  82618. vertexShader?: WebGLShader;
  82619. fragmentShader?: WebGLShader;
  82620. isParallelCompiled: boolean;
  82621. onCompiled?: () => void;
  82622. transformFeedback?: WebGLTransformFeedback | null;
  82623. vertexCompilationError: Nullable<string>;
  82624. fragmentCompilationError: Nullable<string>;
  82625. programLinkError: Nullable<string>;
  82626. programValidationError: Nullable<string>;
  82627. get isAsync(): boolean;
  82628. get isReady(): boolean;
  82629. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  82630. _getVertexShaderCode(): string | null;
  82631. _getFragmentShaderCode(): string | null;
  82632. }
  82633. }
  82634. declare module BABYLON {
  82635. interface ThinEngine {
  82636. /**
  82637. * Create an uniform buffer
  82638. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  82639. * @param elements defines the content of the uniform buffer
  82640. * @returns the webGL uniform buffer
  82641. */
  82642. createUniformBuffer(elements: FloatArray): DataBuffer;
  82643. /**
  82644. * Create a dynamic uniform buffer
  82645. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  82646. * @param elements defines the content of the uniform buffer
  82647. * @returns the webGL uniform buffer
  82648. */
  82649. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  82650. /**
  82651. * Update an existing uniform buffer
  82652. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  82653. * @param uniformBuffer defines the target uniform buffer
  82654. * @param elements defines the content to update
  82655. * @param offset defines the offset in the uniform buffer where update should start
  82656. * @param count defines the size of the data to update
  82657. */
  82658. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  82659. /**
  82660. * Bind an uniform buffer to the current webGL context
  82661. * @param buffer defines the buffer to bind
  82662. */
  82663. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  82664. /**
  82665. * Bind a buffer to the current webGL context at a given location
  82666. * @param buffer defines the buffer to bind
  82667. * @param location defines the index where to bind the buffer
  82668. */
  82669. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  82670. /**
  82671. * Bind a specific block at a given index in a specific shader program
  82672. * @param pipelineContext defines the pipeline context to use
  82673. * @param blockName defines the block name
  82674. * @param index defines the index where to bind the block
  82675. */
  82676. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  82677. }
  82678. }
  82679. declare module BABYLON {
  82680. /**
  82681. * Uniform buffer objects.
  82682. *
  82683. * Handles blocks of uniform on the GPU.
  82684. *
  82685. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  82686. *
  82687. * For more information, please refer to :
  82688. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  82689. */
  82690. export class UniformBuffer {
  82691. private _engine;
  82692. private _buffer;
  82693. private _data;
  82694. private _bufferData;
  82695. private _dynamic?;
  82696. private _uniformLocations;
  82697. private _uniformSizes;
  82698. private _uniformLocationPointer;
  82699. private _needSync;
  82700. private _noUBO;
  82701. private _currentEffect;
  82702. /** @hidden */
  82703. _alreadyBound: boolean;
  82704. private static _MAX_UNIFORM_SIZE;
  82705. private static _tempBuffer;
  82706. /**
  82707. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  82708. * This is dynamic to allow compat with webgl 1 and 2.
  82709. * You will need to pass the name of the uniform as well as the value.
  82710. */
  82711. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  82712. /**
  82713. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  82714. * This is dynamic to allow compat with webgl 1 and 2.
  82715. * You will need to pass the name of the uniform as well as the value.
  82716. */
  82717. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  82718. /**
  82719. * Lambda to Update a single float in a uniform buffer.
  82720. * This is dynamic to allow compat with webgl 1 and 2.
  82721. * You will need to pass the name of the uniform as well as the value.
  82722. */
  82723. updateFloat: (name: string, x: number) => void;
  82724. /**
  82725. * Lambda to Update a vec2 of float in a uniform buffer.
  82726. * This is dynamic to allow compat with webgl 1 and 2.
  82727. * You will need to pass the name of the uniform as well as the value.
  82728. */
  82729. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  82730. /**
  82731. * Lambda to Update a vec3 of float in a uniform buffer.
  82732. * This is dynamic to allow compat with webgl 1 and 2.
  82733. * You will need to pass the name of the uniform as well as the value.
  82734. */
  82735. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  82736. /**
  82737. * Lambda to Update a vec4 of float in a uniform buffer.
  82738. * This is dynamic to allow compat with webgl 1 and 2.
  82739. * You will need to pass the name of the uniform as well as the value.
  82740. */
  82741. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  82742. /**
  82743. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  82744. * This is dynamic to allow compat with webgl 1 and 2.
  82745. * You will need to pass the name of the uniform as well as the value.
  82746. */
  82747. updateMatrix: (name: string, mat: Matrix) => void;
  82748. /**
  82749. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  82750. * This is dynamic to allow compat with webgl 1 and 2.
  82751. * You will need to pass the name of the uniform as well as the value.
  82752. */
  82753. updateVector3: (name: string, vector: Vector3) => void;
  82754. /**
  82755. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  82756. * This is dynamic to allow compat with webgl 1 and 2.
  82757. * You will need to pass the name of the uniform as well as the value.
  82758. */
  82759. updateVector4: (name: string, vector: Vector4) => void;
  82760. /**
  82761. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  82762. * This is dynamic to allow compat with webgl 1 and 2.
  82763. * You will need to pass the name of the uniform as well as the value.
  82764. */
  82765. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  82766. /**
  82767. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  82768. * This is dynamic to allow compat with webgl 1 and 2.
  82769. * You will need to pass the name of the uniform as well as the value.
  82770. */
  82771. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  82772. /**
  82773. * Instantiates a new Uniform buffer objects.
  82774. *
  82775. * Handles blocks of uniform on the GPU.
  82776. *
  82777. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  82778. *
  82779. * For more information, please refer to :
  82780. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  82781. * @param engine Define the engine the buffer is associated with
  82782. * @param data Define the data contained in the buffer
  82783. * @param dynamic Define if the buffer is updatable
  82784. */
  82785. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  82786. /**
  82787. * Indicates if the buffer is using the WebGL2 UBO implementation,
  82788. * or just falling back on setUniformXXX calls.
  82789. */
  82790. get useUbo(): boolean;
  82791. /**
  82792. * Indicates if the WebGL underlying uniform buffer is in sync
  82793. * with the javascript cache data.
  82794. */
  82795. get isSync(): boolean;
  82796. /**
  82797. * Indicates if the WebGL underlying uniform buffer is dynamic.
  82798. * Also, a dynamic UniformBuffer will disable cache verification and always
  82799. * update the underlying WebGL uniform buffer to the GPU.
  82800. * @returns if Dynamic, otherwise false
  82801. */
  82802. isDynamic(): boolean;
  82803. /**
  82804. * The data cache on JS side.
  82805. * @returns the underlying data as a float array
  82806. */
  82807. getData(): Float32Array;
  82808. /**
  82809. * The underlying WebGL Uniform buffer.
  82810. * @returns the webgl buffer
  82811. */
  82812. getBuffer(): Nullable<DataBuffer>;
  82813. /**
  82814. * std140 layout specifies how to align data within an UBO structure.
  82815. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  82816. * for specs.
  82817. */
  82818. private _fillAlignment;
  82819. /**
  82820. * Adds an uniform in the buffer.
  82821. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  82822. * for the layout to be correct !
  82823. * @param name Name of the uniform, as used in the uniform block in the shader.
  82824. * @param size Data size, or data directly.
  82825. */
  82826. addUniform(name: string, size: number | number[]): void;
  82827. /**
  82828. * Adds a Matrix 4x4 to the uniform buffer.
  82829. * @param name Name of the uniform, as used in the uniform block in the shader.
  82830. * @param mat A 4x4 matrix.
  82831. */
  82832. addMatrix(name: string, mat: Matrix): void;
  82833. /**
  82834. * Adds a vec2 to the uniform buffer.
  82835. * @param name Name of the uniform, as used in the uniform block in the shader.
  82836. * @param x Define the x component value of the vec2
  82837. * @param y Define the y component value of the vec2
  82838. */
  82839. addFloat2(name: string, x: number, y: number): void;
  82840. /**
  82841. * Adds a vec3 to the uniform buffer.
  82842. * @param name Name of the uniform, as used in the uniform block in the shader.
  82843. * @param x Define the x component value of the vec3
  82844. * @param y Define the y component value of the vec3
  82845. * @param z Define the z component value of the vec3
  82846. */
  82847. addFloat3(name: string, x: number, y: number, z: number): void;
  82848. /**
  82849. * Adds a vec3 to the uniform buffer.
  82850. * @param name Name of the uniform, as used in the uniform block in the shader.
  82851. * @param color Define the vec3 from a Color
  82852. */
  82853. addColor3(name: string, color: Color3): void;
  82854. /**
  82855. * Adds a vec4 to the uniform buffer.
  82856. * @param name Name of the uniform, as used in the uniform block in the shader.
  82857. * @param color Define the rgb components from a Color
  82858. * @param alpha Define the a component of the vec4
  82859. */
  82860. addColor4(name: string, color: Color3, alpha: number): void;
  82861. /**
  82862. * Adds a vec3 to the uniform buffer.
  82863. * @param name Name of the uniform, as used in the uniform block in the shader.
  82864. * @param vector Define the vec3 components from a Vector
  82865. */
  82866. addVector3(name: string, vector: Vector3): void;
  82867. /**
  82868. * Adds a Matrix 3x3 to the uniform buffer.
  82869. * @param name Name of the uniform, as used in the uniform block in the shader.
  82870. */
  82871. addMatrix3x3(name: string): void;
  82872. /**
  82873. * Adds a Matrix 2x2 to the uniform buffer.
  82874. * @param name Name of the uniform, as used in the uniform block in the shader.
  82875. */
  82876. addMatrix2x2(name: string): void;
  82877. /**
  82878. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  82879. */
  82880. create(): void;
  82881. /** @hidden */
  82882. _rebuild(): void;
  82883. /**
  82884. * Updates the WebGL Uniform Buffer on the GPU.
  82885. * If the `dynamic` flag is set to true, no cache comparison is done.
  82886. * Otherwise, the buffer will be updated only if the cache differs.
  82887. */
  82888. update(): void;
  82889. /**
  82890. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  82891. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  82892. * @param data Define the flattened data
  82893. * @param size Define the size of the data.
  82894. */
  82895. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  82896. private _valueCache;
  82897. private _cacheMatrix;
  82898. private _updateMatrix3x3ForUniform;
  82899. private _updateMatrix3x3ForEffect;
  82900. private _updateMatrix2x2ForEffect;
  82901. private _updateMatrix2x2ForUniform;
  82902. private _updateFloatForEffect;
  82903. private _updateFloatForUniform;
  82904. private _updateFloat2ForEffect;
  82905. private _updateFloat2ForUniform;
  82906. private _updateFloat3ForEffect;
  82907. private _updateFloat3ForUniform;
  82908. private _updateFloat4ForEffect;
  82909. private _updateFloat4ForUniform;
  82910. private _updateMatrixForEffect;
  82911. private _updateMatrixForUniform;
  82912. private _updateVector3ForEffect;
  82913. private _updateVector3ForUniform;
  82914. private _updateVector4ForEffect;
  82915. private _updateVector4ForUniform;
  82916. private _updateColor3ForEffect;
  82917. private _updateColor3ForUniform;
  82918. private _updateColor4ForEffect;
  82919. private _updateColor4ForUniform;
  82920. /**
  82921. * Sets a sampler uniform on the effect.
  82922. * @param name Define the name of the sampler.
  82923. * @param texture Define the texture to set in the sampler
  82924. */
  82925. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  82926. /**
  82927. * Directly updates the value of the uniform in the cache AND on the GPU.
  82928. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  82929. * @param data Define the flattened data
  82930. */
  82931. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  82932. /**
  82933. * Binds this uniform buffer to an effect.
  82934. * @param effect Define the effect to bind the buffer to
  82935. * @param name Name of the uniform block in the shader.
  82936. */
  82937. bindToEffect(effect: Effect, name: string): void;
  82938. /**
  82939. * Disposes the uniform buffer.
  82940. */
  82941. dispose(): void;
  82942. }
  82943. }
  82944. declare module BABYLON {
  82945. /**
  82946. * Enum that determines the text-wrapping mode to use.
  82947. */
  82948. export enum InspectableType {
  82949. /**
  82950. * Checkbox for booleans
  82951. */
  82952. Checkbox = 0,
  82953. /**
  82954. * Sliders for numbers
  82955. */
  82956. Slider = 1,
  82957. /**
  82958. * Vector3
  82959. */
  82960. Vector3 = 2,
  82961. /**
  82962. * Quaternions
  82963. */
  82964. Quaternion = 3,
  82965. /**
  82966. * Color3
  82967. */
  82968. Color3 = 4,
  82969. /**
  82970. * String
  82971. */
  82972. String = 5
  82973. }
  82974. /**
  82975. * Interface used to define custom inspectable properties.
  82976. * This interface is used by the inspector to display custom property grids
  82977. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  82978. */
  82979. export interface IInspectable {
  82980. /**
  82981. * Gets the label to display
  82982. */
  82983. label: string;
  82984. /**
  82985. * Gets the name of the property to edit
  82986. */
  82987. propertyName: string;
  82988. /**
  82989. * Gets the type of the editor to use
  82990. */
  82991. type: InspectableType;
  82992. /**
  82993. * Gets the minimum value of the property when using in "slider" mode
  82994. */
  82995. min?: number;
  82996. /**
  82997. * Gets the maximum value of the property when using in "slider" mode
  82998. */
  82999. max?: number;
  83000. /**
  83001. * Gets the setp to use when using in "slider" mode
  83002. */
  83003. step?: number;
  83004. }
  83005. }
  83006. declare module BABYLON {
  83007. /**
  83008. * Class used to provide helper for timing
  83009. */
  83010. export class TimingTools {
  83011. /**
  83012. * Polyfill for setImmediate
  83013. * @param action defines the action to execute after the current execution block
  83014. */
  83015. static SetImmediate(action: () => void): void;
  83016. }
  83017. }
  83018. declare module BABYLON {
  83019. /**
  83020. * Class used to enable instatition of objects by class name
  83021. */
  83022. export class InstantiationTools {
  83023. /**
  83024. * Use this object to register external classes like custom textures or material
  83025. * to allow the laoders to instantiate them
  83026. */
  83027. static RegisteredExternalClasses: {
  83028. [key: string]: Object;
  83029. };
  83030. /**
  83031. * Tries to instantiate a new object from a given class name
  83032. * @param className defines the class name to instantiate
  83033. * @returns the new object or null if the system was not able to do the instantiation
  83034. */
  83035. static Instantiate(className: string): any;
  83036. }
  83037. }
  83038. declare module BABYLON {
  83039. /**
  83040. * Define options used to create a depth texture
  83041. */
  83042. export class DepthTextureCreationOptions {
  83043. /** Specifies whether or not a stencil should be allocated in the texture */
  83044. generateStencil?: boolean;
  83045. /** Specifies whether or not bilinear filtering is enable on the texture */
  83046. bilinearFiltering?: boolean;
  83047. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  83048. comparisonFunction?: number;
  83049. /** Specifies if the created texture is a cube texture */
  83050. isCube?: boolean;
  83051. }
  83052. }
  83053. declare module BABYLON {
  83054. interface ThinEngine {
  83055. /**
  83056. * Creates a depth stencil cube texture.
  83057. * This is only available in WebGL 2.
  83058. * @param size The size of face edge in the cube texture.
  83059. * @param options The options defining the cube texture.
  83060. * @returns The cube texture
  83061. */
  83062. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  83063. /**
  83064. * Creates a cube texture
  83065. * @param rootUrl defines the url where the files to load is located
  83066. * @param scene defines the current scene
  83067. * @param files defines the list of files to load (1 per face)
  83068. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  83069. * @param onLoad defines an optional callback raised when the texture is loaded
  83070. * @param onError defines an optional callback raised if there is an issue to load the texture
  83071. * @param format defines the format of the data
  83072. * @param forcedExtension defines the extension to use to pick the right loader
  83073. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  83074. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  83075. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  83076. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  83077. * @returns the cube texture as an InternalTexture
  83078. */
  83079. 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;
  83080. /**
  83081. * Creates a cube texture
  83082. * @param rootUrl defines the url where the files to load is located
  83083. * @param scene defines the current scene
  83084. * @param files defines the list of files to load (1 per face)
  83085. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  83086. * @param onLoad defines an optional callback raised when the texture is loaded
  83087. * @param onError defines an optional callback raised if there is an issue to load the texture
  83088. * @param format defines the format of the data
  83089. * @param forcedExtension defines the extension to use to pick the right loader
  83090. * @returns the cube texture as an InternalTexture
  83091. */
  83092. 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;
  83093. /**
  83094. * Creates a cube texture
  83095. * @param rootUrl defines the url where the files to load is located
  83096. * @param scene defines the current scene
  83097. * @param files defines the list of files to load (1 per face)
  83098. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  83099. * @param onLoad defines an optional callback raised when the texture is loaded
  83100. * @param onError defines an optional callback raised if there is an issue to load the texture
  83101. * @param format defines the format of the data
  83102. * @param forcedExtension defines the extension to use to pick the right loader
  83103. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  83104. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  83105. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  83106. * @returns the cube texture as an InternalTexture
  83107. */
  83108. 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;
  83109. /** @hidden */
  83110. _partialLoadFile(url: string, index: number, loadedFiles: ArrayBuffer[], onfinish: (files: ArrayBuffer[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  83111. /** @hidden */
  83112. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: ArrayBuffer[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  83113. /** @hidden */
  83114. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  83115. /** @hidden */
  83116. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  83117. /**
  83118. * @hidden
  83119. */
  83120. _setCubeMapTextureParams(loadMipmap: boolean): void;
  83121. }
  83122. }
  83123. declare module BABYLON {
  83124. /**
  83125. * Class for creating a cube texture
  83126. */
  83127. export class CubeTexture extends BaseTexture {
  83128. private _delayedOnLoad;
  83129. /**
  83130. * Observable triggered once the texture has been loaded.
  83131. */
  83132. onLoadObservable: Observable<CubeTexture>;
  83133. /**
  83134. * The url of the texture
  83135. */
  83136. url: string;
  83137. /**
  83138. * Gets or sets the center of the bounding box associated with the cube texture.
  83139. * It must define where the camera used to render the texture was set
  83140. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  83141. */
  83142. boundingBoxPosition: Vector3;
  83143. private _boundingBoxSize;
  83144. /**
  83145. * Gets or sets the size of the bounding box associated with the cube texture
  83146. * When defined, the cubemap will switch to local mode
  83147. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  83148. * @example https://www.babylonjs-playground.com/#RNASML
  83149. */
  83150. set boundingBoxSize(value: Vector3);
  83151. /**
  83152. * Returns the bounding box size
  83153. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  83154. */
  83155. get boundingBoxSize(): Vector3;
  83156. protected _rotationY: number;
  83157. /**
  83158. * Sets texture matrix rotation angle around Y axis in radians.
  83159. */
  83160. set rotationY(value: number);
  83161. /**
  83162. * Gets texture matrix rotation angle around Y axis radians.
  83163. */
  83164. get rotationY(): number;
  83165. /**
  83166. * Are mip maps generated for this texture or not.
  83167. */
  83168. get noMipmap(): boolean;
  83169. private _noMipmap;
  83170. private _files;
  83171. protected _forcedExtension: Nullable<string>;
  83172. private _extensions;
  83173. private _textureMatrix;
  83174. private _format;
  83175. private _createPolynomials;
  83176. /** @hidden */
  83177. _prefiltered: boolean;
  83178. /**
  83179. * Creates a cube texture from an array of image urls
  83180. * @param files defines an array of image urls
  83181. * @param scene defines the hosting scene
  83182. * @param noMipmap specifies if mip maps are not used
  83183. * @returns a cube texture
  83184. */
  83185. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  83186. /**
  83187. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  83188. * @param url defines the url of the prefiltered texture
  83189. * @param scene defines the scene the texture is attached to
  83190. * @param forcedExtension defines the extension of the file if different from the url
  83191. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  83192. * @return the prefiltered texture
  83193. */
  83194. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  83195. /**
  83196. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  83197. * as prefiltered data.
  83198. * @param rootUrl defines the url of the texture or the root name of the six images
  83199. * @param scene defines the scene the texture is attached to
  83200. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  83201. * @param noMipmap defines if mipmaps should be created or not
  83202. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  83203. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  83204. * @param onError defines a callback triggered in case of error during load
  83205. * @param format defines the internal format to use for the texture once loaded
  83206. * @param prefiltered defines whether or not the texture is created from prefiltered data
  83207. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  83208. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  83209. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  83210. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  83211. * @return the cube texture
  83212. */
  83213. 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);
  83214. /**
  83215. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  83216. */
  83217. get isPrefiltered(): boolean;
  83218. /**
  83219. * Get the current class name of the texture useful for serialization or dynamic coding.
  83220. * @returns "CubeTexture"
  83221. */
  83222. getClassName(): string;
  83223. /**
  83224. * Update the url (and optional buffer) of this texture if url was null during construction.
  83225. * @param url the url of the texture
  83226. * @param forcedExtension defines the extension to use
  83227. * @param onLoad callback called when the texture is loaded (defaults to null)
  83228. * @param prefiltered Defines whether the updated texture is prefiltered or not
  83229. */
  83230. updateURL(url: string, forcedExtension?: string, onLoad?: () => void, prefiltered?: boolean): void;
  83231. /**
  83232. * Delays loading of the cube texture
  83233. * @param forcedExtension defines the extension to use
  83234. */
  83235. delayLoad(forcedExtension?: string): void;
  83236. /**
  83237. * Returns the reflection texture matrix
  83238. * @returns the reflection texture matrix
  83239. */
  83240. getReflectionTextureMatrix(): Matrix;
  83241. /**
  83242. * Sets the reflection texture matrix
  83243. * @param value Reflection texture matrix
  83244. */
  83245. setReflectionTextureMatrix(value: Matrix): void;
  83246. /**
  83247. * Parses text to create a cube texture
  83248. * @param parsedTexture define the serialized text to read from
  83249. * @param scene defines the hosting scene
  83250. * @param rootUrl defines the root url of the cube texture
  83251. * @returns a cube texture
  83252. */
  83253. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  83254. /**
  83255. * Makes a clone, or deep copy, of the cube texture
  83256. * @returns a new cube texture
  83257. */
  83258. clone(): CubeTexture;
  83259. }
  83260. }
  83261. declare module BABYLON {
  83262. /**
  83263. * Manages the defines for the Material
  83264. */
  83265. export class MaterialDefines {
  83266. /** @hidden */
  83267. protected _keys: string[];
  83268. private _isDirty;
  83269. /** @hidden */
  83270. _renderId: number;
  83271. /** @hidden */
  83272. _areLightsDirty: boolean;
  83273. /** @hidden */
  83274. _areLightsDisposed: boolean;
  83275. /** @hidden */
  83276. _areAttributesDirty: boolean;
  83277. /** @hidden */
  83278. _areTexturesDirty: boolean;
  83279. /** @hidden */
  83280. _areFresnelDirty: boolean;
  83281. /** @hidden */
  83282. _areMiscDirty: boolean;
  83283. /** @hidden */
  83284. _areImageProcessingDirty: boolean;
  83285. /** @hidden */
  83286. _normals: boolean;
  83287. /** @hidden */
  83288. _uvs: boolean;
  83289. /** @hidden */
  83290. _needNormals: boolean;
  83291. /** @hidden */
  83292. _needUVs: boolean;
  83293. [id: string]: any;
  83294. /**
  83295. * Specifies if the material needs to be re-calculated
  83296. */
  83297. get isDirty(): boolean;
  83298. /**
  83299. * Marks the material to indicate that it has been re-calculated
  83300. */
  83301. markAsProcessed(): void;
  83302. /**
  83303. * Marks the material to indicate that it needs to be re-calculated
  83304. */
  83305. markAsUnprocessed(): void;
  83306. /**
  83307. * Marks the material to indicate all of its defines need to be re-calculated
  83308. */
  83309. markAllAsDirty(): void;
  83310. /**
  83311. * Marks the material to indicate that image processing needs to be re-calculated
  83312. */
  83313. markAsImageProcessingDirty(): void;
  83314. /**
  83315. * Marks the material to indicate the lights need to be re-calculated
  83316. * @param disposed Defines whether the light is dirty due to dispose or not
  83317. */
  83318. markAsLightDirty(disposed?: boolean): void;
  83319. /**
  83320. * Marks the attribute state as changed
  83321. */
  83322. markAsAttributesDirty(): void;
  83323. /**
  83324. * Marks the texture state as changed
  83325. */
  83326. markAsTexturesDirty(): void;
  83327. /**
  83328. * Marks the fresnel state as changed
  83329. */
  83330. markAsFresnelDirty(): void;
  83331. /**
  83332. * Marks the misc state as changed
  83333. */
  83334. markAsMiscDirty(): void;
  83335. /**
  83336. * Rebuilds the material defines
  83337. */
  83338. rebuild(): void;
  83339. /**
  83340. * Specifies if two material defines are equal
  83341. * @param other - A material define instance to compare to
  83342. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  83343. */
  83344. isEqual(other: MaterialDefines): boolean;
  83345. /**
  83346. * Clones this instance's defines to another instance
  83347. * @param other - material defines to clone values to
  83348. */
  83349. cloneTo(other: MaterialDefines): void;
  83350. /**
  83351. * Resets the material define values
  83352. */
  83353. reset(): void;
  83354. /**
  83355. * Converts the material define values to a string
  83356. * @returns - String of material define information
  83357. */
  83358. toString(): string;
  83359. }
  83360. }
  83361. declare module BABYLON {
  83362. /**
  83363. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  83364. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  83365. * 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;
  83366. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  83367. */
  83368. export class ColorCurves {
  83369. private _dirty;
  83370. private _tempColor;
  83371. private _globalCurve;
  83372. private _highlightsCurve;
  83373. private _midtonesCurve;
  83374. private _shadowsCurve;
  83375. private _positiveCurve;
  83376. private _negativeCurve;
  83377. private _globalHue;
  83378. private _globalDensity;
  83379. private _globalSaturation;
  83380. private _globalExposure;
  83381. /**
  83382. * Gets the global Hue value.
  83383. * 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).
  83384. */
  83385. get globalHue(): number;
  83386. /**
  83387. * Sets the global Hue value.
  83388. * 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).
  83389. */
  83390. set globalHue(value: number);
  83391. /**
  83392. * Gets the global Density value.
  83393. * 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.
  83394. * Values less than zero provide a filter of opposite hue.
  83395. */
  83396. get globalDensity(): number;
  83397. /**
  83398. * Sets the global Density value.
  83399. * 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.
  83400. * Values less than zero provide a filter of opposite hue.
  83401. */
  83402. set globalDensity(value: number);
  83403. /**
  83404. * Gets the global Saturation value.
  83405. * 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.
  83406. */
  83407. get globalSaturation(): number;
  83408. /**
  83409. * Sets the global Saturation value.
  83410. * 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.
  83411. */
  83412. set globalSaturation(value: number);
  83413. /**
  83414. * Gets the global Exposure value.
  83415. * 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.
  83416. */
  83417. get globalExposure(): number;
  83418. /**
  83419. * Sets the global Exposure value.
  83420. * 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.
  83421. */
  83422. set globalExposure(value: number);
  83423. private _highlightsHue;
  83424. private _highlightsDensity;
  83425. private _highlightsSaturation;
  83426. private _highlightsExposure;
  83427. /**
  83428. * Gets the highlights Hue value.
  83429. * 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).
  83430. */
  83431. get highlightsHue(): number;
  83432. /**
  83433. * Sets the highlights Hue value.
  83434. * 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).
  83435. */
  83436. set highlightsHue(value: number);
  83437. /**
  83438. * Gets the highlights Density value.
  83439. * 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.
  83440. * Values less than zero provide a filter of opposite hue.
  83441. */
  83442. get highlightsDensity(): number;
  83443. /**
  83444. * Sets the highlights Density value.
  83445. * 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.
  83446. * Values less than zero provide a filter of opposite hue.
  83447. */
  83448. set highlightsDensity(value: number);
  83449. /**
  83450. * Gets the highlights Saturation value.
  83451. * 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.
  83452. */
  83453. get highlightsSaturation(): number;
  83454. /**
  83455. * Sets the highlights Saturation value.
  83456. * 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.
  83457. */
  83458. set highlightsSaturation(value: number);
  83459. /**
  83460. * Gets the highlights Exposure value.
  83461. * 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.
  83462. */
  83463. get highlightsExposure(): number;
  83464. /**
  83465. * Sets the highlights Exposure value.
  83466. * 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.
  83467. */
  83468. set highlightsExposure(value: number);
  83469. private _midtonesHue;
  83470. private _midtonesDensity;
  83471. private _midtonesSaturation;
  83472. private _midtonesExposure;
  83473. /**
  83474. * Gets the midtones Hue value.
  83475. * 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).
  83476. */
  83477. get midtonesHue(): number;
  83478. /**
  83479. * Sets the midtones Hue value.
  83480. * 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).
  83481. */
  83482. set midtonesHue(value: number);
  83483. /**
  83484. * Gets the midtones Density value.
  83485. * 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.
  83486. * Values less than zero provide a filter of opposite hue.
  83487. */
  83488. get midtonesDensity(): number;
  83489. /**
  83490. * Sets the midtones Density value.
  83491. * 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.
  83492. * Values less than zero provide a filter of opposite hue.
  83493. */
  83494. set midtonesDensity(value: number);
  83495. /**
  83496. * Gets the midtones Saturation value.
  83497. * 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.
  83498. */
  83499. get midtonesSaturation(): number;
  83500. /**
  83501. * Sets the midtones Saturation value.
  83502. * 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.
  83503. */
  83504. set midtonesSaturation(value: number);
  83505. /**
  83506. * Gets the midtones Exposure value.
  83507. * 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.
  83508. */
  83509. get midtonesExposure(): number;
  83510. /**
  83511. * Sets the midtones Exposure value.
  83512. * 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.
  83513. */
  83514. set midtonesExposure(value: number);
  83515. private _shadowsHue;
  83516. private _shadowsDensity;
  83517. private _shadowsSaturation;
  83518. private _shadowsExposure;
  83519. /**
  83520. * Gets the shadows Hue value.
  83521. * 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).
  83522. */
  83523. get shadowsHue(): number;
  83524. /**
  83525. * Sets the shadows Hue value.
  83526. * 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).
  83527. */
  83528. set shadowsHue(value: number);
  83529. /**
  83530. * Gets the shadows Density value.
  83531. * 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.
  83532. * Values less than zero provide a filter of opposite hue.
  83533. */
  83534. get shadowsDensity(): number;
  83535. /**
  83536. * Sets the shadows Density value.
  83537. * 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.
  83538. * Values less than zero provide a filter of opposite hue.
  83539. */
  83540. set shadowsDensity(value: number);
  83541. /**
  83542. * Gets the shadows Saturation value.
  83543. * 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.
  83544. */
  83545. get shadowsSaturation(): number;
  83546. /**
  83547. * Sets the shadows Saturation value.
  83548. * 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.
  83549. */
  83550. set shadowsSaturation(value: number);
  83551. /**
  83552. * Gets the shadows Exposure value.
  83553. * 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.
  83554. */
  83555. get shadowsExposure(): number;
  83556. /**
  83557. * Sets the shadows Exposure value.
  83558. * 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.
  83559. */
  83560. set shadowsExposure(value: number);
  83561. /**
  83562. * Returns the class name
  83563. * @returns The class name
  83564. */
  83565. getClassName(): string;
  83566. /**
  83567. * Binds the color curves to the shader.
  83568. * @param colorCurves The color curve to bind
  83569. * @param effect The effect to bind to
  83570. * @param positiveUniform The positive uniform shader parameter
  83571. * @param neutralUniform The neutral uniform shader parameter
  83572. * @param negativeUniform The negative uniform shader parameter
  83573. */
  83574. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  83575. /**
  83576. * Prepare the list of uniforms associated with the ColorCurves effects.
  83577. * @param uniformsList The list of uniforms used in the effect
  83578. */
  83579. static PrepareUniforms(uniformsList: string[]): void;
  83580. /**
  83581. * Returns color grading data based on a hue, density, saturation and exposure value.
  83582. * @param filterHue The hue of the color filter.
  83583. * @param filterDensity The density of the color filter.
  83584. * @param saturation The saturation.
  83585. * @param exposure The exposure.
  83586. * @param result The result data container.
  83587. */
  83588. private getColorGradingDataToRef;
  83589. /**
  83590. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  83591. * @param value The input slider value in range [-100,100].
  83592. * @returns Adjusted value.
  83593. */
  83594. private static applyColorGradingSliderNonlinear;
  83595. /**
  83596. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  83597. * @param hue The hue (H) input.
  83598. * @param saturation The saturation (S) input.
  83599. * @param brightness The brightness (B) input.
  83600. * @result An RGBA color represented as Vector4.
  83601. */
  83602. private static fromHSBToRef;
  83603. /**
  83604. * Returns a value clamped between min and max
  83605. * @param value The value to clamp
  83606. * @param min The minimum of value
  83607. * @param max The maximum of value
  83608. * @returns The clamped value.
  83609. */
  83610. private static clamp;
  83611. /**
  83612. * Clones the current color curve instance.
  83613. * @return The cloned curves
  83614. */
  83615. clone(): ColorCurves;
  83616. /**
  83617. * Serializes the current color curve instance to a json representation.
  83618. * @return a JSON representation
  83619. */
  83620. serialize(): any;
  83621. /**
  83622. * Parses the color curve from a json representation.
  83623. * @param source the JSON source to parse
  83624. * @return The parsed curves
  83625. */
  83626. static Parse(source: any): ColorCurves;
  83627. }
  83628. }
  83629. declare module BABYLON {
  83630. /**
  83631. * Interface to follow in your material defines to integrate easily the
  83632. * Image proccessing functions.
  83633. * @hidden
  83634. */
  83635. export interface IImageProcessingConfigurationDefines {
  83636. IMAGEPROCESSING: boolean;
  83637. VIGNETTE: boolean;
  83638. VIGNETTEBLENDMODEMULTIPLY: boolean;
  83639. VIGNETTEBLENDMODEOPAQUE: boolean;
  83640. TONEMAPPING: boolean;
  83641. TONEMAPPING_ACES: boolean;
  83642. CONTRAST: boolean;
  83643. EXPOSURE: boolean;
  83644. COLORCURVES: boolean;
  83645. COLORGRADING: boolean;
  83646. COLORGRADING3D: boolean;
  83647. SAMPLER3DGREENDEPTH: boolean;
  83648. SAMPLER3DBGRMAP: boolean;
  83649. IMAGEPROCESSINGPOSTPROCESS: boolean;
  83650. }
  83651. /**
  83652. * @hidden
  83653. */
  83654. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  83655. IMAGEPROCESSING: boolean;
  83656. VIGNETTE: boolean;
  83657. VIGNETTEBLENDMODEMULTIPLY: boolean;
  83658. VIGNETTEBLENDMODEOPAQUE: boolean;
  83659. TONEMAPPING: boolean;
  83660. TONEMAPPING_ACES: boolean;
  83661. CONTRAST: boolean;
  83662. COLORCURVES: boolean;
  83663. COLORGRADING: boolean;
  83664. COLORGRADING3D: boolean;
  83665. SAMPLER3DGREENDEPTH: boolean;
  83666. SAMPLER3DBGRMAP: boolean;
  83667. IMAGEPROCESSINGPOSTPROCESS: boolean;
  83668. EXPOSURE: boolean;
  83669. constructor();
  83670. }
  83671. /**
  83672. * This groups together the common properties used for image processing either in direct forward pass
  83673. * or through post processing effect depending on the use of the image processing pipeline in your scene
  83674. * or not.
  83675. */
  83676. export class ImageProcessingConfiguration {
  83677. /**
  83678. * Default tone mapping applied in BabylonJS.
  83679. */
  83680. static readonly TONEMAPPING_STANDARD: number;
  83681. /**
  83682. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  83683. * to other engines rendering to increase portability.
  83684. */
  83685. static readonly TONEMAPPING_ACES: number;
  83686. /**
  83687. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  83688. */
  83689. colorCurves: Nullable<ColorCurves>;
  83690. private _colorCurvesEnabled;
  83691. /**
  83692. * Gets wether the color curves effect is enabled.
  83693. */
  83694. get colorCurvesEnabled(): boolean;
  83695. /**
  83696. * Sets wether the color curves effect is enabled.
  83697. */
  83698. set colorCurvesEnabled(value: boolean);
  83699. private _colorGradingTexture;
  83700. /**
  83701. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  83702. */
  83703. get colorGradingTexture(): Nullable<BaseTexture>;
  83704. /**
  83705. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  83706. */
  83707. set colorGradingTexture(value: Nullable<BaseTexture>);
  83708. private _colorGradingEnabled;
  83709. /**
  83710. * Gets wether the color grading effect is enabled.
  83711. */
  83712. get colorGradingEnabled(): boolean;
  83713. /**
  83714. * Sets wether the color grading effect is enabled.
  83715. */
  83716. set colorGradingEnabled(value: boolean);
  83717. private _colorGradingWithGreenDepth;
  83718. /**
  83719. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  83720. */
  83721. get colorGradingWithGreenDepth(): boolean;
  83722. /**
  83723. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  83724. */
  83725. set colorGradingWithGreenDepth(value: boolean);
  83726. private _colorGradingBGR;
  83727. /**
  83728. * Gets wether the color grading texture contains BGR values.
  83729. */
  83730. get colorGradingBGR(): boolean;
  83731. /**
  83732. * Sets wether the color grading texture contains BGR values.
  83733. */
  83734. set colorGradingBGR(value: boolean);
  83735. /** @hidden */
  83736. _exposure: number;
  83737. /**
  83738. * Gets the Exposure used in the effect.
  83739. */
  83740. get exposure(): number;
  83741. /**
  83742. * Sets the Exposure used in the effect.
  83743. */
  83744. set exposure(value: number);
  83745. private _toneMappingEnabled;
  83746. /**
  83747. * Gets wether the tone mapping effect is enabled.
  83748. */
  83749. get toneMappingEnabled(): boolean;
  83750. /**
  83751. * Sets wether the tone mapping effect is enabled.
  83752. */
  83753. set toneMappingEnabled(value: boolean);
  83754. private _toneMappingType;
  83755. /**
  83756. * Gets the type of tone mapping effect.
  83757. */
  83758. get toneMappingType(): number;
  83759. /**
  83760. * Sets the type of tone mapping effect used in BabylonJS.
  83761. */
  83762. set toneMappingType(value: number);
  83763. protected _contrast: number;
  83764. /**
  83765. * Gets the contrast used in the effect.
  83766. */
  83767. get contrast(): number;
  83768. /**
  83769. * Sets the contrast used in the effect.
  83770. */
  83771. set contrast(value: number);
  83772. /**
  83773. * Vignette stretch size.
  83774. */
  83775. vignetteStretch: number;
  83776. /**
  83777. * Vignette centre X Offset.
  83778. */
  83779. vignetteCentreX: number;
  83780. /**
  83781. * Vignette centre Y Offset.
  83782. */
  83783. vignetteCentreY: number;
  83784. /**
  83785. * Vignette weight or intensity of the vignette effect.
  83786. */
  83787. vignetteWeight: number;
  83788. /**
  83789. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  83790. * if vignetteEnabled is set to true.
  83791. */
  83792. vignetteColor: Color4;
  83793. /**
  83794. * Camera field of view used by the Vignette effect.
  83795. */
  83796. vignetteCameraFov: number;
  83797. private _vignetteBlendMode;
  83798. /**
  83799. * Gets the vignette blend mode allowing different kind of effect.
  83800. */
  83801. get vignetteBlendMode(): number;
  83802. /**
  83803. * Sets the vignette blend mode allowing different kind of effect.
  83804. */
  83805. set vignetteBlendMode(value: number);
  83806. private _vignetteEnabled;
  83807. /**
  83808. * Gets wether the vignette effect is enabled.
  83809. */
  83810. get vignetteEnabled(): boolean;
  83811. /**
  83812. * Sets wether the vignette effect is enabled.
  83813. */
  83814. set vignetteEnabled(value: boolean);
  83815. private _applyByPostProcess;
  83816. /**
  83817. * Gets wether the image processing is applied through a post process or not.
  83818. */
  83819. get applyByPostProcess(): boolean;
  83820. /**
  83821. * Sets wether the image processing is applied through a post process or not.
  83822. */
  83823. set applyByPostProcess(value: boolean);
  83824. private _isEnabled;
  83825. /**
  83826. * Gets wether the image processing is enabled or not.
  83827. */
  83828. get isEnabled(): boolean;
  83829. /**
  83830. * Sets wether the image processing is enabled or not.
  83831. */
  83832. set isEnabled(value: boolean);
  83833. /**
  83834. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  83835. */
  83836. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  83837. /**
  83838. * Method called each time the image processing information changes requires to recompile the effect.
  83839. */
  83840. protected _updateParameters(): void;
  83841. /**
  83842. * Gets the current class name.
  83843. * @return "ImageProcessingConfiguration"
  83844. */
  83845. getClassName(): string;
  83846. /**
  83847. * Prepare the list of uniforms associated with the Image Processing effects.
  83848. * @param uniforms The list of uniforms used in the effect
  83849. * @param defines the list of defines currently in use
  83850. */
  83851. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  83852. /**
  83853. * Prepare the list of samplers associated with the Image Processing effects.
  83854. * @param samplersList The list of uniforms used in the effect
  83855. * @param defines the list of defines currently in use
  83856. */
  83857. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  83858. /**
  83859. * Prepare the list of defines associated to the shader.
  83860. * @param defines the list of defines to complete
  83861. * @param forPostProcess Define if we are currently in post process mode or not
  83862. */
  83863. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  83864. /**
  83865. * Returns true if all the image processing information are ready.
  83866. * @returns True if ready, otherwise, false
  83867. */
  83868. isReady(): boolean;
  83869. /**
  83870. * Binds the image processing to the shader.
  83871. * @param effect The effect to bind to
  83872. * @param overrideAspectRatio Override the aspect ratio of the effect
  83873. */
  83874. bind(effect: Effect, overrideAspectRatio?: number): void;
  83875. /**
  83876. * Clones the current image processing instance.
  83877. * @return The cloned image processing
  83878. */
  83879. clone(): ImageProcessingConfiguration;
  83880. /**
  83881. * Serializes the current image processing instance to a json representation.
  83882. * @return a JSON representation
  83883. */
  83884. serialize(): any;
  83885. /**
  83886. * Parses the image processing from a json representation.
  83887. * @param source the JSON source to parse
  83888. * @return The parsed image processing
  83889. */
  83890. static Parse(source: any): ImageProcessingConfiguration;
  83891. private static _VIGNETTEMODE_MULTIPLY;
  83892. private static _VIGNETTEMODE_OPAQUE;
  83893. /**
  83894. * Used to apply the vignette as a mix with the pixel color.
  83895. */
  83896. static get VIGNETTEMODE_MULTIPLY(): number;
  83897. /**
  83898. * Used to apply the vignette as a replacement of the pixel color.
  83899. */
  83900. static get VIGNETTEMODE_OPAQUE(): number;
  83901. }
  83902. }
  83903. declare module BABYLON {
  83904. /** @hidden */
  83905. export var postprocessVertexShader: {
  83906. name: string;
  83907. shader: string;
  83908. };
  83909. }
  83910. declare module BABYLON {
  83911. interface ThinEngine {
  83912. /**
  83913. * Creates a new render target texture
  83914. * @param size defines the size of the texture
  83915. * @param options defines the options used to create the texture
  83916. * @returns a new render target texture stored in an InternalTexture
  83917. */
  83918. createRenderTargetTexture(size: number | {
  83919. width: number;
  83920. height: number;
  83921. layers?: number;
  83922. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  83923. /**
  83924. * Creates a depth stencil texture.
  83925. * This is only available in WebGL 2 or with the depth texture extension available.
  83926. * @param size The size of face edge in the texture.
  83927. * @param options The options defining the texture.
  83928. * @returns The texture
  83929. */
  83930. createDepthStencilTexture(size: number | {
  83931. width: number;
  83932. height: number;
  83933. layers?: number;
  83934. }, options: DepthTextureCreationOptions): InternalTexture;
  83935. /** @hidden */
  83936. _createDepthStencilTexture(size: number | {
  83937. width: number;
  83938. height: number;
  83939. layers?: number;
  83940. }, options: DepthTextureCreationOptions): InternalTexture;
  83941. }
  83942. }
  83943. declare module BABYLON {
  83944. /** Defines supported spaces */
  83945. export enum Space {
  83946. /** Local (object) space */
  83947. LOCAL = 0,
  83948. /** World space */
  83949. WORLD = 1,
  83950. /** Bone space */
  83951. BONE = 2
  83952. }
  83953. /** Defines the 3 main axes */
  83954. export class Axis {
  83955. /** X axis */
  83956. static X: Vector3;
  83957. /** Y axis */
  83958. static Y: Vector3;
  83959. /** Z axis */
  83960. static Z: Vector3;
  83961. }
  83962. }
  83963. declare module BABYLON {
  83964. /**
  83965. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  83966. * This is the base of the follow, arc rotate cameras and Free camera
  83967. * @see http://doc.babylonjs.com/features/cameras
  83968. */
  83969. export class TargetCamera extends Camera {
  83970. private static _RigCamTransformMatrix;
  83971. private static _TargetTransformMatrix;
  83972. private static _TargetFocalPoint;
  83973. /**
  83974. * Define the current direction the camera is moving to
  83975. */
  83976. cameraDirection: Vector3;
  83977. /**
  83978. * Define the current rotation the camera is rotating to
  83979. */
  83980. cameraRotation: Vector2;
  83981. /**
  83982. * When set, the up vector of the camera will be updated by the rotation of the camera
  83983. */
  83984. updateUpVectorFromRotation: boolean;
  83985. private _tmpQuaternion;
  83986. /**
  83987. * Define the current rotation of the camera
  83988. */
  83989. rotation: Vector3;
  83990. /**
  83991. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  83992. */
  83993. rotationQuaternion: Quaternion;
  83994. /**
  83995. * Define the current speed of the camera
  83996. */
  83997. speed: number;
  83998. /**
  83999. * Add constraint to the camera to prevent it to move freely in all directions and
  84000. * around all axis.
  84001. */
  84002. noRotationConstraint: boolean;
  84003. /**
  84004. * Reverses mouselook direction to 'natural' panning as opposed to traditional direct
  84005. * panning
  84006. */
  84007. invertRotation: boolean;
  84008. /**
  84009. * Speed multiplier for inverse camera panning
  84010. */
  84011. inverseRotationSpeed: number;
  84012. /**
  84013. * Define the current target of the camera as an object or a position.
  84014. */
  84015. lockedTarget: any;
  84016. /** @hidden */
  84017. _currentTarget: Vector3;
  84018. /** @hidden */
  84019. _initialFocalDistance: number;
  84020. /** @hidden */
  84021. _viewMatrix: Matrix;
  84022. /** @hidden */
  84023. _camMatrix: Matrix;
  84024. /** @hidden */
  84025. _cameraTransformMatrix: Matrix;
  84026. /** @hidden */
  84027. _cameraRotationMatrix: Matrix;
  84028. /** @hidden */
  84029. _referencePoint: Vector3;
  84030. /** @hidden */
  84031. _transformedReferencePoint: Vector3;
  84032. protected _globalCurrentTarget: Vector3;
  84033. protected _globalCurrentUpVector: Vector3;
  84034. /** @hidden */
  84035. _reset: () => void;
  84036. private _defaultUp;
  84037. /**
  84038. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  84039. * This is the base of the follow, arc rotate cameras and Free camera
  84040. * @see http://doc.babylonjs.com/features/cameras
  84041. * @param name Defines the name of the camera in the scene
  84042. * @param position Defines the start position of the camera in the scene
  84043. * @param scene Defines the scene the camera belongs to
  84044. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  84045. */
  84046. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  84047. /**
  84048. * Gets the position in front of the camera at a given distance.
  84049. * @param distance The distance from the camera we want the position to be
  84050. * @returns the position
  84051. */
  84052. getFrontPosition(distance: number): Vector3;
  84053. /** @hidden */
  84054. _getLockedTargetPosition(): Nullable<Vector3>;
  84055. private _storedPosition;
  84056. private _storedRotation;
  84057. private _storedRotationQuaternion;
  84058. /**
  84059. * Store current camera state of the camera (fov, position, rotation, etc..)
  84060. * @returns the camera
  84061. */
  84062. storeState(): Camera;
  84063. /**
  84064. * Restored camera state. You must call storeState() first
  84065. * @returns whether it was successful or not
  84066. * @hidden
  84067. */
  84068. _restoreStateValues(): boolean;
  84069. /** @hidden */
  84070. _initCache(): void;
  84071. /** @hidden */
  84072. _updateCache(ignoreParentClass?: boolean): void;
  84073. /** @hidden */
  84074. _isSynchronizedViewMatrix(): boolean;
  84075. /** @hidden */
  84076. _computeLocalCameraSpeed(): number;
  84077. /**
  84078. * Defines the target the camera should look at.
  84079. * @param target Defines the new target as a Vector or a mesh
  84080. */
  84081. setTarget(target: Vector3): void;
  84082. /**
  84083. * Return the current target position of the camera. This value is expressed in local space.
  84084. * @returns the target position
  84085. */
  84086. getTarget(): Vector3;
  84087. /** @hidden */
  84088. _decideIfNeedsToMove(): boolean;
  84089. /** @hidden */
  84090. _updatePosition(): void;
  84091. /** @hidden */
  84092. _checkInputs(): void;
  84093. protected _updateCameraRotationMatrix(): void;
  84094. /**
  84095. * 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)
  84096. * @returns the current camera
  84097. */
  84098. private _rotateUpVectorWithCameraRotationMatrix;
  84099. private _cachedRotationZ;
  84100. private _cachedQuaternionRotationZ;
  84101. /** @hidden */
  84102. _getViewMatrix(): Matrix;
  84103. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  84104. /**
  84105. * @hidden
  84106. */
  84107. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  84108. /**
  84109. * @hidden
  84110. */
  84111. _updateRigCameras(): void;
  84112. private _getRigCamPositionAndTarget;
  84113. /**
  84114. * Gets the current object class name.
  84115. * @return the class name
  84116. */
  84117. getClassName(): string;
  84118. }
  84119. }
  84120. declare module BABYLON {
  84121. /**
  84122. * Gather the list of keyboard event types as constants.
  84123. */
  84124. export class KeyboardEventTypes {
  84125. /**
  84126. * The keydown event is fired when a key becomes active (pressed).
  84127. */
  84128. static readonly KEYDOWN: number;
  84129. /**
  84130. * The keyup event is fired when a key has been released.
  84131. */
  84132. static readonly KEYUP: number;
  84133. }
  84134. /**
  84135. * This class is used to store keyboard related info for the onKeyboardObservable event.
  84136. */
  84137. export class KeyboardInfo {
  84138. /**
  84139. * Defines the type of event (KeyboardEventTypes)
  84140. */
  84141. type: number;
  84142. /**
  84143. * Defines the related dom event
  84144. */
  84145. event: KeyboardEvent;
  84146. /**
  84147. * Instantiates a new keyboard info.
  84148. * This class is used to store keyboard related info for the onKeyboardObservable event.
  84149. * @param type Defines the type of event (KeyboardEventTypes)
  84150. * @param event Defines the related dom event
  84151. */
  84152. constructor(
  84153. /**
  84154. * Defines the type of event (KeyboardEventTypes)
  84155. */
  84156. type: number,
  84157. /**
  84158. * Defines the related dom event
  84159. */
  84160. event: KeyboardEvent);
  84161. }
  84162. /**
  84163. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  84164. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  84165. */
  84166. export class KeyboardInfoPre extends KeyboardInfo {
  84167. /**
  84168. * Defines the type of event (KeyboardEventTypes)
  84169. */
  84170. type: number;
  84171. /**
  84172. * Defines the related dom event
  84173. */
  84174. event: KeyboardEvent;
  84175. /**
  84176. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  84177. */
  84178. skipOnPointerObservable: boolean;
  84179. /**
  84180. * Instantiates a new keyboard pre info.
  84181. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  84182. * @param type Defines the type of event (KeyboardEventTypes)
  84183. * @param event Defines the related dom event
  84184. */
  84185. constructor(
  84186. /**
  84187. * Defines the type of event (KeyboardEventTypes)
  84188. */
  84189. type: number,
  84190. /**
  84191. * Defines the related dom event
  84192. */
  84193. event: KeyboardEvent);
  84194. }
  84195. }
  84196. declare module BABYLON {
  84197. /**
  84198. * Manage the keyboard inputs to control the movement of a free camera.
  84199. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  84200. */
  84201. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  84202. /**
  84203. * Defines the camera the input is attached to.
  84204. */
  84205. camera: FreeCamera;
  84206. /**
  84207. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  84208. */
  84209. keysUp: number[];
  84210. /**
  84211. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  84212. */
  84213. keysUpward: number[];
  84214. /**
  84215. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  84216. */
  84217. keysDown: number[];
  84218. /**
  84219. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  84220. */
  84221. keysDownward: number[];
  84222. /**
  84223. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  84224. */
  84225. keysLeft: number[];
  84226. /**
  84227. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  84228. */
  84229. keysRight: number[];
  84230. private _keys;
  84231. private _onCanvasBlurObserver;
  84232. private _onKeyboardObserver;
  84233. private _engine;
  84234. private _scene;
  84235. /**
  84236. * Attach the input controls to a specific dom element to get the input from.
  84237. * @param element Defines the element the controls should be listened from
  84238. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  84239. */
  84240. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  84241. /**
  84242. * Detach the current controls from the specified dom element.
  84243. * @param element Defines the element to stop listening the inputs from
  84244. */
  84245. detachControl(element: Nullable<HTMLElement>): void;
  84246. /**
  84247. * Update the current camera state depending on the inputs that have been used this frame.
  84248. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  84249. */
  84250. checkInputs(): void;
  84251. /**
  84252. * Gets the class name of the current intput.
  84253. * @returns the class name
  84254. */
  84255. getClassName(): string;
  84256. /** @hidden */
  84257. _onLostFocus(): void;
  84258. /**
  84259. * Get the friendly name associated with the input class.
  84260. * @returns the input friendly name
  84261. */
  84262. getSimpleName(): string;
  84263. }
  84264. }
  84265. declare module BABYLON {
  84266. /**
  84267. * Interface describing all the common properties and methods a shadow light needs to implement.
  84268. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  84269. * as well as binding the different shadow properties to the effects.
  84270. */
  84271. export interface IShadowLight extends Light {
  84272. /**
  84273. * The light id in the scene (used in scene.findLighById for instance)
  84274. */
  84275. id: string;
  84276. /**
  84277. * The position the shdow will be casted from.
  84278. */
  84279. position: Vector3;
  84280. /**
  84281. * In 2d mode (needCube being false), the direction used to cast the shadow.
  84282. */
  84283. direction: Vector3;
  84284. /**
  84285. * The transformed position. Position of the light in world space taking parenting in account.
  84286. */
  84287. transformedPosition: Vector3;
  84288. /**
  84289. * The transformed direction. Direction of the light in world space taking parenting in account.
  84290. */
  84291. transformedDirection: Vector3;
  84292. /**
  84293. * The friendly name of the light in the scene.
  84294. */
  84295. name: string;
  84296. /**
  84297. * Defines the shadow projection clipping minimum z value.
  84298. */
  84299. shadowMinZ: number;
  84300. /**
  84301. * Defines the shadow projection clipping maximum z value.
  84302. */
  84303. shadowMaxZ: number;
  84304. /**
  84305. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  84306. * @returns true if the information has been computed, false if it does not need to (no parenting)
  84307. */
  84308. computeTransformedInformation(): boolean;
  84309. /**
  84310. * Gets the scene the light belongs to.
  84311. * @returns The scene
  84312. */
  84313. getScene(): Scene;
  84314. /**
  84315. * Callback defining a custom Projection Matrix Builder.
  84316. * This can be used to override the default projection matrix computation.
  84317. */
  84318. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  84319. /**
  84320. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  84321. * @param matrix The materix to updated with the projection information
  84322. * @param viewMatrix The transform matrix of the light
  84323. * @param renderList The list of mesh to render in the map
  84324. * @returns The current light
  84325. */
  84326. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  84327. /**
  84328. * Gets the current depth scale used in ESM.
  84329. * @returns The scale
  84330. */
  84331. getDepthScale(): number;
  84332. /**
  84333. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  84334. * @returns true if a cube texture needs to be use
  84335. */
  84336. needCube(): boolean;
  84337. /**
  84338. * Detects if the projection matrix requires to be recomputed this frame.
  84339. * @returns true if it requires to be recomputed otherwise, false.
  84340. */
  84341. needProjectionMatrixCompute(): boolean;
  84342. /**
  84343. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  84344. */
  84345. forceProjectionMatrixCompute(): void;
  84346. /**
  84347. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  84348. * @param faceIndex The index of the face we are computed the direction to generate shadow
  84349. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  84350. */
  84351. getShadowDirection(faceIndex?: number): Vector3;
  84352. /**
  84353. * Gets the minZ used for shadow according to both the scene and the light.
  84354. * @param activeCamera The camera we are returning the min for
  84355. * @returns the depth min z
  84356. */
  84357. getDepthMinZ(activeCamera: Camera): number;
  84358. /**
  84359. * Gets the maxZ used for shadow according to both the scene and the light.
  84360. * @param activeCamera The camera we are returning the max for
  84361. * @returns the depth max z
  84362. */
  84363. getDepthMaxZ(activeCamera: Camera): number;
  84364. }
  84365. /**
  84366. * Base implementation IShadowLight
  84367. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  84368. */
  84369. export abstract class ShadowLight extends Light implements IShadowLight {
  84370. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  84371. protected _position: Vector3;
  84372. protected _setPosition(value: Vector3): void;
  84373. /**
  84374. * Sets the position the shadow will be casted from. Also use as the light position for both
  84375. * point and spot lights.
  84376. */
  84377. get position(): Vector3;
  84378. /**
  84379. * Sets the position the shadow will be casted from. Also use as the light position for both
  84380. * point and spot lights.
  84381. */
  84382. set position(value: Vector3);
  84383. protected _direction: Vector3;
  84384. protected _setDirection(value: Vector3): void;
  84385. /**
  84386. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  84387. * Also use as the light direction on spot and directional lights.
  84388. */
  84389. get direction(): Vector3;
  84390. /**
  84391. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  84392. * Also use as the light direction on spot and directional lights.
  84393. */
  84394. set direction(value: Vector3);
  84395. protected _shadowMinZ: number;
  84396. /**
  84397. * Gets the shadow projection clipping minimum z value.
  84398. */
  84399. get shadowMinZ(): number;
  84400. /**
  84401. * Sets the shadow projection clipping minimum z value.
  84402. */
  84403. set shadowMinZ(value: number);
  84404. protected _shadowMaxZ: number;
  84405. /**
  84406. * Sets the shadow projection clipping maximum z value.
  84407. */
  84408. get shadowMaxZ(): number;
  84409. /**
  84410. * Gets the shadow projection clipping maximum z value.
  84411. */
  84412. set shadowMaxZ(value: number);
  84413. /**
  84414. * Callback defining a custom Projection Matrix Builder.
  84415. * This can be used to override the default projection matrix computation.
  84416. */
  84417. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  84418. /**
  84419. * The transformed position. Position of the light in world space taking parenting in account.
  84420. */
  84421. transformedPosition: Vector3;
  84422. /**
  84423. * The transformed direction. Direction of the light in world space taking parenting in account.
  84424. */
  84425. transformedDirection: Vector3;
  84426. private _needProjectionMatrixCompute;
  84427. /**
  84428. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  84429. * @returns true if the information has been computed, false if it does not need to (no parenting)
  84430. */
  84431. computeTransformedInformation(): boolean;
  84432. /**
  84433. * Return the depth scale used for the shadow map.
  84434. * @returns the depth scale.
  84435. */
  84436. getDepthScale(): number;
  84437. /**
  84438. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  84439. * @param faceIndex The index of the face we are computed the direction to generate shadow
  84440. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  84441. */
  84442. getShadowDirection(faceIndex?: number): Vector3;
  84443. /**
  84444. * Returns the ShadowLight absolute position in the World.
  84445. * @returns the position vector in world space
  84446. */
  84447. getAbsolutePosition(): Vector3;
  84448. /**
  84449. * Sets the ShadowLight direction toward the passed target.
  84450. * @param target The point to target in local space
  84451. * @returns the updated ShadowLight direction
  84452. */
  84453. setDirectionToTarget(target: Vector3): Vector3;
  84454. /**
  84455. * Returns the light rotation in euler definition.
  84456. * @returns the x y z rotation in local space.
  84457. */
  84458. getRotation(): Vector3;
  84459. /**
  84460. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  84461. * @returns true if a cube texture needs to be use
  84462. */
  84463. needCube(): boolean;
  84464. /**
  84465. * Detects if the projection matrix requires to be recomputed this frame.
  84466. * @returns true if it requires to be recomputed otherwise, false.
  84467. */
  84468. needProjectionMatrixCompute(): boolean;
  84469. /**
  84470. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  84471. */
  84472. forceProjectionMatrixCompute(): void;
  84473. /** @hidden */
  84474. _initCache(): void;
  84475. /** @hidden */
  84476. _isSynchronized(): boolean;
  84477. /**
  84478. * Computes the world matrix of the node
  84479. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  84480. * @returns the world matrix
  84481. */
  84482. computeWorldMatrix(force?: boolean): Matrix;
  84483. /**
  84484. * Gets the minZ used for shadow according to both the scene and the light.
  84485. * @param activeCamera The camera we are returning the min for
  84486. * @returns the depth min z
  84487. */
  84488. getDepthMinZ(activeCamera: Camera): number;
  84489. /**
  84490. * Gets the maxZ used for shadow according to both the scene and the light.
  84491. * @param activeCamera The camera we are returning the max for
  84492. * @returns the depth max z
  84493. */
  84494. getDepthMaxZ(activeCamera: Camera): number;
  84495. /**
  84496. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  84497. * @param matrix The materix to updated with the projection information
  84498. * @param viewMatrix The transform matrix of the light
  84499. * @param renderList The list of mesh to render in the map
  84500. * @returns The current light
  84501. */
  84502. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  84503. }
  84504. }
  84505. declare module BABYLON {
  84506. /**
  84507. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  84508. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  84509. */
  84510. export class EffectFallbacks implements IEffectFallbacks {
  84511. private _defines;
  84512. private _currentRank;
  84513. private _maxRank;
  84514. private _mesh;
  84515. /**
  84516. * Removes the fallback from the bound mesh.
  84517. */
  84518. unBindMesh(): void;
  84519. /**
  84520. * Adds a fallback on the specified property.
  84521. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  84522. * @param define The name of the define in the shader
  84523. */
  84524. addFallback(rank: number, define: string): void;
  84525. /**
  84526. * Sets the mesh to use CPU skinning when needing to fallback.
  84527. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  84528. * @param mesh The mesh to use the fallbacks.
  84529. */
  84530. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  84531. /**
  84532. * Checks to see if more fallbacks are still availible.
  84533. */
  84534. get hasMoreFallbacks(): boolean;
  84535. /**
  84536. * Removes the defines that should be removed when falling back.
  84537. * @param currentDefines defines the current define statements for the shader.
  84538. * @param effect defines the current effect we try to compile
  84539. * @returns The resulting defines with defines of the current rank removed.
  84540. */
  84541. reduce(currentDefines: string, effect: Effect): string;
  84542. }
  84543. }
  84544. declare module BABYLON {
  84545. /**
  84546. * "Static Class" containing the most commonly used helper while dealing with material for
  84547. * rendering purpose.
  84548. *
  84549. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  84550. *
  84551. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  84552. */
  84553. export class MaterialHelper {
  84554. /**
  84555. * Bind the current view position to an effect.
  84556. * @param effect The effect to be bound
  84557. * @param scene The scene the eyes position is used from
  84558. * @param variableName name of the shader variable that will hold the eye position
  84559. */
  84560. static BindEyePosition(effect: Effect, scene: Scene, variableName?: string): void;
  84561. /**
  84562. * Helps preparing the defines values about the UVs in used in the effect.
  84563. * UVs are shared as much as we can accross channels in the shaders.
  84564. * @param texture The texture we are preparing the UVs for
  84565. * @param defines The defines to update
  84566. * @param key The channel key "diffuse", "specular"... used in the shader
  84567. */
  84568. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  84569. /**
  84570. * Binds a texture matrix value to its corrsponding uniform
  84571. * @param texture The texture to bind the matrix for
  84572. * @param uniformBuffer The uniform buffer receivin the data
  84573. * @param key The channel key "diffuse", "specular"... used in the shader
  84574. */
  84575. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  84576. /**
  84577. * Gets the current status of the fog (should it be enabled?)
  84578. * @param mesh defines the mesh to evaluate for fog support
  84579. * @param scene defines the hosting scene
  84580. * @returns true if fog must be enabled
  84581. */
  84582. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  84583. /**
  84584. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  84585. * @param mesh defines the current mesh
  84586. * @param scene defines the current scene
  84587. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  84588. * @param pointsCloud defines if point cloud rendering has to be turned on
  84589. * @param fogEnabled defines if fog has to be turned on
  84590. * @param alphaTest defines if alpha testing has to be turned on
  84591. * @param defines defines the current list of defines
  84592. */
  84593. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  84594. /**
  84595. * Helper used to prepare the list of defines associated with frame values for shader compilation
  84596. * @param scene defines the current scene
  84597. * @param engine defines the current engine
  84598. * @param defines specifies the list of active defines
  84599. * @param useInstances defines if instances have to be turned on
  84600. * @param useClipPlane defines if clip plane have to be turned on
  84601. */
  84602. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  84603. /**
  84604. * Prepares the defines for bones
  84605. * @param mesh The mesh containing the geometry data we will draw
  84606. * @param defines The defines to update
  84607. */
  84608. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  84609. /**
  84610. * Prepares the defines for morph targets
  84611. * @param mesh The mesh containing the geometry data we will draw
  84612. * @param defines The defines to update
  84613. */
  84614. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  84615. /**
  84616. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  84617. * @param mesh The mesh containing the geometry data we will draw
  84618. * @param defines The defines to update
  84619. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  84620. * @param useBones Precise whether bones should be used or not (override mesh info)
  84621. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  84622. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  84623. * @returns false if defines are considered not dirty and have not been checked
  84624. */
  84625. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  84626. /**
  84627. * Prepares the defines related to multiview
  84628. * @param scene The scene we are intending to draw
  84629. * @param defines The defines to update
  84630. */
  84631. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  84632. /**
  84633. * Prepares the defines related to the light information passed in parameter
  84634. * @param scene The scene we are intending to draw
  84635. * @param mesh The mesh the effect is compiling for
  84636. * @param light The light the effect is compiling for
  84637. * @param lightIndex The index of the light
  84638. * @param defines The defines to update
  84639. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  84640. * @param state Defines the current state regarding what is needed (normals, etc...)
  84641. */
  84642. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  84643. needNormals: boolean;
  84644. needRebuild: boolean;
  84645. shadowEnabled: boolean;
  84646. specularEnabled: boolean;
  84647. lightmapMode: boolean;
  84648. }): void;
  84649. /**
  84650. * Prepares the defines related to the light information passed in parameter
  84651. * @param scene The scene we are intending to draw
  84652. * @param mesh The mesh the effect is compiling for
  84653. * @param defines The defines to update
  84654. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  84655. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  84656. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  84657. * @returns true if normals will be required for the rest of the effect
  84658. */
  84659. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  84660. /**
  84661. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  84662. * @param lightIndex defines the light index
  84663. * @param uniformsList The uniform list
  84664. * @param samplersList The sampler list
  84665. * @param projectedLightTexture defines if projected texture must be used
  84666. * @param uniformBuffersList defines an optional list of uniform buffers
  84667. */
  84668. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  84669. /**
  84670. * Prepares the uniforms and samplers list to be used in the effect
  84671. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  84672. * @param samplersList The sampler list
  84673. * @param defines The defines helping in the list generation
  84674. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  84675. */
  84676. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  84677. /**
  84678. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  84679. * @param defines The defines to update while falling back
  84680. * @param fallbacks The authorized effect fallbacks
  84681. * @param maxSimultaneousLights The maximum number of lights allowed
  84682. * @param rank the current rank of the Effect
  84683. * @returns The newly affected rank
  84684. */
  84685. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  84686. private static _TmpMorphInfluencers;
  84687. /**
  84688. * Prepares the list of attributes required for morph targets according to the effect defines.
  84689. * @param attribs The current list of supported attribs
  84690. * @param mesh The mesh to prepare the morph targets attributes for
  84691. * @param influencers The number of influencers
  84692. */
  84693. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  84694. /**
  84695. * Prepares the list of attributes required for morph targets according to the effect defines.
  84696. * @param attribs The current list of supported attribs
  84697. * @param mesh The mesh to prepare the morph targets attributes for
  84698. * @param defines The current Defines of the effect
  84699. */
  84700. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  84701. /**
  84702. * Prepares the list of attributes required for bones according to the effect defines.
  84703. * @param attribs The current list of supported attribs
  84704. * @param mesh The mesh to prepare the bones attributes for
  84705. * @param defines The current Defines of the effect
  84706. * @param fallbacks The current efffect fallback strategy
  84707. */
  84708. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  84709. /**
  84710. * Check and prepare the list of attributes required for instances according to the effect defines.
  84711. * @param attribs The current list of supported attribs
  84712. * @param defines The current MaterialDefines of the effect
  84713. */
  84714. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  84715. /**
  84716. * Add the list of attributes required for instances to the attribs array.
  84717. * @param attribs The current list of supported attribs
  84718. */
  84719. static PushAttributesForInstances(attribs: string[]): void;
  84720. /**
  84721. * Binds the light information to the effect.
  84722. * @param light The light containing the generator
  84723. * @param effect The effect we are binding the data to
  84724. * @param lightIndex The light index in the effect used to render
  84725. */
  84726. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  84727. /**
  84728. * Binds the lights information from the scene to the effect for the given mesh.
  84729. * @param light Light to bind
  84730. * @param lightIndex Light index
  84731. * @param scene The scene where the light belongs to
  84732. * @param effect The effect we are binding the data to
  84733. * @param useSpecular Defines if specular is supported
  84734. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  84735. */
  84736. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  84737. /**
  84738. * Binds the lights information from the scene to the effect for the given mesh.
  84739. * @param scene The scene the lights belongs to
  84740. * @param mesh The mesh we are binding the information to render
  84741. * @param effect The effect we are binding the data to
  84742. * @param defines The generated defines for the effect
  84743. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  84744. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  84745. */
  84746. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, rebuildInParallel?: boolean): void;
  84747. private static _tempFogColor;
  84748. /**
  84749. * Binds the fog information from the scene to the effect for the given mesh.
  84750. * @param scene The scene the lights belongs to
  84751. * @param mesh The mesh we are binding the information to render
  84752. * @param effect The effect we are binding the data to
  84753. * @param linearSpace Defines if the fog effect is applied in linear space
  84754. */
  84755. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  84756. /**
  84757. * Binds the bones information from the mesh to the effect.
  84758. * @param mesh The mesh we are binding the information to render
  84759. * @param effect The effect we are binding the data to
  84760. */
  84761. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  84762. /**
  84763. * Binds the morph targets information from the mesh to the effect.
  84764. * @param abstractMesh The mesh we are binding the information to render
  84765. * @param effect The effect we are binding the data to
  84766. */
  84767. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  84768. /**
  84769. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  84770. * @param defines The generated defines used in the effect
  84771. * @param effect The effect we are binding the data to
  84772. * @param scene The scene we are willing to render with logarithmic scale for
  84773. */
  84774. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  84775. /**
  84776. * Binds the clip plane information from the scene to the effect.
  84777. * @param scene The scene the clip plane information are extracted from
  84778. * @param effect The effect we are binding the data to
  84779. */
  84780. static BindClipPlane(effect: Effect, scene: Scene): void;
  84781. }
  84782. }
  84783. declare module BABYLON {
  84784. /** @hidden */
  84785. export var packingFunctions: {
  84786. name: string;
  84787. shader: string;
  84788. };
  84789. }
  84790. declare module BABYLON {
  84791. /** @hidden */
  84792. export var shadowMapFragmentDeclaration: {
  84793. name: string;
  84794. shader: string;
  84795. };
  84796. }
  84797. declare module BABYLON {
  84798. /** @hidden */
  84799. export var clipPlaneFragmentDeclaration: {
  84800. name: string;
  84801. shader: string;
  84802. };
  84803. }
  84804. declare module BABYLON {
  84805. /** @hidden */
  84806. export var clipPlaneFragment: {
  84807. name: string;
  84808. shader: string;
  84809. };
  84810. }
  84811. declare module BABYLON {
  84812. /** @hidden */
  84813. export var shadowMapFragment: {
  84814. name: string;
  84815. shader: string;
  84816. };
  84817. }
  84818. declare module BABYLON {
  84819. /** @hidden */
  84820. export var shadowMapPixelShader: {
  84821. name: string;
  84822. shader: string;
  84823. };
  84824. }
  84825. declare module BABYLON {
  84826. /** @hidden */
  84827. export var bonesDeclaration: {
  84828. name: string;
  84829. shader: string;
  84830. };
  84831. }
  84832. declare module BABYLON {
  84833. /** @hidden */
  84834. export var morphTargetsVertexGlobalDeclaration: {
  84835. name: string;
  84836. shader: string;
  84837. };
  84838. }
  84839. declare module BABYLON {
  84840. /** @hidden */
  84841. export var morphTargetsVertexDeclaration: {
  84842. name: string;
  84843. shader: string;
  84844. };
  84845. }
  84846. declare module BABYLON {
  84847. /** @hidden */
  84848. export var instancesDeclaration: {
  84849. name: string;
  84850. shader: string;
  84851. };
  84852. }
  84853. declare module BABYLON {
  84854. /** @hidden */
  84855. export var helperFunctions: {
  84856. name: string;
  84857. shader: string;
  84858. };
  84859. }
  84860. declare module BABYLON {
  84861. /** @hidden */
  84862. export var shadowMapVertexDeclaration: {
  84863. name: string;
  84864. shader: string;
  84865. };
  84866. }
  84867. declare module BABYLON {
  84868. /** @hidden */
  84869. export var clipPlaneVertexDeclaration: {
  84870. name: string;
  84871. shader: string;
  84872. };
  84873. }
  84874. declare module BABYLON {
  84875. /** @hidden */
  84876. export var morphTargetsVertex: {
  84877. name: string;
  84878. shader: string;
  84879. };
  84880. }
  84881. declare module BABYLON {
  84882. /** @hidden */
  84883. export var instancesVertex: {
  84884. name: string;
  84885. shader: string;
  84886. };
  84887. }
  84888. declare module BABYLON {
  84889. /** @hidden */
  84890. export var bonesVertex: {
  84891. name: string;
  84892. shader: string;
  84893. };
  84894. }
  84895. declare module BABYLON {
  84896. /** @hidden */
  84897. export var shadowMapVertexNormalBias: {
  84898. name: string;
  84899. shader: string;
  84900. };
  84901. }
  84902. declare module BABYLON {
  84903. /** @hidden */
  84904. export var shadowMapVertexMetric: {
  84905. name: string;
  84906. shader: string;
  84907. };
  84908. }
  84909. declare module BABYLON {
  84910. /** @hidden */
  84911. export var clipPlaneVertex: {
  84912. name: string;
  84913. shader: string;
  84914. };
  84915. }
  84916. declare module BABYLON {
  84917. /** @hidden */
  84918. export var shadowMapVertexShader: {
  84919. name: string;
  84920. shader: string;
  84921. };
  84922. }
  84923. declare module BABYLON {
  84924. /** @hidden */
  84925. export var depthBoxBlurPixelShader: {
  84926. name: string;
  84927. shader: string;
  84928. };
  84929. }
  84930. declare module BABYLON {
  84931. /**
  84932. * Class representing a ray with position and direction
  84933. */
  84934. export class Ray {
  84935. /** origin point */
  84936. origin: Vector3;
  84937. /** direction */
  84938. direction: Vector3;
  84939. /** length of the ray */
  84940. length: number;
  84941. private static readonly TmpVector3;
  84942. private _tmpRay;
  84943. /**
  84944. * Creates a new ray
  84945. * @param origin origin point
  84946. * @param direction direction
  84947. * @param length length of the ray
  84948. */
  84949. constructor(
  84950. /** origin point */
  84951. origin: Vector3,
  84952. /** direction */
  84953. direction: Vector3,
  84954. /** length of the ray */
  84955. length?: number);
  84956. /**
  84957. * Checks if the ray intersects a box
  84958. * This does not account for the ray lenght by design to improve perfs.
  84959. * @param minimum bound of the box
  84960. * @param maximum bound of the box
  84961. * @param intersectionTreshold extra extend to be added to the box in all direction
  84962. * @returns if the box was hit
  84963. */
  84964. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  84965. /**
  84966. * Checks if the ray intersects a box
  84967. * This does not account for the ray lenght by design to improve perfs.
  84968. * @param box the bounding box to check
  84969. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  84970. * @returns if the box was hit
  84971. */
  84972. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  84973. /**
  84974. * If the ray hits a sphere
  84975. * @param sphere the bounding sphere to check
  84976. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  84977. * @returns true if it hits the sphere
  84978. */
  84979. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  84980. /**
  84981. * If the ray hits a triange
  84982. * @param vertex0 triangle vertex
  84983. * @param vertex1 triangle vertex
  84984. * @param vertex2 triangle vertex
  84985. * @returns intersection information if hit
  84986. */
  84987. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  84988. /**
  84989. * Checks if ray intersects a plane
  84990. * @param plane the plane to check
  84991. * @returns the distance away it was hit
  84992. */
  84993. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  84994. /**
  84995. * Calculate the intercept of a ray on a given axis
  84996. * @param axis to check 'x' | 'y' | 'z'
  84997. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  84998. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  84999. */
  85000. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  85001. /**
  85002. * Checks if ray intersects a mesh
  85003. * @param mesh the mesh to check
  85004. * @param fastCheck defines if the first intersection will be used (and not the closest)
  85005. * @returns picking info of the intersecton
  85006. */
  85007. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  85008. /**
  85009. * Checks if ray intersects a mesh
  85010. * @param meshes the meshes to check
  85011. * @param fastCheck defines if the first intersection will be used (and not the closest)
  85012. * @param results array to store result in
  85013. * @returns Array of picking infos
  85014. */
  85015. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  85016. private _comparePickingInfo;
  85017. private static smallnum;
  85018. private static rayl;
  85019. /**
  85020. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  85021. * @param sega the first point of the segment to test the intersection against
  85022. * @param segb the second point of the segment to test the intersection against
  85023. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  85024. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  85025. */
  85026. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  85027. /**
  85028. * Update the ray from viewport position
  85029. * @param x position
  85030. * @param y y position
  85031. * @param viewportWidth viewport width
  85032. * @param viewportHeight viewport height
  85033. * @param world world matrix
  85034. * @param view view matrix
  85035. * @param projection projection matrix
  85036. * @returns this ray updated
  85037. */
  85038. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  85039. /**
  85040. * Creates a ray with origin and direction of 0,0,0
  85041. * @returns the new ray
  85042. */
  85043. static Zero(): Ray;
  85044. /**
  85045. * Creates a new ray from screen space and viewport
  85046. * @param x position
  85047. * @param y y position
  85048. * @param viewportWidth viewport width
  85049. * @param viewportHeight viewport height
  85050. * @param world world matrix
  85051. * @param view view matrix
  85052. * @param projection projection matrix
  85053. * @returns new ray
  85054. */
  85055. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  85056. /**
  85057. * 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
  85058. * transformed to the given world matrix.
  85059. * @param origin The origin point
  85060. * @param end The end point
  85061. * @param world a matrix to transform the ray to. Default is the identity matrix.
  85062. * @returns the new ray
  85063. */
  85064. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  85065. /**
  85066. * Transforms a ray by a matrix
  85067. * @param ray ray to transform
  85068. * @param matrix matrix to apply
  85069. * @returns the resulting new ray
  85070. */
  85071. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  85072. /**
  85073. * Transforms a ray by a matrix
  85074. * @param ray ray to transform
  85075. * @param matrix matrix to apply
  85076. * @param result ray to store result in
  85077. */
  85078. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  85079. /**
  85080. * Unproject a ray from screen space to object space
  85081. * @param sourceX defines the screen space x coordinate to use
  85082. * @param sourceY defines the screen space y coordinate to use
  85083. * @param viewportWidth defines the current width of the viewport
  85084. * @param viewportHeight defines the current height of the viewport
  85085. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  85086. * @param view defines the view matrix to use
  85087. * @param projection defines the projection matrix to use
  85088. */
  85089. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  85090. }
  85091. /**
  85092. * Type used to define predicate used to select faces when a mesh intersection is detected
  85093. */
  85094. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  85095. interface Scene {
  85096. /** @hidden */
  85097. _tempPickingRay: Nullable<Ray>;
  85098. /** @hidden */
  85099. _cachedRayForTransform: Ray;
  85100. /** @hidden */
  85101. _pickWithRayInverseMatrix: Matrix;
  85102. /** @hidden */
  85103. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  85104. /** @hidden */
  85105. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  85106. }
  85107. }
  85108. declare module BABYLON {
  85109. /**
  85110. * Groups all the scene component constants in one place to ease maintenance.
  85111. * @hidden
  85112. */
  85113. export class SceneComponentConstants {
  85114. static readonly NAME_EFFECTLAYER: string;
  85115. static readonly NAME_LAYER: string;
  85116. static readonly NAME_LENSFLARESYSTEM: string;
  85117. static readonly NAME_BOUNDINGBOXRENDERER: string;
  85118. static readonly NAME_PARTICLESYSTEM: string;
  85119. static readonly NAME_GAMEPAD: string;
  85120. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  85121. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  85122. static readonly NAME_DEPTHRENDERER: string;
  85123. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  85124. static readonly NAME_SPRITE: string;
  85125. static readonly NAME_OUTLINERENDERER: string;
  85126. static readonly NAME_PROCEDURALTEXTURE: string;
  85127. static readonly NAME_SHADOWGENERATOR: string;
  85128. static readonly NAME_OCTREE: string;
  85129. static readonly NAME_PHYSICSENGINE: string;
  85130. static readonly NAME_AUDIO: string;
  85131. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  85132. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  85133. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  85134. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  85135. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  85136. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  85137. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  85138. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  85139. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  85140. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  85141. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  85142. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  85143. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  85144. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  85145. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  85146. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  85147. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  85148. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  85149. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  85150. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  85151. static readonly STEP_AFTERRENDER_AUDIO: number;
  85152. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  85153. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  85154. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  85155. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  85156. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  85157. static readonly STEP_POINTERMOVE_SPRITE: number;
  85158. static readonly STEP_POINTERDOWN_SPRITE: number;
  85159. static readonly STEP_POINTERUP_SPRITE: number;
  85160. }
  85161. /**
  85162. * This represents a scene component.
  85163. *
  85164. * This is used to decouple the dependency the scene is having on the different workloads like
  85165. * layers, post processes...
  85166. */
  85167. export interface ISceneComponent {
  85168. /**
  85169. * The name of the component. Each component must have a unique name.
  85170. */
  85171. name: string;
  85172. /**
  85173. * The scene the component belongs to.
  85174. */
  85175. scene: Scene;
  85176. /**
  85177. * Register the component to one instance of a scene.
  85178. */
  85179. register(): void;
  85180. /**
  85181. * Rebuilds the elements related to this component in case of
  85182. * context lost for instance.
  85183. */
  85184. rebuild(): void;
  85185. /**
  85186. * Disposes the component and the associated ressources.
  85187. */
  85188. dispose(): void;
  85189. }
  85190. /**
  85191. * This represents a SERIALIZABLE scene component.
  85192. *
  85193. * This extends Scene Component to add Serialization methods on top.
  85194. */
  85195. export interface ISceneSerializableComponent extends ISceneComponent {
  85196. /**
  85197. * Adds all the elements from the container to the scene
  85198. * @param container the container holding the elements
  85199. */
  85200. addFromContainer(container: AbstractScene): void;
  85201. /**
  85202. * Removes all the elements in the container from the scene
  85203. * @param container contains the elements to remove
  85204. * @param dispose if the removed element should be disposed (default: false)
  85205. */
  85206. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  85207. /**
  85208. * Serializes the component data to the specified json object
  85209. * @param serializationObject The object to serialize to
  85210. */
  85211. serialize(serializationObject: any): void;
  85212. }
  85213. /**
  85214. * Strong typing of a Mesh related stage step action
  85215. */
  85216. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  85217. /**
  85218. * Strong typing of a Evaluate Sub Mesh related stage step action
  85219. */
  85220. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  85221. /**
  85222. * Strong typing of a Active Mesh related stage step action
  85223. */
  85224. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  85225. /**
  85226. * Strong typing of a Camera related stage step action
  85227. */
  85228. export type CameraStageAction = (camera: Camera) => void;
  85229. /**
  85230. * Strong typing of a Camera Frame buffer related stage step action
  85231. */
  85232. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  85233. /**
  85234. * Strong typing of a Render Target related stage step action
  85235. */
  85236. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  85237. /**
  85238. * Strong typing of a RenderingGroup related stage step action
  85239. */
  85240. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  85241. /**
  85242. * Strong typing of a Mesh Render related stage step action
  85243. */
  85244. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  85245. /**
  85246. * Strong typing of a simple stage step action
  85247. */
  85248. export type SimpleStageAction = () => void;
  85249. /**
  85250. * Strong typing of a render target action.
  85251. */
  85252. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  85253. /**
  85254. * Strong typing of a pointer move action.
  85255. */
  85256. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  85257. /**
  85258. * Strong typing of a pointer up/down action.
  85259. */
  85260. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  85261. /**
  85262. * Representation of a stage in the scene (Basically a list of ordered steps)
  85263. * @hidden
  85264. */
  85265. export class Stage<T extends Function> extends Array<{
  85266. index: number;
  85267. component: ISceneComponent;
  85268. action: T;
  85269. }> {
  85270. /**
  85271. * Hide ctor from the rest of the world.
  85272. * @param items The items to add.
  85273. */
  85274. private constructor();
  85275. /**
  85276. * Creates a new Stage.
  85277. * @returns A new instance of a Stage
  85278. */
  85279. static Create<T extends Function>(): Stage<T>;
  85280. /**
  85281. * Registers a step in an ordered way in the targeted stage.
  85282. * @param index Defines the position to register the step in
  85283. * @param component Defines the component attached to the step
  85284. * @param action Defines the action to launch during the step
  85285. */
  85286. registerStep(index: number, component: ISceneComponent, action: T): void;
  85287. /**
  85288. * Clears all the steps from the stage.
  85289. */
  85290. clear(): void;
  85291. }
  85292. }
  85293. declare module BABYLON {
  85294. interface Scene {
  85295. /** @hidden */
  85296. _pointerOverSprite: Nullable<Sprite>;
  85297. /** @hidden */
  85298. _pickedDownSprite: Nullable<Sprite>;
  85299. /** @hidden */
  85300. _tempSpritePickingRay: Nullable<Ray>;
  85301. /**
  85302. * All of the sprite managers added to this scene
  85303. * @see http://doc.babylonjs.com/babylon101/sprites
  85304. */
  85305. spriteManagers: Array<ISpriteManager>;
  85306. /**
  85307. * An event triggered when sprites rendering is about to start
  85308. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  85309. */
  85310. onBeforeSpritesRenderingObservable: Observable<Scene>;
  85311. /**
  85312. * An event triggered when sprites rendering is done
  85313. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  85314. */
  85315. onAfterSpritesRenderingObservable: Observable<Scene>;
  85316. /** @hidden */
  85317. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  85318. /** Launch a ray to try to pick a sprite in the scene
  85319. * @param x position on screen
  85320. * @param y position on screen
  85321. * @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
  85322. * @param fastCheck defines if the first intersection will be used (and not the closest)
  85323. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  85324. * @returns a PickingInfo
  85325. */
  85326. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  85327. /** Use the given ray to pick a sprite in the scene
  85328. * @param ray The ray (in world space) to use to pick meshes
  85329. * @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
  85330. * @param fastCheck defines if the first intersection will be used (and not the closest)
  85331. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  85332. * @returns a PickingInfo
  85333. */
  85334. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  85335. /** @hidden */
  85336. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  85337. /** Launch a ray to try to pick sprites in the scene
  85338. * @param x position on screen
  85339. * @param y position on screen
  85340. * @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
  85341. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  85342. * @returns a PickingInfo array
  85343. */
  85344. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  85345. /** Use the given ray to pick sprites in the scene
  85346. * @param ray The ray (in world space) to use to pick meshes
  85347. * @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
  85348. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  85349. * @returns a PickingInfo array
  85350. */
  85351. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  85352. /**
  85353. * Force the sprite under the pointer
  85354. * @param sprite defines the sprite to use
  85355. */
  85356. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  85357. /**
  85358. * Gets the sprite under the pointer
  85359. * @returns a Sprite or null if no sprite is under the pointer
  85360. */
  85361. getPointerOverSprite(): Nullable<Sprite>;
  85362. }
  85363. /**
  85364. * Defines the sprite scene component responsible to manage sprites
  85365. * in a given scene.
  85366. */
  85367. export class SpriteSceneComponent implements ISceneComponent {
  85368. /**
  85369. * The component name helpfull to identify the component in the list of scene components.
  85370. */
  85371. readonly name: string;
  85372. /**
  85373. * The scene the component belongs to.
  85374. */
  85375. scene: Scene;
  85376. /** @hidden */
  85377. private _spritePredicate;
  85378. /**
  85379. * Creates a new instance of the component for the given scene
  85380. * @param scene Defines the scene to register the component in
  85381. */
  85382. constructor(scene: Scene);
  85383. /**
  85384. * Registers the component in a given scene
  85385. */
  85386. register(): void;
  85387. /**
  85388. * Rebuilds the elements related to this component in case of
  85389. * context lost for instance.
  85390. */
  85391. rebuild(): void;
  85392. /**
  85393. * Disposes the component and the associated ressources.
  85394. */
  85395. dispose(): void;
  85396. private _pickSpriteButKeepRay;
  85397. private _pointerMove;
  85398. private _pointerDown;
  85399. private _pointerUp;
  85400. }
  85401. }
  85402. declare module BABYLON {
  85403. /** @hidden */
  85404. export var fogFragmentDeclaration: {
  85405. name: string;
  85406. shader: string;
  85407. };
  85408. }
  85409. declare module BABYLON {
  85410. /** @hidden */
  85411. export var fogFragment: {
  85412. name: string;
  85413. shader: string;
  85414. };
  85415. }
  85416. declare module BABYLON {
  85417. /** @hidden */
  85418. export var spritesPixelShader: {
  85419. name: string;
  85420. shader: string;
  85421. };
  85422. }
  85423. declare module BABYLON {
  85424. /** @hidden */
  85425. export var fogVertexDeclaration: {
  85426. name: string;
  85427. shader: string;
  85428. };
  85429. }
  85430. declare module BABYLON {
  85431. /** @hidden */
  85432. export var spritesVertexShader: {
  85433. name: string;
  85434. shader: string;
  85435. };
  85436. }
  85437. declare module BABYLON {
  85438. /**
  85439. * Defines the minimum interface to fullfil in order to be a sprite manager.
  85440. */
  85441. export interface ISpriteManager extends IDisposable {
  85442. /**
  85443. * Restricts the camera to viewing objects with the same layerMask.
  85444. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  85445. */
  85446. layerMask: number;
  85447. /**
  85448. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  85449. */
  85450. isPickable: boolean;
  85451. /**
  85452. * Specifies the rendering group id for this mesh (0 by default)
  85453. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  85454. */
  85455. renderingGroupId: number;
  85456. /**
  85457. * Defines the list of sprites managed by the manager.
  85458. */
  85459. sprites: Array<Sprite>;
  85460. /**
  85461. * Tests the intersection of a sprite with a specific ray.
  85462. * @param ray The ray we are sending to test the collision
  85463. * @param camera The camera space we are sending rays in
  85464. * @param predicate A predicate allowing excluding sprites from the list of object to test
  85465. * @param fastCheck defines if the first intersection will be used (and not the closest)
  85466. * @returns picking info or null.
  85467. */
  85468. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  85469. /**
  85470. * Intersects the sprites with a ray
  85471. * @param ray defines the ray to intersect with
  85472. * @param camera defines the current active camera
  85473. * @param predicate defines a predicate used to select candidate sprites
  85474. * @returns null if no hit or a PickingInfo array
  85475. */
  85476. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  85477. /**
  85478. * Renders the list of sprites on screen.
  85479. */
  85480. render(): void;
  85481. }
  85482. /**
  85483. * Class used to manage multiple sprites on the same spritesheet
  85484. * @see http://doc.babylonjs.com/babylon101/sprites
  85485. */
  85486. export class SpriteManager implements ISpriteManager {
  85487. /** defines the manager's name */
  85488. name: string;
  85489. /** Gets the list of sprites */
  85490. sprites: Sprite[];
  85491. /** Gets or sets the rendering group id (0 by default) */
  85492. renderingGroupId: number;
  85493. /** Gets or sets camera layer mask */
  85494. layerMask: number;
  85495. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  85496. fogEnabled: boolean;
  85497. /** Gets or sets a boolean indicating if the sprites are pickable */
  85498. isPickable: boolean;
  85499. /** Defines the default width of a cell in the spritesheet */
  85500. cellWidth: number;
  85501. /** Defines the default height of a cell in the spritesheet */
  85502. cellHeight: number;
  85503. /** Associative array from JSON sprite data file */
  85504. private _cellData;
  85505. /** Array of sprite names from JSON sprite data file */
  85506. private _spriteMap;
  85507. /** True when packed cell data from JSON file is ready*/
  85508. private _packedAndReady;
  85509. private _textureContent;
  85510. /**
  85511. * An event triggered when the manager is disposed.
  85512. */
  85513. onDisposeObservable: Observable<SpriteManager>;
  85514. private _onDisposeObserver;
  85515. /**
  85516. * Callback called when the manager is disposed
  85517. */
  85518. set onDispose(callback: () => void);
  85519. private _capacity;
  85520. private _fromPacked;
  85521. private _spriteTexture;
  85522. private _epsilon;
  85523. private _scene;
  85524. private _vertexData;
  85525. private _buffer;
  85526. private _vertexBuffers;
  85527. private _indexBuffer;
  85528. private _effectBase;
  85529. private _effectFog;
  85530. /**
  85531. * Gets or sets the spritesheet texture
  85532. */
  85533. get texture(): Texture;
  85534. set texture(value: Texture);
  85535. private _blendMode;
  85536. /**
  85537. * Blend mode use to render the particle, it can be any of
  85538. * the static Constants.ALPHA_x properties provided in this class.
  85539. * Default value is Constants.ALPHA_COMBINE
  85540. */
  85541. get blendMode(): number;
  85542. set blendMode(blendMode: number);
  85543. /** Disables writing to the depth buffer when rendering the sprites.
  85544. * It can be handy to disable depth writing when using textures without alpha channel
  85545. * and setting some specific blend modes.
  85546. */
  85547. disableDepthWrite: boolean;
  85548. /**
  85549. * Creates a new sprite manager
  85550. * @param name defines the manager's name
  85551. * @param imgUrl defines the sprite sheet url
  85552. * @param capacity defines the maximum allowed number of sprites
  85553. * @param cellSize defines the size of a sprite cell
  85554. * @param scene defines the hosting scene
  85555. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  85556. * @param samplingMode defines the smapling mode to use with spritesheet
  85557. * @param fromPacked set to false; do not alter
  85558. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  85559. */
  85560. constructor(
  85561. /** defines the manager's name */
  85562. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  85563. private _makePacked;
  85564. private _appendSpriteVertex;
  85565. private _checkTextureAlpha;
  85566. /**
  85567. * Intersects the sprites with a ray
  85568. * @param ray defines the ray to intersect with
  85569. * @param camera defines the current active camera
  85570. * @param predicate defines a predicate used to select candidate sprites
  85571. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  85572. * @returns null if no hit or a PickingInfo
  85573. */
  85574. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  85575. /**
  85576. * Intersects the sprites with a ray
  85577. * @param ray defines the ray to intersect with
  85578. * @param camera defines the current active camera
  85579. * @param predicate defines a predicate used to select candidate sprites
  85580. * @returns null if no hit or a PickingInfo array
  85581. */
  85582. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  85583. /**
  85584. * Render all child sprites
  85585. */
  85586. render(): void;
  85587. /**
  85588. * Release associated resources
  85589. */
  85590. dispose(): void;
  85591. }
  85592. }
  85593. declare module BABYLON {
  85594. /** Interface used by value gradients (color, factor, ...) */
  85595. export interface IValueGradient {
  85596. /**
  85597. * Gets or sets the gradient value (between 0 and 1)
  85598. */
  85599. gradient: number;
  85600. }
  85601. /** Class used to store color4 gradient */
  85602. export class ColorGradient implements IValueGradient {
  85603. /**
  85604. * Gets or sets the gradient value (between 0 and 1)
  85605. */
  85606. gradient: number;
  85607. /**
  85608. * Gets or sets first associated color
  85609. */
  85610. color1: Color4;
  85611. /**
  85612. * Gets or sets second associated color
  85613. */
  85614. color2?: Color4 | undefined;
  85615. /**
  85616. * Creates a new color4 gradient
  85617. * @param gradient gets or sets the gradient value (between 0 and 1)
  85618. * @param color1 gets or sets first associated color
  85619. * @param color2 gets or sets first second color
  85620. */
  85621. constructor(
  85622. /**
  85623. * Gets or sets the gradient value (between 0 and 1)
  85624. */
  85625. gradient: number,
  85626. /**
  85627. * Gets or sets first associated color
  85628. */
  85629. color1: Color4,
  85630. /**
  85631. * Gets or sets second associated color
  85632. */
  85633. color2?: Color4 | undefined);
  85634. /**
  85635. * Will get a color picked randomly between color1 and color2.
  85636. * If color2 is undefined then color1 will be used
  85637. * @param result defines the target Color4 to store the result in
  85638. */
  85639. getColorToRef(result: Color4): void;
  85640. }
  85641. /** Class used to store color 3 gradient */
  85642. export class Color3Gradient implements IValueGradient {
  85643. /**
  85644. * Gets or sets the gradient value (between 0 and 1)
  85645. */
  85646. gradient: number;
  85647. /**
  85648. * Gets or sets the associated color
  85649. */
  85650. color: Color3;
  85651. /**
  85652. * Creates a new color3 gradient
  85653. * @param gradient gets or sets the gradient value (between 0 and 1)
  85654. * @param color gets or sets associated color
  85655. */
  85656. constructor(
  85657. /**
  85658. * Gets or sets the gradient value (between 0 and 1)
  85659. */
  85660. gradient: number,
  85661. /**
  85662. * Gets or sets the associated color
  85663. */
  85664. color: Color3);
  85665. }
  85666. /** Class used to store factor gradient */
  85667. export class FactorGradient implements IValueGradient {
  85668. /**
  85669. * Gets or sets the gradient value (between 0 and 1)
  85670. */
  85671. gradient: number;
  85672. /**
  85673. * Gets or sets first associated factor
  85674. */
  85675. factor1: number;
  85676. /**
  85677. * Gets or sets second associated factor
  85678. */
  85679. factor2?: number | undefined;
  85680. /**
  85681. * Creates a new factor gradient
  85682. * @param gradient gets or sets the gradient value (between 0 and 1)
  85683. * @param factor1 gets or sets first associated factor
  85684. * @param factor2 gets or sets second associated factor
  85685. */
  85686. constructor(
  85687. /**
  85688. * Gets or sets the gradient value (between 0 and 1)
  85689. */
  85690. gradient: number,
  85691. /**
  85692. * Gets or sets first associated factor
  85693. */
  85694. factor1: number,
  85695. /**
  85696. * Gets or sets second associated factor
  85697. */
  85698. factor2?: number | undefined);
  85699. /**
  85700. * Will get a number picked randomly between factor1 and factor2.
  85701. * If factor2 is undefined then factor1 will be used
  85702. * @returns the picked number
  85703. */
  85704. getFactor(): number;
  85705. }
  85706. /**
  85707. * Helper used to simplify some generic gradient tasks
  85708. */
  85709. export class GradientHelper {
  85710. /**
  85711. * Gets the current gradient from an array of IValueGradient
  85712. * @param ratio defines the current ratio to get
  85713. * @param gradients defines the array of IValueGradient
  85714. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  85715. */
  85716. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  85717. }
  85718. }
  85719. declare module BABYLON {
  85720. /**
  85721. * Interface for the size containing width and height
  85722. */
  85723. export interface ISize {
  85724. /**
  85725. * Width
  85726. */
  85727. width: number;
  85728. /**
  85729. * Heighht
  85730. */
  85731. height: number;
  85732. }
  85733. /**
  85734. * Size containing widht and height
  85735. */
  85736. export class Size implements ISize {
  85737. /**
  85738. * Width
  85739. */
  85740. width: number;
  85741. /**
  85742. * Height
  85743. */
  85744. height: number;
  85745. /**
  85746. * Creates a Size object from the given width and height (floats).
  85747. * @param width width of the new size
  85748. * @param height height of the new size
  85749. */
  85750. constructor(width: number, height: number);
  85751. /**
  85752. * Returns a string with the Size width and height
  85753. * @returns a string with the Size width and height
  85754. */
  85755. toString(): string;
  85756. /**
  85757. * "Size"
  85758. * @returns the string "Size"
  85759. */
  85760. getClassName(): string;
  85761. /**
  85762. * Returns the Size hash code.
  85763. * @returns a hash code for a unique width and height
  85764. */
  85765. getHashCode(): number;
  85766. /**
  85767. * Updates the current size from the given one.
  85768. * @param src the given size
  85769. */
  85770. copyFrom(src: Size): void;
  85771. /**
  85772. * Updates in place the current Size from the given floats.
  85773. * @param width width of the new size
  85774. * @param height height of the new size
  85775. * @returns the updated Size.
  85776. */
  85777. copyFromFloats(width: number, height: number): Size;
  85778. /**
  85779. * Updates in place the current Size from the given floats.
  85780. * @param width width to set
  85781. * @param height height to set
  85782. * @returns the updated Size.
  85783. */
  85784. set(width: number, height: number): Size;
  85785. /**
  85786. * Multiplies the width and height by numbers
  85787. * @param w factor to multiple the width by
  85788. * @param h factor to multiple the height by
  85789. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  85790. */
  85791. multiplyByFloats(w: number, h: number): Size;
  85792. /**
  85793. * Clones the size
  85794. * @returns a new Size copied from the given one.
  85795. */
  85796. clone(): Size;
  85797. /**
  85798. * True if the current Size and the given one width and height are strictly equal.
  85799. * @param other the other size to compare against
  85800. * @returns True if the current Size and the given one width and height are strictly equal.
  85801. */
  85802. equals(other: Size): boolean;
  85803. /**
  85804. * The surface of the Size : width * height (float).
  85805. */
  85806. get surface(): number;
  85807. /**
  85808. * Create a new size of zero
  85809. * @returns a new Size set to (0.0, 0.0)
  85810. */
  85811. static Zero(): Size;
  85812. /**
  85813. * Sums the width and height of two sizes
  85814. * @param otherSize size to add to this size
  85815. * @returns a new Size set as the addition result of the current Size and the given one.
  85816. */
  85817. add(otherSize: Size): Size;
  85818. /**
  85819. * Subtracts the width and height of two
  85820. * @param otherSize size to subtract to this size
  85821. * @returns a new Size set as the subtraction result of the given one from the current Size.
  85822. */
  85823. subtract(otherSize: Size): Size;
  85824. /**
  85825. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  85826. * @param start starting size to lerp between
  85827. * @param end end size to lerp between
  85828. * @param amount amount to lerp between the start and end values
  85829. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  85830. */
  85831. static Lerp(start: Size, end: Size, amount: number): Size;
  85832. }
  85833. }
  85834. declare module BABYLON {
  85835. interface ThinEngine {
  85836. /**
  85837. * Creates a dynamic texture
  85838. * @param width defines the width of the texture
  85839. * @param height defines the height of the texture
  85840. * @param generateMipMaps defines if the engine should generate the mip levels
  85841. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  85842. * @returns the dynamic texture inside an InternalTexture
  85843. */
  85844. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  85845. /**
  85846. * Update the content of a dynamic texture
  85847. * @param texture defines the texture to update
  85848. * @param canvas defines the canvas containing the source
  85849. * @param invertY defines if data must be stored with Y axis inverted
  85850. * @param premulAlpha defines if alpha is stored as premultiplied
  85851. * @param format defines the format of the data
  85852. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  85853. */
  85854. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  85855. }
  85856. }
  85857. declare module BABYLON {
  85858. /**
  85859. * Helper class used to generate a canvas to manipulate images
  85860. */
  85861. export class CanvasGenerator {
  85862. /**
  85863. * Create a new canvas (or offscreen canvas depending on the context)
  85864. * @param width defines the expected width
  85865. * @param height defines the expected height
  85866. * @return a new canvas or offscreen canvas
  85867. */
  85868. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  85869. }
  85870. }
  85871. declare module BABYLON {
  85872. /**
  85873. * A class extending Texture allowing drawing on a texture
  85874. * @see http://doc.babylonjs.com/how_to/dynamictexture
  85875. */
  85876. export class DynamicTexture extends Texture {
  85877. private _generateMipMaps;
  85878. private _canvas;
  85879. private _context;
  85880. private _engine;
  85881. /**
  85882. * Creates a DynamicTexture
  85883. * @param name defines the name of the texture
  85884. * @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
  85885. * @param scene defines the scene where you want the texture
  85886. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  85887. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  85888. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  85889. */
  85890. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  85891. /**
  85892. * Get the current class name of the texture useful for serialization or dynamic coding.
  85893. * @returns "DynamicTexture"
  85894. */
  85895. getClassName(): string;
  85896. /**
  85897. * Gets the current state of canRescale
  85898. */
  85899. get canRescale(): boolean;
  85900. private _recreate;
  85901. /**
  85902. * Scales the texture
  85903. * @param ratio the scale factor to apply to both width and height
  85904. */
  85905. scale(ratio: number): void;
  85906. /**
  85907. * Resizes the texture
  85908. * @param width the new width
  85909. * @param height the new height
  85910. */
  85911. scaleTo(width: number, height: number): void;
  85912. /**
  85913. * Gets the context of the canvas used by the texture
  85914. * @returns the canvas context of the dynamic texture
  85915. */
  85916. getContext(): CanvasRenderingContext2D;
  85917. /**
  85918. * Clears the texture
  85919. */
  85920. clear(): void;
  85921. /**
  85922. * Updates the texture
  85923. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  85924. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  85925. */
  85926. update(invertY?: boolean, premulAlpha?: boolean): void;
  85927. /**
  85928. * Draws text onto the texture
  85929. * @param text defines the text to be drawn
  85930. * @param x defines the placement of the text from the left
  85931. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  85932. * @param font defines the font to be used with font-style, font-size, font-name
  85933. * @param color defines the color used for the text
  85934. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  85935. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  85936. * @param update defines whether texture is immediately update (default is true)
  85937. */
  85938. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string | null, clearColor: string, invertY?: boolean, update?: boolean): void;
  85939. /**
  85940. * Clones the texture
  85941. * @returns the clone of the texture.
  85942. */
  85943. clone(): DynamicTexture;
  85944. /**
  85945. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  85946. * @returns a serialized dynamic texture object
  85947. */
  85948. serialize(): any;
  85949. /** @hidden */
  85950. _rebuild(): void;
  85951. }
  85952. }
  85953. declare module BABYLON {
  85954. interface ThinEngine {
  85955. /**
  85956. * Creates a raw texture
  85957. * @param data defines the data to store in the texture
  85958. * @param width defines the width of the texture
  85959. * @param height defines the height of the texture
  85960. * @param format defines the format of the data
  85961. * @param generateMipMaps defines if the engine should generate the mip levels
  85962. * @param invertY defines if data must be stored with Y axis inverted
  85963. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  85964. * @param compression defines the compression used (null by default)
  85965. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  85966. * @returns the raw texture inside an InternalTexture
  85967. */
  85968. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  85969. /**
  85970. * Update a raw texture
  85971. * @param texture defines the texture to update
  85972. * @param data defines the data to store in the texture
  85973. * @param format defines the format of the data
  85974. * @param invertY defines if data must be stored with Y axis inverted
  85975. */
  85976. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  85977. /**
  85978. * Update a raw texture
  85979. * @param texture defines the texture to update
  85980. * @param data defines the data to store in the texture
  85981. * @param format defines the format of the data
  85982. * @param invertY defines if data must be stored with Y axis inverted
  85983. * @param compression defines the compression used (null by default)
  85984. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  85985. */
  85986. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  85987. /**
  85988. * Creates a new raw cube texture
  85989. * @param data defines the array of data to use to create each face
  85990. * @param size defines the size of the textures
  85991. * @param format defines the format of the data
  85992. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  85993. * @param generateMipMaps defines if the engine should generate the mip levels
  85994. * @param invertY defines if data must be stored with Y axis inverted
  85995. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  85996. * @param compression defines the compression used (null by default)
  85997. * @returns the cube texture as an InternalTexture
  85998. */
  85999. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  86000. /**
  86001. * Update a raw cube texture
  86002. * @param texture defines the texture to udpdate
  86003. * @param data defines the data to store
  86004. * @param format defines the data format
  86005. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  86006. * @param invertY defines if data must be stored with Y axis inverted
  86007. */
  86008. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  86009. /**
  86010. * Update a raw cube texture
  86011. * @param texture defines the texture to udpdate
  86012. * @param data defines the data to store
  86013. * @param format defines the data format
  86014. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  86015. * @param invertY defines if data must be stored with Y axis inverted
  86016. * @param compression defines the compression used (null by default)
  86017. */
  86018. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  86019. /**
  86020. * Update a raw cube texture
  86021. * @param texture defines the texture to udpdate
  86022. * @param data defines the data to store
  86023. * @param format defines the data format
  86024. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  86025. * @param invertY defines if data must be stored with Y axis inverted
  86026. * @param compression defines the compression used (null by default)
  86027. * @param level defines which level of the texture to update
  86028. */
  86029. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  86030. /**
  86031. * Creates a new raw cube texture from a specified url
  86032. * @param url defines the url where the data is located
  86033. * @param scene defines the current scene
  86034. * @param size defines the size of the textures
  86035. * @param format defines the format of the data
  86036. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  86037. * @param noMipmap defines if the engine should avoid generating the mip levels
  86038. * @param callback defines a callback used to extract texture data from loaded data
  86039. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  86040. * @param onLoad defines a callback called when texture is loaded
  86041. * @param onError defines a callback called if there is an error
  86042. * @returns the cube texture as an InternalTexture
  86043. */
  86044. 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;
  86045. /**
  86046. * Creates a new raw cube texture from a specified url
  86047. * @param url defines the url where the data is located
  86048. * @param scene defines the current scene
  86049. * @param size defines the size of the textures
  86050. * @param format defines the format of the data
  86051. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  86052. * @param noMipmap defines if the engine should avoid generating the mip levels
  86053. * @param callback defines a callback used to extract texture data from loaded data
  86054. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  86055. * @param onLoad defines a callback called when texture is loaded
  86056. * @param onError defines a callback called if there is an error
  86057. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  86058. * @param invertY defines if data must be stored with Y axis inverted
  86059. * @returns the cube texture as an InternalTexture
  86060. */
  86061. 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;
  86062. /**
  86063. * Creates a new raw 3D texture
  86064. * @param data defines the data used to create the texture
  86065. * @param width defines the width of the texture
  86066. * @param height defines the height of the texture
  86067. * @param depth defines the depth of the texture
  86068. * @param format defines the format of the texture
  86069. * @param generateMipMaps defines if the engine must generate mip levels
  86070. * @param invertY defines if data must be stored with Y axis inverted
  86071. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  86072. * @param compression defines the compressed used (can be null)
  86073. * @param textureType defines the compressed used (can be null)
  86074. * @returns a new raw 3D texture (stored in an InternalTexture)
  86075. */
  86076. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  86077. /**
  86078. * Update a raw 3D texture
  86079. * @param texture defines the texture to update
  86080. * @param data defines the data to store
  86081. * @param format defines the data format
  86082. * @param invertY defines if data must be stored with Y axis inverted
  86083. */
  86084. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  86085. /**
  86086. * Update a raw 3D texture
  86087. * @param texture defines the texture to update
  86088. * @param data defines the data to store
  86089. * @param format defines the data format
  86090. * @param invertY defines if data must be stored with Y axis inverted
  86091. * @param compression defines the used compression (can be null)
  86092. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  86093. */
  86094. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  86095. /**
  86096. * Creates a new raw 2D array texture
  86097. * @param data defines the data used to create the texture
  86098. * @param width defines the width of the texture
  86099. * @param height defines the height of the texture
  86100. * @param depth defines the number of layers of the texture
  86101. * @param format defines the format of the texture
  86102. * @param generateMipMaps defines if the engine must generate mip levels
  86103. * @param invertY defines if data must be stored with Y axis inverted
  86104. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  86105. * @param compression defines the compressed used (can be null)
  86106. * @param textureType defines the compressed used (can be null)
  86107. * @returns a new raw 2D array texture (stored in an InternalTexture)
  86108. */
  86109. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  86110. /**
  86111. * Update a raw 2D array texture
  86112. * @param texture defines the texture to update
  86113. * @param data defines the data to store
  86114. * @param format defines the data format
  86115. * @param invertY defines if data must be stored with Y axis inverted
  86116. */
  86117. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  86118. /**
  86119. * Update a raw 2D array texture
  86120. * @param texture defines the texture to update
  86121. * @param data defines the data to store
  86122. * @param format defines the data format
  86123. * @param invertY defines if data must be stored with Y axis inverted
  86124. * @param compression defines the used compression (can be null)
  86125. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  86126. */
  86127. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  86128. }
  86129. }
  86130. declare module BABYLON {
  86131. /**
  86132. * Raw texture can help creating a texture directly from an array of data.
  86133. * This can be super useful if you either get the data from an uncompressed source or
  86134. * if you wish to create your texture pixel by pixel.
  86135. */
  86136. export class RawTexture extends Texture {
  86137. /**
  86138. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  86139. */
  86140. format: number;
  86141. private _engine;
  86142. /**
  86143. * Instantiates a new RawTexture.
  86144. * Raw texture can help creating a texture directly from an array of data.
  86145. * This can be super useful if you either get the data from an uncompressed source or
  86146. * if you wish to create your texture pixel by pixel.
  86147. * @param data define the array of data to use to create the texture
  86148. * @param width define the width of the texture
  86149. * @param height define the height of the texture
  86150. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  86151. * @param scene define the scene the texture belongs to
  86152. * @param generateMipMaps define whether mip maps should be generated or not
  86153. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  86154. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  86155. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  86156. */
  86157. constructor(data: ArrayBufferView, width: number, height: number,
  86158. /**
  86159. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  86160. */
  86161. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  86162. /**
  86163. * Updates the texture underlying data.
  86164. * @param data Define the new data of the texture
  86165. */
  86166. update(data: ArrayBufferView): void;
  86167. /**
  86168. * Creates a luminance texture from some data.
  86169. * @param data Define the texture data
  86170. * @param width Define the width of the texture
  86171. * @param height Define the height of the texture
  86172. * @param scene Define the scene the texture belongs to
  86173. * @param generateMipMaps Define whether or not to create mip maps for the texture
  86174. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  86175. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  86176. * @returns the luminance texture
  86177. */
  86178. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  86179. /**
  86180. * Creates a luminance alpha texture from some data.
  86181. * @param data Define the texture data
  86182. * @param width Define the width of the texture
  86183. * @param height Define the height of the texture
  86184. * @param scene Define the scene the texture belongs to
  86185. * @param generateMipMaps Define whether or not to create mip maps for the texture
  86186. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  86187. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  86188. * @returns the luminance alpha texture
  86189. */
  86190. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  86191. /**
  86192. * Creates an alpha texture from some data.
  86193. * @param data Define the texture data
  86194. * @param width Define the width of the texture
  86195. * @param height Define the height of the texture
  86196. * @param scene Define the scene the texture belongs to
  86197. * @param generateMipMaps Define whether or not to create mip maps for the texture
  86198. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  86199. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  86200. * @returns the alpha texture
  86201. */
  86202. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  86203. /**
  86204. * Creates a RGB texture from some data.
  86205. * @param data Define the texture data
  86206. * @param width Define the width of the texture
  86207. * @param height Define the height of the texture
  86208. * @param scene Define the scene the texture belongs to
  86209. * @param generateMipMaps Define whether or not to create mip maps for the texture
  86210. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  86211. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  86212. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  86213. * @returns the RGB alpha texture
  86214. */
  86215. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  86216. /**
  86217. * Creates a RGBA texture from some data.
  86218. * @param data Define the texture data
  86219. * @param width Define the width of the texture
  86220. * @param height Define the height of the texture
  86221. * @param scene Define the scene the texture belongs to
  86222. * @param generateMipMaps Define whether or not to create mip maps for the texture
  86223. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  86224. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  86225. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  86226. * @returns the RGBA texture
  86227. */
  86228. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  86229. /**
  86230. * Creates a R texture from some data.
  86231. * @param data Define the texture data
  86232. * @param width Define the width of the texture
  86233. * @param height Define the height of the texture
  86234. * @param scene Define the scene the texture belongs to
  86235. * @param generateMipMaps Define whether or not to create mip maps for the texture
  86236. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  86237. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  86238. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  86239. * @returns the R texture
  86240. */
  86241. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  86242. }
  86243. }
  86244. declare module BABYLON {
  86245. interface AbstractScene {
  86246. /**
  86247. * The list of procedural textures added to the scene
  86248. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  86249. */
  86250. proceduralTextures: Array<ProceduralTexture>;
  86251. }
  86252. /**
  86253. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  86254. * in a given scene.
  86255. */
  86256. export class ProceduralTextureSceneComponent implements ISceneComponent {
  86257. /**
  86258. * The component name helpfull to identify the component in the list of scene components.
  86259. */
  86260. readonly name: string;
  86261. /**
  86262. * The scene the component belongs to.
  86263. */
  86264. scene: Scene;
  86265. /**
  86266. * Creates a new instance of the component for the given scene
  86267. * @param scene Defines the scene to register the component in
  86268. */
  86269. constructor(scene: Scene);
  86270. /**
  86271. * Registers the component in a given scene
  86272. */
  86273. register(): void;
  86274. /**
  86275. * Rebuilds the elements related to this component in case of
  86276. * context lost for instance.
  86277. */
  86278. rebuild(): void;
  86279. /**
  86280. * Disposes the component and the associated ressources.
  86281. */
  86282. dispose(): void;
  86283. private _beforeClear;
  86284. }
  86285. }
  86286. declare module BABYLON {
  86287. interface ThinEngine {
  86288. /**
  86289. * Creates a new render target cube texture
  86290. * @param size defines the size of the texture
  86291. * @param options defines the options used to create the texture
  86292. * @returns a new render target cube texture stored in an InternalTexture
  86293. */
  86294. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  86295. }
  86296. }
  86297. declare module BABYLON {
  86298. /** @hidden */
  86299. export var proceduralVertexShader: {
  86300. name: string;
  86301. shader: string;
  86302. };
  86303. }
  86304. declare module BABYLON {
  86305. /**
  86306. * 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.
  86307. * This is the base class of any Procedural texture and contains most of the shareable code.
  86308. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  86309. */
  86310. export class ProceduralTexture extends Texture {
  86311. isCube: boolean;
  86312. /**
  86313. * Define if the texture is enabled or not (disabled texture will not render)
  86314. */
  86315. isEnabled: boolean;
  86316. /**
  86317. * Define if the texture must be cleared before rendering (default is true)
  86318. */
  86319. autoClear: boolean;
  86320. /**
  86321. * Callback called when the texture is generated
  86322. */
  86323. onGenerated: () => void;
  86324. /**
  86325. * Event raised when the texture is generated
  86326. */
  86327. onGeneratedObservable: Observable<ProceduralTexture>;
  86328. /** @hidden */
  86329. _generateMipMaps: boolean;
  86330. /** @hidden **/
  86331. _effect: Effect;
  86332. /** @hidden */
  86333. _textures: {
  86334. [key: string]: Texture;
  86335. };
  86336. /** @hidden */
  86337. protected _fallbackTexture: Nullable<Texture>;
  86338. private _size;
  86339. private _currentRefreshId;
  86340. private _frameId;
  86341. private _refreshRate;
  86342. private _vertexBuffers;
  86343. private _indexBuffer;
  86344. private _uniforms;
  86345. private _samplers;
  86346. private _fragment;
  86347. private _floats;
  86348. private _ints;
  86349. private _floatsArrays;
  86350. private _colors3;
  86351. private _colors4;
  86352. private _vectors2;
  86353. private _vectors3;
  86354. private _matrices;
  86355. private _fallbackTextureUsed;
  86356. private _engine;
  86357. private _cachedDefines;
  86358. private _contentUpdateId;
  86359. private _contentData;
  86360. /**
  86361. * Instantiates a new procedural texture.
  86362. * 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.
  86363. * This is the base class of any Procedural texture and contains most of the shareable code.
  86364. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  86365. * @param name Define the name of the texture
  86366. * @param size Define the size of the texture to create
  86367. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  86368. * @param scene Define the scene the texture belongs to
  86369. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  86370. * @param generateMipMaps Define if the texture should creates mip maps or not
  86371. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  86372. */
  86373. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  86374. /**
  86375. * The effect that is created when initializing the post process.
  86376. * @returns The created effect corresponding the the postprocess.
  86377. */
  86378. getEffect(): Effect;
  86379. /**
  86380. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  86381. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  86382. */
  86383. getContent(): Nullable<ArrayBufferView>;
  86384. private _createIndexBuffer;
  86385. /** @hidden */
  86386. _rebuild(): void;
  86387. /**
  86388. * Resets the texture in order to recreate its associated resources.
  86389. * This can be called in case of context loss
  86390. */
  86391. reset(): void;
  86392. protected _getDefines(): string;
  86393. /**
  86394. * Is the texture ready to be used ? (rendered at least once)
  86395. * @returns true if ready, otherwise, false.
  86396. */
  86397. isReady(): boolean;
  86398. /**
  86399. * Resets the refresh counter of the texture and start bak from scratch.
  86400. * Could be useful to regenerate the texture if it is setup to render only once.
  86401. */
  86402. resetRefreshCounter(): void;
  86403. /**
  86404. * Set the fragment shader to use in order to render the texture.
  86405. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  86406. */
  86407. setFragment(fragment: any): void;
  86408. /**
  86409. * Define the refresh rate of the texture or the rendering frequency.
  86410. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  86411. */
  86412. get refreshRate(): number;
  86413. set refreshRate(value: number);
  86414. /** @hidden */
  86415. _shouldRender(): boolean;
  86416. /**
  86417. * Get the size the texture is rendering at.
  86418. * @returns the size (texture is always squared)
  86419. */
  86420. getRenderSize(): number;
  86421. /**
  86422. * Resize the texture to new value.
  86423. * @param size Define the new size the texture should have
  86424. * @param generateMipMaps Define whether the new texture should create mip maps
  86425. */
  86426. resize(size: number, generateMipMaps: boolean): void;
  86427. private _checkUniform;
  86428. /**
  86429. * Set a texture in the shader program used to render.
  86430. * @param name Define the name of the uniform samplers as defined in the shader
  86431. * @param texture Define the texture to bind to this sampler
  86432. * @return the texture itself allowing "fluent" like uniform updates
  86433. */
  86434. setTexture(name: string, texture: Texture): ProceduralTexture;
  86435. /**
  86436. * Set a float in the shader.
  86437. * @param name Define the name of the uniform as defined in the shader
  86438. * @param value Define the value to give to the uniform
  86439. * @return the texture itself allowing "fluent" like uniform updates
  86440. */
  86441. setFloat(name: string, value: number): ProceduralTexture;
  86442. /**
  86443. * Set a int in the shader.
  86444. * @param name Define the name of the uniform as defined in the shader
  86445. * @param value Define the value to give to the uniform
  86446. * @return the texture itself allowing "fluent" like uniform updates
  86447. */
  86448. setInt(name: string, value: number): ProceduralTexture;
  86449. /**
  86450. * Set an array of floats in the shader.
  86451. * @param name Define the name of the uniform as defined in the shader
  86452. * @param value Define the value to give to the uniform
  86453. * @return the texture itself allowing "fluent" like uniform updates
  86454. */
  86455. setFloats(name: string, value: number[]): ProceduralTexture;
  86456. /**
  86457. * Set a vec3 in the shader from a Color3.
  86458. * @param name Define the name of the uniform as defined in the shader
  86459. * @param value Define the value to give to the uniform
  86460. * @return the texture itself allowing "fluent" like uniform updates
  86461. */
  86462. setColor3(name: string, value: Color3): ProceduralTexture;
  86463. /**
  86464. * Set a vec4 in the shader from a Color4.
  86465. * @param name Define the name of the uniform as defined in the shader
  86466. * @param value Define the value to give to the uniform
  86467. * @return the texture itself allowing "fluent" like uniform updates
  86468. */
  86469. setColor4(name: string, value: Color4): ProceduralTexture;
  86470. /**
  86471. * Set a vec2 in the shader from a Vector2.
  86472. * @param name Define the name of the uniform as defined in the shader
  86473. * @param value Define the value to give to the uniform
  86474. * @return the texture itself allowing "fluent" like uniform updates
  86475. */
  86476. setVector2(name: string, value: Vector2): ProceduralTexture;
  86477. /**
  86478. * Set a vec3 in the shader from a Vector3.
  86479. * @param name Define the name of the uniform as defined in the shader
  86480. * @param value Define the value to give to the uniform
  86481. * @return the texture itself allowing "fluent" like uniform updates
  86482. */
  86483. setVector3(name: string, value: Vector3): ProceduralTexture;
  86484. /**
  86485. * Set a mat4 in the shader from a MAtrix.
  86486. * @param name Define the name of the uniform as defined in the shader
  86487. * @param value Define the value to give to the uniform
  86488. * @return the texture itself allowing "fluent" like uniform updates
  86489. */
  86490. setMatrix(name: string, value: Matrix): ProceduralTexture;
  86491. /**
  86492. * Render the texture to its associated render target.
  86493. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  86494. */
  86495. render(useCameraPostProcess?: boolean): void;
  86496. /**
  86497. * Clone the texture.
  86498. * @returns the cloned texture
  86499. */
  86500. clone(): ProceduralTexture;
  86501. /**
  86502. * Dispose the texture and release its asoociated resources.
  86503. */
  86504. dispose(): void;
  86505. }
  86506. }
  86507. declare module BABYLON {
  86508. /**
  86509. * This represents the base class for particle system in Babylon.
  86510. * 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.
  86511. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  86512. * @example https://doc.babylonjs.com/babylon101/particles
  86513. */
  86514. export class BaseParticleSystem {
  86515. /**
  86516. * Source color is added to the destination color without alpha affecting the result
  86517. */
  86518. static BLENDMODE_ONEONE: number;
  86519. /**
  86520. * Blend current color and particle color using particle’s alpha
  86521. */
  86522. static BLENDMODE_STANDARD: number;
  86523. /**
  86524. * Add current color and particle color multiplied by particle’s alpha
  86525. */
  86526. static BLENDMODE_ADD: number;
  86527. /**
  86528. * Multiply current color with particle color
  86529. */
  86530. static BLENDMODE_MULTIPLY: number;
  86531. /**
  86532. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  86533. */
  86534. static BLENDMODE_MULTIPLYADD: number;
  86535. /**
  86536. * List of animations used by the particle system.
  86537. */
  86538. animations: Animation[];
  86539. /**
  86540. * Gets or sets the unique id of the particle system
  86541. */
  86542. uniqueId: number;
  86543. /**
  86544. * The id of the Particle system.
  86545. */
  86546. id: string;
  86547. /**
  86548. * The friendly name of the Particle system.
  86549. */
  86550. name: string;
  86551. /**
  86552. * Snippet ID if the particle system was created from the snippet server
  86553. */
  86554. snippetId: string;
  86555. /**
  86556. * The rendering group used by the Particle system to chose when to render.
  86557. */
  86558. renderingGroupId: number;
  86559. /**
  86560. * The emitter represents the Mesh or position we are attaching the particle system to.
  86561. */
  86562. emitter: Nullable<AbstractMesh | Vector3>;
  86563. /**
  86564. * The maximum number of particles to emit per frame
  86565. */
  86566. emitRate: number;
  86567. /**
  86568. * If you want to launch only a few particles at once, that can be done, as well.
  86569. */
  86570. manualEmitCount: number;
  86571. /**
  86572. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  86573. */
  86574. updateSpeed: number;
  86575. /**
  86576. * The amount of time the particle system is running (depends of the overall update speed).
  86577. */
  86578. targetStopDuration: number;
  86579. /**
  86580. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  86581. */
  86582. disposeOnStop: boolean;
  86583. /**
  86584. * Minimum power of emitting particles.
  86585. */
  86586. minEmitPower: number;
  86587. /**
  86588. * Maximum power of emitting particles.
  86589. */
  86590. maxEmitPower: number;
  86591. /**
  86592. * Minimum life time of emitting particles.
  86593. */
  86594. minLifeTime: number;
  86595. /**
  86596. * Maximum life time of emitting particles.
  86597. */
  86598. maxLifeTime: number;
  86599. /**
  86600. * Minimum Size of emitting particles.
  86601. */
  86602. minSize: number;
  86603. /**
  86604. * Maximum Size of emitting particles.
  86605. */
  86606. maxSize: number;
  86607. /**
  86608. * Minimum scale of emitting particles on X axis.
  86609. */
  86610. minScaleX: number;
  86611. /**
  86612. * Maximum scale of emitting particles on X axis.
  86613. */
  86614. maxScaleX: number;
  86615. /**
  86616. * Minimum scale of emitting particles on Y axis.
  86617. */
  86618. minScaleY: number;
  86619. /**
  86620. * Maximum scale of emitting particles on Y axis.
  86621. */
  86622. maxScaleY: number;
  86623. /**
  86624. * Gets or sets the minimal initial rotation in radians.
  86625. */
  86626. minInitialRotation: number;
  86627. /**
  86628. * Gets or sets the maximal initial rotation in radians.
  86629. */
  86630. maxInitialRotation: number;
  86631. /**
  86632. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  86633. */
  86634. minAngularSpeed: number;
  86635. /**
  86636. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  86637. */
  86638. maxAngularSpeed: number;
  86639. /**
  86640. * The texture used to render each particle. (this can be a spritesheet)
  86641. */
  86642. particleTexture: Nullable<Texture>;
  86643. /**
  86644. * The layer mask we are rendering the particles through.
  86645. */
  86646. layerMask: number;
  86647. /**
  86648. * This can help using your own shader to render the particle system.
  86649. * The according effect will be created
  86650. */
  86651. customShader: any;
  86652. /**
  86653. * By default particle system starts as soon as they are created. This prevents the
  86654. * automatic start to happen and let you decide when to start emitting particles.
  86655. */
  86656. preventAutoStart: boolean;
  86657. private _noiseTexture;
  86658. /**
  86659. * Gets or sets a texture used to add random noise to particle positions
  86660. */
  86661. get noiseTexture(): Nullable<ProceduralTexture>;
  86662. set noiseTexture(value: Nullable<ProceduralTexture>);
  86663. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  86664. noiseStrength: Vector3;
  86665. /**
  86666. * Callback triggered when the particle animation is ending.
  86667. */
  86668. onAnimationEnd: Nullable<() => void>;
  86669. /**
  86670. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  86671. */
  86672. blendMode: number;
  86673. /**
  86674. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  86675. * to override the particles.
  86676. */
  86677. forceDepthWrite: boolean;
  86678. /** 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 */
  86679. preWarmCycles: number;
  86680. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  86681. preWarmStepOffset: number;
  86682. /**
  86683. * 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)
  86684. */
  86685. spriteCellChangeSpeed: number;
  86686. /**
  86687. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  86688. */
  86689. startSpriteCellID: number;
  86690. /**
  86691. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  86692. */
  86693. endSpriteCellID: number;
  86694. /**
  86695. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  86696. */
  86697. spriteCellWidth: number;
  86698. /**
  86699. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  86700. */
  86701. spriteCellHeight: number;
  86702. /**
  86703. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  86704. */
  86705. spriteRandomStartCell: boolean;
  86706. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  86707. translationPivot: Vector2;
  86708. /** @hidden */
  86709. protected _isAnimationSheetEnabled: boolean;
  86710. /**
  86711. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  86712. */
  86713. beginAnimationOnStart: boolean;
  86714. /**
  86715. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  86716. */
  86717. beginAnimationFrom: number;
  86718. /**
  86719. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  86720. */
  86721. beginAnimationTo: number;
  86722. /**
  86723. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  86724. */
  86725. beginAnimationLoop: boolean;
  86726. /**
  86727. * Gets or sets a world offset applied to all particles
  86728. */
  86729. worldOffset: Vector3;
  86730. /**
  86731. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  86732. */
  86733. get isAnimationSheetEnabled(): boolean;
  86734. set isAnimationSheetEnabled(value: boolean);
  86735. /**
  86736. * Get hosting scene
  86737. * @returns the scene
  86738. */
  86739. getScene(): Scene;
  86740. /**
  86741. * You can use gravity if you want to give an orientation to your particles.
  86742. */
  86743. gravity: Vector3;
  86744. protected _colorGradients: Nullable<Array<ColorGradient>>;
  86745. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  86746. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  86747. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  86748. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  86749. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  86750. protected _dragGradients: Nullable<Array<FactorGradient>>;
  86751. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  86752. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  86753. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  86754. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  86755. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  86756. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  86757. /**
  86758. * Defines the delay in milliseconds before starting the system (0 by default)
  86759. */
  86760. startDelay: number;
  86761. /**
  86762. * Gets the current list of drag gradients.
  86763. * You must use addDragGradient and removeDragGradient to udpate this list
  86764. * @returns the list of drag gradients
  86765. */
  86766. getDragGradients(): Nullable<Array<FactorGradient>>;
  86767. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  86768. limitVelocityDamping: number;
  86769. /**
  86770. * Gets the current list of limit velocity gradients.
  86771. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  86772. * @returns the list of limit velocity gradients
  86773. */
  86774. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  86775. /**
  86776. * Gets the current list of color gradients.
  86777. * You must use addColorGradient and removeColorGradient to udpate this list
  86778. * @returns the list of color gradients
  86779. */
  86780. getColorGradients(): Nullable<Array<ColorGradient>>;
  86781. /**
  86782. * Gets the current list of size gradients.
  86783. * You must use addSizeGradient and removeSizeGradient to udpate this list
  86784. * @returns the list of size gradients
  86785. */
  86786. getSizeGradients(): Nullable<Array<FactorGradient>>;
  86787. /**
  86788. * Gets the current list of color remap gradients.
  86789. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  86790. * @returns the list of color remap gradients
  86791. */
  86792. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  86793. /**
  86794. * Gets the current list of alpha remap gradients.
  86795. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  86796. * @returns the list of alpha remap gradients
  86797. */
  86798. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  86799. /**
  86800. * Gets the current list of life time gradients.
  86801. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  86802. * @returns the list of life time gradients
  86803. */
  86804. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  86805. /**
  86806. * Gets the current list of angular speed gradients.
  86807. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  86808. * @returns the list of angular speed gradients
  86809. */
  86810. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  86811. /**
  86812. * Gets the current list of velocity gradients.
  86813. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  86814. * @returns the list of velocity gradients
  86815. */
  86816. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  86817. /**
  86818. * Gets the current list of start size gradients.
  86819. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  86820. * @returns the list of start size gradients
  86821. */
  86822. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  86823. /**
  86824. * Gets the current list of emit rate gradients.
  86825. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  86826. * @returns the list of emit rate gradients
  86827. */
  86828. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  86829. /**
  86830. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  86831. * This only works when particleEmitterTyps is a BoxParticleEmitter
  86832. */
  86833. get direction1(): Vector3;
  86834. set direction1(value: Vector3);
  86835. /**
  86836. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  86837. * This only works when particleEmitterTyps is a BoxParticleEmitter
  86838. */
  86839. get direction2(): Vector3;
  86840. set direction2(value: Vector3);
  86841. /**
  86842. * 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.
  86843. * This only works when particleEmitterTyps is a BoxParticleEmitter
  86844. */
  86845. get minEmitBox(): Vector3;
  86846. set minEmitBox(value: Vector3);
  86847. /**
  86848. * 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.
  86849. * This only works when particleEmitterTyps is a BoxParticleEmitter
  86850. */
  86851. get maxEmitBox(): Vector3;
  86852. set maxEmitBox(value: Vector3);
  86853. /**
  86854. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  86855. */
  86856. color1: Color4;
  86857. /**
  86858. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  86859. */
  86860. color2: Color4;
  86861. /**
  86862. * Color the particle will have at the end of its lifetime
  86863. */
  86864. colorDead: Color4;
  86865. /**
  86866. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  86867. */
  86868. textureMask: Color4;
  86869. /**
  86870. * The particle emitter type defines the emitter used by the particle system.
  86871. * It can be for example box, sphere, or cone...
  86872. */
  86873. particleEmitterType: IParticleEmitterType;
  86874. /** @hidden */
  86875. _isSubEmitter: boolean;
  86876. /**
  86877. * Gets or sets the billboard mode to use when isBillboardBased = true.
  86878. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  86879. */
  86880. billboardMode: number;
  86881. protected _isBillboardBased: boolean;
  86882. /**
  86883. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  86884. */
  86885. get isBillboardBased(): boolean;
  86886. set isBillboardBased(value: boolean);
  86887. /**
  86888. * The scene the particle system belongs to.
  86889. */
  86890. protected _scene: Scene;
  86891. /**
  86892. * Local cache of defines for image processing.
  86893. */
  86894. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  86895. /**
  86896. * Default configuration related to image processing available in the standard Material.
  86897. */
  86898. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  86899. /**
  86900. * Gets the image processing configuration used either in this material.
  86901. */
  86902. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  86903. /**
  86904. * Sets the Default image processing configuration used either in the this material.
  86905. *
  86906. * If sets to null, the scene one is in use.
  86907. */
  86908. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  86909. /**
  86910. * Attaches a new image processing configuration to the Standard Material.
  86911. * @param configuration
  86912. */
  86913. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  86914. /** @hidden */
  86915. protected _reset(): void;
  86916. /** @hidden */
  86917. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  86918. /**
  86919. * Instantiates a particle system.
  86920. * 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.
  86921. * @param name The name of the particle system
  86922. */
  86923. constructor(name: string);
  86924. /**
  86925. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  86926. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  86927. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  86928. * @returns the emitter
  86929. */
  86930. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  86931. /**
  86932. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  86933. * @param radius The radius of the hemisphere to emit from
  86934. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  86935. * @returns the emitter
  86936. */
  86937. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  86938. /**
  86939. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  86940. * @param radius The radius of the sphere to emit from
  86941. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  86942. * @returns the emitter
  86943. */
  86944. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  86945. /**
  86946. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  86947. * @param radius The radius of the sphere to emit from
  86948. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  86949. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  86950. * @returns the emitter
  86951. */
  86952. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  86953. /**
  86954. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  86955. * @param radius The radius of the emission cylinder
  86956. * @param height The height of the emission cylinder
  86957. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  86958. * @param directionRandomizer How much to randomize the particle direction [0-1]
  86959. * @returns the emitter
  86960. */
  86961. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  86962. /**
  86963. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  86964. * @param radius The radius of the cylinder to emit from
  86965. * @param height The height of the emission cylinder
  86966. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  86967. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  86968. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  86969. * @returns the emitter
  86970. */
  86971. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  86972. /**
  86973. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  86974. * @param radius The radius of the cone to emit from
  86975. * @param angle The base angle of the cone
  86976. * @returns the emitter
  86977. */
  86978. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  86979. /**
  86980. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  86981. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  86982. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  86983. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  86984. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  86985. * @returns the emitter
  86986. */
  86987. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  86988. }
  86989. }
  86990. declare module BABYLON {
  86991. /**
  86992. * Type of sub emitter
  86993. */
  86994. export enum SubEmitterType {
  86995. /**
  86996. * Attached to the particle over it's lifetime
  86997. */
  86998. ATTACHED = 0,
  86999. /**
  87000. * Created when the particle dies
  87001. */
  87002. END = 1
  87003. }
  87004. /**
  87005. * Sub emitter class used to emit particles from an existing particle
  87006. */
  87007. export class SubEmitter {
  87008. /**
  87009. * the particle system to be used by the sub emitter
  87010. */
  87011. particleSystem: ParticleSystem;
  87012. /**
  87013. * Type of the submitter (Default: END)
  87014. */
  87015. type: SubEmitterType;
  87016. /**
  87017. * 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)
  87018. * Note: This only is supported when using an emitter of type Mesh
  87019. */
  87020. inheritDirection: boolean;
  87021. /**
  87022. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  87023. */
  87024. inheritedVelocityAmount: number;
  87025. /**
  87026. * Creates a sub emitter
  87027. * @param particleSystem the particle system to be used by the sub emitter
  87028. */
  87029. constructor(
  87030. /**
  87031. * the particle system to be used by the sub emitter
  87032. */
  87033. particleSystem: ParticleSystem);
  87034. /**
  87035. * Clones the sub emitter
  87036. * @returns the cloned sub emitter
  87037. */
  87038. clone(): SubEmitter;
  87039. /**
  87040. * Serialize current object to a JSON object
  87041. * @returns the serialized object
  87042. */
  87043. serialize(): any;
  87044. /** @hidden */
  87045. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  87046. /**
  87047. * Creates a new SubEmitter from a serialized JSON version
  87048. * @param serializationObject defines the JSON object to read from
  87049. * @param scene defines the hosting scene
  87050. * @param rootUrl defines the rootUrl for data loading
  87051. * @returns a new SubEmitter
  87052. */
  87053. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  87054. /** Release associated resources */
  87055. dispose(): void;
  87056. }
  87057. }
  87058. declare module BABYLON {
  87059. /** @hidden */
  87060. export var imageProcessingDeclaration: {
  87061. name: string;
  87062. shader: string;
  87063. };
  87064. }
  87065. declare module BABYLON {
  87066. /** @hidden */
  87067. export var imageProcessingFunctions: {
  87068. name: string;
  87069. shader: string;
  87070. };
  87071. }
  87072. declare module BABYLON {
  87073. /** @hidden */
  87074. export var particlesPixelShader: {
  87075. name: string;
  87076. shader: string;
  87077. };
  87078. }
  87079. declare module BABYLON {
  87080. /** @hidden */
  87081. export var particlesVertexShader: {
  87082. name: string;
  87083. shader: string;
  87084. };
  87085. }
  87086. declare module BABYLON {
  87087. /**
  87088. * This represents a particle system in Babylon.
  87089. * 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.
  87090. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  87091. * @example https://doc.babylonjs.com/babylon101/particles
  87092. */
  87093. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  87094. /**
  87095. * Billboard mode will only apply to Y axis
  87096. */
  87097. static readonly BILLBOARDMODE_Y: number;
  87098. /**
  87099. * Billboard mode will apply to all axes
  87100. */
  87101. static readonly BILLBOARDMODE_ALL: number;
  87102. /**
  87103. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  87104. */
  87105. static readonly BILLBOARDMODE_STRETCHED: number;
  87106. /**
  87107. * This function can be defined to provide custom update for active particles.
  87108. * This function will be called instead of regular update (age, position, color, etc.).
  87109. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  87110. */
  87111. updateFunction: (particles: Particle[]) => void;
  87112. private _emitterWorldMatrix;
  87113. /**
  87114. * This function can be defined to specify initial direction for every new particle.
  87115. * It by default use the emitterType defined function
  87116. */
  87117. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  87118. /**
  87119. * This function can be defined to specify initial position for every new particle.
  87120. * It by default use the emitterType defined function
  87121. */
  87122. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  87123. /**
  87124. * @hidden
  87125. */
  87126. _inheritedVelocityOffset: Vector3;
  87127. /**
  87128. * An event triggered when the system is disposed
  87129. */
  87130. onDisposeObservable: Observable<ParticleSystem>;
  87131. private _onDisposeObserver;
  87132. /**
  87133. * Sets a callback that will be triggered when the system is disposed
  87134. */
  87135. set onDispose(callback: () => void);
  87136. private _particles;
  87137. private _epsilon;
  87138. private _capacity;
  87139. private _stockParticles;
  87140. private _newPartsExcess;
  87141. private _vertexData;
  87142. private _vertexBuffer;
  87143. private _vertexBuffers;
  87144. private _spriteBuffer;
  87145. private _indexBuffer;
  87146. private _effect;
  87147. private _customEffect;
  87148. private _cachedDefines;
  87149. private _scaledColorStep;
  87150. private _colorDiff;
  87151. private _scaledDirection;
  87152. private _scaledGravity;
  87153. private _currentRenderId;
  87154. private _alive;
  87155. private _useInstancing;
  87156. private _started;
  87157. private _stopped;
  87158. private _actualFrame;
  87159. private _scaledUpdateSpeed;
  87160. private _vertexBufferSize;
  87161. /** @hidden */
  87162. _currentEmitRateGradient: Nullable<FactorGradient>;
  87163. /** @hidden */
  87164. _currentEmitRate1: number;
  87165. /** @hidden */
  87166. _currentEmitRate2: number;
  87167. /** @hidden */
  87168. _currentStartSizeGradient: Nullable<FactorGradient>;
  87169. /** @hidden */
  87170. _currentStartSize1: number;
  87171. /** @hidden */
  87172. _currentStartSize2: number;
  87173. private readonly _rawTextureWidth;
  87174. private _rampGradientsTexture;
  87175. private _useRampGradients;
  87176. /** Gets or sets a boolean indicating that ramp gradients must be used
  87177. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  87178. */
  87179. get useRampGradients(): boolean;
  87180. set useRampGradients(value: boolean);
  87181. /**
  87182. * 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.
  87183. * 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: [])
  87184. */
  87185. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  87186. private _subEmitters;
  87187. /**
  87188. * @hidden
  87189. * If the particle systems emitter should be disposed when the particle system is disposed
  87190. */
  87191. _disposeEmitterOnDispose: boolean;
  87192. /**
  87193. * The current active Sub-systems, this property is used by the root particle system only.
  87194. */
  87195. activeSubSystems: Array<ParticleSystem>;
  87196. /**
  87197. * Specifies if the particles are updated in emitter local space or world space
  87198. */
  87199. isLocal: boolean;
  87200. private _rootParticleSystem;
  87201. /**
  87202. * Gets the current list of active particles
  87203. */
  87204. get particles(): Particle[];
  87205. /**
  87206. * Gets the number of particles active at the same time.
  87207. * @returns The number of active particles.
  87208. */
  87209. getActiveCount(): number;
  87210. /**
  87211. * Returns the string "ParticleSystem"
  87212. * @returns a string containing the class name
  87213. */
  87214. getClassName(): string;
  87215. /**
  87216. * Gets a boolean indicating that the system is stopping
  87217. * @returns true if the system is currently stopping
  87218. */
  87219. isStopping(): boolean;
  87220. /**
  87221. * Instantiates a particle system.
  87222. * 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.
  87223. * @param name The name of the particle system
  87224. * @param capacity The max number of particles alive at the same time
  87225. * @param scene The scene the particle system belongs to
  87226. * @param customEffect a custom effect used to change the way particles are rendered by default
  87227. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  87228. * @param epsilon Offset used to render the particles
  87229. */
  87230. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  87231. private _addFactorGradient;
  87232. private _removeFactorGradient;
  87233. /**
  87234. * Adds a new life time gradient
  87235. * @param gradient defines the gradient to use (between 0 and 1)
  87236. * @param factor defines the life time factor to affect to the specified gradient
  87237. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  87238. * @returns the current particle system
  87239. */
  87240. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  87241. /**
  87242. * Remove a specific life time gradient
  87243. * @param gradient defines the gradient to remove
  87244. * @returns the current particle system
  87245. */
  87246. removeLifeTimeGradient(gradient: number): IParticleSystem;
  87247. /**
  87248. * Adds a new size gradient
  87249. * @param gradient defines the gradient to use (between 0 and 1)
  87250. * @param factor defines the size factor to affect to the specified gradient
  87251. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  87252. * @returns the current particle system
  87253. */
  87254. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  87255. /**
  87256. * Remove a specific size gradient
  87257. * @param gradient defines the gradient to remove
  87258. * @returns the current particle system
  87259. */
  87260. removeSizeGradient(gradient: number): IParticleSystem;
  87261. /**
  87262. * Adds a new color remap gradient
  87263. * @param gradient defines the gradient to use (between 0 and 1)
  87264. * @param min defines the color remap minimal range
  87265. * @param max defines the color remap maximal range
  87266. * @returns the current particle system
  87267. */
  87268. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  87269. /**
  87270. * Remove a specific color remap gradient
  87271. * @param gradient defines the gradient to remove
  87272. * @returns the current particle system
  87273. */
  87274. removeColorRemapGradient(gradient: number): IParticleSystem;
  87275. /**
  87276. * Adds a new alpha remap gradient
  87277. * @param gradient defines the gradient to use (between 0 and 1)
  87278. * @param min defines the alpha remap minimal range
  87279. * @param max defines the alpha remap maximal range
  87280. * @returns the current particle system
  87281. */
  87282. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  87283. /**
  87284. * Remove a specific alpha remap gradient
  87285. * @param gradient defines the gradient to remove
  87286. * @returns the current particle system
  87287. */
  87288. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  87289. /**
  87290. * Adds a new angular speed gradient
  87291. * @param gradient defines the gradient to use (between 0 and 1)
  87292. * @param factor defines the angular speed to affect to the specified gradient
  87293. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  87294. * @returns the current particle system
  87295. */
  87296. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  87297. /**
  87298. * Remove a specific angular speed gradient
  87299. * @param gradient defines the gradient to remove
  87300. * @returns the current particle system
  87301. */
  87302. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  87303. /**
  87304. * Adds a new velocity gradient
  87305. * @param gradient defines the gradient to use (between 0 and 1)
  87306. * @param factor defines the velocity to affect to the specified gradient
  87307. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  87308. * @returns the current particle system
  87309. */
  87310. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  87311. /**
  87312. * Remove a specific velocity gradient
  87313. * @param gradient defines the gradient to remove
  87314. * @returns the current particle system
  87315. */
  87316. removeVelocityGradient(gradient: number): IParticleSystem;
  87317. /**
  87318. * Adds a new limit velocity gradient
  87319. * @param gradient defines the gradient to use (between 0 and 1)
  87320. * @param factor defines the limit velocity value to affect to the specified gradient
  87321. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  87322. * @returns the current particle system
  87323. */
  87324. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  87325. /**
  87326. * Remove a specific limit velocity gradient
  87327. * @param gradient defines the gradient to remove
  87328. * @returns the current particle system
  87329. */
  87330. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  87331. /**
  87332. * Adds a new drag gradient
  87333. * @param gradient defines the gradient to use (between 0 and 1)
  87334. * @param factor defines the drag value to affect to the specified gradient
  87335. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  87336. * @returns the current particle system
  87337. */
  87338. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  87339. /**
  87340. * Remove a specific drag gradient
  87341. * @param gradient defines the gradient to remove
  87342. * @returns the current particle system
  87343. */
  87344. removeDragGradient(gradient: number): IParticleSystem;
  87345. /**
  87346. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  87347. * @param gradient defines the gradient to use (between 0 and 1)
  87348. * @param factor defines the emit rate value to affect to the specified gradient
  87349. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  87350. * @returns the current particle system
  87351. */
  87352. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  87353. /**
  87354. * Remove a specific emit rate gradient
  87355. * @param gradient defines the gradient to remove
  87356. * @returns the current particle system
  87357. */
  87358. removeEmitRateGradient(gradient: number): IParticleSystem;
  87359. /**
  87360. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  87361. * @param gradient defines the gradient to use (between 0 and 1)
  87362. * @param factor defines the start size value to affect to the specified gradient
  87363. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  87364. * @returns the current particle system
  87365. */
  87366. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  87367. /**
  87368. * Remove a specific start size gradient
  87369. * @param gradient defines the gradient to remove
  87370. * @returns the current particle system
  87371. */
  87372. removeStartSizeGradient(gradient: number): IParticleSystem;
  87373. private _createRampGradientTexture;
  87374. /**
  87375. * Gets the current list of ramp gradients.
  87376. * You must use addRampGradient and removeRampGradient to udpate this list
  87377. * @returns the list of ramp gradients
  87378. */
  87379. getRampGradients(): Nullable<Array<Color3Gradient>>;
  87380. /** Force the system to rebuild all gradients that need to be resync */
  87381. forceRefreshGradients(): void;
  87382. private _syncRampGradientTexture;
  87383. /**
  87384. * Adds a new ramp gradient used to remap particle colors
  87385. * @param gradient defines the gradient to use (between 0 and 1)
  87386. * @param color defines the color to affect to the specified gradient
  87387. * @returns the current particle system
  87388. */
  87389. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  87390. /**
  87391. * Remove a specific ramp gradient
  87392. * @param gradient defines the gradient to remove
  87393. * @returns the current particle system
  87394. */
  87395. removeRampGradient(gradient: number): ParticleSystem;
  87396. /**
  87397. * Adds a new color gradient
  87398. * @param gradient defines the gradient to use (between 0 and 1)
  87399. * @param color1 defines the color to affect to the specified gradient
  87400. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  87401. * @returns this particle system
  87402. */
  87403. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  87404. /**
  87405. * Remove a specific color gradient
  87406. * @param gradient defines the gradient to remove
  87407. * @returns this particle system
  87408. */
  87409. removeColorGradient(gradient: number): IParticleSystem;
  87410. private _fetchR;
  87411. protected _reset(): void;
  87412. private _resetEffect;
  87413. private _createVertexBuffers;
  87414. private _createIndexBuffer;
  87415. /**
  87416. * Gets the maximum number of particles active at the same time.
  87417. * @returns The max number of active particles.
  87418. */
  87419. getCapacity(): number;
  87420. /**
  87421. * Gets whether there are still active particles in the system.
  87422. * @returns True if it is alive, otherwise false.
  87423. */
  87424. isAlive(): boolean;
  87425. /**
  87426. * Gets if the system has been started. (Note: this will still be true after stop is called)
  87427. * @returns True if it has been started, otherwise false.
  87428. */
  87429. isStarted(): boolean;
  87430. private _prepareSubEmitterInternalArray;
  87431. /**
  87432. * Starts the particle system and begins to emit
  87433. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  87434. */
  87435. start(delay?: number): void;
  87436. /**
  87437. * Stops the particle system.
  87438. * @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.
  87439. */
  87440. stop(stopSubEmitters?: boolean): void;
  87441. /**
  87442. * Remove all active particles
  87443. */
  87444. reset(): void;
  87445. /**
  87446. * @hidden (for internal use only)
  87447. */
  87448. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  87449. /**
  87450. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  87451. * Its lifetime will start back at 0.
  87452. */
  87453. recycleParticle: (particle: Particle) => void;
  87454. private _stopSubEmitters;
  87455. private _createParticle;
  87456. private _removeFromRoot;
  87457. private _emitFromParticle;
  87458. private _update;
  87459. /** @hidden */
  87460. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  87461. /** @hidden */
  87462. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  87463. /** @hidden */
  87464. private _getEffect;
  87465. /**
  87466. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  87467. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  87468. */
  87469. animate(preWarmOnly?: boolean): void;
  87470. private _appendParticleVertices;
  87471. /**
  87472. * Rebuilds the particle system.
  87473. */
  87474. rebuild(): void;
  87475. /**
  87476. * Is this system ready to be used/rendered
  87477. * @return true if the system is ready
  87478. */
  87479. isReady(): boolean;
  87480. private _render;
  87481. /**
  87482. * Renders the particle system in its current state.
  87483. * @returns the current number of particles
  87484. */
  87485. render(): number;
  87486. /**
  87487. * Disposes the particle system and free the associated resources
  87488. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  87489. */
  87490. dispose(disposeTexture?: boolean): void;
  87491. /**
  87492. * Clones the particle system.
  87493. * @param name The name of the cloned object
  87494. * @param newEmitter The new emitter to use
  87495. * @returns the cloned particle system
  87496. */
  87497. clone(name: string, newEmitter: any): ParticleSystem;
  87498. /**
  87499. * Serializes the particle system to a JSON object
  87500. * @param serializeTexture defines if the texture must be serialized as well
  87501. * @returns the JSON object
  87502. */
  87503. serialize(serializeTexture?: boolean): any;
  87504. /** @hidden */
  87505. static _Serialize(serializationObject: any, particleSystem: IParticleSystem, serializeTexture: boolean): void;
  87506. /** @hidden */
  87507. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  87508. /**
  87509. * Parses a JSON object to create a particle system.
  87510. * @param parsedParticleSystem The JSON object to parse
  87511. * @param scene The scene to create the particle system in
  87512. * @param rootUrl The root url to use to load external dependencies like texture
  87513. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  87514. * @returns the Parsed particle system
  87515. */
  87516. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  87517. }
  87518. }
  87519. declare module BABYLON {
  87520. /**
  87521. * A particle represents one of the element emitted by a particle system.
  87522. * This is mainly define by its coordinates, direction, velocity and age.
  87523. */
  87524. export class Particle {
  87525. /**
  87526. * The particle system the particle belongs to.
  87527. */
  87528. particleSystem: ParticleSystem;
  87529. private static _Count;
  87530. /**
  87531. * Unique ID of the particle
  87532. */
  87533. id: number;
  87534. /**
  87535. * The world position of the particle in the scene.
  87536. */
  87537. position: Vector3;
  87538. /**
  87539. * The world direction of the particle in the scene.
  87540. */
  87541. direction: Vector3;
  87542. /**
  87543. * The color of the particle.
  87544. */
  87545. color: Color4;
  87546. /**
  87547. * The color change of the particle per step.
  87548. */
  87549. colorStep: Color4;
  87550. /**
  87551. * Defines how long will the life of the particle be.
  87552. */
  87553. lifeTime: number;
  87554. /**
  87555. * The current age of the particle.
  87556. */
  87557. age: number;
  87558. /**
  87559. * The current size of the particle.
  87560. */
  87561. size: number;
  87562. /**
  87563. * The current scale of the particle.
  87564. */
  87565. scale: Vector2;
  87566. /**
  87567. * The current angle of the particle.
  87568. */
  87569. angle: number;
  87570. /**
  87571. * Defines how fast is the angle changing.
  87572. */
  87573. angularSpeed: number;
  87574. /**
  87575. * Defines the cell index used by the particle to be rendered from a sprite.
  87576. */
  87577. cellIndex: number;
  87578. /**
  87579. * The information required to support color remapping
  87580. */
  87581. remapData: Vector4;
  87582. /** @hidden */
  87583. _randomCellOffset?: number;
  87584. /** @hidden */
  87585. _initialDirection: Nullable<Vector3>;
  87586. /** @hidden */
  87587. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  87588. /** @hidden */
  87589. _initialStartSpriteCellID: number;
  87590. /** @hidden */
  87591. _initialEndSpriteCellID: number;
  87592. /** @hidden */
  87593. _currentColorGradient: Nullable<ColorGradient>;
  87594. /** @hidden */
  87595. _currentColor1: Color4;
  87596. /** @hidden */
  87597. _currentColor2: Color4;
  87598. /** @hidden */
  87599. _currentSizeGradient: Nullable<FactorGradient>;
  87600. /** @hidden */
  87601. _currentSize1: number;
  87602. /** @hidden */
  87603. _currentSize2: number;
  87604. /** @hidden */
  87605. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  87606. /** @hidden */
  87607. _currentAngularSpeed1: number;
  87608. /** @hidden */
  87609. _currentAngularSpeed2: number;
  87610. /** @hidden */
  87611. _currentVelocityGradient: Nullable<FactorGradient>;
  87612. /** @hidden */
  87613. _currentVelocity1: number;
  87614. /** @hidden */
  87615. _currentVelocity2: number;
  87616. /** @hidden */
  87617. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  87618. /** @hidden */
  87619. _currentLimitVelocity1: number;
  87620. /** @hidden */
  87621. _currentLimitVelocity2: number;
  87622. /** @hidden */
  87623. _currentDragGradient: Nullable<FactorGradient>;
  87624. /** @hidden */
  87625. _currentDrag1: number;
  87626. /** @hidden */
  87627. _currentDrag2: number;
  87628. /** @hidden */
  87629. _randomNoiseCoordinates1: Vector3;
  87630. /** @hidden */
  87631. _randomNoiseCoordinates2: Vector3;
  87632. /** @hidden */
  87633. _localPosition?: Vector3;
  87634. /**
  87635. * Creates a new instance Particle
  87636. * @param particleSystem the particle system the particle belongs to
  87637. */
  87638. constructor(
  87639. /**
  87640. * The particle system the particle belongs to.
  87641. */
  87642. particleSystem: ParticleSystem);
  87643. private updateCellInfoFromSystem;
  87644. /**
  87645. * Defines how the sprite cell index is updated for the particle
  87646. */
  87647. updateCellIndex(): void;
  87648. /** @hidden */
  87649. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  87650. /** @hidden */
  87651. _inheritParticleInfoToSubEmitters(): void;
  87652. /** @hidden */
  87653. _reset(): void;
  87654. /**
  87655. * Copy the properties of particle to another one.
  87656. * @param other the particle to copy the information to.
  87657. */
  87658. copyTo(other: Particle): void;
  87659. }
  87660. }
  87661. declare module BABYLON {
  87662. /**
  87663. * Particle emitter represents a volume emitting particles.
  87664. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  87665. */
  87666. export interface IParticleEmitterType {
  87667. /**
  87668. * Called by the particle System when the direction is computed for the created particle.
  87669. * @param worldMatrix is the world matrix of the particle system
  87670. * @param directionToUpdate is the direction vector to update with the result
  87671. * @param particle is the particle we are computed the direction for
  87672. * @param isLocal defines if the direction should be set in local space
  87673. */
  87674. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  87675. /**
  87676. * Called by the particle System when the position is computed for the created particle.
  87677. * @param worldMatrix is the world matrix of the particle system
  87678. * @param positionToUpdate is the position vector to update with the result
  87679. * @param particle is the particle we are computed the position for
  87680. * @param isLocal defines if the position should be set in local space
  87681. */
  87682. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  87683. /**
  87684. * Clones the current emitter and returns a copy of it
  87685. * @returns the new emitter
  87686. */
  87687. clone(): IParticleEmitterType;
  87688. /**
  87689. * Called by the GPUParticleSystem to setup the update shader
  87690. * @param effect defines the update shader
  87691. */
  87692. applyToShader(effect: Effect): void;
  87693. /**
  87694. * Returns a string to use to update the GPU particles update shader
  87695. * @returns the effect defines string
  87696. */
  87697. getEffectDefines(): string;
  87698. /**
  87699. * Returns a string representing the class name
  87700. * @returns a string containing the class name
  87701. */
  87702. getClassName(): string;
  87703. /**
  87704. * Serializes the particle system to a JSON object.
  87705. * @returns the JSON object
  87706. */
  87707. serialize(): any;
  87708. /**
  87709. * Parse properties from a JSON object
  87710. * @param serializationObject defines the JSON object
  87711. * @param scene defines the hosting scene
  87712. */
  87713. parse(serializationObject: any, scene: Scene): void;
  87714. }
  87715. }
  87716. declare module BABYLON {
  87717. /**
  87718. * Particle emitter emitting particles from the inside of a box.
  87719. * It emits the particles randomly between 2 given directions.
  87720. */
  87721. export class BoxParticleEmitter implements IParticleEmitterType {
  87722. /**
  87723. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  87724. */
  87725. direction1: Vector3;
  87726. /**
  87727. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  87728. */
  87729. direction2: Vector3;
  87730. /**
  87731. * 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.
  87732. */
  87733. minEmitBox: Vector3;
  87734. /**
  87735. * 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.
  87736. */
  87737. maxEmitBox: Vector3;
  87738. /**
  87739. * Creates a new instance BoxParticleEmitter
  87740. */
  87741. constructor();
  87742. /**
  87743. * Called by the particle System when the direction is computed for the created particle.
  87744. * @param worldMatrix is the world matrix of the particle system
  87745. * @param directionToUpdate is the direction vector to update with the result
  87746. * @param particle is the particle we are computed the direction for
  87747. * @param isLocal defines if the direction should be set in local space
  87748. */
  87749. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  87750. /**
  87751. * Called by the particle System when the position is computed for the created particle.
  87752. * @param worldMatrix is the world matrix of the particle system
  87753. * @param positionToUpdate is the position vector to update with the result
  87754. * @param particle is the particle we are computed the position for
  87755. * @param isLocal defines if the position should be set in local space
  87756. */
  87757. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  87758. /**
  87759. * Clones the current emitter and returns a copy of it
  87760. * @returns the new emitter
  87761. */
  87762. clone(): BoxParticleEmitter;
  87763. /**
  87764. * Called by the GPUParticleSystem to setup the update shader
  87765. * @param effect defines the update shader
  87766. */
  87767. applyToShader(effect: Effect): void;
  87768. /**
  87769. * Returns a string to use to update the GPU particles update shader
  87770. * @returns a string containng the defines string
  87771. */
  87772. getEffectDefines(): string;
  87773. /**
  87774. * Returns the string "BoxParticleEmitter"
  87775. * @returns a string containing the class name
  87776. */
  87777. getClassName(): string;
  87778. /**
  87779. * Serializes the particle system to a JSON object.
  87780. * @returns the JSON object
  87781. */
  87782. serialize(): any;
  87783. /**
  87784. * Parse properties from a JSON object
  87785. * @param serializationObject defines the JSON object
  87786. */
  87787. parse(serializationObject: any): void;
  87788. }
  87789. }
  87790. declare module BABYLON {
  87791. /**
  87792. * Particle emitter emitting particles from the inside of a cone.
  87793. * It emits the particles alongside the cone volume from the base to the particle.
  87794. * The emission direction might be randomized.
  87795. */
  87796. export class ConeParticleEmitter implements IParticleEmitterType {
  87797. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  87798. directionRandomizer: number;
  87799. private _radius;
  87800. private _angle;
  87801. private _height;
  87802. /**
  87803. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  87804. */
  87805. radiusRange: number;
  87806. /**
  87807. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  87808. */
  87809. heightRange: number;
  87810. /**
  87811. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  87812. */
  87813. emitFromSpawnPointOnly: boolean;
  87814. /**
  87815. * Gets or sets the radius of the emission cone
  87816. */
  87817. get radius(): number;
  87818. set radius(value: number);
  87819. /**
  87820. * Gets or sets the angle of the emission cone
  87821. */
  87822. get angle(): number;
  87823. set angle(value: number);
  87824. private _buildHeight;
  87825. /**
  87826. * Creates a new instance ConeParticleEmitter
  87827. * @param radius the radius of the emission cone (1 by default)
  87828. * @param angle the cone base angle (PI by default)
  87829. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  87830. */
  87831. constructor(radius?: number, angle?: number,
  87832. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  87833. directionRandomizer?: number);
  87834. /**
  87835. * Called by the particle System when the direction is computed for the created particle.
  87836. * @param worldMatrix is the world matrix of the particle system
  87837. * @param directionToUpdate is the direction vector to update with the result
  87838. * @param particle is the particle we are computed the direction for
  87839. * @param isLocal defines if the direction should be set in local space
  87840. */
  87841. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  87842. /**
  87843. * Called by the particle System when the position is computed for the created particle.
  87844. * @param worldMatrix is the world matrix of the particle system
  87845. * @param positionToUpdate is the position vector to update with the result
  87846. * @param particle is the particle we are computed the position for
  87847. * @param isLocal defines if the position should be set in local space
  87848. */
  87849. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  87850. /**
  87851. * Clones the current emitter and returns a copy of it
  87852. * @returns the new emitter
  87853. */
  87854. clone(): ConeParticleEmitter;
  87855. /**
  87856. * Called by the GPUParticleSystem to setup the update shader
  87857. * @param effect defines the update shader
  87858. */
  87859. applyToShader(effect: Effect): void;
  87860. /**
  87861. * Returns a string to use to update the GPU particles update shader
  87862. * @returns a string containng the defines string
  87863. */
  87864. getEffectDefines(): string;
  87865. /**
  87866. * Returns the string "ConeParticleEmitter"
  87867. * @returns a string containing the class name
  87868. */
  87869. getClassName(): string;
  87870. /**
  87871. * Serializes the particle system to a JSON object.
  87872. * @returns the JSON object
  87873. */
  87874. serialize(): any;
  87875. /**
  87876. * Parse properties from a JSON object
  87877. * @param serializationObject defines the JSON object
  87878. */
  87879. parse(serializationObject: any): void;
  87880. }
  87881. }
  87882. declare module BABYLON {
  87883. /**
  87884. * Particle emitter emitting particles from the inside of a cylinder.
  87885. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  87886. */
  87887. export class CylinderParticleEmitter implements IParticleEmitterType {
  87888. /**
  87889. * The radius of the emission cylinder.
  87890. */
  87891. radius: number;
  87892. /**
  87893. * The height of the emission cylinder.
  87894. */
  87895. height: number;
  87896. /**
  87897. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  87898. */
  87899. radiusRange: number;
  87900. /**
  87901. * How much to randomize the particle direction [0-1].
  87902. */
  87903. directionRandomizer: number;
  87904. /**
  87905. * Creates a new instance CylinderParticleEmitter
  87906. * @param radius the radius of the emission cylinder (1 by default)
  87907. * @param height the height of the emission cylinder (1 by default)
  87908. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  87909. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  87910. */
  87911. constructor(
  87912. /**
  87913. * The radius of the emission cylinder.
  87914. */
  87915. radius?: number,
  87916. /**
  87917. * The height of the emission cylinder.
  87918. */
  87919. height?: number,
  87920. /**
  87921. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  87922. */
  87923. radiusRange?: number,
  87924. /**
  87925. * How much to randomize the particle direction [0-1].
  87926. */
  87927. directionRandomizer?: number);
  87928. /**
  87929. * Called by the particle System when the direction is computed for the created particle.
  87930. * @param worldMatrix is the world matrix of the particle system
  87931. * @param directionToUpdate is the direction vector to update with the result
  87932. * @param particle is the particle we are computed the direction for
  87933. * @param isLocal defines if the direction should be set in local space
  87934. */
  87935. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  87936. /**
  87937. * Called by the particle System when the position is computed for the created particle.
  87938. * @param worldMatrix is the world matrix of the particle system
  87939. * @param positionToUpdate is the position vector to update with the result
  87940. * @param particle is the particle we are computed the position for
  87941. * @param isLocal defines if the position should be set in local space
  87942. */
  87943. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  87944. /**
  87945. * Clones the current emitter and returns a copy of it
  87946. * @returns the new emitter
  87947. */
  87948. clone(): CylinderParticleEmitter;
  87949. /**
  87950. * Called by the GPUParticleSystem to setup the update shader
  87951. * @param effect defines the update shader
  87952. */
  87953. applyToShader(effect: Effect): void;
  87954. /**
  87955. * Returns a string to use to update the GPU particles update shader
  87956. * @returns a string containng the defines string
  87957. */
  87958. getEffectDefines(): string;
  87959. /**
  87960. * Returns the string "CylinderParticleEmitter"
  87961. * @returns a string containing the class name
  87962. */
  87963. getClassName(): string;
  87964. /**
  87965. * Serializes the particle system to a JSON object.
  87966. * @returns the JSON object
  87967. */
  87968. serialize(): any;
  87969. /**
  87970. * Parse properties from a JSON object
  87971. * @param serializationObject defines the JSON object
  87972. */
  87973. parse(serializationObject: any): void;
  87974. }
  87975. /**
  87976. * Particle emitter emitting particles from the inside of a cylinder.
  87977. * It emits the particles randomly between two vectors.
  87978. */
  87979. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  87980. /**
  87981. * The min limit of the emission direction.
  87982. */
  87983. direction1: Vector3;
  87984. /**
  87985. * The max limit of the emission direction.
  87986. */
  87987. direction2: Vector3;
  87988. /**
  87989. * Creates a new instance CylinderDirectedParticleEmitter
  87990. * @param radius the radius of the emission cylinder (1 by default)
  87991. * @param height the height of the emission cylinder (1 by default)
  87992. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  87993. * @param direction1 the min limit of the emission direction (up vector by default)
  87994. * @param direction2 the max limit of the emission direction (up vector by default)
  87995. */
  87996. constructor(radius?: number, height?: number, radiusRange?: number,
  87997. /**
  87998. * The min limit of the emission direction.
  87999. */
  88000. direction1?: Vector3,
  88001. /**
  88002. * The max limit of the emission direction.
  88003. */
  88004. direction2?: Vector3);
  88005. /**
  88006. * Called by the particle System when the direction is computed for the created particle.
  88007. * @param worldMatrix is the world matrix of the particle system
  88008. * @param directionToUpdate is the direction vector to update with the result
  88009. * @param particle is the particle we are computed the direction for
  88010. */
  88011. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  88012. /**
  88013. * Clones the current emitter and returns a copy of it
  88014. * @returns the new emitter
  88015. */
  88016. clone(): CylinderDirectedParticleEmitter;
  88017. /**
  88018. * Called by the GPUParticleSystem to setup the update shader
  88019. * @param effect defines the update shader
  88020. */
  88021. applyToShader(effect: Effect): void;
  88022. /**
  88023. * Returns a string to use to update the GPU particles update shader
  88024. * @returns a string containng the defines string
  88025. */
  88026. getEffectDefines(): string;
  88027. /**
  88028. * Returns the string "CylinderDirectedParticleEmitter"
  88029. * @returns a string containing the class name
  88030. */
  88031. getClassName(): string;
  88032. /**
  88033. * Serializes the particle system to a JSON object.
  88034. * @returns the JSON object
  88035. */
  88036. serialize(): any;
  88037. /**
  88038. * Parse properties from a JSON object
  88039. * @param serializationObject defines the JSON object
  88040. */
  88041. parse(serializationObject: any): void;
  88042. }
  88043. }
  88044. declare module BABYLON {
  88045. /**
  88046. * Particle emitter emitting particles from the inside of a hemisphere.
  88047. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  88048. */
  88049. export class HemisphericParticleEmitter implements IParticleEmitterType {
  88050. /**
  88051. * The radius of the emission hemisphere.
  88052. */
  88053. radius: number;
  88054. /**
  88055. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  88056. */
  88057. radiusRange: number;
  88058. /**
  88059. * How much to randomize the particle direction [0-1].
  88060. */
  88061. directionRandomizer: number;
  88062. /**
  88063. * Creates a new instance HemisphericParticleEmitter
  88064. * @param radius the radius of the emission hemisphere (1 by default)
  88065. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  88066. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  88067. */
  88068. constructor(
  88069. /**
  88070. * The radius of the emission hemisphere.
  88071. */
  88072. radius?: number,
  88073. /**
  88074. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  88075. */
  88076. radiusRange?: number,
  88077. /**
  88078. * How much to randomize the particle direction [0-1].
  88079. */
  88080. directionRandomizer?: number);
  88081. /**
  88082. * Called by the particle System when the direction is computed for the created particle.
  88083. * @param worldMatrix is the world matrix of the particle system
  88084. * @param directionToUpdate is the direction vector to update with the result
  88085. * @param particle is the particle we are computed the direction for
  88086. * @param isLocal defines if the direction should be set in local space
  88087. */
  88088. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  88089. /**
  88090. * Called by the particle System when the position is computed for the created particle.
  88091. * @param worldMatrix is the world matrix of the particle system
  88092. * @param positionToUpdate is the position vector to update with the result
  88093. * @param particle is the particle we are computed the position for
  88094. * @param isLocal defines if the position should be set in local space
  88095. */
  88096. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  88097. /**
  88098. * Clones the current emitter and returns a copy of it
  88099. * @returns the new emitter
  88100. */
  88101. clone(): HemisphericParticleEmitter;
  88102. /**
  88103. * Called by the GPUParticleSystem to setup the update shader
  88104. * @param effect defines the update shader
  88105. */
  88106. applyToShader(effect: Effect): void;
  88107. /**
  88108. * Returns a string to use to update the GPU particles update shader
  88109. * @returns a string containng the defines string
  88110. */
  88111. getEffectDefines(): string;
  88112. /**
  88113. * Returns the string "HemisphericParticleEmitter"
  88114. * @returns a string containing the class name
  88115. */
  88116. getClassName(): string;
  88117. /**
  88118. * Serializes the particle system to a JSON object.
  88119. * @returns the JSON object
  88120. */
  88121. serialize(): any;
  88122. /**
  88123. * Parse properties from a JSON object
  88124. * @param serializationObject defines the JSON object
  88125. */
  88126. parse(serializationObject: any): void;
  88127. }
  88128. }
  88129. declare module BABYLON {
  88130. /**
  88131. * Particle emitter emitting particles from a point.
  88132. * It emits the particles randomly between 2 given directions.
  88133. */
  88134. export class PointParticleEmitter implements IParticleEmitterType {
  88135. /**
  88136. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  88137. */
  88138. direction1: Vector3;
  88139. /**
  88140. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  88141. */
  88142. direction2: Vector3;
  88143. /**
  88144. * Creates a new instance PointParticleEmitter
  88145. */
  88146. constructor();
  88147. /**
  88148. * Called by the particle System when the direction is computed for the created particle.
  88149. * @param worldMatrix is the world matrix of the particle system
  88150. * @param directionToUpdate is the direction vector to update with the result
  88151. * @param particle is the particle we are computed the direction for
  88152. * @param isLocal defines if the direction should be set in local space
  88153. */
  88154. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  88155. /**
  88156. * Called by the particle System when the position is computed for the created particle.
  88157. * @param worldMatrix is the world matrix of the particle system
  88158. * @param positionToUpdate is the position vector to update with the result
  88159. * @param particle is the particle we are computed the position for
  88160. * @param isLocal defines if the position should be set in local space
  88161. */
  88162. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  88163. /**
  88164. * Clones the current emitter and returns a copy of it
  88165. * @returns the new emitter
  88166. */
  88167. clone(): PointParticleEmitter;
  88168. /**
  88169. * Called by the GPUParticleSystem to setup the update shader
  88170. * @param effect defines the update shader
  88171. */
  88172. applyToShader(effect: Effect): void;
  88173. /**
  88174. * Returns a string to use to update the GPU particles update shader
  88175. * @returns a string containng the defines string
  88176. */
  88177. getEffectDefines(): string;
  88178. /**
  88179. * Returns the string "PointParticleEmitter"
  88180. * @returns a string containing the class name
  88181. */
  88182. getClassName(): string;
  88183. /**
  88184. * Serializes the particle system to a JSON object.
  88185. * @returns the JSON object
  88186. */
  88187. serialize(): any;
  88188. /**
  88189. * Parse properties from a JSON object
  88190. * @param serializationObject defines the JSON object
  88191. */
  88192. parse(serializationObject: any): void;
  88193. }
  88194. }
  88195. declare module BABYLON {
  88196. /**
  88197. * Particle emitter emitting particles from the inside of a sphere.
  88198. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  88199. */
  88200. export class SphereParticleEmitter implements IParticleEmitterType {
  88201. /**
  88202. * The radius of the emission sphere.
  88203. */
  88204. radius: number;
  88205. /**
  88206. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  88207. */
  88208. radiusRange: number;
  88209. /**
  88210. * How much to randomize the particle direction [0-1].
  88211. */
  88212. directionRandomizer: number;
  88213. /**
  88214. * Creates a new instance SphereParticleEmitter
  88215. * @param radius the radius of the emission sphere (1 by default)
  88216. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  88217. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  88218. */
  88219. constructor(
  88220. /**
  88221. * The radius of the emission sphere.
  88222. */
  88223. radius?: number,
  88224. /**
  88225. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  88226. */
  88227. radiusRange?: number,
  88228. /**
  88229. * How much to randomize the particle direction [0-1].
  88230. */
  88231. directionRandomizer?: number);
  88232. /**
  88233. * Called by the particle System when the direction is computed for the created particle.
  88234. * @param worldMatrix is the world matrix of the particle system
  88235. * @param directionToUpdate is the direction vector to update with the result
  88236. * @param particle is the particle we are computed the direction for
  88237. * @param isLocal defines if the direction should be set in local space
  88238. */
  88239. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  88240. /**
  88241. * Called by the particle System when the position is computed for the created particle.
  88242. * @param worldMatrix is the world matrix of the particle system
  88243. * @param positionToUpdate is the position vector to update with the result
  88244. * @param particle is the particle we are computed the position for
  88245. * @param isLocal defines if the position should be set in local space
  88246. */
  88247. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  88248. /**
  88249. * Clones the current emitter and returns a copy of it
  88250. * @returns the new emitter
  88251. */
  88252. clone(): SphereParticleEmitter;
  88253. /**
  88254. * Called by the GPUParticleSystem to setup the update shader
  88255. * @param effect defines the update shader
  88256. */
  88257. applyToShader(effect: Effect): void;
  88258. /**
  88259. * Returns a string to use to update the GPU particles update shader
  88260. * @returns a string containng the defines string
  88261. */
  88262. getEffectDefines(): string;
  88263. /**
  88264. * Returns the string "SphereParticleEmitter"
  88265. * @returns a string containing the class name
  88266. */
  88267. getClassName(): string;
  88268. /**
  88269. * Serializes the particle system to a JSON object.
  88270. * @returns the JSON object
  88271. */
  88272. serialize(): any;
  88273. /**
  88274. * Parse properties from a JSON object
  88275. * @param serializationObject defines the JSON object
  88276. */
  88277. parse(serializationObject: any): void;
  88278. }
  88279. /**
  88280. * Particle emitter emitting particles from the inside of a sphere.
  88281. * It emits the particles randomly between two vectors.
  88282. */
  88283. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  88284. /**
  88285. * The min limit of the emission direction.
  88286. */
  88287. direction1: Vector3;
  88288. /**
  88289. * The max limit of the emission direction.
  88290. */
  88291. direction2: Vector3;
  88292. /**
  88293. * Creates a new instance SphereDirectedParticleEmitter
  88294. * @param radius the radius of the emission sphere (1 by default)
  88295. * @param direction1 the min limit of the emission direction (up vector by default)
  88296. * @param direction2 the max limit of the emission direction (up vector by default)
  88297. */
  88298. constructor(radius?: number,
  88299. /**
  88300. * The min limit of the emission direction.
  88301. */
  88302. direction1?: Vector3,
  88303. /**
  88304. * The max limit of the emission direction.
  88305. */
  88306. direction2?: Vector3);
  88307. /**
  88308. * Called by the particle System when the direction is computed for the created particle.
  88309. * @param worldMatrix is the world matrix of the particle system
  88310. * @param directionToUpdate is the direction vector to update with the result
  88311. * @param particle is the particle we are computed the direction for
  88312. */
  88313. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  88314. /**
  88315. * Clones the current emitter and returns a copy of it
  88316. * @returns the new emitter
  88317. */
  88318. clone(): SphereDirectedParticleEmitter;
  88319. /**
  88320. * Called by the GPUParticleSystem to setup the update shader
  88321. * @param effect defines the update shader
  88322. */
  88323. applyToShader(effect: Effect): void;
  88324. /**
  88325. * Returns a string to use to update the GPU particles update shader
  88326. * @returns a string containng the defines string
  88327. */
  88328. getEffectDefines(): string;
  88329. /**
  88330. * Returns the string "SphereDirectedParticleEmitter"
  88331. * @returns a string containing the class name
  88332. */
  88333. getClassName(): string;
  88334. /**
  88335. * Serializes the particle system to a JSON object.
  88336. * @returns the JSON object
  88337. */
  88338. serialize(): any;
  88339. /**
  88340. * Parse properties from a JSON object
  88341. * @param serializationObject defines the JSON object
  88342. */
  88343. parse(serializationObject: any): void;
  88344. }
  88345. }
  88346. declare module BABYLON {
  88347. /**
  88348. * Particle emitter emitting particles from a custom list of positions.
  88349. */
  88350. export class CustomParticleEmitter implements IParticleEmitterType {
  88351. /**
  88352. * Gets or sets the position generator that will create the inital position of each particle.
  88353. * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  88354. */
  88355. particlePositionGenerator: (index: number, particle: Nullable<Particle>, outPosition: Vector3) => void;
  88356. /**
  88357. * Gets or sets the destination generator that will create the final destination of each particle.
  88358. * * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  88359. */
  88360. particleDestinationGenerator: (index: number, particle: Nullable<Particle>, outDestination: Vector3) => void;
  88361. /**
  88362. * Creates a new instance CustomParticleEmitter
  88363. */
  88364. constructor();
  88365. /**
  88366. * Called by the particle System when the direction is computed for the created particle.
  88367. * @param worldMatrix is the world matrix of the particle system
  88368. * @param directionToUpdate is the direction vector to update with the result
  88369. * @param particle is the particle we are computed the direction for
  88370. * @param isLocal defines if the direction should be set in local space
  88371. */
  88372. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  88373. /**
  88374. * Called by the particle System when the position is computed for the created particle.
  88375. * @param worldMatrix is the world matrix of the particle system
  88376. * @param positionToUpdate is the position vector to update with the result
  88377. * @param particle is the particle we are computed the position for
  88378. * @param isLocal defines if the position should be set in local space
  88379. */
  88380. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  88381. /**
  88382. * Clones the current emitter and returns a copy of it
  88383. * @returns the new emitter
  88384. */
  88385. clone(): CustomParticleEmitter;
  88386. /**
  88387. * Called by the GPUParticleSystem to setup the update shader
  88388. * @param effect defines the update shader
  88389. */
  88390. applyToShader(effect: Effect): void;
  88391. /**
  88392. * Returns a string to use to update the GPU particles update shader
  88393. * @returns a string containng the defines string
  88394. */
  88395. getEffectDefines(): string;
  88396. /**
  88397. * Returns the string "PointParticleEmitter"
  88398. * @returns a string containing the class name
  88399. */
  88400. getClassName(): string;
  88401. /**
  88402. * Serializes the particle system to a JSON object.
  88403. * @returns the JSON object
  88404. */
  88405. serialize(): any;
  88406. /**
  88407. * Parse properties from a JSON object
  88408. * @param serializationObject defines the JSON object
  88409. */
  88410. parse(serializationObject: any): void;
  88411. }
  88412. }
  88413. declare module BABYLON {
  88414. /**
  88415. * Particle emitter emitting particles from the inside of a box.
  88416. * It emits the particles randomly between 2 given directions.
  88417. */
  88418. export class MeshParticleEmitter implements IParticleEmitterType {
  88419. private _indices;
  88420. private _positions;
  88421. private _normals;
  88422. private _storedNormal;
  88423. private _mesh;
  88424. /**
  88425. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  88426. */
  88427. direction1: Vector3;
  88428. /**
  88429. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  88430. */
  88431. direction2: Vector3;
  88432. /**
  88433. * Gets or sets a boolean indicating that particle directions must be built from mesh face normals
  88434. */
  88435. useMeshNormalsForDirection: boolean;
  88436. /** Defines the mesh to use as source */
  88437. get mesh(): Nullable<AbstractMesh>;
  88438. set mesh(value: Nullable<AbstractMesh>);
  88439. /**
  88440. * Creates a new instance MeshParticleEmitter
  88441. * @param mesh defines the mesh to use as source
  88442. */
  88443. constructor(mesh?: Nullable<AbstractMesh>);
  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(): MeshParticleEmitter;
  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 "BoxParticleEmitter"
  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. * @param scene defines the hosting scene
  88489. */
  88490. parse(serializationObject: any, scene: Scene): void;
  88491. }
  88492. }
  88493. declare module BABYLON {
  88494. /**
  88495. * Interface representing a particle system in Babylon.js.
  88496. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  88497. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  88498. */
  88499. export interface IParticleSystem {
  88500. /**
  88501. * List of animations used by the particle system.
  88502. */
  88503. animations: Animation[];
  88504. /**
  88505. * The id of the Particle system.
  88506. */
  88507. id: string;
  88508. /**
  88509. * The name of the Particle system.
  88510. */
  88511. name: string;
  88512. /**
  88513. * The emitter represents the Mesh or position we are attaching the particle system to.
  88514. */
  88515. emitter: Nullable<AbstractMesh | Vector3>;
  88516. /**
  88517. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  88518. */
  88519. isBillboardBased: boolean;
  88520. /**
  88521. * The rendering group used by the Particle system to chose when to render.
  88522. */
  88523. renderingGroupId: number;
  88524. /**
  88525. * The layer mask we are rendering the particles through.
  88526. */
  88527. layerMask: number;
  88528. /**
  88529. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  88530. */
  88531. updateSpeed: number;
  88532. /**
  88533. * The amount of time the particle system is running (depends of the overall update speed).
  88534. */
  88535. targetStopDuration: number;
  88536. /**
  88537. * The texture used to render each particle. (this can be a spritesheet)
  88538. */
  88539. particleTexture: Nullable<Texture>;
  88540. /**
  88541. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  88542. */
  88543. blendMode: number;
  88544. /**
  88545. * Minimum life time of emitting particles.
  88546. */
  88547. minLifeTime: number;
  88548. /**
  88549. * Maximum life time of emitting particles.
  88550. */
  88551. maxLifeTime: number;
  88552. /**
  88553. * Minimum Size of emitting particles.
  88554. */
  88555. minSize: number;
  88556. /**
  88557. * Maximum Size of emitting particles.
  88558. */
  88559. maxSize: number;
  88560. /**
  88561. * Minimum scale of emitting particles on X axis.
  88562. */
  88563. minScaleX: number;
  88564. /**
  88565. * Maximum scale of emitting particles on X axis.
  88566. */
  88567. maxScaleX: number;
  88568. /**
  88569. * Minimum scale of emitting particles on Y axis.
  88570. */
  88571. minScaleY: number;
  88572. /**
  88573. * Maximum scale of emitting particles on Y axis.
  88574. */
  88575. maxScaleY: number;
  88576. /**
  88577. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  88578. */
  88579. color1: Color4;
  88580. /**
  88581. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  88582. */
  88583. color2: Color4;
  88584. /**
  88585. * Color the particle will have at the end of its lifetime.
  88586. */
  88587. colorDead: Color4;
  88588. /**
  88589. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  88590. */
  88591. emitRate: number;
  88592. /**
  88593. * You can use gravity if you want to give an orientation to your particles.
  88594. */
  88595. gravity: Vector3;
  88596. /**
  88597. * Minimum power of emitting particles.
  88598. */
  88599. minEmitPower: number;
  88600. /**
  88601. * Maximum power of emitting particles.
  88602. */
  88603. maxEmitPower: number;
  88604. /**
  88605. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  88606. */
  88607. minAngularSpeed: number;
  88608. /**
  88609. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  88610. */
  88611. maxAngularSpeed: number;
  88612. /**
  88613. * Gets or sets the minimal initial rotation in radians.
  88614. */
  88615. minInitialRotation: number;
  88616. /**
  88617. * Gets or sets the maximal initial rotation in radians.
  88618. */
  88619. maxInitialRotation: number;
  88620. /**
  88621. * The particle emitter type defines the emitter used by the particle system.
  88622. * It can be for example box, sphere, or cone...
  88623. */
  88624. particleEmitterType: Nullable<IParticleEmitterType>;
  88625. /**
  88626. * Defines the delay in milliseconds before starting the system (0 by default)
  88627. */
  88628. startDelay: number;
  88629. /**
  88630. * 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
  88631. */
  88632. preWarmCycles: number;
  88633. /**
  88634. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  88635. */
  88636. preWarmStepOffset: number;
  88637. /**
  88638. * 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)
  88639. */
  88640. spriteCellChangeSpeed: number;
  88641. /**
  88642. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  88643. */
  88644. startSpriteCellID: number;
  88645. /**
  88646. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  88647. */
  88648. endSpriteCellID: number;
  88649. /**
  88650. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  88651. */
  88652. spriteCellWidth: number;
  88653. /**
  88654. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  88655. */
  88656. spriteCellHeight: number;
  88657. /**
  88658. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  88659. */
  88660. spriteRandomStartCell: boolean;
  88661. /**
  88662. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  88663. */
  88664. isAnimationSheetEnabled: boolean;
  88665. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  88666. translationPivot: Vector2;
  88667. /**
  88668. * Gets or sets a texture used to add random noise to particle positions
  88669. */
  88670. noiseTexture: Nullable<BaseTexture>;
  88671. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  88672. noiseStrength: Vector3;
  88673. /**
  88674. * Gets or sets the billboard mode to use when isBillboardBased = true.
  88675. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  88676. */
  88677. billboardMode: number;
  88678. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  88679. limitVelocityDamping: number;
  88680. /**
  88681. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  88682. */
  88683. beginAnimationOnStart: boolean;
  88684. /**
  88685. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  88686. */
  88687. beginAnimationFrom: number;
  88688. /**
  88689. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  88690. */
  88691. beginAnimationTo: number;
  88692. /**
  88693. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  88694. */
  88695. beginAnimationLoop: boolean;
  88696. /**
  88697. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  88698. */
  88699. disposeOnStop: boolean;
  88700. /**
  88701. * Specifies if the particles are updated in emitter local space or world space
  88702. */
  88703. isLocal: boolean;
  88704. /** Snippet ID if the particle system was created from the snippet server */
  88705. snippetId: string;
  88706. /**
  88707. * Gets the maximum number of particles active at the same time.
  88708. * @returns The max number of active particles.
  88709. */
  88710. getCapacity(): number;
  88711. /**
  88712. * Gets the number of particles active at the same time.
  88713. * @returns The number of active particles.
  88714. */
  88715. getActiveCount(): number;
  88716. /**
  88717. * Gets if the system has been started. (Note: this will still be true after stop is called)
  88718. * @returns True if it has been started, otherwise false.
  88719. */
  88720. isStarted(): boolean;
  88721. /**
  88722. * Animates the particle system for this frame.
  88723. */
  88724. animate(): void;
  88725. /**
  88726. * Renders the particle system in its current state.
  88727. * @returns the current number of particles
  88728. */
  88729. render(): number;
  88730. /**
  88731. * Dispose the particle system and frees its associated resources.
  88732. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  88733. */
  88734. dispose(disposeTexture?: boolean): void;
  88735. /**
  88736. * Clones the particle system.
  88737. * @param name The name of the cloned object
  88738. * @param newEmitter The new emitter to use
  88739. * @returns the cloned particle system
  88740. */
  88741. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  88742. /**
  88743. * Serializes the particle system to a JSON object
  88744. * @param serializeTexture defines if the texture must be serialized as well
  88745. * @returns the JSON object
  88746. */
  88747. serialize(serializeTexture: boolean): any;
  88748. /**
  88749. * Rebuild the particle system
  88750. */
  88751. rebuild(): void;
  88752. /** Force the system to rebuild all gradients that need to be resync */
  88753. forceRefreshGradients(): void;
  88754. /**
  88755. * Starts the particle system and begins to emit
  88756. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  88757. */
  88758. start(delay?: number): void;
  88759. /**
  88760. * Stops the particle system.
  88761. */
  88762. stop(): void;
  88763. /**
  88764. * Remove all active particles
  88765. */
  88766. reset(): void;
  88767. /**
  88768. * Gets a boolean indicating that the system is stopping
  88769. * @returns true if the system is currently stopping
  88770. */
  88771. isStopping(): boolean;
  88772. /**
  88773. * Is this system ready to be used/rendered
  88774. * @return true if the system is ready
  88775. */
  88776. isReady(): boolean;
  88777. /**
  88778. * Returns the string "ParticleSystem"
  88779. * @returns a string containing the class name
  88780. */
  88781. getClassName(): string;
  88782. /**
  88783. * Adds a new color gradient
  88784. * @param gradient defines the gradient to use (between 0 and 1)
  88785. * @param color1 defines the color to affect to the specified gradient
  88786. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  88787. * @returns the current particle system
  88788. */
  88789. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  88790. /**
  88791. * Remove a specific color gradient
  88792. * @param gradient defines the gradient to remove
  88793. * @returns the current particle system
  88794. */
  88795. removeColorGradient(gradient: number): IParticleSystem;
  88796. /**
  88797. * Adds a new size gradient
  88798. * @param gradient defines the gradient to use (between 0 and 1)
  88799. * @param factor defines the size factor to affect to the specified gradient
  88800. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  88801. * @returns the current particle system
  88802. */
  88803. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  88804. /**
  88805. * Remove a specific size gradient
  88806. * @param gradient defines the gradient to remove
  88807. * @returns the current particle system
  88808. */
  88809. removeSizeGradient(gradient: number): IParticleSystem;
  88810. /**
  88811. * Gets the current list of color gradients.
  88812. * You must use addColorGradient and removeColorGradient to udpate this list
  88813. * @returns the list of color gradients
  88814. */
  88815. getColorGradients(): Nullable<Array<ColorGradient>>;
  88816. /**
  88817. * Gets the current list of size gradients.
  88818. * You must use addSizeGradient and removeSizeGradient to udpate this list
  88819. * @returns the list of size gradients
  88820. */
  88821. getSizeGradients(): Nullable<Array<FactorGradient>>;
  88822. /**
  88823. * Gets the current list of angular speed gradients.
  88824. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  88825. * @returns the list of angular speed gradients
  88826. */
  88827. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  88828. /**
  88829. * Adds a new angular speed gradient
  88830. * @param gradient defines the gradient to use (between 0 and 1)
  88831. * @param factor defines the angular speed to affect to the specified gradient
  88832. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  88833. * @returns the current particle system
  88834. */
  88835. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  88836. /**
  88837. * Remove a specific angular speed gradient
  88838. * @param gradient defines the gradient to remove
  88839. * @returns the current particle system
  88840. */
  88841. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  88842. /**
  88843. * Gets the current list of velocity gradients.
  88844. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  88845. * @returns the list of velocity gradients
  88846. */
  88847. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  88848. /**
  88849. * Adds a new velocity gradient
  88850. * @param gradient defines the gradient to use (between 0 and 1)
  88851. * @param factor defines the velocity to affect to the specified gradient
  88852. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  88853. * @returns the current particle system
  88854. */
  88855. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  88856. /**
  88857. * Remove a specific velocity gradient
  88858. * @param gradient defines the gradient to remove
  88859. * @returns the current particle system
  88860. */
  88861. removeVelocityGradient(gradient: number): IParticleSystem;
  88862. /**
  88863. * Gets the current list of limit velocity gradients.
  88864. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  88865. * @returns the list of limit velocity gradients
  88866. */
  88867. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  88868. /**
  88869. * Adds a new limit velocity gradient
  88870. * @param gradient defines the gradient to use (between 0 and 1)
  88871. * @param factor defines the limit velocity to affect to the specified gradient
  88872. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  88873. * @returns the current particle system
  88874. */
  88875. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  88876. /**
  88877. * Remove a specific limit velocity gradient
  88878. * @param gradient defines the gradient to remove
  88879. * @returns the current particle system
  88880. */
  88881. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  88882. /**
  88883. * Adds a new drag gradient
  88884. * @param gradient defines the gradient to use (between 0 and 1)
  88885. * @param factor defines the drag to affect to the specified gradient
  88886. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  88887. * @returns the current particle system
  88888. */
  88889. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  88890. /**
  88891. * Remove a specific drag gradient
  88892. * @param gradient defines the gradient to remove
  88893. * @returns the current particle system
  88894. */
  88895. removeDragGradient(gradient: number): IParticleSystem;
  88896. /**
  88897. * Gets the current list of drag gradients.
  88898. * You must use addDragGradient and removeDragGradient to udpate this list
  88899. * @returns the list of drag gradients
  88900. */
  88901. getDragGradients(): Nullable<Array<FactorGradient>>;
  88902. /**
  88903. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  88904. * @param gradient defines the gradient to use (between 0 and 1)
  88905. * @param factor defines the emit rate to affect to the specified gradient
  88906. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  88907. * @returns the current particle system
  88908. */
  88909. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  88910. /**
  88911. * Remove a specific emit rate gradient
  88912. * @param gradient defines the gradient to remove
  88913. * @returns the current particle system
  88914. */
  88915. removeEmitRateGradient(gradient: number): IParticleSystem;
  88916. /**
  88917. * Gets the current list of emit rate gradients.
  88918. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  88919. * @returns the list of emit rate gradients
  88920. */
  88921. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  88922. /**
  88923. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  88924. * @param gradient defines the gradient to use (between 0 and 1)
  88925. * @param factor defines the start size to affect to the specified gradient
  88926. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  88927. * @returns the current particle system
  88928. */
  88929. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  88930. /**
  88931. * Remove a specific start size gradient
  88932. * @param gradient defines the gradient to remove
  88933. * @returns the current particle system
  88934. */
  88935. removeStartSizeGradient(gradient: number): IParticleSystem;
  88936. /**
  88937. * Gets the current list of start size gradients.
  88938. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  88939. * @returns the list of start size gradients
  88940. */
  88941. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  88942. /**
  88943. * Adds a new life time gradient
  88944. * @param gradient defines the gradient to use (between 0 and 1)
  88945. * @param factor defines the life time factor to affect to the specified gradient
  88946. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  88947. * @returns the current particle system
  88948. */
  88949. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  88950. /**
  88951. * Remove a specific life time gradient
  88952. * @param gradient defines the gradient to remove
  88953. * @returns the current particle system
  88954. */
  88955. removeLifeTimeGradient(gradient: number): IParticleSystem;
  88956. /**
  88957. * Gets the current list of life time gradients.
  88958. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  88959. * @returns the list of life time gradients
  88960. */
  88961. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  88962. /**
  88963. * Gets the current list of color gradients.
  88964. * You must use addColorGradient and removeColorGradient to udpate this list
  88965. * @returns the list of color gradients
  88966. */
  88967. getColorGradients(): Nullable<Array<ColorGradient>>;
  88968. /**
  88969. * Adds a new ramp gradient used to remap particle colors
  88970. * @param gradient defines the gradient to use (between 0 and 1)
  88971. * @param color defines the color to affect to the specified gradient
  88972. * @returns the current particle system
  88973. */
  88974. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  88975. /**
  88976. * Gets the current list of ramp gradients.
  88977. * You must use addRampGradient and removeRampGradient to udpate this list
  88978. * @returns the list of ramp gradients
  88979. */
  88980. getRampGradients(): Nullable<Array<Color3Gradient>>;
  88981. /** Gets or sets a boolean indicating that ramp gradients must be used
  88982. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  88983. */
  88984. useRampGradients: boolean;
  88985. /**
  88986. * Adds a new color remap gradient
  88987. * @param gradient defines the gradient to use (between 0 and 1)
  88988. * @param min defines the color remap minimal range
  88989. * @param max defines the color remap maximal range
  88990. * @returns the current particle system
  88991. */
  88992. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  88993. /**
  88994. * Gets the current list of color remap gradients.
  88995. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  88996. * @returns the list of color remap gradients
  88997. */
  88998. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  88999. /**
  89000. * Adds a new alpha remap gradient
  89001. * @param gradient defines the gradient to use (between 0 and 1)
  89002. * @param min defines the alpha remap minimal range
  89003. * @param max defines the alpha remap maximal range
  89004. * @returns the current particle system
  89005. */
  89006. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  89007. /**
  89008. * Gets the current list of alpha remap gradients.
  89009. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  89010. * @returns the list of alpha remap gradients
  89011. */
  89012. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  89013. /**
  89014. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  89015. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  89016. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  89017. * @returns the emitter
  89018. */
  89019. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  89020. /**
  89021. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  89022. * @param radius The radius of the hemisphere to emit from
  89023. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  89024. * @returns the emitter
  89025. */
  89026. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  89027. /**
  89028. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  89029. * @param radius The radius of the sphere to emit from
  89030. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  89031. * @returns the emitter
  89032. */
  89033. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  89034. /**
  89035. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  89036. * @param radius The radius of the sphere to emit from
  89037. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  89038. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  89039. * @returns the emitter
  89040. */
  89041. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  89042. /**
  89043. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  89044. * @param radius The radius of the emission cylinder
  89045. * @param height The height of the emission cylinder
  89046. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  89047. * @param directionRandomizer How much to randomize the particle direction [0-1]
  89048. * @returns the emitter
  89049. */
  89050. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  89051. /**
  89052. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  89053. * @param radius The radius of the cylinder to emit from
  89054. * @param height The height of the emission cylinder
  89055. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  89056. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  89057. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  89058. * @returns the emitter
  89059. */
  89060. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  89061. /**
  89062. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  89063. * @param radius The radius of the cone to emit from
  89064. * @param angle The base angle of the cone
  89065. * @returns the emitter
  89066. */
  89067. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  89068. /**
  89069. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  89070. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  89071. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  89072. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  89073. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  89074. * @returns the emitter
  89075. */
  89076. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  89077. /**
  89078. * Get hosting scene
  89079. * @returns the scene
  89080. */
  89081. getScene(): Scene;
  89082. }
  89083. }
  89084. declare module BABYLON {
  89085. /**
  89086. * 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.
  89087. * @see https://doc.babylonjs.com/how_to/transformnode
  89088. */
  89089. export class TransformNode extends Node {
  89090. /**
  89091. * Object will not rotate to face the camera
  89092. */
  89093. static BILLBOARDMODE_NONE: number;
  89094. /**
  89095. * Object will rotate to face the camera but only on the x axis
  89096. */
  89097. static BILLBOARDMODE_X: number;
  89098. /**
  89099. * Object will rotate to face the camera but only on the y axis
  89100. */
  89101. static BILLBOARDMODE_Y: number;
  89102. /**
  89103. * Object will rotate to face the camera but only on the z axis
  89104. */
  89105. static BILLBOARDMODE_Z: number;
  89106. /**
  89107. * Object will rotate to face the camera
  89108. */
  89109. static BILLBOARDMODE_ALL: number;
  89110. /**
  89111. * Object will rotate to face the camera's position instead of orientation
  89112. */
  89113. static BILLBOARDMODE_USE_POSITION: number;
  89114. private _forward;
  89115. private _forwardInverted;
  89116. private _up;
  89117. private _right;
  89118. private _rightInverted;
  89119. private _position;
  89120. private _rotation;
  89121. private _rotationQuaternion;
  89122. protected _scaling: Vector3;
  89123. protected _isDirty: boolean;
  89124. private _transformToBoneReferal;
  89125. private _isAbsoluteSynced;
  89126. private _billboardMode;
  89127. /**
  89128. * Gets or sets the billboard mode. Default is 0.
  89129. *
  89130. * | Value | Type | Description |
  89131. * | --- | --- | --- |
  89132. * | 0 | BILLBOARDMODE_NONE | |
  89133. * | 1 | BILLBOARDMODE_X | |
  89134. * | 2 | BILLBOARDMODE_Y | |
  89135. * | 4 | BILLBOARDMODE_Z | |
  89136. * | 7 | BILLBOARDMODE_ALL | |
  89137. *
  89138. */
  89139. get billboardMode(): number;
  89140. set billboardMode(value: number);
  89141. private _preserveParentRotationForBillboard;
  89142. /**
  89143. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  89144. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  89145. */
  89146. get preserveParentRotationForBillboard(): boolean;
  89147. set preserveParentRotationForBillboard(value: boolean);
  89148. /**
  89149. * 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
  89150. */
  89151. scalingDeterminant: number;
  89152. private _infiniteDistance;
  89153. /**
  89154. * Gets or sets the distance of the object to max, often used by skybox
  89155. */
  89156. get infiniteDistance(): boolean;
  89157. set infiniteDistance(value: boolean);
  89158. /**
  89159. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  89160. * By default the system will update normals to compensate
  89161. */
  89162. ignoreNonUniformScaling: boolean;
  89163. /**
  89164. * 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
  89165. */
  89166. reIntegrateRotationIntoRotationQuaternion: boolean;
  89167. /** @hidden */
  89168. _poseMatrix: Nullable<Matrix>;
  89169. /** @hidden */
  89170. _localMatrix: Matrix;
  89171. private _usePivotMatrix;
  89172. private _absolutePosition;
  89173. private _absoluteScaling;
  89174. private _absoluteRotationQuaternion;
  89175. private _pivotMatrix;
  89176. private _pivotMatrixInverse;
  89177. protected _postMultiplyPivotMatrix: boolean;
  89178. protected _isWorldMatrixFrozen: boolean;
  89179. /** @hidden */
  89180. _indexInSceneTransformNodesArray: number;
  89181. /**
  89182. * An event triggered after the world matrix is updated
  89183. */
  89184. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  89185. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  89186. /**
  89187. * Gets a string identifying the name of the class
  89188. * @returns "TransformNode" string
  89189. */
  89190. getClassName(): string;
  89191. /**
  89192. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  89193. */
  89194. get position(): Vector3;
  89195. set position(newPosition: Vector3);
  89196. /**
  89197. * 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)).
  89198. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  89199. */
  89200. get rotation(): Vector3;
  89201. set rotation(newRotation: Vector3);
  89202. /**
  89203. * 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)).
  89204. */
  89205. get scaling(): Vector3;
  89206. set scaling(newScaling: Vector3);
  89207. /**
  89208. * 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).
  89209. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  89210. */
  89211. get rotationQuaternion(): Nullable<Quaternion>;
  89212. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  89213. /**
  89214. * The forward direction of that transform in world space.
  89215. */
  89216. get forward(): Vector3;
  89217. /**
  89218. * The up direction of that transform in world space.
  89219. */
  89220. get up(): Vector3;
  89221. /**
  89222. * The right direction of that transform in world space.
  89223. */
  89224. get right(): Vector3;
  89225. /**
  89226. * Copies the parameter passed Matrix into the mesh Pose matrix.
  89227. * @param matrix the matrix to copy the pose from
  89228. * @returns this TransformNode.
  89229. */
  89230. updatePoseMatrix(matrix: Matrix): TransformNode;
  89231. /**
  89232. * Returns the mesh Pose matrix.
  89233. * @returns the pose matrix
  89234. */
  89235. getPoseMatrix(): Matrix;
  89236. /** @hidden */
  89237. _isSynchronized(): boolean;
  89238. /** @hidden */
  89239. _initCache(): void;
  89240. /**
  89241. * Flag the transform node as dirty (Forcing it to update everything)
  89242. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  89243. * @returns this transform node
  89244. */
  89245. markAsDirty(property: string): TransformNode;
  89246. /**
  89247. * Returns the current mesh absolute position.
  89248. * Returns a Vector3.
  89249. */
  89250. get absolutePosition(): Vector3;
  89251. /**
  89252. * Returns the current mesh absolute scaling.
  89253. * Returns a Vector3.
  89254. */
  89255. get absoluteScaling(): Vector3;
  89256. /**
  89257. * Returns the current mesh absolute rotation.
  89258. * Returns a Quaternion.
  89259. */
  89260. get absoluteRotationQuaternion(): Quaternion;
  89261. /**
  89262. * Sets a new matrix to apply before all other transformation
  89263. * @param matrix defines the transform matrix
  89264. * @returns the current TransformNode
  89265. */
  89266. setPreTransformMatrix(matrix: Matrix): TransformNode;
  89267. /**
  89268. * Sets a new pivot matrix to the current node
  89269. * @param matrix defines the new pivot matrix to use
  89270. * @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
  89271. * @returns the current TransformNode
  89272. */
  89273. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  89274. /**
  89275. * Returns the mesh pivot matrix.
  89276. * Default : Identity.
  89277. * @returns the matrix
  89278. */
  89279. getPivotMatrix(): Matrix;
  89280. /**
  89281. * Instantiate (when possible) or clone that node with its hierarchy
  89282. * @param newParent defines the new parent to use for the instance (or clone)
  89283. * @param options defines options to configure how copy is done
  89284. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  89285. * @returns an instance (or a clone) of the current node with its hiearchy
  89286. */
  89287. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  89288. doNotInstantiate: boolean;
  89289. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  89290. /**
  89291. * Prevents the World matrix to be computed any longer
  89292. * @param newWorldMatrix defines an optional matrix to use as world matrix
  89293. * @returns the TransformNode.
  89294. */
  89295. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  89296. /**
  89297. * Allows back the World matrix computation.
  89298. * @returns the TransformNode.
  89299. */
  89300. unfreezeWorldMatrix(): this;
  89301. /**
  89302. * True if the World matrix has been frozen.
  89303. */
  89304. get isWorldMatrixFrozen(): boolean;
  89305. /**
  89306. * Retuns the mesh absolute position in the World.
  89307. * @returns a Vector3.
  89308. */
  89309. getAbsolutePosition(): Vector3;
  89310. /**
  89311. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  89312. * @param absolutePosition the absolute position to set
  89313. * @returns the TransformNode.
  89314. */
  89315. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  89316. /**
  89317. * Sets the mesh position in its local space.
  89318. * @param vector3 the position to set in localspace
  89319. * @returns the TransformNode.
  89320. */
  89321. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  89322. /**
  89323. * Returns the mesh position in the local space from the current World matrix values.
  89324. * @returns a new Vector3.
  89325. */
  89326. getPositionExpressedInLocalSpace(): Vector3;
  89327. /**
  89328. * Translates the mesh along the passed Vector3 in its local space.
  89329. * @param vector3 the distance to translate in localspace
  89330. * @returns the TransformNode.
  89331. */
  89332. locallyTranslate(vector3: Vector3): TransformNode;
  89333. private static _lookAtVectorCache;
  89334. /**
  89335. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  89336. * @param targetPoint the position (must be in same space as current mesh) to look at
  89337. * @param yawCor optional yaw (y-axis) correction in radians
  89338. * @param pitchCor optional pitch (x-axis) correction in radians
  89339. * @param rollCor optional roll (z-axis) correction in radians
  89340. * @param space the choosen space of the target
  89341. * @returns the TransformNode.
  89342. */
  89343. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  89344. /**
  89345. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  89346. * This Vector3 is expressed in the World space.
  89347. * @param localAxis axis to rotate
  89348. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  89349. */
  89350. getDirection(localAxis: Vector3): Vector3;
  89351. /**
  89352. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  89353. * localAxis is expressed in the mesh local space.
  89354. * result is computed in the Wordl space from the mesh World matrix.
  89355. * @param localAxis axis to rotate
  89356. * @param result the resulting transformnode
  89357. * @returns this TransformNode.
  89358. */
  89359. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  89360. /**
  89361. * Sets this transform node rotation to the given local axis.
  89362. * @param localAxis the axis in local space
  89363. * @param yawCor optional yaw (y-axis) correction in radians
  89364. * @param pitchCor optional pitch (x-axis) correction in radians
  89365. * @param rollCor optional roll (z-axis) correction in radians
  89366. * @returns this TransformNode
  89367. */
  89368. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  89369. /**
  89370. * Sets a new pivot point to the current node
  89371. * @param point defines the new pivot point to use
  89372. * @param space defines if the point is in world or local space (local by default)
  89373. * @returns the current TransformNode
  89374. */
  89375. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  89376. /**
  89377. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  89378. * @returns the pivot point
  89379. */
  89380. getPivotPoint(): Vector3;
  89381. /**
  89382. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  89383. * @param result the vector3 to store the result
  89384. * @returns this TransformNode.
  89385. */
  89386. getPivotPointToRef(result: Vector3): TransformNode;
  89387. /**
  89388. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  89389. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  89390. */
  89391. getAbsolutePivotPoint(): Vector3;
  89392. /**
  89393. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  89394. * @param result vector3 to store the result
  89395. * @returns this TransformNode.
  89396. */
  89397. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  89398. /**
  89399. * Defines the passed node as the parent of the current node.
  89400. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  89401. * @see https://doc.babylonjs.com/how_to/parenting
  89402. * @param node the node ot set as the parent
  89403. * @returns this TransformNode.
  89404. */
  89405. setParent(node: Nullable<Node>): TransformNode;
  89406. private _nonUniformScaling;
  89407. /**
  89408. * True if the scaling property of this object is non uniform eg. (1,2,1)
  89409. */
  89410. get nonUniformScaling(): boolean;
  89411. /** @hidden */
  89412. _updateNonUniformScalingState(value: boolean): boolean;
  89413. /**
  89414. * Attach the current TransformNode to another TransformNode associated with a bone
  89415. * @param bone Bone affecting the TransformNode
  89416. * @param affectedTransformNode TransformNode associated with the bone
  89417. * @returns this object
  89418. */
  89419. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  89420. /**
  89421. * Detach the transform node if its associated with a bone
  89422. * @returns this object
  89423. */
  89424. detachFromBone(): TransformNode;
  89425. private static _rotationAxisCache;
  89426. /**
  89427. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  89428. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  89429. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  89430. * The passed axis is also normalized.
  89431. * @param axis the axis to rotate around
  89432. * @param amount the amount to rotate in radians
  89433. * @param space Space to rotate in (Default: local)
  89434. * @returns the TransformNode.
  89435. */
  89436. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  89437. /**
  89438. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  89439. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  89440. * The passed axis is also normalized. .
  89441. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  89442. * @param point the point to rotate around
  89443. * @param axis the axis to rotate around
  89444. * @param amount the amount to rotate in radians
  89445. * @returns the TransformNode
  89446. */
  89447. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  89448. /**
  89449. * Translates the mesh along the axis vector for the passed distance in the given space.
  89450. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  89451. * @param axis the axis to translate in
  89452. * @param distance the distance to translate
  89453. * @param space Space to rotate in (Default: local)
  89454. * @returns the TransformNode.
  89455. */
  89456. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  89457. /**
  89458. * Adds a rotation step to the mesh current rotation.
  89459. * x, y, z are Euler angles expressed in radians.
  89460. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  89461. * This means this rotation is made in the mesh local space only.
  89462. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  89463. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  89464. * ```javascript
  89465. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  89466. * ```
  89467. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  89468. * 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.
  89469. * @param x Rotation to add
  89470. * @param y Rotation to add
  89471. * @param z Rotation to add
  89472. * @returns the TransformNode.
  89473. */
  89474. addRotation(x: number, y: number, z: number): TransformNode;
  89475. /**
  89476. * @hidden
  89477. */
  89478. protected _getEffectiveParent(): Nullable<Node>;
  89479. /**
  89480. * Computes the world matrix of the node
  89481. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  89482. * @returns the world matrix
  89483. */
  89484. computeWorldMatrix(force?: boolean): Matrix;
  89485. /**
  89486. * Resets this nodeTransform's local matrix to Matrix.Identity().
  89487. * @param independentOfChildren indicates if all child nodeTransform's world-space transform should be preserved.
  89488. */
  89489. resetLocalMatrix(independentOfChildren?: boolean): void;
  89490. protected _afterComputeWorldMatrix(): void;
  89491. /**
  89492. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  89493. * @param func callback function to add
  89494. *
  89495. * @returns the TransformNode.
  89496. */
  89497. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  89498. /**
  89499. * Removes a registered callback function.
  89500. * @param func callback function to remove
  89501. * @returns the TransformNode.
  89502. */
  89503. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  89504. /**
  89505. * Gets the position of the current mesh in camera space
  89506. * @param camera defines the camera to use
  89507. * @returns a position
  89508. */
  89509. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  89510. /**
  89511. * Returns the distance from the mesh to the active camera
  89512. * @param camera defines the camera to use
  89513. * @returns the distance
  89514. */
  89515. getDistanceToCamera(camera?: Nullable<Camera>): number;
  89516. /**
  89517. * Clone the current transform node
  89518. * @param name Name of the new clone
  89519. * @param newParent New parent for the clone
  89520. * @param doNotCloneChildren Do not clone children hierarchy
  89521. * @returns the new transform node
  89522. */
  89523. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  89524. /**
  89525. * Serializes the objects information.
  89526. * @param currentSerializationObject defines the object to serialize in
  89527. * @returns the serialized object
  89528. */
  89529. serialize(currentSerializationObject?: any): any;
  89530. /**
  89531. * Returns a new TransformNode object parsed from the source provided.
  89532. * @param parsedTransformNode is the source.
  89533. * @param scene the scne the object belongs to
  89534. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  89535. * @returns a new TransformNode object parsed from the source provided.
  89536. */
  89537. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  89538. /**
  89539. * Get all child-transformNodes of this node
  89540. * @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
  89541. * @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
  89542. * @returns an array of TransformNode
  89543. */
  89544. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  89545. /**
  89546. * Releases resources associated with this transform node.
  89547. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  89548. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  89549. */
  89550. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  89551. /**
  89552. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  89553. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  89554. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  89555. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  89556. * @returns the current mesh
  89557. */
  89558. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  89559. private _syncAbsoluteScalingAndRotation;
  89560. }
  89561. }
  89562. declare module BABYLON {
  89563. /**
  89564. * Class used to override all child animations of a given target
  89565. */
  89566. export class AnimationPropertiesOverride {
  89567. /**
  89568. * Gets or sets a value indicating if animation blending must be used
  89569. */
  89570. enableBlending: boolean;
  89571. /**
  89572. * Gets or sets the blending speed to use when enableBlending is true
  89573. */
  89574. blendingSpeed: number;
  89575. /**
  89576. * Gets or sets the default loop mode to use
  89577. */
  89578. loopMode: number;
  89579. }
  89580. }
  89581. declare module BABYLON {
  89582. /**
  89583. * Class used to store bone information
  89584. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  89585. */
  89586. export class Bone extends Node {
  89587. /**
  89588. * defines the bone name
  89589. */
  89590. name: string;
  89591. private static _tmpVecs;
  89592. private static _tmpQuat;
  89593. private static _tmpMats;
  89594. /**
  89595. * Gets the list of child bones
  89596. */
  89597. children: Bone[];
  89598. /** Gets the animations associated with this bone */
  89599. animations: Animation[];
  89600. /**
  89601. * Gets or sets bone length
  89602. */
  89603. length: number;
  89604. /**
  89605. * @hidden Internal only
  89606. * Set this value to map this bone to a different index in the transform matrices
  89607. * Set this value to -1 to exclude the bone from the transform matrices
  89608. */
  89609. _index: Nullable<number>;
  89610. private _skeleton;
  89611. private _localMatrix;
  89612. private _restPose;
  89613. private _baseMatrix;
  89614. private _absoluteTransform;
  89615. private _invertedAbsoluteTransform;
  89616. private _parent;
  89617. private _scalingDeterminant;
  89618. private _worldTransform;
  89619. private _localScaling;
  89620. private _localRotation;
  89621. private _localPosition;
  89622. private _needToDecompose;
  89623. private _needToCompose;
  89624. /** @hidden */
  89625. _linkedTransformNode: Nullable<TransformNode>;
  89626. /** @hidden */
  89627. _waitingTransformNodeId: Nullable<string>;
  89628. /** @hidden */
  89629. get _matrix(): Matrix;
  89630. /** @hidden */
  89631. set _matrix(value: Matrix);
  89632. /**
  89633. * Create a new bone
  89634. * @param name defines the bone name
  89635. * @param skeleton defines the parent skeleton
  89636. * @param parentBone defines the parent (can be null if the bone is the root)
  89637. * @param localMatrix defines the local matrix
  89638. * @param restPose defines the rest pose matrix
  89639. * @param baseMatrix defines the base matrix
  89640. * @param index defines index of the bone in the hiearchy
  89641. */
  89642. constructor(
  89643. /**
  89644. * defines the bone name
  89645. */
  89646. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  89647. /**
  89648. * Gets the current object class name.
  89649. * @return the class name
  89650. */
  89651. getClassName(): string;
  89652. /**
  89653. * Gets the parent skeleton
  89654. * @returns a skeleton
  89655. */
  89656. getSkeleton(): Skeleton;
  89657. /**
  89658. * Gets parent bone
  89659. * @returns a bone or null if the bone is the root of the bone hierarchy
  89660. */
  89661. getParent(): Nullable<Bone>;
  89662. /**
  89663. * Returns an array containing the root bones
  89664. * @returns an array containing the root bones
  89665. */
  89666. getChildren(): Array<Bone>;
  89667. /**
  89668. * Gets the node index in matrix array generated for rendering
  89669. * @returns the node index
  89670. */
  89671. getIndex(): number;
  89672. /**
  89673. * Sets the parent bone
  89674. * @param parent defines the parent (can be null if the bone is the root)
  89675. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  89676. */
  89677. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  89678. /**
  89679. * Gets the local matrix
  89680. * @returns a matrix
  89681. */
  89682. getLocalMatrix(): Matrix;
  89683. /**
  89684. * Gets the base matrix (initial matrix which remains unchanged)
  89685. * @returns a matrix
  89686. */
  89687. getBaseMatrix(): Matrix;
  89688. /**
  89689. * Gets the rest pose matrix
  89690. * @returns a matrix
  89691. */
  89692. getRestPose(): Matrix;
  89693. /**
  89694. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  89695. */
  89696. getWorldMatrix(): Matrix;
  89697. /**
  89698. * Sets the local matrix to rest pose matrix
  89699. */
  89700. returnToRest(): void;
  89701. /**
  89702. * Gets the inverse of the absolute transform matrix.
  89703. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  89704. * @returns a matrix
  89705. */
  89706. getInvertedAbsoluteTransform(): Matrix;
  89707. /**
  89708. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  89709. * @returns a matrix
  89710. */
  89711. getAbsoluteTransform(): Matrix;
  89712. /**
  89713. * Links with the given transform node.
  89714. * The local matrix of this bone is copied from the transform node every frame.
  89715. * @param transformNode defines the transform node to link to
  89716. */
  89717. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  89718. /**
  89719. * Gets the node used to drive the bone's transformation
  89720. * @returns a transform node or null
  89721. */
  89722. getTransformNode(): Nullable<TransformNode>;
  89723. /** Gets or sets current position (in local space) */
  89724. get position(): Vector3;
  89725. set position(newPosition: Vector3);
  89726. /** Gets or sets current rotation (in local space) */
  89727. get rotation(): Vector3;
  89728. set rotation(newRotation: Vector3);
  89729. /** Gets or sets current rotation quaternion (in local space) */
  89730. get rotationQuaternion(): Quaternion;
  89731. set rotationQuaternion(newRotation: Quaternion);
  89732. /** Gets or sets current scaling (in local space) */
  89733. get scaling(): Vector3;
  89734. set scaling(newScaling: Vector3);
  89735. /**
  89736. * Gets the animation properties override
  89737. */
  89738. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  89739. private _decompose;
  89740. private _compose;
  89741. /**
  89742. * Update the base and local matrices
  89743. * @param matrix defines the new base or local matrix
  89744. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  89745. * @param updateLocalMatrix defines if the local matrix should be updated
  89746. */
  89747. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  89748. /** @hidden */
  89749. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  89750. /**
  89751. * Flag the bone as dirty (Forcing it to update everything)
  89752. */
  89753. markAsDirty(): void;
  89754. /** @hidden */
  89755. _markAsDirtyAndCompose(): void;
  89756. private _markAsDirtyAndDecompose;
  89757. /**
  89758. * Translate the bone in local or world space
  89759. * @param vec The amount to translate the bone
  89760. * @param space The space that the translation is in
  89761. * @param mesh The mesh that this bone is attached to. This is only used in world space
  89762. */
  89763. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  89764. /**
  89765. * Set the postion of the bone in local or world space
  89766. * @param position The position to set the bone
  89767. * @param space The space that the position is in
  89768. * @param mesh The mesh that this bone is attached to. This is only used in world space
  89769. */
  89770. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  89771. /**
  89772. * Set the absolute position of the bone (world space)
  89773. * @param position The position to set the bone
  89774. * @param mesh The mesh that this bone is attached to
  89775. */
  89776. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  89777. /**
  89778. * Scale the bone on the x, y and z axes (in local space)
  89779. * @param x The amount to scale the bone on the x axis
  89780. * @param y The amount to scale the bone on the y axis
  89781. * @param z The amount to scale the bone on the z axis
  89782. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  89783. */
  89784. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  89785. /**
  89786. * Set the bone scaling in local space
  89787. * @param scale defines the scaling vector
  89788. */
  89789. setScale(scale: Vector3): void;
  89790. /**
  89791. * Gets the current scaling in local space
  89792. * @returns the current scaling vector
  89793. */
  89794. getScale(): Vector3;
  89795. /**
  89796. * Gets the current scaling in local space and stores it in a target vector
  89797. * @param result defines the target vector
  89798. */
  89799. getScaleToRef(result: Vector3): void;
  89800. /**
  89801. * Set the yaw, pitch, and roll of the bone in local or world space
  89802. * @param yaw The rotation of the bone on the y axis
  89803. * @param pitch The rotation of the bone on the x axis
  89804. * @param roll The rotation of the bone on the z axis
  89805. * @param space The space that the axes of rotation are in
  89806. * @param mesh The mesh that this bone is attached to. This is only used in world space
  89807. */
  89808. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  89809. /**
  89810. * Add a rotation to the bone on an axis in local or world space
  89811. * @param axis The axis to rotate the bone on
  89812. * @param amount The amount to rotate the bone
  89813. * @param space The space that the axis is in
  89814. * @param mesh The mesh that this bone is attached to. This is only used in world space
  89815. */
  89816. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  89817. /**
  89818. * Set the rotation of the bone to a particular axis angle in local or world space
  89819. * @param axis The axis to rotate the bone on
  89820. * @param angle The angle that the bone should be rotated to
  89821. * @param space The space that the axis is in
  89822. * @param mesh The mesh that this bone is attached to. This is only used in world space
  89823. */
  89824. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  89825. /**
  89826. * Set the euler rotation of the bone in local of world space
  89827. * @param rotation The euler rotation that the bone should be set to
  89828. * @param space The space that the rotation is in
  89829. * @param mesh The mesh that this bone is attached to. This is only used in world space
  89830. */
  89831. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  89832. /**
  89833. * Set the quaternion rotation of the bone in local of world space
  89834. * @param quat The quaternion rotation that the bone should be set to
  89835. * @param space The space that the rotation is in
  89836. * @param mesh The mesh that this bone is attached to. This is only used in world space
  89837. */
  89838. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  89839. /**
  89840. * Set the rotation matrix of the bone in local of world space
  89841. * @param rotMat The rotation matrix that the bone should be set to
  89842. * @param space The space that the rotation is in
  89843. * @param mesh The mesh that this bone is attached to. This is only used in world space
  89844. */
  89845. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  89846. private _rotateWithMatrix;
  89847. private _getNegativeRotationToRef;
  89848. /**
  89849. * Get the position of the bone in local or world space
  89850. * @param space The space that the returned position is in
  89851. * @param mesh The mesh that this bone is attached to. This is only used in world space
  89852. * @returns The position of the bone
  89853. */
  89854. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  89855. /**
  89856. * Copy the position of the bone to a vector3 in local or world space
  89857. * @param space The space that the returned position is in
  89858. * @param mesh The mesh that this bone is attached to. This is only used in world space
  89859. * @param result The vector3 to copy the position to
  89860. */
  89861. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  89862. /**
  89863. * Get the absolute position of the bone (world space)
  89864. * @param mesh The mesh that this bone is attached to
  89865. * @returns The absolute position of the bone
  89866. */
  89867. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  89868. /**
  89869. * Copy the absolute position of the bone (world space) to the result param
  89870. * @param mesh The mesh that this bone is attached to
  89871. * @param result The vector3 to copy the absolute position to
  89872. */
  89873. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  89874. /**
  89875. * Compute the absolute transforms of this bone and its children
  89876. */
  89877. computeAbsoluteTransforms(): void;
  89878. /**
  89879. * Get the world direction from an axis that is in the local space of the bone
  89880. * @param localAxis The local direction that is used to compute the world direction
  89881. * @param mesh The mesh that this bone is attached to
  89882. * @returns The world direction
  89883. */
  89884. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  89885. /**
  89886. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  89887. * @param localAxis The local direction that is used to compute the world direction
  89888. * @param mesh The mesh that this bone is attached to
  89889. * @param result The vector3 that the world direction will be copied to
  89890. */
  89891. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  89892. /**
  89893. * Get the euler rotation of the bone in local or world space
  89894. * @param space The space that the rotation should be in
  89895. * @param mesh The mesh that this bone is attached to. This is only used in world space
  89896. * @returns The euler rotation
  89897. */
  89898. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  89899. /**
  89900. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  89901. * @param space The space that the rotation should be in
  89902. * @param mesh The mesh that this bone is attached to. This is only used in world space
  89903. * @param result The vector3 that the rotation should be copied to
  89904. */
  89905. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  89906. /**
  89907. * Get the quaternion rotation of the bone in either local or world space
  89908. * @param space The space that the rotation should be in
  89909. * @param mesh The mesh that this bone is attached to. This is only used in world space
  89910. * @returns The quaternion rotation
  89911. */
  89912. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  89913. /**
  89914. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  89915. * @param space The space that the rotation should be in
  89916. * @param mesh The mesh that this bone is attached to. This is only used in world space
  89917. * @param result The quaternion that the rotation should be copied to
  89918. */
  89919. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  89920. /**
  89921. * Get the rotation matrix of the bone in local or world space
  89922. * @param space The space that the rotation should be in
  89923. * @param mesh The mesh that this bone is attached to. This is only used in world space
  89924. * @returns The rotation matrix
  89925. */
  89926. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  89927. /**
  89928. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  89929. * @param space The space that the rotation should be in
  89930. * @param mesh The mesh that this bone is attached to. This is only used in world space
  89931. * @param result The quaternion that the rotation should be copied to
  89932. */
  89933. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  89934. /**
  89935. * Get the world position of a point that is in the local space of the bone
  89936. * @param position The local position
  89937. * @param mesh The mesh that this bone is attached to
  89938. * @returns The world position
  89939. */
  89940. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  89941. /**
  89942. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  89943. * @param position The local position
  89944. * @param mesh The mesh that this bone is attached to
  89945. * @param result The vector3 that the world position should be copied to
  89946. */
  89947. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  89948. /**
  89949. * Get the local position of a point that is in world space
  89950. * @param position The world position
  89951. * @param mesh The mesh that this bone is attached to
  89952. * @returns The local position
  89953. */
  89954. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  89955. /**
  89956. * Get the local position of a point that is in world space and copy it to the result param
  89957. * @param position The world position
  89958. * @param mesh The mesh that this bone is attached to
  89959. * @param result The vector3 that the local position should be copied to
  89960. */
  89961. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  89962. }
  89963. }
  89964. declare module BABYLON {
  89965. /**
  89966. * Defines a runtime animation
  89967. */
  89968. export class RuntimeAnimation {
  89969. private _events;
  89970. /**
  89971. * The current frame of the runtime animation
  89972. */
  89973. private _currentFrame;
  89974. /**
  89975. * The animation used by the runtime animation
  89976. */
  89977. private _animation;
  89978. /**
  89979. * The target of the runtime animation
  89980. */
  89981. private _target;
  89982. /**
  89983. * The initiating animatable
  89984. */
  89985. private _host;
  89986. /**
  89987. * The original value of the runtime animation
  89988. */
  89989. private _originalValue;
  89990. /**
  89991. * The original blend value of the runtime animation
  89992. */
  89993. private _originalBlendValue;
  89994. /**
  89995. * The offsets cache of the runtime animation
  89996. */
  89997. private _offsetsCache;
  89998. /**
  89999. * The high limits cache of the runtime animation
  90000. */
  90001. private _highLimitsCache;
  90002. /**
  90003. * Specifies if the runtime animation has been stopped
  90004. */
  90005. private _stopped;
  90006. /**
  90007. * The blending factor of the runtime animation
  90008. */
  90009. private _blendingFactor;
  90010. /**
  90011. * The BabylonJS scene
  90012. */
  90013. private _scene;
  90014. /**
  90015. * The current value of the runtime animation
  90016. */
  90017. private _currentValue;
  90018. /** @hidden */
  90019. _animationState: _IAnimationState;
  90020. /**
  90021. * The active target of the runtime animation
  90022. */
  90023. private _activeTargets;
  90024. private _currentActiveTarget;
  90025. private _directTarget;
  90026. /**
  90027. * The target path of the runtime animation
  90028. */
  90029. private _targetPath;
  90030. /**
  90031. * The weight of the runtime animation
  90032. */
  90033. private _weight;
  90034. /**
  90035. * The ratio offset of the runtime animation
  90036. */
  90037. private _ratioOffset;
  90038. /**
  90039. * The previous delay of the runtime animation
  90040. */
  90041. private _previousDelay;
  90042. /**
  90043. * The previous ratio of the runtime animation
  90044. */
  90045. private _previousRatio;
  90046. private _enableBlending;
  90047. private _keys;
  90048. private _minFrame;
  90049. private _maxFrame;
  90050. private _minValue;
  90051. private _maxValue;
  90052. private _targetIsArray;
  90053. /**
  90054. * Gets the current frame of the runtime animation
  90055. */
  90056. get currentFrame(): number;
  90057. /**
  90058. * Gets the weight of the runtime animation
  90059. */
  90060. get weight(): number;
  90061. /**
  90062. * Gets the current value of the runtime animation
  90063. */
  90064. get currentValue(): any;
  90065. /**
  90066. * Gets the target path of the runtime animation
  90067. */
  90068. get targetPath(): string;
  90069. /**
  90070. * Gets the actual target of the runtime animation
  90071. */
  90072. get target(): any;
  90073. /**
  90074. * Gets the additive state of the runtime animation
  90075. */
  90076. get isAdditive(): boolean;
  90077. /** @hidden */
  90078. _onLoop: () => void;
  90079. /**
  90080. * Create a new RuntimeAnimation object
  90081. * @param target defines the target of the animation
  90082. * @param animation defines the source animation object
  90083. * @param scene defines the hosting scene
  90084. * @param host defines the initiating Animatable
  90085. */
  90086. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  90087. private _preparePath;
  90088. /**
  90089. * Gets the animation from the runtime animation
  90090. */
  90091. get animation(): Animation;
  90092. /**
  90093. * Resets the runtime animation to the beginning
  90094. * @param restoreOriginal defines whether to restore the target property to the original value
  90095. */
  90096. reset(restoreOriginal?: boolean): void;
  90097. /**
  90098. * Specifies if the runtime animation is stopped
  90099. * @returns Boolean specifying if the runtime animation is stopped
  90100. */
  90101. isStopped(): boolean;
  90102. /**
  90103. * Disposes of the runtime animation
  90104. */
  90105. dispose(): void;
  90106. /**
  90107. * Apply the interpolated value to the target
  90108. * @param currentValue defines the value computed by the animation
  90109. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  90110. */
  90111. setValue(currentValue: any, weight: number): void;
  90112. private _getOriginalValues;
  90113. private _setValue;
  90114. /**
  90115. * Gets the loop pmode of the runtime animation
  90116. * @returns Loop Mode
  90117. */
  90118. private _getCorrectLoopMode;
  90119. /**
  90120. * Move the current animation to a given frame
  90121. * @param frame defines the frame to move to
  90122. */
  90123. goToFrame(frame: number): void;
  90124. /**
  90125. * @hidden Internal use only
  90126. */
  90127. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  90128. /**
  90129. * Execute the current animation
  90130. * @param delay defines the delay to add to the current frame
  90131. * @param from defines the lower bound of the animation range
  90132. * @param to defines the upper bound of the animation range
  90133. * @param loop defines if the current animation must loop
  90134. * @param speedRatio defines the current speed ratio
  90135. * @param weight defines the weight of the animation (default is -1 so no weight)
  90136. * @param onLoop optional callback called when animation loops
  90137. * @returns a boolean indicating if the animation is running
  90138. */
  90139. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  90140. }
  90141. }
  90142. declare module BABYLON {
  90143. /**
  90144. * Class used to store an actual running animation
  90145. */
  90146. export class Animatable {
  90147. /** defines the target object */
  90148. target: any;
  90149. /** defines the starting frame number (default is 0) */
  90150. fromFrame: number;
  90151. /** defines the ending frame number (default is 100) */
  90152. toFrame: number;
  90153. /** defines if the animation must loop (default is false) */
  90154. loopAnimation: boolean;
  90155. /** defines a callback to call when animation ends if it is not looping */
  90156. onAnimationEnd?: (() => void) | null | undefined;
  90157. /** defines a callback to call when animation loops */
  90158. onAnimationLoop?: (() => void) | null | undefined;
  90159. /** defines whether the animation should be evaluated additively */
  90160. isAdditive: boolean;
  90161. private _localDelayOffset;
  90162. private _pausedDelay;
  90163. private _runtimeAnimations;
  90164. private _paused;
  90165. private _scene;
  90166. private _speedRatio;
  90167. private _weight;
  90168. private _syncRoot;
  90169. /**
  90170. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  90171. * This will only apply for non looping animation (default is true)
  90172. */
  90173. disposeOnEnd: boolean;
  90174. /**
  90175. * Gets a boolean indicating if the animation has started
  90176. */
  90177. animationStarted: boolean;
  90178. /**
  90179. * Observer raised when the animation ends
  90180. */
  90181. onAnimationEndObservable: Observable<Animatable>;
  90182. /**
  90183. * Observer raised when the animation loops
  90184. */
  90185. onAnimationLoopObservable: Observable<Animatable>;
  90186. /**
  90187. * Gets the root Animatable used to synchronize and normalize animations
  90188. */
  90189. get syncRoot(): Nullable<Animatable>;
  90190. /**
  90191. * Gets the current frame of the first RuntimeAnimation
  90192. * Used to synchronize Animatables
  90193. */
  90194. get masterFrame(): number;
  90195. /**
  90196. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  90197. */
  90198. get weight(): number;
  90199. set weight(value: number);
  90200. /**
  90201. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  90202. */
  90203. get speedRatio(): number;
  90204. set speedRatio(value: number);
  90205. /**
  90206. * Creates a new Animatable
  90207. * @param scene defines the hosting scene
  90208. * @param target defines the target object
  90209. * @param fromFrame defines the starting frame number (default is 0)
  90210. * @param toFrame defines the ending frame number (default is 100)
  90211. * @param loopAnimation defines if the animation must loop (default is false)
  90212. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  90213. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  90214. * @param animations defines a group of animation to add to the new Animatable
  90215. * @param onAnimationLoop defines a callback to call when animation loops
  90216. * @param isAdditive defines whether the animation should be evaluated additively
  90217. */
  90218. constructor(scene: Scene,
  90219. /** defines the target object */
  90220. target: any,
  90221. /** defines the starting frame number (default is 0) */
  90222. fromFrame?: number,
  90223. /** defines the ending frame number (default is 100) */
  90224. toFrame?: number,
  90225. /** defines if the animation must loop (default is false) */
  90226. loopAnimation?: boolean, speedRatio?: number,
  90227. /** defines a callback to call when animation ends if it is not looping */
  90228. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  90229. /** defines a callback to call when animation loops */
  90230. onAnimationLoop?: (() => void) | null | undefined,
  90231. /** defines whether the animation should be evaluated additively */
  90232. isAdditive?: boolean);
  90233. /**
  90234. * Synchronize and normalize current Animatable with a source Animatable
  90235. * This is useful when using animation weights and when animations are not of the same length
  90236. * @param root defines the root Animatable to synchronize with
  90237. * @returns the current Animatable
  90238. */
  90239. syncWith(root: Animatable): Animatable;
  90240. /**
  90241. * Gets the list of runtime animations
  90242. * @returns an array of RuntimeAnimation
  90243. */
  90244. getAnimations(): RuntimeAnimation[];
  90245. /**
  90246. * Adds more animations to the current animatable
  90247. * @param target defines the target of the animations
  90248. * @param animations defines the new animations to add
  90249. */
  90250. appendAnimations(target: any, animations: Animation[]): void;
  90251. /**
  90252. * Gets the source animation for a specific property
  90253. * @param property defines the propertyu to look for
  90254. * @returns null or the source animation for the given property
  90255. */
  90256. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  90257. /**
  90258. * Gets the runtime animation for a specific property
  90259. * @param property defines the propertyu to look for
  90260. * @returns null or the runtime animation for the given property
  90261. */
  90262. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  90263. /**
  90264. * Resets the animatable to its original state
  90265. */
  90266. reset(): void;
  90267. /**
  90268. * Allows the animatable to blend with current running animations
  90269. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  90270. * @param blendingSpeed defines the blending speed to use
  90271. */
  90272. enableBlending(blendingSpeed: number): void;
  90273. /**
  90274. * Disable animation blending
  90275. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  90276. */
  90277. disableBlending(): void;
  90278. /**
  90279. * Jump directly to a given frame
  90280. * @param frame defines the frame to jump to
  90281. */
  90282. goToFrame(frame: number): void;
  90283. /**
  90284. * Pause the animation
  90285. */
  90286. pause(): void;
  90287. /**
  90288. * Restart the animation
  90289. */
  90290. restart(): void;
  90291. private _raiseOnAnimationEnd;
  90292. /**
  90293. * Stop and delete the current animation
  90294. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  90295. * @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)
  90296. */
  90297. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  90298. /**
  90299. * Wait asynchronously for the animation to end
  90300. * @returns a promise which will be fullfilled when the animation ends
  90301. */
  90302. waitAsync(): Promise<Animatable>;
  90303. /** @hidden */
  90304. _animate(delay: number): boolean;
  90305. }
  90306. interface Scene {
  90307. /** @hidden */
  90308. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  90309. /** @hidden */
  90310. _processLateAnimationBindingsForMatrices(holder: {
  90311. totalWeight: number;
  90312. totalAdditiveWeight: number;
  90313. animations: RuntimeAnimation[];
  90314. additiveAnimations: RuntimeAnimation[];
  90315. originalValue: Matrix;
  90316. }): any;
  90317. /** @hidden */
  90318. _processLateAnimationBindingsForQuaternions(holder: {
  90319. totalWeight: number;
  90320. totalAdditiveWeight: number;
  90321. animations: RuntimeAnimation[];
  90322. additiveAnimations: RuntimeAnimation[];
  90323. originalValue: Quaternion;
  90324. }, refQuaternion: Quaternion): Quaternion;
  90325. /** @hidden */
  90326. _processLateAnimationBindings(): void;
  90327. /**
  90328. * Will start the animation sequence of a given target
  90329. * @param target defines the target
  90330. * @param from defines from which frame should animation start
  90331. * @param to defines until which frame should animation run.
  90332. * @param weight defines the weight to apply to the animation (1.0 by default)
  90333. * @param loop defines if the animation loops
  90334. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  90335. * @param onAnimationEnd defines the function to be executed when the animation ends
  90336. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  90337. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  90338. * @param onAnimationLoop defines the callback to call when an animation loops
  90339. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  90340. * @returns the animatable object created for this animation
  90341. */
  90342. 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;
  90343. /**
  90344. * Will start the animation sequence of a given target
  90345. * @param target defines the target
  90346. * @param from defines from which frame should animation start
  90347. * @param to defines until which frame should animation run.
  90348. * @param loop defines if the animation loops
  90349. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  90350. * @param onAnimationEnd defines the function to be executed when the animation ends
  90351. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  90352. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  90353. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  90354. * @param onAnimationLoop defines the callback to call when an animation loops
  90355. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  90356. * @returns the animatable object created for this animation
  90357. */
  90358. 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;
  90359. /**
  90360. * Will start the animation sequence of a given target and its hierarchy
  90361. * @param target defines the target
  90362. * @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.
  90363. * @param from defines from which frame should animation start
  90364. * @param to defines until which frame should animation run.
  90365. * @param loop defines if the animation loops
  90366. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  90367. * @param onAnimationEnd defines the function to be executed when the animation ends
  90368. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  90369. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  90370. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  90371. * @param onAnimationLoop defines the callback to call when an animation loops
  90372. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  90373. * @returns the list of created animatables
  90374. */
  90375. 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[];
  90376. /**
  90377. * Begin a new animation on a given node
  90378. * @param target defines the target where the animation will take place
  90379. * @param animations defines the list of animations to start
  90380. * @param from defines the initial value
  90381. * @param to defines the final value
  90382. * @param loop defines if you want animation to loop (off by default)
  90383. * @param speedRatio defines the speed ratio to apply to all animations
  90384. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  90385. * @param onAnimationLoop defines the callback to call when an animation loops
  90386. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  90387. * @returns the list of created animatables
  90388. */
  90389. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  90390. /**
  90391. * Begin a new animation on a given node and its hierarchy
  90392. * @param target defines the root node where the animation will take place
  90393. * @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.
  90394. * @param animations defines the list of animations to start
  90395. * @param from defines the initial value
  90396. * @param to defines the final value
  90397. * @param loop defines if you want animation to loop (off by default)
  90398. * @param speedRatio defines the speed ratio to apply to all animations
  90399. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  90400. * @param onAnimationLoop defines the callback to call when an animation loops
  90401. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  90402. * @returns the list of animatables created for all nodes
  90403. */
  90404. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable[];
  90405. /**
  90406. * Gets the animatable associated with a specific target
  90407. * @param target defines the target of the animatable
  90408. * @returns the required animatable if found
  90409. */
  90410. getAnimatableByTarget(target: any): Nullable<Animatable>;
  90411. /**
  90412. * Gets all animatables associated with a given target
  90413. * @param target defines the target to look animatables for
  90414. * @returns an array of Animatables
  90415. */
  90416. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  90417. /**
  90418. * Stops and removes all animations that have been applied to the scene
  90419. */
  90420. stopAllAnimations(): void;
  90421. /**
  90422. * Gets the current delta time used by animation engine
  90423. */
  90424. deltaTime: number;
  90425. }
  90426. interface Bone {
  90427. /**
  90428. * Copy an animation range from another bone
  90429. * @param source defines the source bone
  90430. * @param rangeName defines the range name to copy
  90431. * @param frameOffset defines the frame offset
  90432. * @param rescaleAsRequired defines if rescaling must be applied if required
  90433. * @param skelDimensionsRatio defines the scaling ratio
  90434. * @returns true if operation was successful
  90435. */
  90436. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  90437. }
  90438. }
  90439. declare module BABYLON {
  90440. /**
  90441. * Class used to handle skinning animations
  90442. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  90443. */
  90444. export class Skeleton implements IAnimatable {
  90445. /** defines the skeleton name */
  90446. name: string;
  90447. /** defines the skeleton Id */
  90448. id: string;
  90449. /**
  90450. * Defines the list of child bones
  90451. */
  90452. bones: Bone[];
  90453. /**
  90454. * Defines an estimate of the dimension of the skeleton at rest
  90455. */
  90456. dimensionsAtRest: Vector3;
  90457. /**
  90458. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  90459. */
  90460. needInitialSkinMatrix: boolean;
  90461. /**
  90462. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  90463. */
  90464. overrideMesh: Nullable<AbstractMesh>;
  90465. /**
  90466. * Gets the list of animations attached to this skeleton
  90467. */
  90468. animations: Array<Animation>;
  90469. private _scene;
  90470. private _isDirty;
  90471. private _transformMatrices;
  90472. private _transformMatrixTexture;
  90473. private _meshesWithPoseMatrix;
  90474. private _animatables;
  90475. private _identity;
  90476. private _synchronizedWithMesh;
  90477. private _ranges;
  90478. private _lastAbsoluteTransformsUpdateId;
  90479. private _canUseTextureForBones;
  90480. private _uniqueId;
  90481. /** @hidden */
  90482. _numBonesWithLinkedTransformNode: number;
  90483. /** @hidden */
  90484. _hasWaitingData: Nullable<boolean>;
  90485. /**
  90486. * Specifies if the skeleton should be serialized
  90487. */
  90488. doNotSerialize: boolean;
  90489. private _useTextureToStoreBoneMatrices;
  90490. /**
  90491. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  90492. * Please note that this option is not available if the hardware does not support it
  90493. */
  90494. get useTextureToStoreBoneMatrices(): boolean;
  90495. set useTextureToStoreBoneMatrices(value: boolean);
  90496. private _animationPropertiesOverride;
  90497. /**
  90498. * Gets or sets the animation properties override
  90499. */
  90500. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  90501. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  90502. /**
  90503. * List of inspectable custom properties (used by the Inspector)
  90504. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  90505. */
  90506. inspectableCustomProperties: IInspectable[];
  90507. /**
  90508. * An observable triggered before computing the skeleton's matrices
  90509. */
  90510. onBeforeComputeObservable: Observable<Skeleton>;
  90511. /**
  90512. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  90513. */
  90514. get isUsingTextureForMatrices(): boolean;
  90515. /**
  90516. * Gets the unique ID of this skeleton
  90517. */
  90518. get uniqueId(): number;
  90519. /**
  90520. * Creates a new skeleton
  90521. * @param name defines the skeleton name
  90522. * @param id defines the skeleton Id
  90523. * @param scene defines the hosting scene
  90524. */
  90525. constructor(
  90526. /** defines the skeleton name */
  90527. name: string,
  90528. /** defines the skeleton Id */
  90529. id: string, scene: Scene);
  90530. /**
  90531. * Gets the current object class name.
  90532. * @return the class name
  90533. */
  90534. getClassName(): string;
  90535. /**
  90536. * Returns an array containing the root bones
  90537. * @returns an array containing the root bones
  90538. */
  90539. getChildren(): Array<Bone>;
  90540. /**
  90541. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  90542. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  90543. * @returns a Float32Array containing matrices data
  90544. */
  90545. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  90546. /**
  90547. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  90548. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  90549. * @returns a raw texture containing the data
  90550. */
  90551. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  90552. /**
  90553. * Gets the current hosting scene
  90554. * @returns a scene object
  90555. */
  90556. getScene(): Scene;
  90557. /**
  90558. * Gets a string representing the current skeleton data
  90559. * @param fullDetails defines a boolean indicating if we want a verbose version
  90560. * @returns a string representing the current skeleton data
  90561. */
  90562. toString(fullDetails?: boolean): string;
  90563. /**
  90564. * Get bone's index searching by name
  90565. * @param name defines bone's name to search for
  90566. * @return the indice of the bone. Returns -1 if not found
  90567. */
  90568. getBoneIndexByName(name: string): number;
  90569. /**
  90570. * Creater a new animation range
  90571. * @param name defines the name of the range
  90572. * @param from defines the start key
  90573. * @param to defines the end key
  90574. */
  90575. createAnimationRange(name: string, from: number, to: number): void;
  90576. /**
  90577. * Delete a specific animation range
  90578. * @param name defines the name of the range
  90579. * @param deleteFrames defines if frames must be removed as well
  90580. */
  90581. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  90582. /**
  90583. * Gets a specific animation range
  90584. * @param name defines the name of the range to look for
  90585. * @returns the requested animation range or null if not found
  90586. */
  90587. getAnimationRange(name: string): Nullable<AnimationRange>;
  90588. /**
  90589. * Gets the list of all animation ranges defined on this skeleton
  90590. * @returns an array
  90591. */
  90592. getAnimationRanges(): Nullable<AnimationRange>[];
  90593. /**
  90594. * Copy animation range from a source skeleton.
  90595. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  90596. * @param source defines the source skeleton
  90597. * @param name defines the name of the range to copy
  90598. * @param rescaleAsRequired defines if rescaling must be applied if required
  90599. * @returns true if operation was successful
  90600. */
  90601. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  90602. /**
  90603. * Forces the skeleton to go to rest pose
  90604. */
  90605. returnToRest(): void;
  90606. private _getHighestAnimationFrame;
  90607. /**
  90608. * Begin a specific animation range
  90609. * @param name defines the name of the range to start
  90610. * @param loop defines if looping must be turned on (false by default)
  90611. * @param speedRatio defines the speed ratio to apply (1 by default)
  90612. * @param onAnimationEnd defines a callback which will be called when animation will end
  90613. * @returns a new animatable
  90614. */
  90615. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  90616. /**
  90617. * Convert the keyframes for a range of animation on a skeleton to be relative to a given reference frame.
  90618. * @param skeleton defines the Skeleton containing the animation range to convert
  90619. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  90620. * @param range defines the name of the AnimationRange belonging to the Skeleton to convert
  90621. * @returns the original skeleton
  90622. */
  90623. static MakeAnimationAdditive(skeleton: Skeleton, referenceFrame: number | undefined, range: string): Nullable<Skeleton>;
  90624. /** @hidden */
  90625. _markAsDirty(): void;
  90626. /** @hidden */
  90627. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  90628. /** @hidden */
  90629. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  90630. private _computeTransformMatrices;
  90631. /**
  90632. * Build all resources required to render a skeleton
  90633. */
  90634. prepare(): void;
  90635. /**
  90636. * Gets the list of animatables currently running for this skeleton
  90637. * @returns an array of animatables
  90638. */
  90639. getAnimatables(): IAnimatable[];
  90640. /**
  90641. * Clone the current skeleton
  90642. * @param name defines the name of the new skeleton
  90643. * @param id defines the id of the new skeleton
  90644. * @returns the new skeleton
  90645. */
  90646. clone(name: string, id?: string): Skeleton;
  90647. /**
  90648. * Enable animation blending for this skeleton
  90649. * @param blendingSpeed defines the blending speed to apply
  90650. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  90651. */
  90652. enableBlending(blendingSpeed?: number): void;
  90653. /**
  90654. * Releases all resources associated with the current skeleton
  90655. */
  90656. dispose(): void;
  90657. /**
  90658. * Serialize the skeleton in a JSON object
  90659. * @returns a JSON object
  90660. */
  90661. serialize(): any;
  90662. /**
  90663. * Creates a new skeleton from serialized data
  90664. * @param parsedSkeleton defines the serialized data
  90665. * @param scene defines the hosting scene
  90666. * @returns a new skeleton
  90667. */
  90668. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  90669. /**
  90670. * Compute all node absolute transforms
  90671. * @param forceUpdate defines if computation must be done even if cache is up to date
  90672. */
  90673. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  90674. /**
  90675. * Gets the root pose matrix
  90676. * @returns a matrix
  90677. */
  90678. getPoseMatrix(): Nullable<Matrix>;
  90679. /**
  90680. * Sorts bones per internal index
  90681. */
  90682. sortBones(): void;
  90683. private _sortBones;
  90684. }
  90685. }
  90686. declare module BABYLON {
  90687. /**
  90688. * Creates an instance based on a source mesh.
  90689. */
  90690. export class InstancedMesh extends AbstractMesh {
  90691. private _sourceMesh;
  90692. private _currentLOD;
  90693. /** @hidden */
  90694. _indexInSourceMeshInstanceArray: number;
  90695. constructor(name: string, source: Mesh);
  90696. /**
  90697. * Returns the string "InstancedMesh".
  90698. */
  90699. getClassName(): string;
  90700. /** Gets the list of lights affecting that mesh */
  90701. get lightSources(): Light[];
  90702. _resyncLightSources(): void;
  90703. _resyncLightSource(light: Light): void;
  90704. _removeLightSource(light: Light, dispose: boolean): void;
  90705. /**
  90706. * If the source mesh receives shadows
  90707. */
  90708. get receiveShadows(): boolean;
  90709. /**
  90710. * The material of the source mesh
  90711. */
  90712. get material(): Nullable<Material>;
  90713. /**
  90714. * Visibility of the source mesh
  90715. */
  90716. get visibility(): number;
  90717. /**
  90718. * Skeleton of the source mesh
  90719. */
  90720. get skeleton(): Nullable<Skeleton>;
  90721. /**
  90722. * Rendering ground id of the source mesh
  90723. */
  90724. get renderingGroupId(): number;
  90725. set renderingGroupId(value: number);
  90726. /**
  90727. * Returns the total number of vertices (integer).
  90728. */
  90729. getTotalVertices(): number;
  90730. /**
  90731. * Returns a positive integer : the total number of indices in this mesh geometry.
  90732. * @returns the numner of indices or zero if the mesh has no geometry.
  90733. */
  90734. getTotalIndices(): number;
  90735. /**
  90736. * The source mesh of the instance
  90737. */
  90738. get sourceMesh(): Mesh;
  90739. /**
  90740. * Is this node ready to be used/rendered
  90741. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  90742. * @return {boolean} is it ready
  90743. */
  90744. isReady(completeCheck?: boolean): boolean;
  90745. /**
  90746. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  90747. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  90748. * @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.
  90749. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  90750. */
  90751. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  90752. /**
  90753. * Sets the vertex data of the mesh geometry for the requested `kind`.
  90754. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  90755. * The `data` are either a numeric array either a Float32Array.
  90756. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  90757. * 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).
  90758. * Note that a new underlying VertexBuffer object is created each call.
  90759. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  90760. *
  90761. * Possible `kind` values :
  90762. * - VertexBuffer.PositionKind
  90763. * - VertexBuffer.UVKind
  90764. * - VertexBuffer.UV2Kind
  90765. * - VertexBuffer.UV3Kind
  90766. * - VertexBuffer.UV4Kind
  90767. * - VertexBuffer.UV5Kind
  90768. * - VertexBuffer.UV6Kind
  90769. * - VertexBuffer.ColorKind
  90770. * - VertexBuffer.MatricesIndicesKind
  90771. * - VertexBuffer.MatricesIndicesExtraKind
  90772. * - VertexBuffer.MatricesWeightsKind
  90773. * - VertexBuffer.MatricesWeightsExtraKind
  90774. *
  90775. * Returns the Mesh.
  90776. */
  90777. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  90778. /**
  90779. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  90780. * If the mesh has no geometry, it is simply returned as it is.
  90781. * The `data` are either a numeric array either a Float32Array.
  90782. * No new underlying VertexBuffer object is created.
  90783. * 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.
  90784. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  90785. *
  90786. * Possible `kind` values :
  90787. * - VertexBuffer.PositionKind
  90788. * - VertexBuffer.UVKind
  90789. * - VertexBuffer.UV2Kind
  90790. * - VertexBuffer.UV3Kind
  90791. * - VertexBuffer.UV4Kind
  90792. * - VertexBuffer.UV5Kind
  90793. * - VertexBuffer.UV6Kind
  90794. * - VertexBuffer.ColorKind
  90795. * - VertexBuffer.MatricesIndicesKind
  90796. * - VertexBuffer.MatricesIndicesExtraKind
  90797. * - VertexBuffer.MatricesWeightsKind
  90798. * - VertexBuffer.MatricesWeightsExtraKind
  90799. *
  90800. * Returns the Mesh.
  90801. */
  90802. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  90803. /**
  90804. * Sets the mesh indices.
  90805. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  90806. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  90807. * This method creates a new index buffer each call.
  90808. * Returns the Mesh.
  90809. */
  90810. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  90811. /**
  90812. * Boolean : True if the mesh owns the requested kind of data.
  90813. */
  90814. isVerticesDataPresent(kind: string): boolean;
  90815. /**
  90816. * Returns an array of indices (IndicesArray).
  90817. */
  90818. getIndices(): Nullable<IndicesArray>;
  90819. get _positions(): Nullable<Vector3[]>;
  90820. /**
  90821. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  90822. * This means the mesh underlying bounding box and sphere are recomputed.
  90823. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  90824. * @returns the current mesh
  90825. */
  90826. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  90827. /** @hidden */
  90828. _preActivate(): InstancedMesh;
  90829. /** @hidden */
  90830. _activate(renderId: number, intermediateRendering: boolean): boolean;
  90831. /** @hidden */
  90832. _postActivate(): void;
  90833. getWorldMatrix(): Matrix;
  90834. get isAnInstance(): boolean;
  90835. /**
  90836. * Returns the current associated LOD AbstractMesh.
  90837. */
  90838. getLOD(camera: Camera): AbstractMesh;
  90839. /** @hidden */
  90840. _preActivateForIntermediateRendering(renderId: number): Mesh;
  90841. /** @hidden */
  90842. _syncSubMeshes(): InstancedMesh;
  90843. /** @hidden */
  90844. _generatePointsArray(): boolean;
  90845. /**
  90846. * Creates a new InstancedMesh from the current mesh.
  90847. * - name (string) : the cloned mesh name
  90848. * - newParent (optional Node) : the optional Node to parent the clone to.
  90849. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  90850. *
  90851. * Returns the clone.
  90852. */
  90853. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): InstancedMesh;
  90854. /**
  90855. * Disposes the InstancedMesh.
  90856. * Returns nothing.
  90857. */
  90858. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  90859. }
  90860. interface Mesh {
  90861. /**
  90862. * Register a custom buffer that will be instanced
  90863. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  90864. * @param kind defines the buffer kind
  90865. * @param stride defines the stride in floats
  90866. */
  90867. registerInstancedBuffer(kind: string, stride: number): void;
  90868. /** @hidden */
  90869. _userInstancedBuffersStorage: {
  90870. data: {
  90871. [key: string]: Float32Array;
  90872. };
  90873. sizes: {
  90874. [key: string]: number;
  90875. };
  90876. vertexBuffers: {
  90877. [key: string]: Nullable<VertexBuffer>;
  90878. };
  90879. strides: {
  90880. [key: string]: number;
  90881. };
  90882. };
  90883. }
  90884. interface AbstractMesh {
  90885. /**
  90886. * Object used to store instanced buffers defined by user
  90887. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  90888. */
  90889. instancedBuffers: {
  90890. [key: string]: any;
  90891. };
  90892. }
  90893. }
  90894. declare module BABYLON {
  90895. /**
  90896. * Defines the options associated with the creation of a shader material.
  90897. */
  90898. export interface IShaderMaterialOptions {
  90899. /**
  90900. * Does the material work in alpha blend mode
  90901. */
  90902. needAlphaBlending: boolean;
  90903. /**
  90904. * Does the material work in alpha test mode
  90905. */
  90906. needAlphaTesting: boolean;
  90907. /**
  90908. * The list of attribute names used in the shader
  90909. */
  90910. attributes: string[];
  90911. /**
  90912. * The list of unifrom names used in the shader
  90913. */
  90914. uniforms: string[];
  90915. /**
  90916. * The list of UBO names used in the shader
  90917. */
  90918. uniformBuffers: string[];
  90919. /**
  90920. * The list of sampler names used in the shader
  90921. */
  90922. samplers: string[];
  90923. /**
  90924. * The list of defines used in the shader
  90925. */
  90926. defines: string[];
  90927. }
  90928. /**
  90929. * 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.
  90930. *
  90931. * This returned material effects how the mesh will look based on the code in the shaders.
  90932. *
  90933. * @see http://doc.babylonjs.com/how_to/shader_material
  90934. */
  90935. export class ShaderMaterial extends Material {
  90936. private _shaderPath;
  90937. private _options;
  90938. private _textures;
  90939. private _textureArrays;
  90940. private _floats;
  90941. private _ints;
  90942. private _floatsArrays;
  90943. private _colors3;
  90944. private _colors3Arrays;
  90945. private _colors4;
  90946. private _colors4Arrays;
  90947. private _vectors2;
  90948. private _vectors3;
  90949. private _vectors4;
  90950. private _matrices;
  90951. private _matrixArrays;
  90952. private _matrices3x3;
  90953. private _matrices2x2;
  90954. private _vectors2Arrays;
  90955. private _vectors3Arrays;
  90956. private _vectors4Arrays;
  90957. private _cachedWorldViewMatrix;
  90958. private _cachedWorldViewProjectionMatrix;
  90959. private _renderId;
  90960. private _multiview;
  90961. private _cachedDefines;
  90962. /**
  90963. * Instantiate a new shader material.
  90964. * 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.
  90965. * This returned material effects how the mesh will look based on the code in the shaders.
  90966. * @see http://doc.babylonjs.com/how_to/shader_material
  90967. * @param name Define the name of the material in the scene
  90968. * @param scene Define the scene the material belongs to
  90969. * @param shaderPath Defines the route to the shader code in one of three ways:
  90970. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  90971. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  90972. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  90973. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  90974. * @param options Define the options used to create the shader
  90975. */
  90976. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  90977. /**
  90978. * Gets the shader path used to define the shader code
  90979. * It can be modified to trigger a new compilation
  90980. */
  90981. get shaderPath(): any;
  90982. /**
  90983. * Sets the shader path used to define the shader code
  90984. * It can be modified to trigger a new compilation
  90985. */
  90986. set shaderPath(shaderPath: any);
  90987. /**
  90988. * Gets the options used to compile the shader.
  90989. * They can be modified to trigger a new compilation
  90990. */
  90991. get options(): IShaderMaterialOptions;
  90992. /**
  90993. * Gets the current class name of the material e.g. "ShaderMaterial"
  90994. * Mainly use in serialization.
  90995. * @returns the class name
  90996. */
  90997. getClassName(): string;
  90998. /**
  90999. * Specifies if the material will require alpha blending
  91000. * @returns a boolean specifying if alpha blending is needed
  91001. */
  91002. needAlphaBlending(): boolean;
  91003. /**
  91004. * Specifies if this material should be rendered in alpha test mode
  91005. * @returns a boolean specifying if an alpha test is needed.
  91006. */
  91007. needAlphaTesting(): boolean;
  91008. private _checkUniform;
  91009. /**
  91010. * Set a texture in the shader.
  91011. * @param name Define the name of the uniform samplers as defined in the shader
  91012. * @param texture Define the texture to bind to this sampler
  91013. * @return the material itself allowing "fluent" like uniform updates
  91014. */
  91015. setTexture(name: string, texture: BaseTexture): ShaderMaterial;
  91016. /**
  91017. * Set a texture array in the shader.
  91018. * @param name Define the name of the uniform sampler array as defined in the shader
  91019. * @param textures Define the list of textures to bind to this sampler
  91020. * @return the material itself allowing "fluent" like uniform updates
  91021. */
  91022. setTextureArray(name: string, textures: BaseTexture[]): ShaderMaterial;
  91023. /**
  91024. * Set a float in the shader.
  91025. * @param name Define the name of the uniform as defined in the shader
  91026. * @param value Define the value to give to the uniform
  91027. * @return the material itself allowing "fluent" like uniform updates
  91028. */
  91029. setFloat(name: string, value: number): ShaderMaterial;
  91030. /**
  91031. * Set a int in the shader.
  91032. * @param name Define the name of the uniform as defined in the shader
  91033. * @param value Define the value to give to the uniform
  91034. * @return the material itself allowing "fluent" like uniform updates
  91035. */
  91036. setInt(name: string, value: number): ShaderMaterial;
  91037. /**
  91038. * Set an array of floats in the shader.
  91039. * @param name Define the name of the uniform as defined in the shader
  91040. * @param value Define the value to give to the uniform
  91041. * @return the material itself allowing "fluent" like uniform updates
  91042. */
  91043. setFloats(name: string, value: number[]): ShaderMaterial;
  91044. /**
  91045. * Set a vec3 in the shader from a Color3.
  91046. * @param name Define the name of the uniform as defined in the shader
  91047. * @param value Define the value to give to the uniform
  91048. * @return the material itself allowing "fluent" like uniform updates
  91049. */
  91050. setColor3(name: string, value: Color3): ShaderMaterial;
  91051. /**
  91052. * Set a vec3 array in the shader from a Color3 array.
  91053. * @param name Define the name of the uniform as defined in the shader
  91054. * @param value Define the value to give to the uniform
  91055. * @return the material itself allowing "fluent" like uniform updates
  91056. */
  91057. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  91058. /**
  91059. * Set a vec4 in the shader from a Color4.
  91060. * @param name Define the name of the uniform as defined in the shader
  91061. * @param value Define the value to give to the uniform
  91062. * @return the material itself allowing "fluent" like uniform updates
  91063. */
  91064. setColor4(name: string, value: Color4): ShaderMaterial;
  91065. /**
  91066. * Set a vec4 array in the shader from a Color4 array.
  91067. * @param name Define the name of the uniform as defined in the shader
  91068. * @param value Define the value to give to the uniform
  91069. * @return the material itself allowing "fluent" like uniform updates
  91070. */
  91071. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  91072. /**
  91073. * Set a vec2 in the shader from a Vector2.
  91074. * @param name Define the name of the uniform as defined in the shader
  91075. * @param value Define the value to give to the uniform
  91076. * @return the material itself allowing "fluent" like uniform updates
  91077. */
  91078. setVector2(name: string, value: Vector2): ShaderMaterial;
  91079. /**
  91080. * Set a vec3 in the shader from a Vector3.
  91081. * @param name Define the name of the uniform as defined in the shader
  91082. * @param value Define the value to give to the uniform
  91083. * @return the material itself allowing "fluent" like uniform updates
  91084. */
  91085. setVector3(name: string, value: Vector3): ShaderMaterial;
  91086. /**
  91087. * Set a vec4 in the shader from a Vector4.
  91088. * @param name Define the name of the uniform as defined in the shader
  91089. * @param value Define the value to give to the uniform
  91090. * @return the material itself allowing "fluent" like uniform updates
  91091. */
  91092. setVector4(name: string, value: Vector4): ShaderMaterial;
  91093. /**
  91094. * Set a mat4 in the shader from a Matrix.
  91095. * @param name Define the name of the uniform as defined in the shader
  91096. * @param value Define the value to give to the uniform
  91097. * @return the material itself allowing "fluent" like uniform updates
  91098. */
  91099. setMatrix(name: string, value: Matrix): ShaderMaterial;
  91100. /**
  91101. * Set a float32Array in the shader from a matrix array.
  91102. * @param name Define the name of the uniform as defined in the shader
  91103. * @param value Define the value to give to the uniform
  91104. * @return the material itself allowing "fluent" like uniform updates
  91105. */
  91106. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  91107. /**
  91108. * Set a mat3 in the shader from a Float32Array.
  91109. * @param name Define the name of the uniform as defined in the shader
  91110. * @param value Define the value to give to the uniform
  91111. * @return the material itself allowing "fluent" like uniform updates
  91112. */
  91113. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  91114. /**
  91115. * Set a mat2 in the shader from a Float32Array.
  91116. * @param name Define the name of the uniform as defined in the shader
  91117. * @param value Define the value to give to the uniform
  91118. * @return the material itself allowing "fluent" like uniform updates
  91119. */
  91120. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  91121. /**
  91122. * Set a vec2 array in the shader from a number array.
  91123. * @param name Define the name of the uniform as defined in the shader
  91124. * @param value Define the value to give to the uniform
  91125. * @return the material itself allowing "fluent" like uniform updates
  91126. */
  91127. setArray2(name: string, value: number[]): ShaderMaterial;
  91128. /**
  91129. * Set a vec3 array in the shader from a number array.
  91130. * @param name Define the name of the uniform as defined in the shader
  91131. * @param value Define the value to give to the uniform
  91132. * @return the material itself allowing "fluent" like uniform updates
  91133. */
  91134. setArray3(name: string, value: number[]): ShaderMaterial;
  91135. /**
  91136. * Set a vec4 array in the shader from a number array.
  91137. * @param name Define the name of the uniform as defined in the shader
  91138. * @param value Define the value to give to the uniform
  91139. * @return the material itself allowing "fluent" like uniform updates
  91140. */
  91141. setArray4(name: string, value: number[]): ShaderMaterial;
  91142. private _checkCache;
  91143. /**
  91144. * Specifies that the submesh is ready to be used
  91145. * @param mesh defines the mesh to check
  91146. * @param subMesh defines which submesh to check
  91147. * @param useInstances specifies that instances should be used
  91148. * @returns a boolean indicating that the submesh is ready or not
  91149. */
  91150. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  91151. /**
  91152. * Checks if the material is ready to render the requested mesh
  91153. * @param mesh Define the mesh to render
  91154. * @param useInstances Define whether or not the material is used with instances
  91155. * @returns true if ready, otherwise false
  91156. */
  91157. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  91158. /**
  91159. * Binds the world matrix to the material
  91160. * @param world defines the world transformation matrix
  91161. * @param effectOverride - If provided, use this effect instead of internal effect
  91162. */
  91163. bindOnlyWorldMatrix(world: Matrix, effectOverride?: Nullable<Effect>): void;
  91164. /**
  91165. * Binds the submesh to this material by preparing the effect and shader to draw
  91166. * @param world defines the world transformation matrix
  91167. * @param mesh defines the mesh containing the submesh
  91168. * @param subMesh defines the submesh to bind the material to
  91169. */
  91170. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  91171. /**
  91172. * Binds the material to the mesh
  91173. * @param world defines the world transformation matrix
  91174. * @param mesh defines the mesh to bind the material to
  91175. * @param effectOverride - If provided, use this effect instead of internal effect
  91176. */
  91177. bind(world: Matrix, mesh?: Mesh, effectOverride?: Nullable<Effect>): void;
  91178. protected _afterBind(mesh?: Mesh): void;
  91179. /**
  91180. * Gets the active textures from the material
  91181. * @returns an array of textures
  91182. */
  91183. getActiveTextures(): BaseTexture[];
  91184. /**
  91185. * Specifies if the material uses a texture
  91186. * @param texture defines the texture to check against the material
  91187. * @returns a boolean specifying if the material uses the texture
  91188. */
  91189. hasTexture(texture: BaseTexture): boolean;
  91190. /**
  91191. * Makes a duplicate of the material, and gives it a new name
  91192. * @param name defines the new name for the duplicated material
  91193. * @returns the cloned material
  91194. */
  91195. clone(name: string): ShaderMaterial;
  91196. /**
  91197. * Disposes the material
  91198. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  91199. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  91200. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  91201. */
  91202. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  91203. /**
  91204. * Serializes this material in a JSON representation
  91205. * @returns the serialized material object
  91206. */
  91207. serialize(): any;
  91208. /**
  91209. * Creates a shader material from parsed shader material data
  91210. * @param source defines the JSON represnetation of the material
  91211. * @param scene defines the hosting scene
  91212. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  91213. * @returns a new material
  91214. */
  91215. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  91216. }
  91217. }
  91218. declare module BABYLON {
  91219. /** @hidden */
  91220. export var colorPixelShader: {
  91221. name: string;
  91222. shader: string;
  91223. };
  91224. }
  91225. declare module BABYLON {
  91226. /** @hidden */
  91227. export var colorVertexShader: {
  91228. name: string;
  91229. shader: string;
  91230. };
  91231. }
  91232. declare module BABYLON {
  91233. /**
  91234. * Line mesh
  91235. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  91236. */
  91237. export class LinesMesh extends Mesh {
  91238. /**
  91239. * If vertex color should be applied to the mesh
  91240. */
  91241. readonly useVertexColor?: boolean | undefined;
  91242. /**
  91243. * If vertex alpha should be applied to the mesh
  91244. */
  91245. readonly useVertexAlpha?: boolean | undefined;
  91246. /**
  91247. * Color of the line (Default: White)
  91248. */
  91249. color: Color3;
  91250. /**
  91251. * Alpha of the line (Default: 1)
  91252. */
  91253. alpha: number;
  91254. /**
  91255. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  91256. * This margin is expressed in world space coordinates, so its value may vary.
  91257. * Default value is 0.1
  91258. */
  91259. intersectionThreshold: number;
  91260. private _colorShader;
  91261. private color4;
  91262. /**
  91263. * Creates a new LinesMesh
  91264. * @param name defines the name
  91265. * @param scene defines the hosting scene
  91266. * @param parent defines the parent mesh if any
  91267. * @param source defines the optional source LinesMesh used to clone data from
  91268. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  91269. * When false, achieved by calling a clone(), also passing False.
  91270. * This will make creation of children, recursive.
  91271. * @param useVertexColor defines if this LinesMesh supports vertex color
  91272. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  91273. */
  91274. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  91275. /**
  91276. * If vertex color should be applied to the mesh
  91277. */
  91278. useVertexColor?: boolean | undefined,
  91279. /**
  91280. * If vertex alpha should be applied to the mesh
  91281. */
  91282. useVertexAlpha?: boolean | undefined);
  91283. private _addClipPlaneDefine;
  91284. private _removeClipPlaneDefine;
  91285. isReady(): boolean;
  91286. /**
  91287. * Returns the string "LineMesh"
  91288. */
  91289. getClassName(): string;
  91290. /**
  91291. * @hidden
  91292. */
  91293. get material(): Material;
  91294. /**
  91295. * @hidden
  91296. */
  91297. set material(value: Material);
  91298. /**
  91299. * @hidden
  91300. */
  91301. get checkCollisions(): boolean;
  91302. /** @hidden */
  91303. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  91304. /** @hidden */
  91305. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  91306. /**
  91307. * Disposes of the line mesh
  91308. * @param doNotRecurse If children should be disposed
  91309. */
  91310. dispose(doNotRecurse?: boolean): void;
  91311. /**
  91312. * Returns a new LineMesh object cloned from the current one.
  91313. */
  91314. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): LinesMesh;
  91315. /**
  91316. * Creates a new InstancedLinesMesh object from the mesh model.
  91317. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  91318. * @param name defines the name of the new instance
  91319. * @returns a new InstancedLinesMesh
  91320. */
  91321. createInstance(name: string): InstancedLinesMesh;
  91322. }
  91323. /**
  91324. * Creates an instance based on a source LinesMesh
  91325. */
  91326. export class InstancedLinesMesh extends InstancedMesh {
  91327. /**
  91328. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  91329. * This margin is expressed in world space coordinates, so its value may vary.
  91330. * Initilized with the intersectionThreshold value of the source LinesMesh
  91331. */
  91332. intersectionThreshold: number;
  91333. constructor(name: string, source: LinesMesh);
  91334. /**
  91335. * Returns the string "InstancedLinesMesh".
  91336. */
  91337. getClassName(): string;
  91338. }
  91339. }
  91340. declare module BABYLON {
  91341. /** @hidden */
  91342. export var linePixelShader: {
  91343. name: string;
  91344. shader: string;
  91345. };
  91346. }
  91347. declare module BABYLON {
  91348. /** @hidden */
  91349. export var lineVertexShader: {
  91350. name: string;
  91351. shader: string;
  91352. };
  91353. }
  91354. declare module BABYLON {
  91355. interface AbstractMesh {
  91356. /**
  91357. * Gets the edgesRenderer associated with the mesh
  91358. */
  91359. edgesRenderer: Nullable<EdgesRenderer>;
  91360. }
  91361. interface LinesMesh {
  91362. /**
  91363. * Enables the edge rendering mode on the mesh.
  91364. * This mode makes the mesh edges visible
  91365. * @param epsilon defines the maximal distance between two angles to detect a face
  91366. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  91367. * @returns the currentAbstractMesh
  91368. * @see https://www.babylonjs-playground.com/#19O9TU#0
  91369. */
  91370. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  91371. }
  91372. interface InstancedLinesMesh {
  91373. /**
  91374. * Enables the edge rendering mode on the mesh.
  91375. * This mode makes the mesh edges visible
  91376. * @param epsilon defines the maximal distance between two angles to detect a face
  91377. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  91378. * @returns the current InstancedLinesMesh
  91379. * @see https://www.babylonjs-playground.com/#19O9TU#0
  91380. */
  91381. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  91382. }
  91383. /**
  91384. * Defines the minimum contract an Edges renderer should follow.
  91385. */
  91386. export interface IEdgesRenderer extends IDisposable {
  91387. /**
  91388. * Gets or sets a boolean indicating if the edgesRenderer is active
  91389. */
  91390. isEnabled: boolean;
  91391. /**
  91392. * Renders the edges of the attached mesh,
  91393. */
  91394. render(): void;
  91395. /**
  91396. * Checks wether or not the edges renderer is ready to render.
  91397. * @return true if ready, otherwise false.
  91398. */
  91399. isReady(): boolean;
  91400. }
  91401. /**
  91402. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  91403. */
  91404. export class EdgesRenderer implements IEdgesRenderer {
  91405. /**
  91406. * Define the size of the edges with an orthographic camera
  91407. */
  91408. edgesWidthScalerForOrthographic: number;
  91409. /**
  91410. * Define the size of the edges with a perspective camera
  91411. */
  91412. edgesWidthScalerForPerspective: number;
  91413. protected _source: AbstractMesh;
  91414. protected _linesPositions: number[];
  91415. protected _linesNormals: number[];
  91416. protected _linesIndices: number[];
  91417. protected _epsilon: number;
  91418. protected _indicesCount: number;
  91419. protected _lineShader: ShaderMaterial;
  91420. protected _ib: DataBuffer;
  91421. protected _buffers: {
  91422. [key: string]: Nullable<VertexBuffer>;
  91423. };
  91424. protected _checkVerticesInsteadOfIndices: boolean;
  91425. private _meshRebuildObserver;
  91426. private _meshDisposeObserver;
  91427. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  91428. isEnabled: boolean;
  91429. /**
  91430. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  91431. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  91432. * @param source Mesh used to create edges
  91433. * @param epsilon sum of angles in adjacency to check for edge
  91434. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  91435. * @param generateEdgesLines - should generate Lines or only prepare resources.
  91436. */
  91437. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  91438. protected _prepareRessources(): void;
  91439. /** @hidden */
  91440. _rebuild(): void;
  91441. /**
  91442. * Releases the required resources for the edges renderer
  91443. */
  91444. dispose(): void;
  91445. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  91446. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  91447. /**
  91448. * Checks if the pair of p0 and p1 is en edge
  91449. * @param faceIndex
  91450. * @param edge
  91451. * @param faceNormals
  91452. * @param p0
  91453. * @param p1
  91454. * @private
  91455. */
  91456. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  91457. /**
  91458. * push line into the position, normal and index buffer
  91459. * @protected
  91460. */
  91461. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  91462. /**
  91463. * Generates lines edges from adjacencjes
  91464. * @private
  91465. */
  91466. _generateEdgesLines(): void;
  91467. /**
  91468. * Checks wether or not the edges renderer is ready to render.
  91469. * @return true if ready, otherwise false.
  91470. */
  91471. isReady(): boolean;
  91472. /**
  91473. * Renders the edges of the attached mesh,
  91474. */
  91475. render(): void;
  91476. }
  91477. /**
  91478. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  91479. */
  91480. export class LineEdgesRenderer extends EdgesRenderer {
  91481. /**
  91482. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  91483. * @param source LineMesh used to generate edges
  91484. * @param epsilon not important (specified angle for edge detection)
  91485. * @param checkVerticesInsteadOfIndices not important for LineMesh
  91486. */
  91487. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  91488. /**
  91489. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  91490. */
  91491. _generateEdgesLines(): void;
  91492. }
  91493. }
  91494. declare module BABYLON {
  91495. /**
  91496. * This represents the object necessary to create a rendering group.
  91497. * This is exclusively used and created by the rendering manager.
  91498. * To modify the behavior, you use the available helpers in your scene or meshes.
  91499. * @hidden
  91500. */
  91501. export class RenderingGroup {
  91502. index: number;
  91503. private static _zeroVector;
  91504. private _scene;
  91505. private _opaqueSubMeshes;
  91506. private _transparentSubMeshes;
  91507. private _alphaTestSubMeshes;
  91508. private _depthOnlySubMeshes;
  91509. private _particleSystems;
  91510. private _spriteManagers;
  91511. private _opaqueSortCompareFn;
  91512. private _alphaTestSortCompareFn;
  91513. private _transparentSortCompareFn;
  91514. private _renderOpaque;
  91515. private _renderAlphaTest;
  91516. private _renderTransparent;
  91517. /** @hidden */
  91518. _edgesRenderers: SmartArray<IEdgesRenderer>;
  91519. onBeforeTransparentRendering: () => void;
  91520. /**
  91521. * Set the opaque sort comparison function.
  91522. * If null the sub meshes will be render in the order they were created
  91523. */
  91524. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  91525. /**
  91526. * Set the alpha test sort comparison function.
  91527. * If null the sub meshes will be render in the order they were created
  91528. */
  91529. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  91530. /**
  91531. * Set the transparent sort comparison function.
  91532. * If null the sub meshes will be render in the order they were created
  91533. */
  91534. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  91535. /**
  91536. * Creates a new rendering group.
  91537. * @param index The rendering group index
  91538. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  91539. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  91540. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  91541. */
  91542. 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>);
  91543. /**
  91544. * Render all the sub meshes contained in the group.
  91545. * @param customRenderFunction Used to override the default render behaviour of the group.
  91546. * @returns true if rendered some submeshes.
  91547. */
  91548. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  91549. /**
  91550. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  91551. * @param subMeshes The submeshes to render
  91552. */
  91553. private renderOpaqueSorted;
  91554. /**
  91555. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  91556. * @param subMeshes The submeshes to render
  91557. */
  91558. private renderAlphaTestSorted;
  91559. /**
  91560. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  91561. * @param subMeshes The submeshes to render
  91562. */
  91563. private renderTransparentSorted;
  91564. /**
  91565. * Renders the submeshes in a specified order.
  91566. * @param subMeshes The submeshes to sort before render
  91567. * @param sortCompareFn The comparison function use to sort
  91568. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  91569. * @param transparent Specifies to activate blending if true
  91570. */
  91571. private static renderSorted;
  91572. /**
  91573. * Renders the submeshes in the order they were dispatched (no sort applied).
  91574. * @param subMeshes The submeshes to render
  91575. */
  91576. private static renderUnsorted;
  91577. /**
  91578. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  91579. * are rendered back to front if in the same alpha index.
  91580. *
  91581. * @param a The first submesh
  91582. * @param b The second submesh
  91583. * @returns The result of the comparison
  91584. */
  91585. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  91586. /**
  91587. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  91588. * are rendered back to front.
  91589. *
  91590. * @param a The first submesh
  91591. * @param b The second submesh
  91592. * @returns The result of the comparison
  91593. */
  91594. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  91595. /**
  91596. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  91597. * are rendered front to back (prevent overdraw).
  91598. *
  91599. * @param a The first submesh
  91600. * @param b The second submesh
  91601. * @returns The result of the comparison
  91602. */
  91603. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  91604. /**
  91605. * Resets the different lists of submeshes to prepare a new frame.
  91606. */
  91607. prepare(): void;
  91608. dispose(): void;
  91609. /**
  91610. * Inserts the submesh in its correct queue depending on its material.
  91611. * @param subMesh The submesh to dispatch
  91612. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  91613. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  91614. */
  91615. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  91616. dispatchSprites(spriteManager: ISpriteManager): void;
  91617. dispatchParticles(particleSystem: IParticleSystem): void;
  91618. private _renderParticles;
  91619. private _renderSprites;
  91620. }
  91621. }
  91622. declare module BABYLON {
  91623. /**
  91624. * Interface describing the different options available in the rendering manager
  91625. * regarding Auto Clear between groups.
  91626. */
  91627. export interface IRenderingManagerAutoClearSetup {
  91628. /**
  91629. * Defines whether or not autoclear is enable.
  91630. */
  91631. autoClear: boolean;
  91632. /**
  91633. * Defines whether or not to autoclear the depth buffer.
  91634. */
  91635. depth: boolean;
  91636. /**
  91637. * Defines whether or not to autoclear the stencil buffer.
  91638. */
  91639. stencil: boolean;
  91640. }
  91641. /**
  91642. * This class is used by the onRenderingGroupObservable
  91643. */
  91644. export class RenderingGroupInfo {
  91645. /**
  91646. * The Scene that being rendered
  91647. */
  91648. scene: Scene;
  91649. /**
  91650. * The camera currently used for the rendering pass
  91651. */
  91652. camera: Nullable<Camera>;
  91653. /**
  91654. * The ID of the renderingGroup being processed
  91655. */
  91656. renderingGroupId: number;
  91657. }
  91658. /**
  91659. * This is the manager responsible of all the rendering for meshes sprites and particles.
  91660. * It is enable to manage the different groups as well as the different necessary sort functions.
  91661. * This should not be used directly aside of the few static configurations
  91662. */
  91663. export class RenderingManager {
  91664. /**
  91665. * The max id used for rendering groups (not included)
  91666. */
  91667. static MAX_RENDERINGGROUPS: number;
  91668. /**
  91669. * The min id used for rendering groups (included)
  91670. */
  91671. static MIN_RENDERINGGROUPS: number;
  91672. /**
  91673. * Used to globally prevent autoclearing scenes.
  91674. */
  91675. static AUTOCLEAR: boolean;
  91676. /**
  91677. * @hidden
  91678. */
  91679. _useSceneAutoClearSetup: boolean;
  91680. private _scene;
  91681. private _renderingGroups;
  91682. private _depthStencilBufferAlreadyCleaned;
  91683. private _autoClearDepthStencil;
  91684. private _customOpaqueSortCompareFn;
  91685. private _customAlphaTestSortCompareFn;
  91686. private _customTransparentSortCompareFn;
  91687. private _renderingGroupInfo;
  91688. /**
  91689. * Instantiates a new rendering group for a particular scene
  91690. * @param scene Defines the scene the groups belongs to
  91691. */
  91692. constructor(scene: Scene);
  91693. private _clearDepthStencilBuffer;
  91694. /**
  91695. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  91696. * @hidden
  91697. */
  91698. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  91699. /**
  91700. * Resets the different information of the group to prepare a new frame
  91701. * @hidden
  91702. */
  91703. reset(): void;
  91704. /**
  91705. * Dispose and release the group and its associated resources.
  91706. * @hidden
  91707. */
  91708. dispose(): void;
  91709. /**
  91710. * Clear the info related to rendering groups preventing retention points during dispose.
  91711. */
  91712. freeRenderingGroups(): void;
  91713. private _prepareRenderingGroup;
  91714. /**
  91715. * Add a sprite manager to the rendering manager in order to render it this frame.
  91716. * @param spriteManager Define the sprite manager to render
  91717. */
  91718. dispatchSprites(spriteManager: ISpriteManager): void;
  91719. /**
  91720. * Add a particle system to the rendering manager in order to render it this frame.
  91721. * @param particleSystem Define the particle system to render
  91722. */
  91723. dispatchParticles(particleSystem: IParticleSystem): void;
  91724. /**
  91725. * Add a submesh to the manager in order to render it this frame
  91726. * @param subMesh The submesh to dispatch
  91727. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  91728. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  91729. */
  91730. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  91731. /**
  91732. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  91733. * This allowed control for front to back rendering or reversly depending of the special needs.
  91734. *
  91735. * @param renderingGroupId The rendering group id corresponding to its index
  91736. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  91737. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  91738. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  91739. */
  91740. 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;
  91741. /**
  91742. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  91743. *
  91744. * @param renderingGroupId The rendering group id corresponding to its index
  91745. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  91746. * @param depth Automatically clears depth between groups if true and autoClear is true.
  91747. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  91748. */
  91749. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  91750. /**
  91751. * Gets the current auto clear configuration for one rendering group of the rendering
  91752. * manager.
  91753. * @param index the rendering group index to get the information for
  91754. * @returns The auto clear setup for the requested rendering group
  91755. */
  91756. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  91757. }
  91758. }
  91759. declare module BABYLON {
  91760. /**
  91761. * Defines the options associated with the creation of a custom shader for a shadow generator.
  91762. */
  91763. export interface ICustomShaderOptions {
  91764. /**
  91765. * Gets or sets the custom shader name to use
  91766. */
  91767. shaderName: string;
  91768. /**
  91769. * The list of attribute names used in the shader
  91770. */
  91771. attributes?: string[];
  91772. /**
  91773. * The list of unifrom names used in the shader
  91774. */
  91775. uniforms?: string[];
  91776. /**
  91777. * The list of sampler names used in the shader
  91778. */
  91779. samplers?: string[];
  91780. /**
  91781. * The list of defines used in the shader
  91782. */
  91783. defines?: string[];
  91784. }
  91785. /**
  91786. * Interface to implement to create a shadow generator compatible with BJS.
  91787. */
  91788. export interface IShadowGenerator {
  91789. /**
  91790. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  91791. * @returns The render target texture if present otherwise, null
  91792. */
  91793. getShadowMap(): Nullable<RenderTargetTexture>;
  91794. /**
  91795. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  91796. * @param subMesh The submesh we want to render in the shadow map
  91797. * @param useInstances Defines wether will draw in the map using instances
  91798. * @returns true if ready otherwise, false
  91799. */
  91800. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  91801. /**
  91802. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  91803. * @param defines Defines of the material we want to update
  91804. * @param lightIndex Index of the light in the enabled light list of the material
  91805. */
  91806. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  91807. /**
  91808. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  91809. * defined in the generator but impacting the effect).
  91810. * It implies the unifroms available on the materials are the standard BJS ones.
  91811. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  91812. * @param effect The effect we are binfing the information for
  91813. */
  91814. bindShadowLight(lightIndex: string, effect: Effect): void;
  91815. /**
  91816. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  91817. * (eq to shadow prjection matrix * light transform matrix)
  91818. * @returns The transform matrix used to create the shadow map
  91819. */
  91820. getTransformMatrix(): Matrix;
  91821. /**
  91822. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  91823. * Cube and 2D textures for instance.
  91824. */
  91825. recreateShadowMap(): void;
  91826. /**
  91827. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  91828. * @param onCompiled Callback triggered at the and of the effects compilation
  91829. * @param options Sets of optional options forcing the compilation with different modes
  91830. */
  91831. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  91832. useInstances: boolean;
  91833. }>): void;
  91834. /**
  91835. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  91836. * @param options Sets of optional options forcing the compilation with different modes
  91837. * @returns A promise that resolves when the compilation completes
  91838. */
  91839. forceCompilationAsync(options?: Partial<{
  91840. useInstances: boolean;
  91841. }>): Promise<void>;
  91842. /**
  91843. * Serializes the shadow generator setup to a json object.
  91844. * @returns The serialized JSON object
  91845. */
  91846. serialize(): any;
  91847. /**
  91848. * Disposes the Shadow map and related Textures and effects.
  91849. */
  91850. dispose(): void;
  91851. }
  91852. /**
  91853. * Default implementation IShadowGenerator.
  91854. * This is the main object responsible of generating shadows in the framework.
  91855. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  91856. */
  91857. export class ShadowGenerator implements IShadowGenerator {
  91858. /**
  91859. * Name of the shadow generator class
  91860. */
  91861. static CLASSNAME: string;
  91862. /**
  91863. * Shadow generator mode None: no filtering applied.
  91864. */
  91865. static readonly FILTER_NONE: number;
  91866. /**
  91867. * Shadow generator mode ESM: Exponential Shadow Mapping.
  91868. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  91869. */
  91870. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  91871. /**
  91872. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  91873. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  91874. */
  91875. static readonly FILTER_POISSONSAMPLING: number;
  91876. /**
  91877. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  91878. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  91879. */
  91880. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  91881. /**
  91882. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  91883. * edge artifacts on steep falloff.
  91884. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  91885. */
  91886. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  91887. /**
  91888. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  91889. * edge artifacts on steep falloff.
  91890. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  91891. */
  91892. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  91893. /**
  91894. * Shadow generator mode PCF: Percentage Closer Filtering
  91895. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  91896. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  91897. */
  91898. static readonly FILTER_PCF: number;
  91899. /**
  91900. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  91901. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  91902. * Contact Hardening
  91903. */
  91904. static readonly FILTER_PCSS: number;
  91905. /**
  91906. * Reserved for PCF and PCSS
  91907. * Highest Quality.
  91908. *
  91909. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  91910. *
  91911. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  91912. */
  91913. static readonly QUALITY_HIGH: number;
  91914. /**
  91915. * Reserved for PCF and PCSS
  91916. * Good tradeoff for quality/perf cross devices
  91917. *
  91918. * Execute PCF on a 3*3 kernel.
  91919. *
  91920. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  91921. */
  91922. static readonly QUALITY_MEDIUM: number;
  91923. /**
  91924. * Reserved for PCF and PCSS
  91925. * The lowest quality but the fastest.
  91926. *
  91927. * Execute PCF on a 1*1 kernel.
  91928. *
  91929. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  91930. */
  91931. static readonly QUALITY_LOW: number;
  91932. /** Gets or sets the custom shader name to use */
  91933. customShaderOptions: ICustomShaderOptions;
  91934. /**
  91935. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  91936. */
  91937. onBeforeShadowMapRenderObservable: Observable<Effect>;
  91938. /**
  91939. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  91940. */
  91941. onAfterShadowMapRenderObservable: Observable<Effect>;
  91942. /**
  91943. * Observable triggered before a mesh is rendered in the shadow map.
  91944. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  91945. */
  91946. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  91947. /**
  91948. * Observable triggered after a mesh is rendered in the shadow map.
  91949. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  91950. */
  91951. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  91952. protected _bias: number;
  91953. /**
  91954. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  91955. */
  91956. get bias(): number;
  91957. /**
  91958. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  91959. */
  91960. set bias(bias: number);
  91961. protected _normalBias: number;
  91962. /**
  91963. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  91964. */
  91965. get normalBias(): number;
  91966. /**
  91967. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  91968. */
  91969. set normalBias(normalBias: number);
  91970. protected _blurBoxOffset: number;
  91971. /**
  91972. * Gets the blur box offset: offset applied during the blur pass.
  91973. * Only useful if useKernelBlur = false
  91974. */
  91975. get blurBoxOffset(): number;
  91976. /**
  91977. * Sets the blur box offset: offset applied during the blur pass.
  91978. * Only useful if useKernelBlur = false
  91979. */
  91980. set blurBoxOffset(value: number);
  91981. protected _blurScale: number;
  91982. /**
  91983. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  91984. * 2 means half of the size.
  91985. */
  91986. get blurScale(): number;
  91987. /**
  91988. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  91989. * 2 means half of the size.
  91990. */
  91991. set blurScale(value: number);
  91992. protected _blurKernel: number;
  91993. /**
  91994. * Gets the blur kernel: kernel size of the blur pass.
  91995. * Only useful if useKernelBlur = true
  91996. */
  91997. get blurKernel(): number;
  91998. /**
  91999. * Sets the blur kernel: kernel size of the blur pass.
  92000. * Only useful if useKernelBlur = true
  92001. */
  92002. set blurKernel(value: number);
  92003. protected _useKernelBlur: boolean;
  92004. /**
  92005. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  92006. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  92007. */
  92008. get useKernelBlur(): boolean;
  92009. /**
  92010. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  92011. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  92012. */
  92013. set useKernelBlur(value: boolean);
  92014. protected _depthScale: number;
  92015. /**
  92016. * Gets the depth scale used in ESM mode.
  92017. */
  92018. get depthScale(): number;
  92019. /**
  92020. * Sets the depth scale used in ESM mode.
  92021. * This can override the scale stored on the light.
  92022. */
  92023. set depthScale(value: number);
  92024. protected _validateFilter(filter: number): number;
  92025. protected _filter: number;
  92026. /**
  92027. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  92028. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  92029. */
  92030. get filter(): number;
  92031. /**
  92032. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  92033. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  92034. */
  92035. set filter(value: number);
  92036. /**
  92037. * Gets if the current filter is set to Poisson Sampling.
  92038. */
  92039. get usePoissonSampling(): boolean;
  92040. /**
  92041. * Sets the current filter to Poisson Sampling.
  92042. */
  92043. set usePoissonSampling(value: boolean);
  92044. /**
  92045. * Gets if the current filter is set to ESM.
  92046. */
  92047. get useExponentialShadowMap(): boolean;
  92048. /**
  92049. * Sets the current filter is to ESM.
  92050. */
  92051. set useExponentialShadowMap(value: boolean);
  92052. /**
  92053. * Gets if the current filter is set to filtered ESM.
  92054. */
  92055. get useBlurExponentialShadowMap(): boolean;
  92056. /**
  92057. * Gets if the current filter is set to filtered ESM.
  92058. */
  92059. set useBlurExponentialShadowMap(value: boolean);
  92060. /**
  92061. * Gets if the current filter is set to "close ESM" (using the inverse of the
  92062. * exponential to prevent steep falloff artifacts).
  92063. */
  92064. get useCloseExponentialShadowMap(): boolean;
  92065. /**
  92066. * Sets the current filter to "close ESM" (using the inverse of the
  92067. * exponential to prevent steep falloff artifacts).
  92068. */
  92069. set useCloseExponentialShadowMap(value: boolean);
  92070. /**
  92071. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  92072. * exponential to prevent steep falloff artifacts).
  92073. */
  92074. get useBlurCloseExponentialShadowMap(): boolean;
  92075. /**
  92076. * Sets the current filter to filtered "close ESM" (using the inverse of the
  92077. * exponential to prevent steep falloff artifacts).
  92078. */
  92079. set useBlurCloseExponentialShadowMap(value: boolean);
  92080. /**
  92081. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  92082. */
  92083. get usePercentageCloserFiltering(): boolean;
  92084. /**
  92085. * Sets the current filter to "PCF" (percentage closer filtering).
  92086. */
  92087. set usePercentageCloserFiltering(value: boolean);
  92088. protected _filteringQuality: number;
  92089. /**
  92090. * Gets the PCF or PCSS Quality.
  92091. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  92092. */
  92093. get filteringQuality(): number;
  92094. /**
  92095. * Sets the PCF or PCSS Quality.
  92096. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  92097. */
  92098. set filteringQuality(filteringQuality: number);
  92099. /**
  92100. * Gets if the current filter is set to "PCSS" (contact hardening).
  92101. */
  92102. get useContactHardeningShadow(): boolean;
  92103. /**
  92104. * Sets the current filter to "PCSS" (contact hardening).
  92105. */
  92106. set useContactHardeningShadow(value: boolean);
  92107. protected _contactHardeningLightSizeUVRatio: number;
  92108. /**
  92109. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  92110. * Using a ratio helps keeping shape stability independently of the map size.
  92111. *
  92112. * It does not account for the light projection as it was having too much
  92113. * instability during the light setup or during light position changes.
  92114. *
  92115. * Only valid if useContactHardeningShadow is true.
  92116. */
  92117. get contactHardeningLightSizeUVRatio(): number;
  92118. /**
  92119. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  92120. * Using a ratio helps keeping shape stability independently of the map size.
  92121. *
  92122. * It does not account for the light projection as it was having too much
  92123. * instability during the light setup or during light position changes.
  92124. *
  92125. * Only valid if useContactHardeningShadow is true.
  92126. */
  92127. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  92128. protected _darkness: number;
  92129. /** Gets or sets the actual darkness of a shadow */
  92130. get darkness(): number;
  92131. set darkness(value: number);
  92132. /**
  92133. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  92134. * 0 means strongest and 1 would means no shadow.
  92135. * @returns the darkness.
  92136. */
  92137. getDarkness(): number;
  92138. /**
  92139. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  92140. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  92141. * @returns the shadow generator allowing fluent coding.
  92142. */
  92143. setDarkness(darkness: number): ShadowGenerator;
  92144. protected _transparencyShadow: boolean;
  92145. /** Gets or sets the ability to have transparent shadow */
  92146. get transparencyShadow(): boolean;
  92147. set transparencyShadow(value: boolean);
  92148. /**
  92149. * Sets the ability to have transparent shadow (boolean).
  92150. * @param transparent True if transparent else False
  92151. * @returns the shadow generator allowing fluent coding
  92152. */
  92153. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  92154. protected _shadowMap: Nullable<RenderTargetTexture>;
  92155. protected _shadowMap2: Nullable<RenderTargetTexture>;
  92156. /**
  92157. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  92158. * @returns The render target texture if present otherwise, null
  92159. */
  92160. getShadowMap(): Nullable<RenderTargetTexture>;
  92161. /**
  92162. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  92163. * @returns The render target texture if the shadow map is present otherwise, null
  92164. */
  92165. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  92166. /**
  92167. * Gets the class name of that object
  92168. * @returns "ShadowGenerator"
  92169. */
  92170. getClassName(): string;
  92171. /**
  92172. * Helper function to add a mesh and its descendants to the list of shadow casters.
  92173. * @param mesh Mesh to add
  92174. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  92175. * @returns the Shadow Generator itself
  92176. */
  92177. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  92178. /**
  92179. * Helper function to remove a mesh and its descendants from the list of shadow casters
  92180. * @param mesh Mesh to remove
  92181. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  92182. * @returns the Shadow Generator itself
  92183. */
  92184. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  92185. /**
  92186. * Controls the extent to which the shadows fade out at the edge of the frustum
  92187. */
  92188. frustumEdgeFalloff: number;
  92189. protected _light: IShadowLight;
  92190. /**
  92191. * Returns the associated light object.
  92192. * @returns the light generating the shadow
  92193. */
  92194. getLight(): IShadowLight;
  92195. /**
  92196. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  92197. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  92198. * It might on the other hand introduce peter panning.
  92199. */
  92200. forceBackFacesOnly: boolean;
  92201. protected _scene: Scene;
  92202. protected _lightDirection: Vector3;
  92203. protected _effect: Effect;
  92204. protected _viewMatrix: Matrix;
  92205. protected _projectionMatrix: Matrix;
  92206. protected _transformMatrix: Matrix;
  92207. protected _cachedPosition: Vector3;
  92208. protected _cachedDirection: Vector3;
  92209. protected _cachedDefines: string;
  92210. protected _currentRenderID: number;
  92211. protected _boxBlurPostprocess: Nullable<PostProcess>;
  92212. protected _kernelBlurXPostprocess: Nullable<PostProcess>;
  92213. protected _kernelBlurYPostprocess: Nullable<PostProcess>;
  92214. protected _blurPostProcesses: PostProcess[];
  92215. protected _mapSize: number;
  92216. protected _currentFaceIndex: number;
  92217. protected _currentFaceIndexCache: number;
  92218. protected _textureType: number;
  92219. protected _defaultTextureMatrix: Matrix;
  92220. protected _storedUniqueId: Nullable<number>;
  92221. /** @hidden */
  92222. static _SceneComponentInitialization: (scene: Scene) => void;
  92223. /**
  92224. * Creates a ShadowGenerator object.
  92225. * A ShadowGenerator is the required tool to use the shadows.
  92226. * Each light casting shadows needs to use its own ShadowGenerator.
  92227. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  92228. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  92229. * @param light The light object generating the shadows.
  92230. * @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.
  92231. */
  92232. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  92233. protected _initializeGenerator(): void;
  92234. protected _createTargetRenderTexture(): void;
  92235. protected _initializeShadowMap(): void;
  92236. protected _initializeBlurRTTAndPostProcesses(): void;
  92237. protected _renderForShadowMap(opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>): void;
  92238. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  92239. protected _renderSubMeshForShadowMap(subMesh: SubMesh): void;
  92240. protected _applyFilterValues(): void;
  92241. /**
  92242. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  92243. * @param onCompiled Callback triggered at the and of the effects compilation
  92244. * @param options Sets of optional options forcing the compilation with different modes
  92245. */
  92246. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  92247. useInstances: boolean;
  92248. }>): void;
  92249. /**
  92250. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  92251. * @param options Sets of optional options forcing the compilation with different modes
  92252. * @returns A promise that resolves when the compilation completes
  92253. */
  92254. forceCompilationAsync(options?: Partial<{
  92255. useInstances: boolean;
  92256. }>): Promise<void>;
  92257. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  92258. private _prepareShadowDefines;
  92259. /**
  92260. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  92261. * @param subMesh The submesh we want to render in the shadow map
  92262. * @param useInstances Defines wether will draw in the map using instances
  92263. * @returns true if ready otherwise, false
  92264. */
  92265. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  92266. /**
  92267. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  92268. * @param defines Defines of the material we want to update
  92269. * @param lightIndex Index of the light in the enabled light list of the material
  92270. */
  92271. prepareDefines(defines: any, lightIndex: number): void;
  92272. /**
  92273. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  92274. * defined in the generator but impacting the effect).
  92275. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  92276. * @param effect The effect we are binfing the information for
  92277. */
  92278. bindShadowLight(lightIndex: string, effect: Effect): void;
  92279. /**
  92280. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  92281. * (eq to shadow prjection matrix * light transform matrix)
  92282. * @returns The transform matrix used to create the shadow map
  92283. */
  92284. getTransformMatrix(): Matrix;
  92285. /**
  92286. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  92287. * Cube and 2D textures for instance.
  92288. */
  92289. recreateShadowMap(): void;
  92290. protected _disposeBlurPostProcesses(): void;
  92291. protected _disposeRTTandPostProcesses(): void;
  92292. /**
  92293. * Disposes the ShadowGenerator.
  92294. * Returns nothing.
  92295. */
  92296. dispose(): void;
  92297. /**
  92298. * Serializes the shadow generator setup to a json object.
  92299. * @returns The serialized JSON object
  92300. */
  92301. serialize(): any;
  92302. /**
  92303. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  92304. * @param parsedShadowGenerator The JSON object to parse
  92305. * @param scene The scene to create the shadow map for
  92306. * @param constr A function that builds a shadow generator or undefined to create an instance of the default shadow generator
  92307. * @returns The parsed shadow generator
  92308. */
  92309. static Parse(parsedShadowGenerator: any, scene: Scene, constr?: (mapSize: number, light: IShadowLight) => ShadowGenerator): ShadowGenerator;
  92310. }
  92311. }
  92312. declare module BABYLON {
  92313. /**
  92314. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  92315. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  92316. * 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.
  92317. */
  92318. export abstract class Light extends Node {
  92319. /**
  92320. * Falloff Default: light is falling off following the material specification:
  92321. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  92322. */
  92323. static readonly FALLOFF_DEFAULT: number;
  92324. /**
  92325. * Falloff Physical: light is falling off following the inverse squared distance law.
  92326. */
  92327. static readonly FALLOFF_PHYSICAL: number;
  92328. /**
  92329. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  92330. * to enhance interoperability with other engines.
  92331. */
  92332. static readonly FALLOFF_GLTF: number;
  92333. /**
  92334. * Falloff Standard: light is falling off like in the standard material
  92335. * to enhance interoperability with other materials.
  92336. */
  92337. static readonly FALLOFF_STANDARD: number;
  92338. /**
  92339. * If every light affecting the material is in this lightmapMode,
  92340. * material.lightmapTexture adds or multiplies
  92341. * (depends on material.useLightmapAsShadowmap)
  92342. * after every other light calculations.
  92343. */
  92344. static readonly LIGHTMAP_DEFAULT: number;
  92345. /**
  92346. * material.lightmapTexture as only diffuse lighting from this light
  92347. * adds only specular lighting from this light
  92348. * adds dynamic shadows
  92349. */
  92350. static readonly LIGHTMAP_SPECULAR: number;
  92351. /**
  92352. * material.lightmapTexture as only lighting
  92353. * no light calculation from this light
  92354. * only adds dynamic shadows from this light
  92355. */
  92356. static readonly LIGHTMAP_SHADOWSONLY: number;
  92357. /**
  92358. * Each light type uses the default quantity according to its type:
  92359. * point/spot lights use luminous intensity
  92360. * directional lights use illuminance
  92361. */
  92362. static readonly INTENSITYMODE_AUTOMATIC: number;
  92363. /**
  92364. * lumen (lm)
  92365. */
  92366. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  92367. /**
  92368. * candela (lm/sr)
  92369. */
  92370. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  92371. /**
  92372. * lux (lm/m^2)
  92373. */
  92374. static readonly INTENSITYMODE_ILLUMINANCE: number;
  92375. /**
  92376. * nit (cd/m^2)
  92377. */
  92378. static readonly INTENSITYMODE_LUMINANCE: number;
  92379. /**
  92380. * Light type const id of the point light.
  92381. */
  92382. static readonly LIGHTTYPEID_POINTLIGHT: number;
  92383. /**
  92384. * Light type const id of the directional light.
  92385. */
  92386. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  92387. /**
  92388. * Light type const id of the spot light.
  92389. */
  92390. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  92391. /**
  92392. * Light type const id of the hemispheric light.
  92393. */
  92394. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  92395. /**
  92396. * Diffuse gives the basic color to an object.
  92397. */
  92398. diffuse: Color3;
  92399. /**
  92400. * Specular produces a highlight color on an object.
  92401. * Note: This is note affecting PBR materials.
  92402. */
  92403. specular: Color3;
  92404. /**
  92405. * Defines the falloff type for this light. This lets overrriding how punctual light are
  92406. * falling off base on range or angle.
  92407. * This can be set to any values in Light.FALLOFF_x.
  92408. *
  92409. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  92410. * other types of materials.
  92411. */
  92412. falloffType: number;
  92413. /**
  92414. * Strength of the light.
  92415. * Note: By default it is define in the framework own unit.
  92416. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  92417. */
  92418. intensity: number;
  92419. private _range;
  92420. protected _inverseSquaredRange: number;
  92421. /**
  92422. * Defines how far from the source the light is impacting in scene units.
  92423. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  92424. */
  92425. get range(): number;
  92426. /**
  92427. * Defines how far from the source the light is impacting in scene units.
  92428. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  92429. */
  92430. set range(value: number);
  92431. /**
  92432. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  92433. * of light.
  92434. */
  92435. private _photometricScale;
  92436. private _intensityMode;
  92437. /**
  92438. * Gets the photometric scale used to interpret the intensity.
  92439. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  92440. */
  92441. get intensityMode(): number;
  92442. /**
  92443. * Sets the photometric scale used to interpret the intensity.
  92444. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  92445. */
  92446. set intensityMode(value: number);
  92447. private _radius;
  92448. /**
  92449. * Gets the light radius used by PBR Materials to simulate soft area lights.
  92450. */
  92451. get radius(): number;
  92452. /**
  92453. * sets the light radius used by PBR Materials to simulate soft area lights.
  92454. */
  92455. set radius(value: number);
  92456. private _renderPriority;
  92457. /**
  92458. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  92459. * exceeding the number allowed of the materials.
  92460. */
  92461. renderPriority: number;
  92462. private _shadowEnabled;
  92463. /**
  92464. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  92465. * the current shadow generator.
  92466. */
  92467. get shadowEnabled(): boolean;
  92468. /**
  92469. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  92470. * the current shadow generator.
  92471. */
  92472. set shadowEnabled(value: boolean);
  92473. private _includedOnlyMeshes;
  92474. /**
  92475. * Gets the only meshes impacted by this light.
  92476. */
  92477. get includedOnlyMeshes(): AbstractMesh[];
  92478. /**
  92479. * Sets the only meshes impacted by this light.
  92480. */
  92481. set includedOnlyMeshes(value: AbstractMesh[]);
  92482. private _excludedMeshes;
  92483. /**
  92484. * Gets the meshes not impacted by this light.
  92485. */
  92486. get excludedMeshes(): AbstractMesh[];
  92487. /**
  92488. * Sets the meshes not impacted by this light.
  92489. */
  92490. set excludedMeshes(value: AbstractMesh[]);
  92491. private _excludeWithLayerMask;
  92492. /**
  92493. * Gets the layer id use to find what meshes are not impacted by the light.
  92494. * Inactive if 0
  92495. */
  92496. get excludeWithLayerMask(): number;
  92497. /**
  92498. * Sets the layer id use to find what meshes are not impacted by the light.
  92499. * Inactive if 0
  92500. */
  92501. set excludeWithLayerMask(value: number);
  92502. private _includeOnlyWithLayerMask;
  92503. /**
  92504. * Gets the layer id use to find what meshes are impacted by the light.
  92505. * Inactive if 0
  92506. */
  92507. get includeOnlyWithLayerMask(): number;
  92508. /**
  92509. * Sets the layer id use to find what meshes are impacted by the light.
  92510. * Inactive if 0
  92511. */
  92512. set includeOnlyWithLayerMask(value: number);
  92513. private _lightmapMode;
  92514. /**
  92515. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  92516. */
  92517. get lightmapMode(): number;
  92518. /**
  92519. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  92520. */
  92521. set lightmapMode(value: number);
  92522. /**
  92523. * Shadow generator associted to the light.
  92524. * @hidden Internal use only.
  92525. */
  92526. _shadowGenerator: Nullable<IShadowGenerator>;
  92527. /**
  92528. * @hidden Internal use only.
  92529. */
  92530. _excludedMeshesIds: string[];
  92531. /**
  92532. * @hidden Internal use only.
  92533. */
  92534. _includedOnlyMeshesIds: string[];
  92535. /**
  92536. * The current light unifom buffer.
  92537. * @hidden Internal use only.
  92538. */
  92539. _uniformBuffer: UniformBuffer;
  92540. /** @hidden */
  92541. _renderId: number;
  92542. /**
  92543. * Creates a Light object in the scene.
  92544. * Documentation : https://doc.babylonjs.com/babylon101/lights
  92545. * @param name The firendly name of the light
  92546. * @param scene The scene the light belongs too
  92547. */
  92548. constructor(name: string, scene: Scene);
  92549. protected abstract _buildUniformLayout(): void;
  92550. /**
  92551. * Sets the passed Effect "effect" with the Light information.
  92552. * @param effect The effect to update
  92553. * @param lightIndex The index of the light in the effect to update
  92554. * @returns The light
  92555. */
  92556. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  92557. /**
  92558. * Sets the passed Effect "effect" with the Light textures.
  92559. * @param effect The effect to update
  92560. * @param lightIndex The index of the light in the effect to update
  92561. * @returns The light
  92562. */
  92563. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  92564. /**
  92565. * Binds the lights information from the scene to the effect for the given mesh.
  92566. * @param lightIndex Light index
  92567. * @param scene The scene where the light belongs to
  92568. * @param effect The effect we are binding the data to
  92569. * @param useSpecular Defines if specular is supported
  92570. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  92571. */
  92572. _bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  92573. /**
  92574. * Sets the passed Effect "effect" with the Light information.
  92575. * @param effect The effect to update
  92576. * @param lightDataUniformName The uniform used to store light data (position or direction)
  92577. * @returns The light
  92578. */
  92579. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  92580. /**
  92581. * Returns the string "Light".
  92582. * @returns the class name
  92583. */
  92584. getClassName(): string;
  92585. /** @hidden */
  92586. readonly _isLight: boolean;
  92587. /**
  92588. * Converts the light information to a readable string for debug purpose.
  92589. * @param fullDetails Supports for multiple levels of logging within scene loading
  92590. * @returns the human readable light info
  92591. */
  92592. toString(fullDetails?: boolean): string;
  92593. /** @hidden */
  92594. protected _syncParentEnabledState(): void;
  92595. /**
  92596. * Set the enabled state of this node.
  92597. * @param value - the new enabled state
  92598. */
  92599. setEnabled(value: boolean): void;
  92600. /**
  92601. * Returns the Light associated shadow generator if any.
  92602. * @return the associated shadow generator.
  92603. */
  92604. getShadowGenerator(): Nullable<IShadowGenerator>;
  92605. /**
  92606. * Returns a Vector3, the absolute light position in the World.
  92607. * @returns the world space position of the light
  92608. */
  92609. getAbsolutePosition(): Vector3;
  92610. /**
  92611. * Specifies if the light will affect the passed mesh.
  92612. * @param mesh The mesh to test against the light
  92613. * @return true the mesh is affected otherwise, false.
  92614. */
  92615. canAffectMesh(mesh: AbstractMesh): boolean;
  92616. /**
  92617. * Sort function to order lights for rendering.
  92618. * @param a First Light object to compare to second.
  92619. * @param b Second Light object to compare first.
  92620. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  92621. */
  92622. static CompareLightsPriority(a: Light, b: Light): number;
  92623. /**
  92624. * Releases resources associated with this node.
  92625. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  92626. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  92627. */
  92628. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  92629. /**
  92630. * Returns the light type ID (integer).
  92631. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  92632. */
  92633. getTypeID(): number;
  92634. /**
  92635. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  92636. * @returns the scaled intensity in intensity mode unit
  92637. */
  92638. getScaledIntensity(): number;
  92639. /**
  92640. * Returns a new Light object, named "name", from the current one.
  92641. * @param name The name of the cloned light
  92642. * @returns the new created light
  92643. */
  92644. clone(name: string): Nullable<Light>;
  92645. /**
  92646. * Serializes the current light into a Serialization object.
  92647. * @returns the serialized object.
  92648. */
  92649. serialize(): any;
  92650. /**
  92651. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  92652. * This new light is named "name" and added to the passed scene.
  92653. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  92654. * @param name The friendly name of the light
  92655. * @param scene The scene the new light will belong to
  92656. * @returns the constructor function
  92657. */
  92658. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  92659. /**
  92660. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  92661. * @param parsedLight The JSON representation of the light
  92662. * @param scene The scene to create the parsed light in
  92663. * @returns the created light after parsing
  92664. */
  92665. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  92666. private _hookArrayForExcluded;
  92667. private _hookArrayForIncludedOnly;
  92668. private _resyncMeshes;
  92669. /**
  92670. * Forces the meshes to update their light related information in their rendering used effects
  92671. * @hidden Internal Use Only
  92672. */
  92673. _markMeshesAsLightDirty(): void;
  92674. /**
  92675. * Recomputes the cached photometric scale if needed.
  92676. */
  92677. private _computePhotometricScale;
  92678. /**
  92679. * Returns the Photometric Scale according to the light type and intensity mode.
  92680. */
  92681. private _getPhotometricScale;
  92682. /**
  92683. * Reorder the light in the scene according to their defined priority.
  92684. * @hidden Internal Use Only
  92685. */
  92686. _reorderLightsInScene(): void;
  92687. /**
  92688. * Prepares the list of defines specific to the light type.
  92689. * @param defines the list of defines
  92690. * @param lightIndex defines the index of the light for the effect
  92691. */
  92692. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  92693. }
  92694. }
  92695. declare module BABYLON {
  92696. /**
  92697. * Interface used to define Action
  92698. */
  92699. export interface IAction {
  92700. /**
  92701. * Trigger for the action
  92702. */
  92703. trigger: number;
  92704. /** Options of the trigger */
  92705. triggerOptions: any;
  92706. /**
  92707. * Gets the trigger parameters
  92708. * @returns the trigger parameters
  92709. */
  92710. getTriggerParameter(): any;
  92711. /**
  92712. * Internal only - executes current action event
  92713. * @hidden
  92714. */
  92715. _executeCurrent(evt?: ActionEvent): void;
  92716. /**
  92717. * Serialize placeholder for child classes
  92718. * @param parent of child
  92719. * @returns the serialized object
  92720. */
  92721. serialize(parent: any): any;
  92722. /**
  92723. * Internal only
  92724. * @hidden
  92725. */
  92726. _prepare(): void;
  92727. /**
  92728. * Internal only - manager for action
  92729. * @hidden
  92730. */
  92731. _actionManager: AbstractActionManager;
  92732. /**
  92733. * Adds action to chain of actions, may be a DoNothingAction
  92734. * @param action defines the next action to execute
  92735. * @returns The action passed in
  92736. * @see https://www.babylonjs-playground.com/#1T30HR#0
  92737. */
  92738. then(action: IAction): IAction;
  92739. }
  92740. /**
  92741. * The action to be carried out following a trigger
  92742. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  92743. */
  92744. export class Action implements IAction {
  92745. /** the trigger, with or without parameters, for the action */
  92746. triggerOptions: any;
  92747. /**
  92748. * Trigger for the action
  92749. */
  92750. trigger: number;
  92751. /**
  92752. * Internal only - manager for action
  92753. * @hidden
  92754. */
  92755. _actionManager: ActionManager;
  92756. private _nextActiveAction;
  92757. private _child;
  92758. private _condition?;
  92759. private _triggerParameter;
  92760. /**
  92761. * An event triggered prior to action being executed.
  92762. */
  92763. onBeforeExecuteObservable: Observable<Action>;
  92764. /**
  92765. * Creates a new Action
  92766. * @param triggerOptions the trigger, with or without parameters, for the action
  92767. * @param condition an optional determinant of action
  92768. */
  92769. constructor(
  92770. /** the trigger, with or without parameters, for the action */
  92771. triggerOptions: any, condition?: Condition);
  92772. /**
  92773. * Internal only
  92774. * @hidden
  92775. */
  92776. _prepare(): void;
  92777. /**
  92778. * Gets the trigger parameters
  92779. * @returns the trigger parameters
  92780. */
  92781. getTriggerParameter(): any;
  92782. /**
  92783. * Internal only - executes current action event
  92784. * @hidden
  92785. */
  92786. _executeCurrent(evt?: ActionEvent): void;
  92787. /**
  92788. * Execute placeholder for child classes
  92789. * @param evt optional action event
  92790. */
  92791. execute(evt?: ActionEvent): void;
  92792. /**
  92793. * Skips to next active action
  92794. */
  92795. skipToNextActiveAction(): void;
  92796. /**
  92797. * Adds action to chain of actions, may be a DoNothingAction
  92798. * @param action defines the next action to execute
  92799. * @returns The action passed in
  92800. * @see https://www.babylonjs-playground.com/#1T30HR#0
  92801. */
  92802. then(action: Action): Action;
  92803. /**
  92804. * Internal only
  92805. * @hidden
  92806. */
  92807. _getProperty(propertyPath: string): string;
  92808. /**
  92809. * Internal only
  92810. * @hidden
  92811. */
  92812. _getEffectiveTarget(target: any, propertyPath: string): any;
  92813. /**
  92814. * Serialize placeholder for child classes
  92815. * @param parent of child
  92816. * @returns the serialized object
  92817. */
  92818. serialize(parent: any): any;
  92819. /**
  92820. * Internal only called by serialize
  92821. * @hidden
  92822. */
  92823. protected _serialize(serializedAction: any, parent?: any): any;
  92824. /**
  92825. * Internal only
  92826. * @hidden
  92827. */
  92828. static _SerializeValueAsString: (value: any) => string;
  92829. /**
  92830. * Internal only
  92831. * @hidden
  92832. */
  92833. static _GetTargetProperty: (target: Node | Scene) => {
  92834. name: string;
  92835. targetType: string;
  92836. value: string;
  92837. };
  92838. }
  92839. }
  92840. declare module BABYLON {
  92841. /**
  92842. * A Condition applied to an Action
  92843. */
  92844. export class Condition {
  92845. /**
  92846. * Internal only - manager for action
  92847. * @hidden
  92848. */
  92849. _actionManager: ActionManager;
  92850. /**
  92851. * Internal only
  92852. * @hidden
  92853. */
  92854. _evaluationId: number;
  92855. /**
  92856. * Internal only
  92857. * @hidden
  92858. */
  92859. _currentResult: boolean;
  92860. /**
  92861. * Creates a new Condition
  92862. * @param actionManager the manager of the action the condition is applied to
  92863. */
  92864. constructor(actionManager: ActionManager);
  92865. /**
  92866. * Check if the current condition is valid
  92867. * @returns a boolean
  92868. */
  92869. isValid(): boolean;
  92870. /**
  92871. * Internal only
  92872. * @hidden
  92873. */
  92874. _getProperty(propertyPath: string): string;
  92875. /**
  92876. * Internal only
  92877. * @hidden
  92878. */
  92879. _getEffectiveTarget(target: any, propertyPath: string): any;
  92880. /**
  92881. * Serialize placeholder for child classes
  92882. * @returns the serialized object
  92883. */
  92884. serialize(): any;
  92885. /**
  92886. * Internal only
  92887. * @hidden
  92888. */
  92889. protected _serialize(serializedCondition: any): any;
  92890. }
  92891. /**
  92892. * Defines specific conditional operators as extensions of Condition
  92893. */
  92894. export class ValueCondition extends Condition {
  92895. /** path to specify the property of the target the conditional operator uses */
  92896. propertyPath: string;
  92897. /** the value compared by the conditional operator against the current value of the property */
  92898. value: any;
  92899. /** the conditional operator, default ValueCondition.IsEqual */
  92900. operator: number;
  92901. /**
  92902. * Internal only
  92903. * @hidden
  92904. */
  92905. private static _IsEqual;
  92906. /**
  92907. * Internal only
  92908. * @hidden
  92909. */
  92910. private static _IsDifferent;
  92911. /**
  92912. * Internal only
  92913. * @hidden
  92914. */
  92915. private static _IsGreater;
  92916. /**
  92917. * Internal only
  92918. * @hidden
  92919. */
  92920. private static _IsLesser;
  92921. /**
  92922. * returns the number for IsEqual
  92923. */
  92924. static get IsEqual(): number;
  92925. /**
  92926. * Returns the number for IsDifferent
  92927. */
  92928. static get IsDifferent(): number;
  92929. /**
  92930. * Returns the number for IsGreater
  92931. */
  92932. static get IsGreater(): number;
  92933. /**
  92934. * Returns the number for IsLesser
  92935. */
  92936. static get IsLesser(): number;
  92937. /**
  92938. * Internal only The action manager for the condition
  92939. * @hidden
  92940. */
  92941. _actionManager: ActionManager;
  92942. /**
  92943. * Internal only
  92944. * @hidden
  92945. */
  92946. private _target;
  92947. /**
  92948. * Internal only
  92949. * @hidden
  92950. */
  92951. private _effectiveTarget;
  92952. /**
  92953. * Internal only
  92954. * @hidden
  92955. */
  92956. private _property;
  92957. /**
  92958. * Creates a new ValueCondition
  92959. * @param actionManager manager for the action the condition applies to
  92960. * @param target for the action
  92961. * @param propertyPath path to specify the property of the target the conditional operator uses
  92962. * @param value the value compared by the conditional operator against the current value of the property
  92963. * @param operator the conditional operator, default ValueCondition.IsEqual
  92964. */
  92965. constructor(actionManager: ActionManager, target: any,
  92966. /** path to specify the property of the target the conditional operator uses */
  92967. propertyPath: string,
  92968. /** the value compared by the conditional operator against the current value of the property */
  92969. value: any,
  92970. /** the conditional operator, default ValueCondition.IsEqual */
  92971. operator?: number);
  92972. /**
  92973. * Compares the given value with the property value for the specified conditional operator
  92974. * @returns the result of the comparison
  92975. */
  92976. isValid(): boolean;
  92977. /**
  92978. * Serialize the ValueCondition into a JSON compatible object
  92979. * @returns serialization object
  92980. */
  92981. serialize(): any;
  92982. /**
  92983. * Gets the name of the conditional operator for the ValueCondition
  92984. * @param operator the conditional operator
  92985. * @returns the name
  92986. */
  92987. static GetOperatorName(operator: number): string;
  92988. }
  92989. /**
  92990. * Defines a predicate condition as an extension of Condition
  92991. */
  92992. export class PredicateCondition extends Condition {
  92993. /** defines the predicate function used to validate the condition */
  92994. predicate: () => boolean;
  92995. /**
  92996. * Internal only - manager for action
  92997. * @hidden
  92998. */
  92999. _actionManager: ActionManager;
  93000. /**
  93001. * Creates a new PredicateCondition
  93002. * @param actionManager manager for the action the condition applies to
  93003. * @param predicate defines the predicate function used to validate the condition
  93004. */
  93005. constructor(actionManager: ActionManager,
  93006. /** defines the predicate function used to validate the condition */
  93007. predicate: () => boolean);
  93008. /**
  93009. * @returns the validity of the predicate condition
  93010. */
  93011. isValid(): boolean;
  93012. }
  93013. /**
  93014. * Defines a state condition as an extension of Condition
  93015. */
  93016. export class StateCondition extends Condition {
  93017. /** Value to compare with target state */
  93018. value: string;
  93019. /**
  93020. * Internal only - manager for action
  93021. * @hidden
  93022. */
  93023. _actionManager: ActionManager;
  93024. /**
  93025. * Internal only
  93026. * @hidden
  93027. */
  93028. private _target;
  93029. /**
  93030. * Creates a new StateCondition
  93031. * @param actionManager manager for the action the condition applies to
  93032. * @param target of the condition
  93033. * @param value to compare with target state
  93034. */
  93035. constructor(actionManager: ActionManager, target: any,
  93036. /** Value to compare with target state */
  93037. value: string);
  93038. /**
  93039. * Gets a boolean indicating if the current condition is met
  93040. * @returns the validity of the state
  93041. */
  93042. isValid(): boolean;
  93043. /**
  93044. * Serialize the StateCondition into a JSON compatible object
  93045. * @returns serialization object
  93046. */
  93047. serialize(): any;
  93048. }
  93049. }
  93050. declare module BABYLON {
  93051. /**
  93052. * This defines an action responsible to toggle a boolean once triggered.
  93053. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  93054. */
  93055. export class SwitchBooleanAction extends Action {
  93056. /**
  93057. * The path to the boolean property in the target object
  93058. */
  93059. propertyPath: string;
  93060. private _target;
  93061. private _effectiveTarget;
  93062. private _property;
  93063. /**
  93064. * Instantiate the action
  93065. * @param triggerOptions defines the trigger options
  93066. * @param target defines the object containing the boolean
  93067. * @param propertyPath defines the path to the boolean property in the target object
  93068. * @param condition defines the trigger related conditions
  93069. */
  93070. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  93071. /** @hidden */
  93072. _prepare(): void;
  93073. /**
  93074. * Execute the action toggle the boolean value.
  93075. */
  93076. execute(): void;
  93077. /**
  93078. * Serializes the actions and its related information.
  93079. * @param parent defines the object to serialize in
  93080. * @returns the serialized object
  93081. */
  93082. serialize(parent: any): any;
  93083. }
  93084. /**
  93085. * This defines an action responsible to set a the state field of the target
  93086. * to a desired value once triggered.
  93087. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  93088. */
  93089. export class SetStateAction extends Action {
  93090. /**
  93091. * The value to store in the state field.
  93092. */
  93093. value: string;
  93094. private _target;
  93095. /**
  93096. * Instantiate the action
  93097. * @param triggerOptions defines the trigger options
  93098. * @param target defines the object containing the state property
  93099. * @param value defines the value to store in the state field
  93100. * @param condition defines the trigger related conditions
  93101. */
  93102. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  93103. /**
  93104. * Execute the action and store the value on the target state property.
  93105. */
  93106. execute(): void;
  93107. /**
  93108. * Serializes the actions and its related information.
  93109. * @param parent defines the object to serialize in
  93110. * @returns the serialized object
  93111. */
  93112. serialize(parent: any): any;
  93113. }
  93114. /**
  93115. * This defines an action responsible to set a property of the target
  93116. * to a desired value once triggered.
  93117. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  93118. */
  93119. export class SetValueAction extends Action {
  93120. /**
  93121. * The path of the property to set in the target.
  93122. */
  93123. propertyPath: string;
  93124. /**
  93125. * The value to set in the property
  93126. */
  93127. value: any;
  93128. private _target;
  93129. private _effectiveTarget;
  93130. private _property;
  93131. /**
  93132. * Instantiate the action
  93133. * @param triggerOptions defines the trigger options
  93134. * @param target defines the object containing the property
  93135. * @param propertyPath defines the path of the property to set in the target
  93136. * @param value defines the value to set in the property
  93137. * @param condition defines the trigger related conditions
  93138. */
  93139. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  93140. /** @hidden */
  93141. _prepare(): void;
  93142. /**
  93143. * Execute the action and set the targetted property to the desired value.
  93144. */
  93145. execute(): void;
  93146. /**
  93147. * Serializes the actions and its related information.
  93148. * @param parent defines the object to serialize in
  93149. * @returns the serialized object
  93150. */
  93151. serialize(parent: any): any;
  93152. }
  93153. /**
  93154. * This defines an action responsible to increment the target value
  93155. * to a desired value once triggered.
  93156. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  93157. */
  93158. export class IncrementValueAction extends Action {
  93159. /**
  93160. * The path of the property to increment in the target.
  93161. */
  93162. propertyPath: string;
  93163. /**
  93164. * The value we should increment the property by.
  93165. */
  93166. value: any;
  93167. private _target;
  93168. private _effectiveTarget;
  93169. private _property;
  93170. /**
  93171. * Instantiate the action
  93172. * @param triggerOptions defines the trigger options
  93173. * @param target defines the object containing the property
  93174. * @param propertyPath defines the path of the property to increment in the target
  93175. * @param value defines the value value we should increment the property by
  93176. * @param condition defines the trigger related conditions
  93177. */
  93178. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  93179. /** @hidden */
  93180. _prepare(): void;
  93181. /**
  93182. * Execute the action and increment the target of the value amount.
  93183. */
  93184. execute(): void;
  93185. /**
  93186. * Serializes the actions and its related information.
  93187. * @param parent defines the object to serialize in
  93188. * @returns the serialized object
  93189. */
  93190. serialize(parent: any): any;
  93191. }
  93192. /**
  93193. * This defines an action responsible to start an animation once triggered.
  93194. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  93195. */
  93196. export class PlayAnimationAction extends Action {
  93197. /**
  93198. * Where the animation should start (animation frame)
  93199. */
  93200. from: number;
  93201. /**
  93202. * Where the animation should stop (animation frame)
  93203. */
  93204. to: number;
  93205. /**
  93206. * Define if the animation should loop or stop after the first play.
  93207. */
  93208. loop?: boolean;
  93209. private _target;
  93210. /**
  93211. * Instantiate the action
  93212. * @param triggerOptions defines the trigger options
  93213. * @param target defines the target animation or animation name
  93214. * @param from defines from where the animation should start (animation frame)
  93215. * @param end defines where the animation should stop (animation frame)
  93216. * @param loop defines if the animation should loop or stop after the first play
  93217. * @param condition defines the trigger related conditions
  93218. */
  93219. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  93220. /** @hidden */
  93221. _prepare(): void;
  93222. /**
  93223. * Execute the action and play the animation.
  93224. */
  93225. execute(): void;
  93226. /**
  93227. * Serializes the actions and its related information.
  93228. * @param parent defines the object to serialize in
  93229. * @returns the serialized object
  93230. */
  93231. serialize(parent: any): any;
  93232. }
  93233. /**
  93234. * This defines an action responsible to stop an animation once triggered.
  93235. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  93236. */
  93237. export class StopAnimationAction extends Action {
  93238. private _target;
  93239. /**
  93240. * Instantiate the action
  93241. * @param triggerOptions defines the trigger options
  93242. * @param target defines the target animation or animation name
  93243. * @param condition defines the trigger related conditions
  93244. */
  93245. constructor(triggerOptions: any, target: any, condition?: Condition);
  93246. /** @hidden */
  93247. _prepare(): void;
  93248. /**
  93249. * Execute the action and stop the animation.
  93250. */
  93251. execute(): void;
  93252. /**
  93253. * Serializes the actions and its related information.
  93254. * @param parent defines the object to serialize in
  93255. * @returns the serialized object
  93256. */
  93257. serialize(parent: any): any;
  93258. }
  93259. /**
  93260. * This defines an action responsible that does nothing once triggered.
  93261. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  93262. */
  93263. export class DoNothingAction extends Action {
  93264. /**
  93265. * Instantiate the action
  93266. * @param triggerOptions defines the trigger options
  93267. * @param condition defines the trigger related conditions
  93268. */
  93269. constructor(triggerOptions?: any, condition?: Condition);
  93270. /**
  93271. * Execute the action and do nothing.
  93272. */
  93273. execute(): void;
  93274. /**
  93275. * Serializes the actions and its related information.
  93276. * @param parent defines the object to serialize in
  93277. * @returns the serialized object
  93278. */
  93279. serialize(parent: any): any;
  93280. }
  93281. /**
  93282. * This defines an action responsible to trigger several actions once triggered.
  93283. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  93284. */
  93285. export class CombineAction extends Action {
  93286. /**
  93287. * The list of aggregated animations to run.
  93288. */
  93289. children: Action[];
  93290. /**
  93291. * Instantiate the action
  93292. * @param triggerOptions defines the trigger options
  93293. * @param children defines the list of aggregated animations to run
  93294. * @param condition defines the trigger related conditions
  93295. */
  93296. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  93297. /** @hidden */
  93298. _prepare(): void;
  93299. /**
  93300. * Execute the action and executes all the aggregated actions.
  93301. */
  93302. execute(evt: ActionEvent): void;
  93303. /**
  93304. * Serializes the actions and its related information.
  93305. * @param parent defines the object to serialize in
  93306. * @returns the serialized object
  93307. */
  93308. serialize(parent: any): any;
  93309. }
  93310. /**
  93311. * This defines an action responsible to run code (external event) once triggered.
  93312. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  93313. */
  93314. export class ExecuteCodeAction extends Action {
  93315. /**
  93316. * The callback function to run.
  93317. */
  93318. func: (evt: ActionEvent) => void;
  93319. /**
  93320. * Instantiate the action
  93321. * @param triggerOptions defines the trigger options
  93322. * @param func defines the callback function to run
  93323. * @param condition defines the trigger related conditions
  93324. */
  93325. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  93326. /**
  93327. * Execute the action and run the attached code.
  93328. */
  93329. execute(evt: ActionEvent): void;
  93330. }
  93331. /**
  93332. * This defines an action responsible to set the parent property of the target once triggered.
  93333. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  93334. */
  93335. export class SetParentAction extends Action {
  93336. private _parent;
  93337. private _target;
  93338. /**
  93339. * Instantiate the action
  93340. * @param triggerOptions defines the trigger options
  93341. * @param target defines the target containing the parent property
  93342. * @param parent defines from where the animation should start (animation frame)
  93343. * @param condition defines the trigger related conditions
  93344. */
  93345. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  93346. /** @hidden */
  93347. _prepare(): void;
  93348. /**
  93349. * Execute the action and set the parent property.
  93350. */
  93351. execute(): void;
  93352. /**
  93353. * Serializes the actions and its related information.
  93354. * @param parent defines the object to serialize in
  93355. * @returns the serialized object
  93356. */
  93357. serialize(parent: any): any;
  93358. }
  93359. }
  93360. declare module BABYLON {
  93361. /**
  93362. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  93363. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  93364. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  93365. */
  93366. export class ActionManager extends AbstractActionManager {
  93367. /**
  93368. * Nothing
  93369. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  93370. */
  93371. static readonly NothingTrigger: number;
  93372. /**
  93373. * On pick
  93374. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  93375. */
  93376. static readonly OnPickTrigger: number;
  93377. /**
  93378. * On left pick
  93379. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  93380. */
  93381. static readonly OnLeftPickTrigger: number;
  93382. /**
  93383. * On right pick
  93384. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  93385. */
  93386. static readonly OnRightPickTrigger: number;
  93387. /**
  93388. * On center pick
  93389. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  93390. */
  93391. static readonly OnCenterPickTrigger: number;
  93392. /**
  93393. * On pick down
  93394. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  93395. */
  93396. static readonly OnPickDownTrigger: number;
  93397. /**
  93398. * On double pick
  93399. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  93400. */
  93401. static readonly OnDoublePickTrigger: number;
  93402. /**
  93403. * On pick up
  93404. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  93405. */
  93406. static readonly OnPickUpTrigger: number;
  93407. /**
  93408. * On pick out.
  93409. * This trigger will only be raised if you also declared a OnPickDown
  93410. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  93411. */
  93412. static readonly OnPickOutTrigger: number;
  93413. /**
  93414. * On long press
  93415. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  93416. */
  93417. static readonly OnLongPressTrigger: number;
  93418. /**
  93419. * On pointer over
  93420. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  93421. */
  93422. static readonly OnPointerOverTrigger: number;
  93423. /**
  93424. * On pointer out
  93425. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  93426. */
  93427. static readonly OnPointerOutTrigger: number;
  93428. /**
  93429. * On every frame
  93430. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  93431. */
  93432. static readonly OnEveryFrameTrigger: number;
  93433. /**
  93434. * On intersection enter
  93435. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  93436. */
  93437. static readonly OnIntersectionEnterTrigger: number;
  93438. /**
  93439. * On intersection exit
  93440. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  93441. */
  93442. static readonly OnIntersectionExitTrigger: number;
  93443. /**
  93444. * On key down
  93445. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  93446. */
  93447. static readonly OnKeyDownTrigger: number;
  93448. /**
  93449. * On key up
  93450. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  93451. */
  93452. static readonly OnKeyUpTrigger: number;
  93453. private _scene;
  93454. /**
  93455. * Creates a new action manager
  93456. * @param scene defines the hosting scene
  93457. */
  93458. constructor(scene: Scene);
  93459. /**
  93460. * Releases all associated resources
  93461. */
  93462. dispose(): void;
  93463. /**
  93464. * Gets hosting scene
  93465. * @returns the hosting scene
  93466. */
  93467. getScene(): Scene;
  93468. /**
  93469. * Does this action manager handles actions of any of the given triggers
  93470. * @param triggers defines the triggers to be tested
  93471. * @return a boolean indicating whether one (or more) of the triggers is handled
  93472. */
  93473. hasSpecificTriggers(triggers: number[]): boolean;
  93474. /**
  93475. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  93476. * speed.
  93477. * @param triggerA defines the trigger to be tested
  93478. * @param triggerB defines the trigger to be tested
  93479. * @return a boolean indicating whether one (or more) of the triggers is handled
  93480. */
  93481. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  93482. /**
  93483. * Does this action manager handles actions of a given trigger
  93484. * @param trigger defines the trigger to be tested
  93485. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  93486. * @return whether the trigger is handled
  93487. */
  93488. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  93489. /**
  93490. * Does this action manager has pointer triggers
  93491. */
  93492. get hasPointerTriggers(): boolean;
  93493. /**
  93494. * Does this action manager has pick triggers
  93495. */
  93496. get hasPickTriggers(): boolean;
  93497. /**
  93498. * Registers an action to this action manager
  93499. * @param action defines the action to be registered
  93500. * @return the action amended (prepared) after registration
  93501. */
  93502. registerAction(action: IAction): Nullable<IAction>;
  93503. /**
  93504. * Unregisters an action to this action manager
  93505. * @param action defines the action to be unregistered
  93506. * @return a boolean indicating whether the action has been unregistered
  93507. */
  93508. unregisterAction(action: IAction): Boolean;
  93509. /**
  93510. * Process a specific trigger
  93511. * @param trigger defines the trigger to process
  93512. * @param evt defines the event details to be processed
  93513. */
  93514. processTrigger(trigger: number, evt?: IActionEvent): void;
  93515. /** @hidden */
  93516. _getEffectiveTarget(target: any, propertyPath: string): any;
  93517. /** @hidden */
  93518. _getProperty(propertyPath: string): string;
  93519. /**
  93520. * Serialize this manager to a JSON object
  93521. * @param name defines the property name to store this manager
  93522. * @returns a JSON representation of this manager
  93523. */
  93524. serialize(name: string): any;
  93525. /**
  93526. * Creates a new ActionManager from a JSON data
  93527. * @param parsedActions defines the JSON data to read from
  93528. * @param object defines the hosting mesh
  93529. * @param scene defines the hosting scene
  93530. */
  93531. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  93532. /**
  93533. * Get a trigger name by index
  93534. * @param trigger defines the trigger index
  93535. * @returns a trigger name
  93536. */
  93537. static GetTriggerName(trigger: number): string;
  93538. }
  93539. }
  93540. declare module BABYLON {
  93541. /**
  93542. * Class used to represent a sprite
  93543. * @see http://doc.babylonjs.com/babylon101/sprites
  93544. */
  93545. export class Sprite {
  93546. /** defines the name */
  93547. name: string;
  93548. /** Gets or sets the current world position */
  93549. position: Vector3;
  93550. /** Gets or sets the main color */
  93551. color: Color4;
  93552. /** Gets or sets the width */
  93553. width: number;
  93554. /** Gets or sets the height */
  93555. height: number;
  93556. /** Gets or sets rotation angle */
  93557. angle: number;
  93558. /** Gets or sets the cell index in the sprite sheet */
  93559. cellIndex: number;
  93560. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  93561. cellRef: string;
  93562. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  93563. invertU: number;
  93564. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  93565. invertV: number;
  93566. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  93567. disposeWhenFinishedAnimating: boolean;
  93568. /** Gets the list of attached animations */
  93569. animations: Animation[];
  93570. /** Gets or sets a boolean indicating if the sprite can be picked */
  93571. isPickable: boolean;
  93572. /** Gets or sets a boolean indicating that sprite texture alpha will be used for precise picking (false by default) */
  93573. useAlphaForPicking: boolean;
  93574. /** @hidden */
  93575. _xOffset: number;
  93576. /** @hidden */
  93577. _yOffset: number;
  93578. /** @hidden */
  93579. _xSize: number;
  93580. /** @hidden */
  93581. _ySize: number;
  93582. /**
  93583. * Gets or sets the associated action manager
  93584. */
  93585. actionManager: Nullable<ActionManager>;
  93586. private _animationStarted;
  93587. private _loopAnimation;
  93588. private _fromIndex;
  93589. private _toIndex;
  93590. private _delay;
  93591. private _direction;
  93592. private _manager;
  93593. private _time;
  93594. private _onAnimationEnd;
  93595. /**
  93596. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  93597. */
  93598. isVisible: boolean;
  93599. /**
  93600. * Gets or sets the sprite size
  93601. */
  93602. get size(): number;
  93603. set size(value: number);
  93604. /**
  93605. * Creates a new Sprite
  93606. * @param name defines the name
  93607. * @param manager defines the manager
  93608. */
  93609. constructor(
  93610. /** defines the name */
  93611. name: string, manager: ISpriteManager);
  93612. /**
  93613. * Starts an animation
  93614. * @param from defines the initial key
  93615. * @param to defines the end key
  93616. * @param loop defines if the animation must loop
  93617. * @param delay defines the start delay (in ms)
  93618. * @param onAnimationEnd defines a callback to call when animation ends
  93619. */
  93620. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  93621. /** Stops current animation (if any) */
  93622. stopAnimation(): void;
  93623. /** @hidden */
  93624. _animate(deltaTime: number): void;
  93625. /** Release associated resources */
  93626. dispose(): void;
  93627. }
  93628. }
  93629. declare module BABYLON {
  93630. /**
  93631. * Information about the result of picking within a scene
  93632. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  93633. */
  93634. export class PickingInfo {
  93635. /** @hidden */
  93636. _pickingUnavailable: boolean;
  93637. /**
  93638. * If the pick collided with an object
  93639. */
  93640. hit: boolean;
  93641. /**
  93642. * Distance away where the pick collided
  93643. */
  93644. distance: number;
  93645. /**
  93646. * The location of pick collision
  93647. */
  93648. pickedPoint: Nullable<Vector3>;
  93649. /**
  93650. * The mesh corresponding the the pick collision
  93651. */
  93652. pickedMesh: Nullable<AbstractMesh>;
  93653. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  93654. bu: number;
  93655. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  93656. bv: number;
  93657. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  93658. faceId: number;
  93659. /** Id of the the submesh that was picked */
  93660. subMeshId: number;
  93661. /** If a sprite was picked, this will be the sprite the pick collided with */
  93662. pickedSprite: Nullable<Sprite>;
  93663. /**
  93664. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  93665. */
  93666. originMesh: Nullable<AbstractMesh>;
  93667. /**
  93668. * The ray that was used to perform the picking.
  93669. */
  93670. ray: Nullable<Ray>;
  93671. /**
  93672. * Gets the normal correspodning to the face the pick collided with
  93673. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  93674. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  93675. * @returns The normal correspodning to the face the pick collided with
  93676. */
  93677. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  93678. /**
  93679. * Gets the texture coordinates of where the pick occured
  93680. * @returns the vector containing the coordnates of the texture
  93681. */
  93682. getTextureCoordinates(): Nullable<Vector2>;
  93683. }
  93684. }
  93685. declare module BABYLON {
  93686. /**
  93687. * Gather the list of pointer event types as constants.
  93688. */
  93689. export class PointerEventTypes {
  93690. /**
  93691. * 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.
  93692. */
  93693. static readonly POINTERDOWN: number;
  93694. /**
  93695. * The pointerup event is fired when a pointer is no longer active.
  93696. */
  93697. static readonly POINTERUP: number;
  93698. /**
  93699. * The pointermove event is fired when a pointer changes coordinates.
  93700. */
  93701. static readonly POINTERMOVE: number;
  93702. /**
  93703. * The pointerwheel event is fired when a mouse wheel has been rotated.
  93704. */
  93705. static readonly POINTERWHEEL: number;
  93706. /**
  93707. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  93708. */
  93709. static readonly POINTERPICK: number;
  93710. /**
  93711. * The pointertap event is fired when a the object has been touched and released without drag.
  93712. */
  93713. static readonly POINTERTAP: number;
  93714. /**
  93715. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  93716. */
  93717. static readonly POINTERDOUBLETAP: number;
  93718. }
  93719. /**
  93720. * Base class of pointer info types.
  93721. */
  93722. export class PointerInfoBase {
  93723. /**
  93724. * Defines the type of event (PointerEventTypes)
  93725. */
  93726. type: number;
  93727. /**
  93728. * Defines the related dom event
  93729. */
  93730. event: PointerEvent | MouseWheelEvent;
  93731. /**
  93732. * Instantiates the base class of pointers info.
  93733. * @param type Defines the type of event (PointerEventTypes)
  93734. * @param event Defines the related dom event
  93735. */
  93736. constructor(
  93737. /**
  93738. * Defines the type of event (PointerEventTypes)
  93739. */
  93740. type: number,
  93741. /**
  93742. * Defines the related dom event
  93743. */
  93744. event: PointerEvent | MouseWheelEvent);
  93745. }
  93746. /**
  93747. * This class is used to store pointer related info for the onPrePointerObservable event.
  93748. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  93749. */
  93750. export class PointerInfoPre extends PointerInfoBase {
  93751. /**
  93752. * Ray from a pointer if availible (eg. 6dof controller)
  93753. */
  93754. ray: Nullable<Ray>;
  93755. /**
  93756. * Defines the local position of the pointer on the canvas.
  93757. */
  93758. localPosition: Vector2;
  93759. /**
  93760. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  93761. */
  93762. skipOnPointerObservable: boolean;
  93763. /**
  93764. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  93765. * @param type Defines the type of event (PointerEventTypes)
  93766. * @param event Defines the related dom event
  93767. * @param localX Defines the local x coordinates of the pointer when the event occured
  93768. * @param localY Defines the local y coordinates of the pointer when the event occured
  93769. */
  93770. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  93771. }
  93772. /**
  93773. * This type contains all the data related to a pointer event in Babylon.js.
  93774. * 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.
  93775. */
  93776. export class PointerInfo extends PointerInfoBase {
  93777. /**
  93778. * Defines the picking info associated to the info (if any)\
  93779. */
  93780. pickInfo: Nullable<PickingInfo>;
  93781. /**
  93782. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  93783. * @param type Defines the type of event (PointerEventTypes)
  93784. * @param event Defines the related dom event
  93785. * @param pickInfo Defines the picking info associated to the info (if any)\
  93786. */
  93787. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  93788. /**
  93789. * Defines the picking info associated to the info (if any)\
  93790. */
  93791. pickInfo: Nullable<PickingInfo>);
  93792. }
  93793. /**
  93794. * Data relating to a touch event on the screen.
  93795. */
  93796. export interface PointerTouch {
  93797. /**
  93798. * X coordinate of touch.
  93799. */
  93800. x: number;
  93801. /**
  93802. * Y coordinate of touch.
  93803. */
  93804. y: number;
  93805. /**
  93806. * Id of touch. Unique for each finger.
  93807. */
  93808. pointerId: number;
  93809. /**
  93810. * Event type passed from DOM.
  93811. */
  93812. type: any;
  93813. }
  93814. }
  93815. declare module BABYLON {
  93816. /**
  93817. * Manage the mouse inputs to control the movement of a free camera.
  93818. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  93819. */
  93820. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  93821. /**
  93822. * Define if touch is enabled in the mouse input
  93823. */
  93824. touchEnabled: boolean;
  93825. /**
  93826. * Defines the camera the input is attached to.
  93827. */
  93828. camera: FreeCamera;
  93829. /**
  93830. * Defines the buttons associated with the input to handle camera move.
  93831. */
  93832. buttons: number[];
  93833. /**
  93834. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  93835. */
  93836. angularSensibility: number;
  93837. private _pointerInput;
  93838. private _onMouseMove;
  93839. private _observer;
  93840. private previousPosition;
  93841. /**
  93842. * Observable for when a pointer move event occurs containing the move offset
  93843. */
  93844. onPointerMovedObservable: Observable<{
  93845. offsetX: number;
  93846. offsetY: number;
  93847. }>;
  93848. /**
  93849. * @hidden
  93850. * If the camera should be rotated automatically based on pointer movement
  93851. */
  93852. _allowCameraRotation: boolean;
  93853. /**
  93854. * Manage the mouse inputs to control the movement of a free camera.
  93855. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  93856. * @param touchEnabled Defines if touch is enabled or not
  93857. */
  93858. constructor(
  93859. /**
  93860. * Define if touch is enabled in the mouse input
  93861. */
  93862. touchEnabled?: boolean);
  93863. /**
  93864. * Attach the input controls to a specific dom element to get the input from.
  93865. * @param element Defines the element the controls should be listened from
  93866. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  93867. */
  93868. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  93869. /**
  93870. * Called on JS contextmenu event.
  93871. * Override this method to provide functionality.
  93872. */
  93873. protected onContextMenu(evt: PointerEvent): void;
  93874. /**
  93875. * Detach the current controls from the specified dom element.
  93876. * @param element Defines the element to stop listening the inputs from
  93877. */
  93878. detachControl(element: Nullable<HTMLElement>): void;
  93879. /**
  93880. * Gets the class name of the current intput.
  93881. * @returns the class name
  93882. */
  93883. getClassName(): string;
  93884. /**
  93885. * Get the friendly name associated with the input class.
  93886. * @returns the input friendly name
  93887. */
  93888. getSimpleName(): string;
  93889. }
  93890. }
  93891. declare module BABYLON {
  93892. /**
  93893. * Manage the touch inputs to control the movement of a free camera.
  93894. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  93895. */
  93896. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  93897. /**
  93898. * Defines the camera the input is attached to.
  93899. */
  93900. camera: FreeCamera;
  93901. /**
  93902. * Defines the touch sensibility for rotation.
  93903. * The higher the faster.
  93904. */
  93905. touchAngularSensibility: number;
  93906. /**
  93907. * Defines the touch sensibility for move.
  93908. * The higher the faster.
  93909. */
  93910. touchMoveSensibility: number;
  93911. private _offsetX;
  93912. private _offsetY;
  93913. private _pointerPressed;
  93914. private _pointerInput;
  93915. private _observer;
  93916. private _onLostFocus;
  93917. /**
  93918. * Attach the input controls to a specific dom element to get the input from.
  93919. * @param element Defines the element the controls should be listened from
  93920. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  93921. */
  93922. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  93923. /**
  93924. * Detach the current controls from the specified dom element.
  93925. * @param element Defines the element to stop listening the inputs from
  93926. */
  93927. detachControl(element: Nullable<HTMLElement>): void;
  93928. /**
  93929. * Update the current camera state depending on the inputs that have been used this frame.
  93930. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  93931. */
  93932. checkInputs(): void;
  93933. /**
  93934. * Gets the class name of the current intput.
  93935. * @returns the class name
  93936. */
  93937. getClassName(): string;
  93938. /**
  93939. * Get the friendly name associated with the input class.
  93940. * @returns the input friendly name
  93941. */
  93942. getSimpleName(): string;
  93943. }
  93944. }
  93945. declare module BABYLON {
  93946. /**
  93947. * Default Inputs manager for the FreeCamera.
  93948. * It groups all the default supported inputs for ease of use.
  93949. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  93950. */
  93951. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  93952. /**
  93953. * @hidden
  93954. */
  93955. _mouseInput: Nullable<FreeCameraMouseInput>;
  93956. /**
  93957. * Instantiates a new FreeCameraInputsManager.
  93958. * @param camera Defines the camera the inputs belong to
  93959. */
  93960. constructor(camera: FreeCamera);
  93961. /**
  93962. * Add keyboard input support to the input manager.
  93963. * @returns the current input manager
  93964. */
  93965. addKeyboard(): FreeCameraInputsManager;
  93966. /**
  93967. * Add mouse input support to the input manager.
  93968. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  93969. * @returns the current input manager
  93970. */
  93971. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  93972. /**
  93973. * Removes the mouse input support from the manager
  93974. * @returns the current input manager
  93975. */
  93976. removeMouse(): FreeCameraInputsManager;
  93977. /**
  93978. * Add touch input support to the input manager.
  93979. * @returns the current input manager
  93980. */
  93981. addTouch(): FreeCameraInputsManager;
  93982. /**
  93983. * Remove all attached input methods from a camera
  93984. */
  93985. clear(): void;
  93986. }
  93987. }
  93988. declare module BABYLON {
  93989. /**
  93990. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  93991. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  93992. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  93993. */
  93994. export class FreeCamera extends TargetCamera {
  93995. /**
  93996. * Define the collision ellipsoid of the camera.
  93997. * This is helpful to simulate a camera body like the player body around the camera
  93998. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  93999. */
  94000. ellipsoid: Vector3;
  94001. /**
  94002. * Define an offset for the position of the ellipsoid around the camera.
  94003. * This can be helpful to determine the center of the body near the gravity center of the body
  94004. * instead of its head.
  94005. */
  94006. ellipsoidOffset: Vector3;
  94007. /**
  94008. * Enable or disable collisions of the camera with the rest of the scene objects.
  94009. */
  94010. checkCollisions: boolean;
  94011. /**
  94012. * Enable or disable gravity on the camera.
  94013. */
  94014. applyGravity: boolean;
  94015. /**
  94016. * Define the input manager associated to the camera.
  94017. */
  94018. inputs: FreeCameraInputsManager;
  94019. /**
  94020. * Gets the input sensibility for a mouse input. (default is 2000.0)
  94021. * Higher values reduce sensitivity.
  94022. */
  94023. get angularSensibility(): number;
  94024. /**
  94025. * Sets the input sensibility for a mouse input. (default is 2000.0)
  94026. * Higher values reduce sensitivity.
  94027. */
  94028. set angularSensibility(value: number);
  94029. /**
  94030. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  94031. */
  94032. get keysUp(): number[];
  94033. set keysUp(value: number[]);
  94034. /**
  94035. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  94036. */
  94037. get keysUpward(): number[];
  94038. set keysUpward(value: number[]);
  94039. /**
  94040. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  94041. */
  94042. get keysDown(): number[];
  94043. set keysDown(value: number[]);
  94044. /**
  94045. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  94046. */
  94047. get keysDownward(): number[];
  94048. set keysDownward(value: number[]);
  94049. /**
  94050. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  94051. */
  94052. get keysLeft(): number[];
  94053. set keysLeft(value: number[]);
  94054. /**
  94055. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  94056. */
  94057. get keysRight(): number[];
  94058. set keysRight(value: number[]);
  94059. /**
  94060. * Event raised when the camera collide with a mesh in the scene.
  94061. */
  94062. onCollide: (collidedMesh: AbstractMesh) => void;
  94063. private _collider;
  94064. private _needMoveForGravity;
  94065. private _oldPosition;
  94066. private _diffPosition;
  94067. private _newPosition;
  94068. /** @hidden */
  94069. _localDirection: Vector3;
  94070. /** @hidden */
  94071. _transformedDirection: Vector3;
  94072. /**
  94073. * Instantiates a Free Camera.
  94074. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  94075. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  94076. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  94077. * @param name Define the name of the camera in the scene
  94078. * @param position Define the start position of the camera in the scene
  94079. * @param scene Define the scene the camera belongs to
  94080. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  94081. */
  94082. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  94083. /**
  94084. * Attached controls to the current camera.
  94085. * @param element Defines the element the controls should be listened from
  94086. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  94087. */
  94088. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  94089. /**
  94090. * Detach the current controls from the camera.
  94091. * The camera will stop reacting to inputs.
  94092. * @param element Defines the element to stop listening the inputs from
  94093. */
  94094. detachControl(element: HTMLElement): void;
  94095. private _collisionMask;
  94096. /**
  94097. * Define a collision mask to limit the list of object the camera can collide with
  94098. */
  94099. get collisionMask(): number;
  94100. set collisionMask(mask: number);
  94101. /** @hidden */
  94102. _collideWithWorld(displacement: Vector3): void;
  94103. private _onCollisionPositionChange;
  94104. /** @hidden */
  94105. _checkInputs(): void;
  94106. /** @hidden */
  94107. _decideIfNeedsToMove(): boolean;
  94108. /** @hidden */
  94109. _updatePosition(): void;
  94110. /**
  94111. * Destroy the camera and release the current resources hold by it.
  94112. */
  94113. dispose(): void;
  94114. /**
  94115. * Gets the current object class name.
  94116. * @return the class name
  94117. */
  94118. getClassName(): string;
  94119. }
  94120. }
  94121. declare module BABYLON {
  94122. /**
  94123. * Represents a gamepad control stick position
  94124. */
  94125. export class StickValues {
  94126. /**
  94127. * The x component of the control stick
  94128. */
  94129. x: number;
  94130. /**
  94131. * The y component of the control stick
  94132. */
  94133. y: number;
  94134. /**
  94135. * Initializes the gamepad x and y control stick values
  94136. * @param x The x component of the gamepad control stick value
  94137. * @param y The y component of the gamepad control stick value
  94138. */
  94139. constructor(
  94140. /**
  94141. * The x component of the control stick
  94142. */
  94143. x: number,
  94144. /**
  94145. * The y component of the control stick
  94146. */
  94147. y: number);
  94148. }
  94149. /**
  94150. * An interface which manages callbacks for gamepad button changes
  94151. */
  94152. export interface GamepadButtonChanges {
  94153. /**
  94154. * Called when a gamepad has been changed
  94155. */
  94156. changed: boolean;
  94157. /**
  94158. * Called when a gamepad press event has been triggered
  94159. */
  94160. pressChanged: boolean;
  94161. /**
  94162. * Called when a touch event has been triggered
  94163. */
  94164. touchChanged: boolean;
  94165. /**
  94166. * Called when a value has changed
  94167. */
  94168. valueChanged: boolean;
  94169. }
  94170. /**
  94171. * Represents a gamepad
  94172. */
  94173. export class Gamepad {
  94174. /**
  94175. * The id of the gamepad
  94176. */
  94177. id: string;
  94178. /**
  94179. * The index of the gamepad
  94180. */
  94181. index: number;
  94182. /**
  94183. * The browser gamepad
  94184. */
  94185. browserGamepad: any;
  94186. /**
  94187. * Specifies what type of gamepad this represents
  94188. */
  94189. type: number;
  94190. private _leftStick;
  94191. private _rightStick;
  94192. /** @hidden */
  94193. _isConnected: boolean;
  94194. private _leftStickAxisX;
  94195. private _leftStickAxisY;
  94196. private _rightStickAxisX;
  94197. private _rightStickAxisY;
  94198. /**
  94199. * Triggered when the left control stick has been changed
  94200. */
  94201. private _onleftstickchanged;
  94202. /**
  94203. * Triggered when the right control stick has been changed
  94204. */
  94205. private _onrightstickchanged;
  94206. /**
  94207. * Represents a gamepad controller
  94208. */
  94209. static GAMEPAD: number;
  94210. /**
  94211. * Represents a generic controller
  94212. */
  94213. static GENERIC: number;
  94214. /**
  94215. * Represents an XBox controller
  94216. */
  94217. static XBOX: number;
  94218. /**
  94219. * Represents a pose-enabled controller
  94220. */
  94221. static POSE_ENABLED: number;
  94222. /**
  94223. * Represents an Dual Shock controller
  94224. */
  94225. static DUALSHOCK: number;
  94226. /**
  94227. * Specifies whether the left control stick should be Y-inverted
  94228. */
  94229. protected _invertLeftStickY: boolean;
  94230. /**
  94231. * Specifies if the gamepad has been connected
  94232. */
  94233. get isConnected(): boolean;
  94234. /**
  94235. * Initializes the gamepad
  94236. * @param id The id of the gamepad
  94237. * @param index The index of the gamepad
  94238. * @param browserGamepad The browser gamepad
  94239. * @param leftStickX The x component of the left joystick
  94240. * @param leftStickY The y component of the left joystick
  94241. * @param rightStickX The x component of the right joystick
  94242. * @param rightStickY The y component of the right joystick
  94243. */
  94244. constructor(
  94245. /**
  94246. * The id of the gamepad
  94247. */
  94248. id: string,
  94249. /**
  94250. * The index of the gamepad
  94251. */
  94252. index: number,
  94253. /**
  94254. * The browser gamepad
  94255. */
  94256. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  94257. /**
  94258. * Callback triggered when the left joystick has changed
  94259. * @param callback
  94260. */
  94261. onleftstickchanged(callback: (values: StickValues) => void): void;
  94262. /**
  94263. * Callback triggered when the right joystick has changed
  94264. * @param callback
  94265. */
  94266. onrightstickchanged(callback: (values: StickValues) => void): void;
  94267. /**
  94268. * Gets the left joystick
  94269. */
  94270. get leftStick(): StickValues;
  94271. /**
  94272. * Sets the left joystick values
  94273. */
  94274. set leftStick(newValues: StickValues);
  94275. /**
  94276. * Gets the right joystick
  94277. */
  94278. get rightStick(): StickValues;
  94279. /**
  94280. * Sets the right joystick value
  94281. */
  94282. set rightStick(newValues: StickValues);
  94283. /**
  94284. * Updates the gamepad joystick positions
  94285. */
  94286. update(): void;
  94287. /**
  94288. * Disposes the gamepad
  94289. */
  94290. dispose(): void;
  94291. }
  94292. /**
  94293. * Represents a generic gamepad
  94294. */
  94295. export class GenericPad extends Gamepad {
  94296. private _buttons;
  94297. private _onbuttondown;
  94298. private _onbuttonup;
  94299. /**
  94300. * Observable triggered when a button has been pressed
  94301. */
  94302. onButtonDownObservable: Observable<number>;
  94303. /**
  94304. * Observable triggered when a button has been released
  94305. */
  94306. onButtonUpObservable: Observable<number>;
  94307. /**
  94308. * Callback triggered when a button has been pressed
  94309. * @param callback Called when a button has been pressed
  94310. */
  94311. onbuttondown(callback: (buttonPressed: number) => void): void;
  94312. /**
  94313. * Callback triggered when a button has been released
  94314. * @param callback Called when a button has been released
  94315. */
  94316. onbuttonup(callback: (buttonReleased: number) => void): void;
  94317. /**
  94318. * Initializes the generic gamepad
  94319. * @param id The id of the generic gamepad
  94320. * @param index The index of the generic gamepad
  94321. * @param browserGamepad The browser gamepad
  94322. */
  94323. constructor(id: string, index: number, browserGamepad: any);
  94324. private _setButtonValue;
  94325. /**
  94326. * Updates the generic gamepad
  94327. */
  94328. update(): void;
  94329. /**
  94330. * Disposes the generic gamepad
  94331. */
  94332. dispose(): void;
  94333. }
  94334. }
  94335. declare module BABYLON {
  94336. /**
  94337. * Defines the types of pose enabled controllers that are supported
  94338. */
  94339. export enum PoseEnabledControllerType {
  94340. /**
  94341. * HTC Vive
  94342. */
  94343. VIVE = 0,
  94344. /**
  94345. * Oculus Rift
  94346. */
  94347. OCULUS = 1,
  94348. /**
  94349. * Windows mixed reality
  94350. */
  94351. WINDOWS = 2,
  94352. /**
  94353. * Samsung gear VR
  94354. */
  94355. GEAR_VR = 3,
  94356. /**
  94357. * Google Daydream
  94358. */
  94359. DAYDREAM = 4,
  94360. /**
  94361. * Generic
  94362. */
  94363. GENERIC = 5
  94364. }
  94365. /**
  94366. * Defines the MutableGamepadButton interface for the state of a gamepad button
  94367. */
  94368. export interface MutableGamepadButton {
  94369. /**
  94370. * Value of the button/trigger
  94371. */
  94372. value: number;
  94373. /**
  94374. * If the button/trigger is currently touched
  94375. */
  94376. touched: boolean;
  94377. /**
  94378. * If the button/trigger is currently pressed
  94379. */
  94380. pressed: boolean;
  94381. }
  94382. /**
  94383. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  94384. * @hidden
  94385. */
  94386. export interface ExtendedGamepadButton extends GamepadButton {
  94387. /**
  94388. * If the button/trigger is currently pressed
  94389. */
  94390. readonly pressed: boolean;
  94391. /**
  94392. * If the button/trigger is currently touched
  94393. */
  94394. readonly touched: boolean;
  94395. /**
  94396. * Value of the button/trigger
  94397. */
  94398. readonly value: number;
  94399. }
  94400. /** @hidden */
  94401. export interface _GamePadFactory {
  94402. /**
  94403. * Returns whether or not the current gamepad can be created for this type of controller.
  94404. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  94405. * @returns true if it can be created, otherwise false
  94406. */
  94407. canCreate(gamepadInfo: any): boolean;
  94408. /**
  94409. * Creates a new instance of the Gamepad.
  94410. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  94411. * @returns the new gamepad instance
  94412. */
  94413. create(gamepadInfo: any): Gamepad;
  94414. }
  94415. /**
  94416. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  94417. */
  94418. export class PoseEnabledControllerHelper {
  94419. /** @hidden */
  94420. static _ControllerFactories: _GamePadFactory[];
  94421. /** @hidden */
  94422. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  94423. /**
  94424. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  94425. * @param vrGamepad the gamepad to initialized
  94426. * @returns a vr controller of the type the gamepad identified as
  94427. */
  94428. static InitiateController(vrGamepad: any): Gamepad;
  94429. }
  94430. /**
  94431. * Defines the PoseEnabledController object that contains state of a vr capable controller
  94432. */
  94433. export class PoseEnabledController extends Gamepad implements PoseControlled {
  94434. /**
  94435. * If the controller is used in a webXR session
  94436. */
  94437. isXR: boolean;
  94438. private _deviceRoomPosition;
  94439. private _deviceRoomRotationQuaternion;
  94440. /**
  94441. * The device position in babylon space
  94442. */
  94443. devicePosition: Vector3;
  94444. /**
  94445. * The device rotation in babylon space
  94446. */
  94447. deviceRotationQuaternion: Quaternion;
  94448. /**
  94449. * The scale factor of the device in babylon space
  94450. */
  94451. deviceScaleFactor: number;
  94452. /**
  94453. * (Likely devicePosition should be used instead) The device position in its room space
  94454. */
  94455. position: Vector3;
  94456. /**
  94457. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  94458. */
  94459. rotationQuaternion: Quaternion;
  94460. /**
  94461. * The type of controller (Eg. Windows mixed reality)
  94462. */
  94463. controllerType: PoseEnabledControllerType;
  94464. protected _calculatedPosition: Vector3;
  94465. private _calculatedRotation;
  94466. /**
  94467. * The raw pose from the device
  94468. */
  94469. rawPose: DevicePose;
  94470. private _trackPosition;
  94471. private _maxRotationDistFromHeadset;
  94472. private _draggedRoomRotation;
  94473. /**
  94474. * @hidden
  94475. */
  94476. _disableTrackPosition(fixedPosition: Vector3): void;
  94477. /**
  94478. * Internal, the mesh attached to the controller
  94479. * @hidden
  94480. */
  94481. _mesh: Nullable<AbstractMesh>;
  94482. private _poseControlledCamera;
  94483. private _leftHandSystemQuaternion;
  94484. /**
  94485. * Internal, matrix used to convert room space to babylon space
  94486. * @hidden
  94487. */
  94488. _deviceToWorld: Matrix;
  94489. /**
  94490. * Node to be used when casting a ray from the controller
  94491. * @hidden
  94492. */
  94493. _pointingPoseNode: Nullable<TransformNode>;
  94494. /**
  94495. * Name of the child mesh that can be used to cast a ray from the controller
  94496. */
  94497. static readonly POINTING_POSE: string;
  94498. /**
  94499. * Creates a new PoseEnabledController from a gamepad
  94500. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  94501. */
  94502. constructor(browserGamepad: any);
  94503. private _workingMatrix;
  94504. /**
  94505. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  94506. */
  94507. update(): void;
  94508. /**
  94509. * Updates only the pose device and mesh without doing any button event checking
  94510. */
  94511. protected _updatePoseAndMesh(): void;
  94512. /**
  94513. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  94514. * @param poseData raw pose fromthe device
  94515. */
  94516. updateFromDevice(poseData: DevicePose): void;
  94517. /**
  94518. * @hidden
  94519. */
  94520. _meshAttachedObservable: Observable<AbstractMesh>;
  94521. /**
  94522. * Attaches a mesh to the controller
  94523. * @param mesh the mesh to be attached
  94524. */
  94525. attachToMesh(mesh: AbstractMesh): void;
  94526. /**
  94527. * Attaches the controllers mesh to a camera
  94528. * @param camera the camera the mesh should be attached to
  94529. */
  94530. attachToPoseControlledCamera(camera: TargetCamera): void;
  94531. /**
  94532. * Disposes of the controller
  94533. */
  94534. dispose(): void;
  94535. /**
  94536. * The mesh that is attached to the controller
  94537. */
  94538. get mesh(): Nullable<AbstractMesh>;
  94539. /**
  94540. * Gets the ray of the controller in the direction the controller is pointing
  94541. * @param length the length the resulting ray should be
  94542. * @returns a ray in the direction the controller is pointing
  94543. */
  94544. getForwardRay(length?: number): Ray;
  94545. }
  94546. }
  94547. declare module BABYLON {
  94548. /**
  94549. * Defines the WebVRController object that represents controllers tracked in 3D space
  94550. */
  94551. export abstract class WebVRController extends PoseEnabledController {
  94552. /**
  94553. * Internal, the default controller model for the controller
  94554. */
  94555. protected _defaultModel: Nullable<AbstractMesh>;
  94556. /**
  94557. * Fired when the trigger state has changed
  94558. */
  94559. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  94560. /**
  94561. * Fired when the main button state has changed
  94562. */
  94563. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  94564. /**
  94565. * Fired when the secondary button state has changed
  94566. */
  94567. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  94568. /**
  94569. * Fired when the pad state has changed
  94570. */
  94571. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  94572. /**
  94573. * Fired when controllers stick values have changed
  94574. */
  94575. onPadValuesChangedObservable: Observable<StickValues>;
  94576. /**
  94577. * Array of button availible on the controller
  94578. */
  94579. protected _buttons: Array<MutableGamepadButton>;
  94580. private _onButtonStateChange;
  94581. /**
  94582. * Fired when a controller button's state has changed
  94583. * @param callback the callback containing the button that was modified
  94584. */
  94585. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  94586. /**
  94587. * X and Y axis corresponding to the controllers joystick
  94588. */
  94589. pad: StickValues;
  94590. /**
  94591. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  94592. */
  94593. hand: string;
  94594. /**
  94595. * The default controller model for the controller
  94596. */
  94597. get defaultModel(): Nullable<AbstractMesh>;
  94598. /**
  94599. * Creates a new WebVRController from a gamepad
  94600. * @param vrGamepad the gamepad that the WebVRController should be created from
  94601. */
  94602. constructor(vrGamepad: any);
  94603. /**
  94604. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  94605. */
  94606. update(): void;
  94607. /**
  94608. * Function to be called when a button is modified
  94609. */
  94610. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  94611. /**
  94612. * Loads a mesh and attaches it to the controller
  94613. * @param scene the scene the mesh should be added to
  94614. * @param meshLoaded callback for when the mesh has been loaded
  94615. */
  94616. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  94617. private _setButtonValue;
  94618. private _changes;
  94619. private _checkChanges;
  94620. /**
  94621. * Disposes of th webVRCOntroller
  94622. */
  94623. dispose(): void;
  94624. }
  94625. }
  94626. declare module BABYLON {
  94627. /**
  94628. * The HemisphericLight simulates the ambient environment light,
  94629. * so the passed direction is the light reflection direction, not the incoming direction.
  94630. */
  94631. export class HemisphericLight extends Light {
  94632. /**
  94633. * The groundColor is the light in the opposite direction to the one specified during creation.
  94634. * 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.
  94635. */
  94636. groundColor: Color3;
  94637. /**
  94638. * The light reflection direction, not the incoming direction.
  94639. */
  94640. direction: Vector3;
  94641. /**
  94642. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  94643. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  94644. * The HemisphericLight can't cast shadows.
  94645. * Documentation : https://doc.babylonjs.com/babylon101/lights
  94646. * @param name The friendly name of the light
  94647. * @param direction The direction of the light reflection
  94648. * @param scene The scene the light belongs to
  94649. */
  94650. constructor(name: string, direction: Vector3, scene: Scene);
  94651. protected _buildUniformLayout(): void;
  94652. /**
  94653. * Returns the string "HemisphericLight".
  94654. * @return The class name
  94655. */
  94656. getClassName(): string;
  94657. /**
  94658. * Sets the HemisphericLight direction towards the passed target (Vector3).
  94659. * Returns the updated direction.
  94660. * @param target The target the direction should point to
  94661. * @return The computed direction
  94662. */
  94663. setDirectionToTarget(target: Vector3): Vector3;
  94664. /**
  94665. * Returns the shadow generator associated to the light.
  94666. * @returns Always null for hemispheric lights because it does not support shadows.
  94667. */
  94668. getShadowGenerator(): Nullable<IShadowGenerator>;
  94669. /**
  94670. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  94671. * @param effect The effect to update
  94672. * @param lightIndex The index of the light in the effect to update
  94673. * @returns The hemispheric light
  94674. */
  94675. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  94676. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  94677. /**
  94678. * Computes the world matrix of the node
  94679. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  94680. * @param useWasUpdatedFlag defines a reserved property
  94681. * @returns the world matrix
  94682. */
  94683. computeWorldMatrix(): Matrix;
  94684. /**
  94685. * Returns the integer 3.
  94686. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  94687. */
  94688. getTypeID(): number;
  94689. /**
  94690. * Prepares the list of defines specific to the light type.
  94691. * @param defines the list of defines
  94692. * @param lightIndex defines the index of the light for the effect
  94693. */
  94694. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  94695. }
  94696. }
  94697. declare module BABYLON {
  94698. /** @hidden */
  94699. export var vrMultiviewToSingleviewPixelShader: {
  94700. name: string;
  94701. shader: string;
  94702. };
  94703. }
  94704. declare module BABYLON {
  94705. /**
  94706. * Renders to multiple views with a single draw call
  94707. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  94708. */
  94709. export class MultiviewRenderTarget extends RenderTargetTexture {
  94710. /**
  94711. * Creates a multiview render target
  94712. * @param scene scene used with the render target
  94713. * @param size the size of the render target (used for each view)
  94714. */
  94715. constructor(scene: Scene, size?: number | {
  94716. width: number;
  94717. height: number;
  94718. } | {
  94719. ratio: number;
  94720. });
  94721. /**
  94722. * @hidden
  94723. * @param faceIndex the face index, if its a cube texture
  94724. */
  94725. _bindFrameBuffer(faceIndex?: number): void;
  94726. /**
  94727. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  94728. * @returns the view count
  94729. */
  94730. getViewCount(): number;
  94731. }
  94732. }
  94733. declare module BABYLON {
  94734. /**
  94735. * Represents a camera frustum
  94736. */
  94737. export class Frustum {
  94738. /**
  94739. * Gets the planes representing the frustum
  94740. * @param transform matrix to be applied to the returned planes
  94741. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  94742. */
  94743. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  94744. /**
  94745. * Gets the near frustum plane transformed by the transform matrix
  94746. * @param transform transformation matrix to be applied to the resulting frustum plane
  94747. * @param frustumPlane the resuling frustum plane
  94748. */
  94749. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  94750. /**
  94751. * Gets the far frustum plane transformed by the transform matrix
  94752. * @param transform transformation matrix to be applied to the resulting frustum plane
  94753. * @param frustumPlane the resuling frustum plane
  94754. */
  94755. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  94756. /**
  94757. * Gets the left frustum plane transformed by the transform matrix
  94758. * @param transform transformation matrix to be applied to the resulting frustum plane
  94759. * @param frustumPlane the resuling frustum plane
  94760. */
  94761. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  94762. /**
  94763. * Gets the right frustum plane transformed by the transform matrix
  94764. * @param transform transformation matrix to be applied to the resulting frustum plane
  94765. * @param frustumPlane the resuling frustum plane
  94766. */
  94767. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  94768. /**
  94769. * Gets the top frustum plane transformed by the transform matrix
  94770. * @param transform transformation matrix to be applied to the resulting frustum plane
  94771. * @param frustumPlane the resuling frustum plane
  94772. */
  94773. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  94774. /**
  94775. * Gets the bottom frustum plane transformed by the transform matrix
  94776. * @param transform transformation matrix to be applied to the resulting frustum plane
  94777. * @param frustumPlane the resuling frustum plane
  94778. */
  94779. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  94780. /**
  94781. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  94782. * @param transform transformation matrix to be applied to the resulting frustum planes
  94783. * @param frustumPlanes the resuling frustum planes
  94784. */
  94785. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  94786. }
  94787. }
  94788. declare module BABYLON {
  94789. interface Engine {
  94790. /**
  94791. * Creates a new multiview render target
  94792. * @param width defines the width of the texture
  94793. * @param height defines the height of the texture
  94794. * @returns the created multiview texture
  94795. */
  94796. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  94797. /**
  94798. * Binds a multiview framebuffer to be drawn to
  94799. * @param multiviewTexture texture to bind
  94800. */
  94801. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  94802. }
  94803. interface Camera {
  94804. /**
  94805. * @hidden
  94806. * 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)
  94807. */
  94808. _useMultiviewToSingleView: boolean;
  94809. /**
  94810. * @hidden
  94811. * 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)
  94812. */
  94813. _multiviewTexture: Nullable<RenderTargetTexture>;
  94814. /**
  94815. * @hidden
  94816. * ensures the multiview texture of the camera exists and has the specified width/height
  94817. * @param width height to set on the multiview texture
  94818. * @param height width to set on the multiview texture
  94819. */
  94820. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  94821. }
  94822. interface Scene {
  94823. /** @hidden */
  94824. _transformMatrixR: Matrix;
  94825. /** @hidden */
  94826. _multiviewSceneUbo: Nullable<UniformBuffer>;
  94827. /** @hidden */
  94828. _createMultiviewUbo(): void;
  94829. /** @hidden */
  94830. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  94831. /** @hidden */
  94832. _renderMultiviewToSingleView(camera: Camera): void;
  94833. }
  94834. }
  94835. declare module BABYLON {
  94836. /**
  94837. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  94838. * This will not be used for webXR as it supports displaying texture arrays directly
  94839. */
  94840. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  94841. /**
  94842. * Initializes a VRMultiviewToSingleview
  94843. * @param name name of the post process
  94844. * @param camera camera to be applied to
  94845. * @param scaleFactor scaling factor to the size of the output texture
  94846. */
  94847. constructor(name: string, camera: Camera, scaleFactor: number);
  94848. }
  94849. }
  94850. declare module BABYLON {
  94851. /**
  94852. * Interface used to define additional presentation attributes
  94853. */
  94854. export interface IVRPresentationAttributes {
  94855. /**
  94856. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  94857. */
  94858. highRefreshRate: boolean;
  94859. /**
  94860. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  94861. */
  94862. foveationLevel: number;
  94863. }
  94864. interface Engine {
  94865. /** @hidden */
  94866. _vrDisplay: any;
  94867. /** @hidden */
  94868. _vrSupported: boolean;
  94869. /** @hidden */
  94870. _oldSize: Size;
  94871. /** @hidden */
  94872. _oldHardwareScaleFactor: number;
  94873. /** @hidden */
  94874. _vrExclusivePointerMode: boolean;
  94875. /** @hidden */
  94876. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  94877. /** @hidden */
  94878. _onVRDisplayPointerRestricted: () => void;
  94879. /** @hidden */
  94880. _onVRDisplayPointerUnrestricted: () => void;
  94881. /** @hidden */
  94882. _onVrDisplayConnect: Nullable<(display: any) => void>;
  94883. /** @hidden */
  94884. _onVrDisplayDisconnect: Nullable<() => void>;
  94885. /** @hidden */
  94886. _onVrDisplayPresentChange: Nullable<() => void>;
  94887. /**
  94888. * Observable signaled when VR display mode changes
  94889. */
  94890. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  94891. /**
  94892. * Observable signaled when VR request present is complete
  94893. */
  94894. onVRRequestPresentComplete: Observable<boolean>;
  94895. /**
  94896. * Observable signaled when VR request present starts
  94897. */
  94898. onVRRequestPresentStart: Observable<Engine>;
  94899. /**
  94900. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  94901. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  94902. */
  94903. isInVRExclusivePointerMode: boolean;
  94904. /**
  94905. * Gets a boolean indicating if a webVR device was detected
  94906. * @returns true if a webVR device was detected
  94907. */
  94908. isVRDevicePresent(): boolean;
  94909. /**
  94910. * Gets the current webVR device
  94911. * @returns the current webVR device (or null)
  94912. */
  94913. getVRDevice(): any;
  94914. /**
  94915. * Initializes a webVR display and starts listening to display change events
  94916. * The onVRDisplayChangedObservable will be notified upon these changes
  94917. * @returns A promise containing a VRDisplay and if vr is supported
  94918. */
  94919. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  94920. /** @hidden */
  94921. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  94922. /**
  94923. * Gets or sets the presentation attributes used to configure VR rendering
  94924. */
  94925. vrPresentationAttributes?: IVRPresentationAttributes;
  94926. /**
  94927. * Call this function to switch to webVR mode
  94928. * Will do nothing if webVR is not supported or if there is no webVR device
  94929. * @param options the webvr options provided to the camera. mainly used for multiview
  94930. * @see http://doc.babylonjs.com/how_to/webvr_camera
  94931. */
  94932. enableVR(options: WebVROptions): void;
  94933. /** @hidden */
  94934. _onVRFullScreenTriggered(): void;
  94935. }
  94936. }
  94937. declare module BABYLON {
  94938. /**
  94939. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  94940. * IMPORTANT!! The data is right-hand data.
  94941. * @export
  94942. * @interface DevicePose
  94943. */
  94944. export interface DevicePose {
  94945. /**
  94946. * The position of the device, values in array are [x,y,z].
  94947. */
  94948. readonly position: Nullable<Float32Array>;
  94949. /**
  94950. * The linearVelocity of the device, values in array are [x,y,z].
  94951. */
  94952. readonly linearVelocity: Nullable<Float32Array>;
  94953. /**
  94954. * The linearAcceleration of the device, values in array are [x,y,z].
  94955. */
  94956. readonly linearAcceleration: Nullable<Float32Array>;
  94957. /**
  94958. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  94959. */
  94960. readonly orientation: Nullable<Float32Array>;
  94961. /**
  94962. * The angularVelocity of the device, values in array are [x,y,z].
  94963. */
  94964. readonly angularVelocity: Nullable<Float32Array>;
  94965. /**
  94966. * The angularAcceleration of the device, values in array are [x,y,z].
  94967. */
  94968. readonly angularAcceleration: Nullable<Float32Array>;
  94969. }
  94970. /**
  94971. * Interface representing a pose controlled object in Babylon.
  94972. * A pose controlled object has both regular pose values as well as pose values
  94973. * from an external device such as a VR head mounted display
  94974. */
  94975. export interface PoseControlled {
  94976. /**
  94977. * The position of the object in babylon space.
  94978. */
  94979. position: Vector3;
  94980. /**
  94981. * The rotation quaternion of the object in babylon space.
  94982. */
  94983. rotationQuaternion: Quaternion;
  94984. /**
  94985. * The position of the device in babylon space.
  94986. */
  94987. devicePosition?: Vector3;
  94988. /**
  94989. * The rotation quaternion of the device in babylon space.
  94990. */
  94991. deviceRotationQuaternion: Quaternion;
  94992. /**
  94993. * The raw pose coming from the device.
  94994. */
  94995. rawPose: Nullable<DevicePose>;
  94996. /**
  94997. * The scale of the device to be used when translating from device space to babylon space.
  94998. */
  94999. deviceScaleFactor: number;
  95000. /**
  95001. * Updates the poseControlled values based on the input device pose.
  95002. * @param poseData the pose data to update the object with
  95003. */
  95004. updateFromDevice(poseData: DevicePose): void;
  95005. }
  95006. /**
  95007. * Set of options to customize the webVRCamera
  95008. */
  95009. export interface WebVROptions {
  95010. /**
  95011. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  95012. */
  95013. trackPosition?: boolean;
  95014. /**
  95015. * Sets the scale of the vrDevice in babylon space. (default: 1)
  95016. */
  95017. positionScale?: number;
  95018. /**
  95019. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  95020. */
  95021. displayName?: string;
  95022. /**
  95023. * Should the native controller meshes be initialized. (default: true)
  95024. */
  95025. controllerMeshes?: boolean;
  95026. /**
  95027. * Creating a default HemiLight only on controllers. (default: true)
  95028. */
  95029. defaultLightingOnControllers?: boolean;
  95030. /**
  95031. * If you don't want to use the default VR button of the helper. (default: false)
  95032. */
  95033. useCustomVRButton?: boolean;
  95034. /**
  95035. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  95036. */
  95037. customVRButton?: HTMLButtonElement;
  95038. /**
  95039. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  95040. */
  95041. rayLength?: number;
  95042. /**
  95043. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  95044. */
  95045. defaultHeight?: number;
  95046. /**
  95047. * If multiview should be used if availible (default: false)
  95048. */
  95049. useMultiview?: boolean;
  95050. }
  95051. /**
  95052. * This represents a WebVR camera.
  95053. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  95054. * @example http://doc.babylonjs.com/how_to/webvr_camera
  95055. */
  95056. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  95057. private webVROptions;
  95058. /**
  95059. * @hidden
  95060. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  95061. */
  95062. _vrDevice: any;
  95063. /**
  95064. * The rawPose of the vrDevice.
  95065. */
  95066. rawPose: Nullable<DevicePose>;
  95067. private _onVREnabled;
  95068. private _specsVersion;
  95069. private _attached;
  95070. private _frameData;
  95071. protected _descendants: Array<Node>;
  95072. private _deviceRoomPosition;
  95073. /** @hidden */
  95074. _deviceRoomRotationQuaternion: Quaternion;
  95075. private _standingMatrix;
  95076. /**
  95077. * Represents device position in babylon space.
  95078. */
  95079. devicePosition: Vector3;
  95080. /**
  95081. * Represents device rotation in babylon space.
  95082. */
  95083. deviceRotationQuaternion: Quaternion;
  95084. /**
  95085. * The scale of the device to be used when translating from device space to babylon space.
  95086. */
  95087. deviceScaleFactor: number;
  95088. private _deviceToWorld;
  95089. private _worldToDevice;
  95090. /**
  95091. * References to the webVR controllers for the vrDevice.
  95092. */
  95093. controllers: Array<WebVRController>;
  95094. /**
  95095. * Emits an event when a controller is attached.
  95096. */
  95097. onControllersAttachedObservable: Observable<WebVRController[]>;
  95098. /**
  95099. * Emits an event when a controller's mesh has been loaded;
  95100. */
  95101. onControllerMeshLoadedObservable: Observable<WebVRController>;
  95102. /**
  95103. * Emits an event when the HMD's pose has been updated.
  95104. */
  95105. onPoseUpdatedFromDeviceObservable: Observable<any>;
  95106. private _poseSet;
  95107. /**
  95108. * If the rig cameras be used as parent instead of this camera.
  95109. */
  95110. rigParenting: boolean;
  95111. private _lightOnControllers;
  95112. private _defaultHeight?;
  95113. /**
  95114. * Instantiates a WebVRFreeCamera.
  95115. * @param name The name of the WebVRFreeCamera
  95116. * @param position The starting anchor position for the camera
  95117. * @param scene The scene the camera belongs to
  95118. * @param webVROptions a set of customizable options for the webVRCamera
  95119. */
  95120. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  95121. /**
  95122. * Gets the device distance from the ground in meters.
  95123. * @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.
  95124. */
  95125. deviceDistanceToRoomGround(): number;
  95126. /**
  95127. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  95128. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  95129. */
  95130. useStandingMatrix(callback?: (bool: boolean) => void): void;
  95131. /**
  95132. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  95133. * @returns A promise with a boolean set to if the standing matrix is supported.
  95134. */
  95135. useStandingMatrixAsync(): Promise<boolean>;
  95136. /**
  95137. * Disposes the camera
  95138. */
  95139. dispose(): void;
  95140. /**
  95141. * Gets a vrController by name.
  95142. * @param name The name of the controller to retreive
  95143. * @returns the controller matching the name specified or null if not found
  95144. */
  95145. getControllerByName(name: string): Nullable<WebVRController>;
  95146. private _leftController;
  95147. /**
  95148. * The controller corresponding to the users left hand.
  95149. */
  95150. get leftController(): Nullable<WebVRController>;
  95151. private _rightController;
  95152. /**
  95153. * The controller corresponding to the users right hand.
  95154. */
  95155. get rightController(): Nullable<WebVRController>;
  95156. /**
  95157. * Casts a ray forward from the vrCamera's gaze.
  95158. * @param length Length of the ray (default: 100)
  95159. * @returns the ray corresponding to the gaze
  95160. */
  95161. getForwardRay(length?: number): Ray;
  95162. /**
  95163. * @hidden
  95164. * Updates the camera based on device's frame data
  95165. */
  95166. _checkInputs(): void;
  95167. /**
  95168. * Updates the poseControlled values based on the input device pose.
  95169. * @param poseData Pose coming from the device
  95170. */
  95171. updateFromDevice(poseData: DevicePose): void;
  95172. private _htmlElementAttached;
  95173. private _detachIfAttached;
  95174. /**
  95175. * WebVR's attach control will start broadcasting frames to the device.
  95176. * Note that in certain browsers (chrome for example) this function must be called
  95177. * within a user-interaction callback. Example:
  95178. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  95179. *
  95180. * @param element html element to attach the vrDevice to
  95181. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  95182. */
  95183. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  95184. /**
  95185. * Detaches the camera from the html element and disables VR
  95186. *
  95187. * @param element html element to detach from
  95188. */
  95189. detachControl(element: HTMLElement): void;
  95190. /**
  95191. * @returns the name of this class
  95192. */
  95193. getClassName(): string;
  95194. /**
  95195. * Calls resetPose on the vrDisplay
  95196. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  95197. */
  95198. resetToCurrentRotation(): void;
  95199. /**
  95200. * @hidden
  95201. * Updates the rig cameras (left and right eye)
  95202. */
  95203. _updateRigCameras(): void;
  95204. private _workingVector;
  95205. private _oneVector;
  95206. private _workingMatrix;
  95207. private updateCacheCalled;
  95208. private _correctPositionIfNotTrackPosition;
  95209. /**
  95210. * @hidden
  95211. * Updates the cached values of the camera
  95212. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  95213. */
  95214. _updateCache(ignoreParentClass?: boolean): void;
  95215. /**
  95216. * @hidden
  95217. * Get current device position in babylon world
  95218. */
  95219. _computeDevicePosition(): void;
  95220. /**
  95221. * Updates the current device position and rotation in the babylon world
  95222. */
  95223. update(): void;
  95224. /**
  95225. * @hidden
  95226. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  95227. * @returns an identity matrix
  95228. */
  95229. _getViewMatrix(): Matrix;
  95230. private _tmpMatrix;
  95231. /**
  95232. * This function is called by the two RIG cameras.
  95233. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  95234. * @hidden
  95235. */
  95236. _getWebVRViewMatrix(): Matrix;
  95237. /** @hidden */
  95238. _getWebVRProjectionMatrix(): Matrix;
  95239. private _onGamepadConnectedObserver;
  95240. private _onGamepadDisconnectedObserver;
  95241. private _updateCacheWhenTrackingDisabledObserver;
  95242. /**
  95243. * Initializes the controllers and their meshes
  95244. */
  95245. initControllers(): void;
  95246. }
  95247. }
  95248. declare module BABYLON {
  95249. /**
  95250. * Size options for a post process
  95251. */
  95252. export type PostProcessOptions = {
  95253. width: number;
  95254. height: number;
  95255. };
  95256. /**
  95257. * PostProcess can be used to apply a shader to a texture after it has been rendered
  95258. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  95259. */
  95260. export class PostProcess {
  95261. /** Name of the PostProcess. */
  95262. name: string;
  95263. /**
  95264. * Gets or sets the unique id of the post process
  95265. */
  95266. uniqueId: number;
  95267. /**
  95268. * Width of the texture to apply the post process on
  95269. */
  95270. width: number;
  95271. /**
  95272. * Height of the texture to apply the post process on
  95273. */
  95274. height: number;
  95275. /**
  95276. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  95277. * @hidden
  95278. */
  95279. _outputTexture: Nullable<InternalTexture>;
  95280. /**
  95281. * Sampling mode used by the shader
  95282. * See https://doc.babylonjs.com/classes/3.1/texture
  95283. */
  95284. renderTargetSamplingMode: number;
  95285. /**
  95286. * Clear color to use when screen clearing
  95287. */
  95288. clearColor: Color4;
  95289. /**
  95290. * If the buffer needs to be cleared before applying the post process. (default: true)
  95291. * Should be set to false if shader will overwrite all previous pixels.
  95292. */
  95293. autoClear: boolean;
  95294. /**
  95295. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  95296. */
  95297. alphaMode: number;
  95298. /**
  95299. * Sets the setAlphaBlendConstants of the babylon engine
  95300. */
  95301. alphaConstants: Color4;
  95302. /**
  95303. * Animations to be used for the post processing
  95304. */
  95305. animations: Animation[];
  95306. /**
  95307. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  95308. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  95309. */
  95310. enablePixelPerfectMode: boolean;
  95311. /**
  95312. * Force the postprocess to be applied without taking in account viewport
  95313. */
  95314. forceFullscreenViewport: boolean;
  95315. /**
  95316. * List of inspectable custom properties (used by the Inspector)
  95317. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  95318. */
  95319. inspectableCustomProperties: IInspectable[];
  95320. /**
  95321. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  95322. *
  95323. * | Value | Type | Description |
  95324. * | ----- | ----------------------------------- | ----------- |
  95325. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  95326. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  95327. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  95328. *
  95329. */
  95330. scaleMode: number;
  95331. /**
  95332. * Force textures to be a power of two (default: false)
  95333. */
  95334. alwaysForcePOT: boolean;
  95335. private _samples;
  95336. /**
  95337. * Number of sample textures (default: 1)
  95338. */
  95339. get samples(): number;
  95340. set samples(n: number);
  95341. /**
  95342. * Modify the scale of the post process to be the same as the viewport (default: false)
  95343. */
  95344. adaptScaleToCurrentViewport: boolean;
  95345. private _camera;
  95346. private _scene;
  95347. private _engine;
  95348. private _options;
  95349. private _reusable;
  95350. private _textureType;
  95351. private _textureFormat;
  95352. /**
  95353. * Smart array of input and output textures for the post process.
  95354. * @hidden
  95355. */
  95356. _textures: SmartArray<InternalTexture>;
  95357. /**
  95358. * The index in _textures that corresponds to the output texture.
  95359. * @hidden
  95360. */
  95361. _currentRenderTextureInd: number;
  95362. private _effect;
  95363. private _samplers;
  95364. private _fragmentUrl;
  95365. private _vertexUrl;
  95366. private _parameters;
  95367. private _scaleRatio;
  95368. protected _indexParameters: any;
  95369. private _shareOutputWithPostProcess;
  95370. private _texelSize;
  95371. private _forcedOutputTexture;
  95372. /**
  95373. * Returns the fragment url or shader name used in the post process.
  95374. * @returns the fragment url or name in the shader store.
  95375. */
  95376. getEffectName(): string;
  95377. /**
  95378. * An event triggered when the postprocess is activated.
  95379. */
  95380. onActivateObservable: Observable<Camera>;
  95381. private _onActivateObserver;
  95382. /**
  95383. * A function that is added to the onActivateObservable
  95384. */
  95385. set onActivate(callback: Nullable<(camera: Camera) => void>);
  95386. /**
  95387. * An event triggered when the postprocess changes its size.
  95388. */
  95389. onSizeChangedObservable: Observable<PostProcess>;
  95390. private _onSizeChangedObserver;
  95391. /**
  95392. * A function that is added to the onSizeChangedObservable
  95393. */
  95394. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  95395. /**
  95396. * An event triggered when the postprocess applies its effect.
  95397. */
  95398. onApplyObservable: Observable<Effect>;
  95399. private _onApplyObserver;
  95400. /**
  95401. * A function that is added to the onApplyObservable
  95402. */
  95403. set onApply(callback: (effect: Effect) => void);
  95404. /**
  95405. * An event triggered before rendering the postprocess
  95406. */
  95407. onBeforeRenderObservable: Observable<Effect>;
  95408. private _onBeforeRenderObserver;
  95409. /**
  95410. * A function that is added to the onBeforeRenderObservable
  95411. */
  95412. set onBeforeRender(callback: (effect: Effect) => void);
  95413. /**
  95414. * An event triggered after rendering the postprocess
  95415. */
  95416. onAfterRenderObservable: Observable<Effect>;
  95417. private _onAfterRenderObserver;
  95418. /**
  95419. * A function that is added to the onAfterRenderObservable
  95420. */
  95421. set onAfterRender(callback: (efect: Effect) => void);
  95422. /**
  95423. * 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
  95424. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  95425. */
  95426. get inputTexture(): InternalTexture;
  95427. set inputTexture(value: InternalTexture);
  95428. /**
  95429. * Gets the camera which post process is applied to.
  95430. * @returns The camera the post process is applied to.
  95431. */
  95432. getCamera(): Camera;
  95433. /**
  95434. * Gets the texel size of the postprocess.
  95435. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  95436. */
  95437. get texelSize(): Vector2;
  95438. /**
  95439. * Creates a new instance PostProcess
  95440. * @param name The name of the PostProcess.
  95441. * @param fragmentUrl The url of the fragment shader to be used.
  95442. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  95443. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  95444. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  95445. * @param camera The camera to apply the render pass to.
  95446. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  95447. * @param engine The engine which the post process will be applied. (default: current engine)
  95448. * @param reusable If the post process can be reused on the same frame. (default: false)
  95449. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  95450. * @param textureType Type of textures used when performing the post process. (default: 0)
  95451. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  95452. * @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
  95453. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  95454. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  95455. */
  95456. constructor(
  95457. /** Name of the PostProcess. */
  95458. 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);
  95459. /**
  95460. * Gets a string idenfifying the name of the class
  95461. * @returns "PostProcess" string
  95462. */
  95463. getClassName(): string;
  95464. /**
  95465. * Gets the engine which this post process belongs to.
  95466. * @returns The engine the post process was enabled with.
  95467. */
  95468. getEngine(): Engine;
  95469. /**
  95470. * The effect that is created when initializing the post process.
  95471. * @returns The created effect corresponding the the postprocess.
  95472. */
  95473. getEffect(): Effect;
  95474. /**
  95475. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  95476. * @param postProcess The post process to share the output with.
  95477. * @returns This post process.
  95478. */
  95479. shareOutputWith(postProcess: PostProcess): PostProcess;
  95480. /**
  95481. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  95482. * This should be called if the post process that shares output with this post process is disabled/disposed.
  95483. */
  95484. useOwnOutput(): void;
  95485. /**
  95486. * Updates the effect with the current post process compile time values and recompiles the shader.
  95487. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  95488. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  95489. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  95490. * @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
  95491. * @param onCompiled Called when the shader has been compiled.
  95492. * @param onError Called if there is an error when compiling a shader.
  95493. */
  95494. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  95495. /**
  95496. * The post process is reusable if it can be used multiple times within one frame.
  95497. * @returns If the post process is reusable
  95498. */
  95499. isReusable(): boolean;
  95500. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  95501. markTextureDirty(): void;
  95502. /**
  95503. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  95504. * 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.
  95505. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  95506. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  95507. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  95508. * @returns The target texture that was bound to be written to.
  95509. */
  95510. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  95511. /**
  95512. * If the post process is supported.
  95513. */
  95514. get isSupported(): boolean;
  95515. /**
  95516. * The aspect ratio of the output texture.
  95517. */
  95518. get aspectRatio(): number;
  95519. /**
  95520. * Get a value indicating if the post-process is ready to be used
  95521. * @returns true if the post-process is ready (shader is compiled)
  95522. */
  95523. isReady(): boolean;
  95524. /**
  95525. * Binds all textures and uniforms to the shader, this will be run on every pass.
  95526. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  95527. */
  95528. apply(): Nullable<Effect>;
  95529. private _disposeTextures;
  95530. /**
  95531. * Disposes the post process.
  95532. * @param camera The camera to dispose the post process on.
  95533. */
  95534. dispose(camera?: Camera): void;
  95535. }
  95536. }
  95537. declare module BABYLON {
  95538. /** @hidden */
  95539. export var kernelBlurVaryingDeclaration: {
  95540. name: string;
  95541. shader: string;
  95542. };
  95543. }
  95544. declare module BABYLON {
  95545. /** @hidden */
  95546. export var kernelBlurFragment: {
  95547. name: string;
  95548. shader: string;
  95549. };
  95550. }
  95551. declare module BABYLON {
  95552. /** @hidden */
  95553. export var kernelBlurFragment2: {
  95554. name: string;
  95555. shader: string;
  95556. };
  95557. }
  95558. declare module BABYLON {
  95559. /** @hidden */
  95560. export var kernelBlurPixelShader: {
  95561. name: string;
  95562. shader: string;
  95563. };
  95564. }
  95565. declare module BABYLON {
  95566. /** @hidden */
  95567. export var kernelBlurVertex: {
  95568. name: string;
  95569. shader: string;
  95570. };
  95571. }
  95572. declare module BABYLON {
  95573. /** @hidden */
  95574. export var kernelBlurVertexShader: {
  95575. name: string;
  95576. shader: string;
  95577. };
  95578. }
  95579. declare module BABYLON {
  95580. /**
  95581. * The Blur Post Process which blurs an image based on a kernel and direction.
  95582. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  95583. */
  95584. export class BlurPostProcess extends PostProcess {
  95585. /** The direction in which to blur the image. */
  95586. direction: Vector2;
  95587. private blockCompilation;
  95588. protected _kernel: number;
  95589. protected _idealKernel: number;
  95590. protected _packedFloat: boolean;
  95591. private _staticDefines;
  95592. /**
  95593. * Sets the length in pixels of the blur sample region
  95594. */
  95595. set kernel(v: number);
  95596. /**
  95597. * Gets the length in pixels of the blur sample region
  95598. */
  95599. get kernel(): number;
  95600. /**
  95601. * Sets wether or not the blur needs to unpack/repack floats
  95602. */
  95603. set packedFloat(v: boolean);
  95604. /**
  95605. * Gets wether or not the blur is unpacking/repacking floats
  95606. */
  95607. get packedFloat(): boolean;
  95608. /**
  95609. * Creates a new instance BlurPostProcess
  95610. * @param name The name of the effect.
  95611. * @param direction The direction in which to blur the image.
  95612. * @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.
  95613. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  95614. * @param camera The camera to apply the render pass to.
  95615. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  95616. * @param engine The engine which the post process will be applied. (default: current engine)
  95617. * @param reusable If the post process can be reused on the same frame. (default: false)
  95618. * @param textureType Type of textures used when performing the post process. (default: 0)
  95619. * @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)
  95620. */
  95621. constructor(name: string,
  95622. /** The direction in which to blur the image. */
  95623. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  95624. /**
  95625. * Updates the effect with the current post process compile time values and recompiles the shader.
  95626. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  95627. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  95628. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  95629. * @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
  95630. * @param onCompiled Called when the shader has been compiled.
  95631. * @param onError Called if there is an error when compiling a shader.
  95632. */
  95633. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  95634. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  95635. /**
  95636. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  95637. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  95638. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  95639. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  95640. * The gaps between physical kernels are compensated for in the weighting of the samples
  95641. * @param idealKernel Ideal blur kernel.
  95642. * @return Nearest best kernel.
  95643. */
  95644. protected _nearestBestKernel(idealKernel: number): number;
  95645. /**
  95646. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  95647. * @param x The point on the Gaussian distribution to sample.
  95648. * @return the value of the Gaussian function at x.
  95649. */
  95650. protected _gaussianWeight(x: number): number;
  95651. /**
  95652. * Generates a string that can be used as a floating point number in GLSL.
  95653. * @param x Value to print.
  95654. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  95655. * @return GLSL float string.
  95656. */
  95657. protected _glslFloat(x: number, decimalFigures?: number): string;
  95658. }
  95659. }
  95660. declare module BABYLON {
  95661. /**
  95662. * Mirror texture can be used to simulate the view from a mirror in a scene.
  95663. * It will dynamically be rendered every frame to adapt to the camera point of view.
  95664. * You can then easily use it as a reflectionTexture on a flat surface.
  95665. * In case the surface is not a plane, please consider relying on reflection probes.
  95666. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  95667. */
  95668. export class MirrorTexture extends RenderTargetTexture {
  95669. private scene;
  95670. /**
  95671. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  95672. * 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.
  95673. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  95674. */
  95675. mirrorPlane: Plane;
  95676. /**
  95677. * Define the blur ratio used to blur the reflection if needed.
  95678. */
  95679. set blurRatio(value: number);
  95680. get blurRatio(): number;
  95681. /**
  95682. * Define the adaptive blur kernel used to blur the reflection if needed.
  95683. * This will autocompute the closest best match for the `blurKernel`
  95684. */
  95685. set adaptiveBlurKernel(value: number);
  95686. /**
  95687. * Define the blur kernel used to blur the reflection if needed.
  95688. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  95689. */
  95690. set blurKernel(value: number);
  95691. /**
  95692. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  95693. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  95694. */
  95695. set blurKernelX(value: number);
  95696. get blurKernelX(): number;
  95697. /**
  95698. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  95699. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  95700. */
  95701. set blurKernelY(value: number);
  95702. get blurKernelY(): number;
  95703. private _autoComputeBlurKernel;
  95704. protected _onRatioRescale(): void;
  95705. private _updateGammaSpace;
  95706. private _imageProcessingConfigChangeObserver;
  95707. private _transformMatrix;
  95708. private _mirrorMatrix;
  95709. private _savedViewMatrix;
  95710. private _blurX;
  95711. private _blurY;
  95712. private _adaptiveBlurKernel;
  95713. private _blurKernelX;
  95714. private _blurKernelY;
  95715. private _blurRatio;
  95716. /**
  95717. * Instantiates a Mirror Texture.
  95718. * Mirror texture can be used to simulate the view from a mirror in a scene.
  95719. * It will dynamically be rendered every frame to adapt to the camera point of view.
  95720. * You can then easily use it as a reflectionTexture on a flat surface.
  95721. * In case the surface is not a plane, please consider relying on reflection probes.
  95722. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  95723. * @param name
  95724. * @param size
  95725. * @param scene
  95726. * @param generateMipMaps
  95727. * @param type
  95728. * @param samplingMode
  95729. * @param generateDepthBuffer
  95730. */
  95731. constructor(name: string, size: number | {
  95732. width: number;
  95733. height: number;
  95734. } | {
  95735. ratio: number;
  95736. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  95737. private _preparePostProcesses;
  95738. /**
  95739. * Clone the mirror texture.
  95740. * @returns the cloned texture
  95741. */
  95742. clone(): MirrorTexture;
  95743. /**
  95744. * Serialize the texture to a JSON representation you could use in Parse later on
  95745. * @returns the serialized JSON representation
  95746. */
  95747. serialize(): any;
  95748. /**
  95749. * Dispose the texture and release its associated resources.
  95750. */
  95751. dispose(): void;
  95752. }
  95753. }
  95754. declare module BABYLON {
  95755. /**
  95756. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  95757. * @see http://doc.babylonjs.com/babylon101/materials#texture
  95758. */
  95759. export class Texture extends BaseTexture {
  95760. /**
  95761. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  95762. */
  95763. static SerializeBuffers: boolean;
  95764. /** @hidden */
  95765. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  95766. /** @hidden */
  95767. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  95768. /** @hidden */
  95769. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  95770. /** nearest is mag = nearest and min = nearest and mip = linear */
  95771. static readonly NEAREST_SAMPLINGMODE: number;
  95772. /** nearest is mag = nearest and min = nearest and mip = linear */
  95773. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  95774. /** Bilinear is mag = linear and min = linear and mip = nearest */
  95775. static readonly BILINEAR_SAMPLINGMODE: number;
  95776. /** Bilinear is mag = linear and min = linear and mip = nearest */
  95777. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  95778. /** Trilinear is mag = linear and min = linear and mip = linear */
  95779. static readonly TRILINEAR_SAMPLINGMODE: number;
  95780. /** Trilinear is mag = linear and min = linear and mip = linear */
  95781. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  95782. /** mag = nearest and min = nearest and mip = nearest */
  95783. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  95784. /** mag = nearest and min = linear and mip = nearest */
  95785. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  95786. /** mag = nearest and min = linear and mip = linear */
  95787. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  95788. /** mag = nearest and min = linear and mip = none */
  95789. static readonly NEAREST_LINEAR: number;
  95790. /** mag = nearest and min = nearest and mip = none */
  95791. static readonly NEAREST_NEAREST: number;
  95792. /** mag = linear and min = nearest and mip = nearest */
  95793. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  95794. /** mag = linear and min = nearest and mip = linear */
  95795. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  95796. /** mag = linear and min = linear and mip = none */
  95797. static readonly LINEAR_LINEAR: number;
  95798. /** mag = linear and min = nearest and mip = none */
  95799. static readonly LINEAR_NEAREST: number;
  95800. /** Explicit coordinates mode */
  95801. static readonly EXPLICIT_MODE: number;
  95802. /** Spherical coordinates mode */
  95803. static readonly SPHERICAL_MODE: number;
  95804. /** Planar coordinates mode */
  95805. static readonly PLANAR_MODE: number;
  95806. /** Cubic coordinates mode */
  95807. static readonly CUBIC_MODE: number;
  95808. /** Projection coordinates mode */
  95809. static readonly PROJECTION_MODE: number;
  95810. /** Inverse Cubic coordinates mode */
  95811. static readonly SKYBOX_MODE: number;
  95812. /** Inverse Cubic coordinates mode */
  95813. static readonly INVCUBIC_MODE: number;
  95814. /** Equirectangular coordinates mode */
  95815. static readonly EQUIRECTANGULAR_MODE: number;
  95816. /** Equirectangular Fixed coordinates mode */
  95817. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  95818. /** Equirectangular Fixed Mirrored coordinates mode */
  95819. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  95820. /** Texture is not repeating outside of 0..1 UVs */
  95821. static readonly CLAMP_ADDRESSMODE: number;
  95822. /** Texture is repeating outside of 0..1 UVs */
  95823. static readonly WRAP_ADDRESSMODE: number;
  95824. /** Texture is repeating and mirrored */
  95825. static readonly MIRROR_ADDRESSMODE: number;
  95826. /**
  95827. * 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
  95828. */
  95829. static UseSerializedUrlIfAny: boolean;
  95830. /**
  95831. * Define the url of the texture.
  95832. */
  95833. url: Nullable<string>;
  95834. /**
  95835. * Define an offset on the texture to offset the u coordinates of the UVs
  95836. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  95837. */
  95838. uOffset: number;
  95839. /**
  95840. * Define an offset on the texture to offset the v coordinates of the UVs
  95841. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  95842. */
  95843. vOffset: number;
  95844. /**
  95845. * Define an offset on the texture to scale the u coordinates of the UVs
  95846. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  95847. */
  95848. uScale: number;
  95849. /**
  95850. * Define an offset on the texture to scale the v coordinates of the UVs
  95851. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  95852. */
  95853. vScale: number;
  95854. /**
  95855. * Define an offset on the texture to rotate around the u coordinates of the UVs
  95856. * @see http://doc.babylonjs.com/how_to/more_materials
  95857. */
  95858. uAng: number;
  95859. /**
  95860. * Define an offset on the texture to rotate around the v coordinates of the UVs
  95861. * @see http://doc.babylonjs.com/how_to/more_materials
  95862. */
  95863. vAng: number;
  95864. /**
  95865. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  95866. * @see http://doc.babylonjs.com/how_to/more_materials
  95867. */
  95868. wAng: number;
  95869. /**
  95870. * Defines the center of rotation (U)
  95871. */
  95872. uRotationCenter: number;
  95873. /**
  95874. * Defines the center of rotation (V)
  95875. */
  95876. vRotationCenter: number;
  95877. /**
  95878. * Defines the center of rotation (W)
  95879. */
  95880. wRotationCenter: number;
  95881. /**
  95882. * Are mip maps generated for this texture or not.
  95883. */
  95884. get noMipmap(): boolean;
  95885. /**
  95886. * List of inspectable custom properties (used by the Inspector)
  95887. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  95888. */
  95889. inspectableCustomProperties: Nullable<IInspectable[]>;
  95890. private _noMipmap;
  95891. /** @hidden */
  95892. _invertY: boolean;
  95893. private _rowGenerationMatrix;
  95894. private _cachedTextureMatrix;
  95895. private _projectionModeMatrix;
  95896. private _t0;
  95897. private _t1;
  95898. private _t2;
  95899. private _cachedUOffset;
  95900. private _cachedVOffset;
  95901. private _cachedUScale;
  95902. private _cachedVScale;
  95903. private _cachedUAng;
  95904. private _cachedVAng;
  95905. private _cachedWAng;
  95906. private _cachedProjectionMatrixId;
  95907. private _cachedCoordinatesMode;
  95908. /** @hidden */
  95909. protected _initialSamplingMode: number;
  95910. /** @hidden */
  95911. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  95912. private _deleteBuffer;
  95913. protected _format: Nullable<number>;
  95914. private _delayedOnLoad;
  95915. private _delayedOnError;
  95916. private _mimeType?;
  95917. /**
  95918. * Observable triggered once the texture has been loaded.
  95919. */
  95920. onLoadObservable: Observable<Texture>;
  95921. protected _isBlocking: boolean;
  95922. /**
  95923. * Is the texture preventing material to render while loading.
  95924. * If false, a default texture will be used instead of the loading one during the preparation step.
  95925. */
  95926. set isBlocking(value: boolean);
  95927. get isBlocking(): boolean;
  95928. /**
  95929. * Get the current sampling mode associated with the texture.
  95930. */
  95931. get samplingMode(): number;
  95932. /**
  95933. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  95934. */
  95935. get invertY(): boolean;
  95936. /**
  95937. * Instantiates a new texture.
  95938. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  95939. * @see http://doc.babylonjs.com/babylon101/materials#texture
  95940. * @param url defines the url of the picture to load as a texture
  95941. * @param scene defines the scene or engine the texture will belong to
  95942. * @param noMipmap defines if the texture will require mip maps or not
  95943. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  95944. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  95945. * @param onLoad defines a callback triggered when the texture has been loaded
  95946. * @param onError defines a callback triggered when an error occurred during the loading session
  95947. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  95948. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  95949. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  95950. * @param mimeType defines an optional mime type information
  95951. */
  95952. 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);
  95953. /**
  95954. * Update the url (and optional buffer) of this texture if url was null during construction.
  95955. * @param url the url of the texture
  95956. * @param buffer the buffer of the texture (defaults to null)
  95957. * @param onLoad callback called when the texture is loaded (defaults to null)
  95958. */
  95959. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  95960. /**
  95961. * Finish the loading sequence of a texture flagged as delayed load.
  95962. * @hidden
  95963. */
  95964. delayLoad(): void;
  95965. private _prepareRowForTextureGeneration;
  95966. /**
  95967. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  95968. * @returns the transform matrix of the texture.
  95969. */
  95970. getTextureMatrix(uBase?: number): Matrix;
  95971. /**
  95972. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  95973. * @returns The reflection texture transform
  95974. */
  95975. getReflectionTextureMatrix(): Matrix;
  95976. /**
  95977. * Clones the texture.
  95978. * @returns the cloned texture
  95979. */
  95980. clone(): Texture;
  95981. /**
  95982. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  95983. * @returns The JSON representation of the texture
  95984. */
  95985. serialize(): any;
  95986. /**
  95987. * Get the current class name of the texture useful for serialization or dynamic coding.
  95988. * @returns "Texture"
  95989. */
  95990. getClassName(): string;
  95991. /**
  95992. * Dispose the texture and release its associated resources.
  95993. */
  95994. dispose(): void;
  95995. /**
  95996. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  95997. * @param parsedTexture Define the JSON representation of the texture
  95998. * @param scene Define the scene the parsed texture should be instantiated in
  95999. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  96000. * @returns The parsed texture if successful
  96001. */
  96002. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  96003. /**
  96004. * Creates a texture from its base 64 representation.
  96005. * @param data Define the base64 payload without the data: prefix
  96006. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  96007. * @param scene Define the scene the texture should belong to
  96008. * @param noMipmap Forces the texture to not create mip map information if true
  96009. * @param invertY define if the texture needs to be inverted on the y axis during loading
  96010. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  96011. * @param onLoad define a callback triggered when the texture has been loaded
  96012. * @param onError define a callback triggered when an error occurred during the loading session
  96013. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  96014. * @returns the created texture
  96015. */
  96016. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  96017. /**
  96018. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  96019. * @param data Define the base64 payload without the data: prefix
  96020. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  96021. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  96022. * @param scene Define the scene the texture should belong to
  96023. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  96024. * @param noMipmap Forces the texture to not create mip map information if true
  96025. * @param invertY define if the texture needs to be inverted on the y axis during loading
  96026. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  96027. * @param onLoad define a callback triggered when the texture has been loaded
  96028. * @param onError define a callback triggered when an error occurred during the loading session
  96029. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  96030. * @returns the created texture
  96031. */
  96032. 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;
  96033. }
  96034. }
  96035. declare module BABYLON {
  96036. /**
  96037. * PostProcessManager is used to manage one or more post processes or post process pipelines
  96038. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  96039. */
  96040. export class PostProcessManager {
  96041. private _scene;
  96042. private _indexBuffer;
  96043. private _vertexBuffers;
  96044. /**
  96045. * Creates a new instance PostProcess
  96046. * @param scene The scene that the post process is associated with.
  96047. */
  96048. constructor(scene: Scene);
  96049. private _prepareBuffers;
  96050. private _buildIndexBuffer;
  96051. /**
  96052. * Rebuilds the vertex buffers of the manager.
  96053. * @hidden
  96054. */
  96055. _rebuild(): void;
  96056. /**
  96057. * Prepares a frame to be run through a post process.
  96058. * @param sourceTexture The input texture to the post procesess. (default: null)
  96059. * @param postProcesses An array of post processes to be run. (default: null)
  96060. * @returns True if the post processes were able to be run.
  96061. * @hidden
  96062. */
  96063. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  96064. /**
  96065. * Manually render a set of post processes to a texture.
  96066. * Please note, the frame buffer won't be unbound after the call in case you have more render to do.
  96067. * @param postProcesses An array of post processes to be run.
  96068. * @param targetTexture The target texture to render to.
  96069. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  96070. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  96071. * @param lodLevel defines which lod of the texture to render to
  96072. */
  96073. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  96074. /**
  96075. * Finalize the result of the output of the postprocesses.
  96076. * @param doNotPresent If true the result will not be displayed to the screen.
  96077. * @param targetTexture The target texture to render to.
  96078. * @param faceIndex The index of the face to bind the target texture to.
  96079. * @param postProcesses The array of post processes to render.
  96080. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  96081. * @hidden
  96082. */
  96083. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  96084. /**
  96085. * Disposes of the post process manager.
  96086. */
  96087. dispose(): void;
  96088. }
  96089. }
  96090. declare module BABYLON {
  96091. /**
  96092. * This Helps creating a texture that will be created from a camera in your scene.
  96093. * It is basically a dynamic texture that could be used to create special effects for instance.
  96094. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  96095. */
  96096. export class RenderTargetTexture extends Texture {
  96097. isCube: boolean;
  96098. /**
  96099. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  96100. */
  96101. static readonly REFRESHRATE_RENDER_ONCE: number;
  96102. /**
  96103. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  96104. */
  96105. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  96106. /**
  96107. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  96108. * the central point of your effect and can save a lot of performances.
  96109. */
  96110. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  96111. /**
  96112. * Use this predicate to dynamically define the list of mesh you want to render.
  96113. * If set, the renderList property will be overwritten.
  96114. */
  96115. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  96116. private _renderList;
  96117. /**
  96118. * Use this list to define the list of mesh you want to render.
  96119. */
  96120. get renderList(): Nullable<Array<AbstractMesh>>;
  96121. set renderList(value: Nullable<Array<AbstractMesh>>);
  96122. /**
  96123. * Use this function to overload the renderList array at rendering time.
  96124. * Return null to render with the curent renderList, else return the list of meshes to use for rendering.
  96125. * For 2DArray RTT, layerOrFace is the index of the layer that is going to be rendered, else it is the faceIndex of
  96126. * the cube (if the RTT is a cube, else layerOrFace=0).
  96127. * The renderList passed to the function is the current render list (the one that will be used if the function returns null).
  96128. * The length of this list is passed through renderListLength: don't use renderList.length directly because the array can
  96129. * hold dummy elements!
  96130. */
  96131. getCustomRenderList: (layerOrFace: number, renderList: Nullable<Immutable<Array<AbstractMesh>>>, renderListLength: number) => Nullable<Array<AbstractMesh>>;
  96132. private _hookArray;
  96133. /**
  96134. * Define if particles should be rendered in your texture.
  96135. */
  96136. renderParticles: boolean;
  96137. /**
  96138. * Define if sprites should be rendered in your texture.
  96139. */
  96140. renderSprites: boolean;
  96141. /**
  96142. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  96143. */
  96144. coordinatesMode: number;
  96145. /**
  96146. * Define the camera used to render the texture.
  96147. */
  96148. activeCamera: Nullable<Camera>;
  96149. /**
  96150. * Override the mesh isReady function with your own one.
  96151. */
  96152. customIsReadyFunction: (mesh: AbstractMesh, refreshRate: number) => boolean;
  96153. /**
  96154. * Override the render function of the texture with your own one.
  96155. */
  96156. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  96157. /**
  96158. * Define if camera post processes should be use while rendering the texture.
  96159. */
  96160. useCameraPostProcesses: boolean;
  96161. /**
  96162. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  96163. */
  96164. ignoreCameraViewport: boolean;
  96165. private _postProcessManager;
  96166. private _postProcesses;
  96167. private _resizeObserver;
  96168. /**
  96169. * An event triggered when the texture is unbind.
  96170. */
  96171. onBeforeBindObservable: Observable<RenderTargetTexture>;
  96172. /**
  96173. * An event triggered when the texture is unbind.
  96174. */
  96175. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  96176. private _onAfterUnbindObserver;
  96177. /**
  96178. * Set a after unbind callback in the texture.
  96179. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  96180. */
  96181. set onAfterUnbind(callback: () => void);
  96182. /**
  96183. * An event triggered before rendering the texture
  96184. */
  96185. onBeforeRenderObservable: Observable<number>;
  96186. private _onBeforeRenderObserver;
  96187. /**
  96188. * Set a before render callback in the texture.
  96189. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  96190. */
  96191. set onBeforeRender(callback: (faceIndex: number) => void);
  96192. /**
  96193. * An event triggered after rendering the texture
  96194. */
  96195. onAfterRenderObservable: Observable<number>;
  96196. private _onAfterRenderObserver;
  96197. /**
  96198. * Set a after render callback in the texture.
  96199. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  96200. */
  96201. set onAfterRender(callback: (faceIndex: number) => void);
  96202. /**
  96203. * An event triggered after the texture clear
  96204. */
  96205. onClearObservable: Observable<Engine>;
  96206. private _onClearObserver;
  96207. /**
  96208. * Set a clear callback in the texture.
  96209. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  96210. */
  96211. set onClear(callback: (Engine: Engine) => void);
  96212. /**
  96213. * An event triggered when the texture is resized.
  96214. */
  96215. onResizeObservable: Observable<RenderTargetTexture>;
  96216. /**
  96217. * Define the clear color of the Render Target if it should be different from the scene.
  96218. */
  96219. clearColor: Color4;
  96220. protected _size: number | {
  96221. width: number;
  96222. height: number;
  96223. layers?: number;
  96224. };
  96225. protected _initialSizeParameter: number | {
  96226. width: number;
  96227. height: number;
  96228. } | {
  96229. ratio: number;
  96230. };
  96231. protected _sizeRatio: Nullable<number>;
  96232. /** @hidden */
  96233. _generateMipMaps: boolean;
  96234. protected _renderingManager: RenderingManager;
  96235. /** @hidden */
  96236. _waitingRenderList: string[];
  96237. protected _doNotChangeAspectRatio: boolean;
  96238. protected _currentRefreshId: number;
  96239. protected _refreshRate: number;
  96240. protected _textureMatrix: Matrix;
  96241. protected _samples: number;
  96242. protected _renderTargetOptions: RenderTargetCreationOptions;
  96243. /**
  96244. * Gets render target creation options that were used.
  96245. */
  96246. get renderTargetOptions(): RenderTargetCreationOptions;
  96247. protected _engine: Engine;
  96248. protected _onRatioRescale(): void;
  96249. /**
  96250. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  96251. * It must define where the camera used to render the texture is set
  96252. */
  96253. boundingBoxPosition: Vector3;
  96254. private _boundingBoxSize;
  96255. /**
  96256. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  96257. * When defined, the cubemap will switch to local mode
  96258. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  96259. * @example https://www.babylonjs-playground.com/#RNASML
  96260. */
  96261. set boundingBoxSize(value: Vector3);
  96262. get boundingBoxSize(): Vector3;
  96263. /**
  96264. * In case the RTT has been created with a depth texture, get the associated
  96265. * depth texture.
  96266. * Otherwise, return null.
  96267. */
  96268. get depthStencilTexture(): Nullable<InternalTexture>;
  96269. /**
  96270. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  96271. * or used a shadow, depth texture...
  96272. * @param name The friendly name of the texture
  96273. * @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)
  96274. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  96275. * @param generateMipMaps True if mip maps need to be generated after render.
  96276. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  96277. * @param type The type of the buffer in the RTT (int, half float, float...)
  96278. * @param isCube True if a cube texture needs to be created
  96279. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  96280. * @param generateDepthBuffer True to generate a depth buffer
  96281. * @param generateStencilBuffer True to generate a stencil buffer
  96282. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  96283. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  96284. * @param delayAllocation if the texture allocation should be delayed (default: false)
  96285. */
  96286. constructor(name: string, size: number | {
  96287. width: number;
  96288. height: number;
  96289. layers?: number;
  96290. } | {
  96291. ratio: number;
  96292. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  96293. /**
  96294. * Creates a depth stencil texture.
  96295. * This is only available in WebGL 2 or with the depth texture extension available.
  96296. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  96297. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  96298. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  96299. */
  96300. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  96301. private _processSizeParameter;
  96302. /**
  96303. * Define the number of samples to use in case of MSAA.
  96304. * It defaults to one meaning no MSAA has been enabled.
  96305. */
  96306. get samples(): number;
  96307. set samples(value: number);
  96308. /**
  96309. * Resets the refresh counter of the texture and start bak from scratch.
  96310. * Could be useful to regenerate the texture if it is setup to render only once.
  96311. */
  96312. resetRefreshCounter(): void;
  96313. /**
  96314. * Define the refresh rate of the texture or the rendering frequency.
  96315. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  96316. */
  96317. get refreshRate(): number;
  96318. set refreshRate(value: number);
  96319. /**
  96320. * Adds a post process to the render target rendering passes.
  96321. * @param postProcess define the post process to add
  96322. */
  96323. addPostProcess(postProcess: PostProcess): void;
  96324. /**
  96325. * Clear all the post processes attached to the render target
  96326. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  96327. */
  96328. clearPostProcesses(dispose?: boolean): void;
  96329. /**
  96330. * Remove one of the post process from the list of attached post processes to the texture
  96331. * @param postProcess define the post process to remove from the list
  96332. */
  96333. removePostProcess(postProcess: PostProcess): void;
  96334. /** @hidden */
  96335. _shouldRender(): boolean;
  96336. /**
  96337. * Gets the actual render size of the texture.
  96338. * @returns the width of the render size
  96339. */
  96340. getRenderSize(): number;
  96341. /**
  96342. * Gets the actual render width of the texture.
  96343. * @returns the width of the render size
  96344. */
  96345. getRenderWidth(): number;
  96346. /**
  96347. * Gets the actual render height of the texture.
  96348. * @returns the height of the render size
  96349. */
  96350. getRenderHeight(): number;
  96351. /**
  96352. * Gets the actual number of layers of the texture.
  96353. * @returns the number of layers
  96354. */
  96355. getRenderLayers(): number;
  96356. /**
  96357. * Get if the texture can be rescaled or not.
  96358. */
  96359. get canRescale(): boolean;
  96360. /**
  96361. * Resize the texture using a ratio.
  96362. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  96363. */
  96364. scale(ratio: number): void;
  96365. /**
  96366. * Get the texture reflection matrix used to rotate/transform the reflection.
  96367. * @returns the reflection matrix
  96368. */
  96369. getReflectionTextureMatrix(): Matrix;
  96370. /**
  96371. * Resize the texture to a new desired size.
  96372. * Be carrefull as it will recreate all the data in the new texture.
  96373. * @param size Define the new size. It can be:
  96374. * - a number for squared texture,
  96375. * - an object containing { width: number, height: number }
  96376. * - or an object containing a ratio { ratio: number }
  96377. */
  96378. resize(size: number | {
  96379. width: number;
  96380. height: number;
  96381. } | {
  96382. ratio: number;
  96383. }): void;
  96384. private _defaultRenderListPrepared;
  96385. /**
  96386. * Renders all the objects from the render list into the texture.
  96387. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  96388. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  96389. */
  96390. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  96391. private _bestReflectionRenderTargetDimension;
  96392. private _prepareRenderingManager;
  96393. /**
  96394. * @hidden
  96395. * @param faceIndex face index to bind to if this is a cubetexture
  96396. * @param layer defines the index of the texture to bind in the array
  96397. */
  96398. _bindFrameBuffer(faceIndex?: number, layer?: number): void;
  96399. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  96400. private renderToTarget;
  96401. /**
  96402. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  96403. * This allowed control for front to back rendering or reversly depending of the special needs.
  96404. *
  96405. * @param renderingGroupId The rendering group id corresponding to its index
  96406. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  96407. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  96408. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  96409. */
  96410. 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;
  96411. /**
  96412. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  96413. *
  96414. * @param renderingGroupId The rendering group id corresponding to its index
  96415. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  96416. */
  96417. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  96418. /**
  96419. * Clones the texture.
  96420. * @returns the cloned texture
  96421. */
  96422. clone(): RenderTargetTexture;
  96423. /**
  96424. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  96425. * @returns The JSON representation of the texture
  96426. */
  96427. serialize(): any;
  96428. /**
  96429. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  96430. */
  96431. disposeFramebufferObjects(): void;
  96432. /**
  96433. * Dispose the texture and release its associated resources.
  96434. */
  96435. dispose(): void;
  96436. /** @hidden */
  96437. _rebuild(): void;
  96438. /**
  96439. * Clear the info related to rendering groups preventing retention point in material dispose.
  96440. */
  96441. freeRenderingGroups(): void;
  96442. /**
  96443. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  96444. * @returns the view count
  96445. */
  96446. getViewCount(): number;
  96447. }
  96448. }
  96449. declare module BABYLON {
  96450. /**
  96451. * Class used to manipulate GUIDs
  96452. */
  96453. export class GUID {
  96454. /**
  96455. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  96456. * Be aware Math.random() could cause collisions, but:
  96457. * "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"
  96458. * @returns a pseudo random id
  96459. */
  96460. static RandomId(): string;
  96461. }
  96462. }
  96463. declare module BABYLON {
  96464. /**
  96465. * Options to be used when creating a shadow depth material
  96466. */
  96467. export interface IIOptionShadowDepthMaterial {
  96468. /** Variables in the vertex shader code that need to have their names remapped.
  96469. * The format is: ["var_name", "var_remapped_name", "var_name", "var_remapped_name", ...]
  96470. * "var_name" should be either: worldPos or vNormalW
  96471. * So, if the variable holding the world position in your vertex shader is not named worldPos, you must tell the system
  96472. * the name to use instead by using: ["worldPos", "myWorldPosVar"] assuming the variable is named myWorldPosVar in your code.
  96473. * If the normal must also be remapped: ["worldPos", "myWorldPosVar", "vNormalW", "myWorldNormal"]
  96474. */
  96475. remappedVariables?: string[];
  96476. /** Set standalone to true if the base material wrapped by ShadowDepthMaterial is not used for a regular object but for depth shadow generation only */
  96477. standalone?: boolean;
  96478. }
  96479. /**
  96480. * Class that can be used to wrap a base material to generate accurate shadows when using custom vertex/fragment code in the base material
  96481. */
  96482. export class ShadowDepthWrapper {
  96483. private _scene;
  96484. private _options?;
  96485. private _baseMaterial;
  96486. private _onEffectCreatedObserver;
  96487. private _subMeshToEffect;
  96488. private _subMeshToDepthEffect;
  96489. private _meshes;
  96490. /** @hidden */
  96491. _matriceNames: any;
  96492. /** Gets the standalone status of the wrapper */
  96493. get standalone(): boolean;
  96494. /** Gets the base material the wrapper is built upon */
  96495. get baseMaterial(): Material;
  96496. /**
  96497. * Instantiate a new shadow depth wrapper.
  96498. * It works by injecting some specific code in the vertex/fragment shaders of the base material and is used by a shadow generator to
  96499. * generate the shadow depth map. For more information, please refer to the documentation:
  96500. * https://doc.babylonjs.com/babylon101/shadows
  96501. * @param baseMaterial Material to wrap
  96502. * @param scene Define the scene the material belongs to
  96503. * @param options Options used to create the wrapper
  96504. */
  96505. constructor(baseMaterial: Material, scene: Scene, options?: IIOptionShadowDepthMaterial);
  96506. /**
  96507. * Gets the effect to use to generate the depth map
  96508. * @param subMesh subMesh to get the effect for
  96509. * @param shadowGenerator shadow generator to get the effect for
  96510. * @returns the effect to use to generate the depth map for the subMesh + shadow generator specified
  96511. */
  96512. getEffect(subMesh: Nullable<SubMesh>, shadowGenerator: ShadowGenerator): Nullable<Effect>;
  96513. /**
  96514. * Specifies that the submesh is ready to be used for depth rendering
  96515. * @param subMesh submesh to check
  96516. * @param defines the list of defines to take into account when checking the effect
  96517. * @param shadowGenerator combined with subMesh, it defines the effect to check
  96518. * @param useInstances specifies that instances should be used
  96519. * @returns a boolean indicating that the submesh is ready or not
  96520. */
  96521. isReadyForSubMesh(subMesh: SubMesh, defines: string[], shadowGenerator: ShadowGenerator, useInstances: boolean): boolean;
  96522. /**
  96523. * Disposes the resources
  96524. */
  96525. dispose(): void;
  96526. private _makeEffect;
  96527. }
  96528. }
  96529. declare module BABYLON {
  96530. /**
  96531. * Options for compiling materials.
  96532. */
  96533. export interface IMaterialCompilationOptions {
  96534. /**
  96535. * Defines whether clip planes are enabled.
  96536. */
  96537. clipPlane: boolean;
  96538. /**
  96539. * Defines whether instances are enabled.
  96540. */
  96541. useInstances: boolean;
  96542. }
  96543. /**
  96544. * Base class for the main features of a material in Babylon.js
  96545. */
  96546. export class Material implements IAnimatable {
  96547. /**
  96548. * Returns the triangle fill mode
  96549. */
  96550. static readonly TriangleFillMode: number;
  96551. /**
  96552. * Returns the wireframe mode
  96553. */
  96554. static readonly WireFrameFillMode: number;
  96555. /**
  96556. * Returns the point fill mode
  96557. */
  96558. static readonly PointFillMode: number;
  96559. /**
  96560. * Returns the point list draw mode
  96561. */
  96562. static readonly PointListDrawMode: number;
  96563. /**
  96564. * Returns the line list draw mode
  96565. */
  96566. static readonly LineListDrawMode: number;
  96567. /**
  96568. * Returns the line loop draw mode
  96569. */
  96570. static readonly LineLoopDrawMode: number;
  96571. /**
  96572. * Returns the line strip draw mode
  96573. */
  96574. static readonly LineStripDrawMode: number;
  96575. /**
  96576. * Returns the triangle strip draw mode
  96577. */
  96578. static readonly TriangleStripDrawMode: number;
  96579. /**
  96580. * Returns the triangle fan draw mode
  96581. */
  96582. static readonly TriangleFanDrawMode: number;
  96583. /**
  96584. * Stores the clock-wise side orientation
  96585. */
  96586. static readonly ClockWiseSideOrientation: number;
  96587. /**
  96588. * Stores the counter clock-wise side orientation
  96589. */
  96590. static readonly CounterClockWiseSideOrientation: number;
  96591. /**
  96592. * The dirty texture flag value
  96593. */
  96594. static readonly TextureDirtyFlag: number;
  96595. /**
  96596. * The dirty light flag value
  96597. */
  96598. static readonly LightDirtyFlag: number;
  96599. /**
  96600. * The dirty fresnel flag value
  96601. */
  96602. static readonly FresnelDirtyFlag: number;
  96603. /**
  96604. * The dirty attribute flag value
  96605. */
  96606. static readonly AttributesDirtyFlag: number;
  96607. /**
  96608. * The dirty misc flag value
  96609. */
  96610. static readonly MiscDirtyFlag: number;
  96611. /**
  96612. * The all dirty flag value
  96613. */
  96614. static readonly AllDirtyFlag: number;
  96615. /**
  96616. * MaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  96617. */
  96618. static readonly MATERIAL_OPAQUE: number;
  96619. /**
  96620. * MaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  96621. */
  96622. static readonly MATERIAL_ALPHATEST: number;
  96623. /**
  96624. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  96625. */
  96626. static readonly MATERIAL_ALPHABLEND: number;
  96627. /**
  96628. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  96629. * They are also discarded below the alpha cutoff threshold to improve performances.
  96630. */
  96631. static readonly MATERIAL_ALPHATESTANDBLEND: number;
  96632. /**
  96633. * Custom callback helping to override the default shader used in the material.
  96634. */
  96635. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: MaterialDefines | string[], attributes?: string[]) => string;
  96636. /**
  96637. * Custom shadow depth material to use for shadow rendering instead of the in-built one
  96638. */
  96639. shadowDepthWrapper: Nullable<ShadowDepthWrapper>;
  96640. /**
  96641. * The ID of the material
  96642. */
  96643. id: string;
  96644. /**
  96645. * Gets or sets the unique id of the material
  96646. */
  96647. uniqueId: number;
  96648. /**
  96649. * The name of the material
  96650. */
  96651. name: string;
  96652. /**
  96653. * Gets or sets user defined metadata
  96654. */
  96655. metadata: any;
  96656. /**
  96657. * For internal use only. Please do not use.
  96658. */
  96659. reservedDataStore: any;
  96660. /**
  96661. * Specifies if the ready state should be checked on each call
  96662. */
  96663. checkReadyOnEveryCall: boolean;
  96664. /**
  96665. * Specifies if the ready state should be checked once
  96666. */
  96667. checkReadyOnlyOnce: boolean;
  96668. /**
  96669. * The state of the material
  96670. */
  96671. state: string;
  96672. /**
  96673. * The alpha value of the material
  96674. */
  96675. protected _alpha: number;
  96676. /**
  96677. * List of inspectable custom properties (used by the Inspector)
  96678. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  96679. */
  96680. inspectableCustomProperties: IInspectable[];
  96681. /**
  96682. * Sets the alpha value of the material
  96683. */
  96684. set alpha(value: number);
  96685. /**
  96686. * Gets the alpha value of the material
  96687. */
  96688. get alpha(): number;
  96689. /**
  96690. * Specifies if back face culling is enabled
  96691. */
  96692. protected _backFaceCulling: boolean;
  96693. /**
  96694. * Sets the back-face culling state
  96695. */
  96696. set backFaceCulling(value: boolean);
  96697. /**
  96698. * Gets the back-face culling state
  96699. */
  96700. get backFaceCulling(): boolean;
  96701. /**
  96702. * Stores the value for side orientation
  96703. */
  96704. sideOrientation: number;
  96705. /**
  96706. * Callback triggered when the material is compiled
  96707. */
  96708. onCompiled: Nullable<(effect: Effect) => void>;
  96709. /**
  96710. * Callback triggered when an error occurs
  96711. */
  96712. onError: Nullable<(effect: Effect, errors: string) => void>;
  96713. /**
  96714. * Callback triggered to get the render target textures
  96715. */
  96716. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  96717. /**
  96718. * Gets a boolean indicating that current material needs to register RTT
  96719. */
  96720. get hasRenderTargetTextures(): boolean;
  96721. /**
  96722. * Specifies if the material should be serialized
  96723. */
  96724. doNotSerialize: boolean;
  96725. /**
  96726. * @hidden
  96727. */
  96728. _storeEffectOnSubMeshes: boolean;
  96729. /**
  96730. * Stores the animations for the material
  96731. */
  96732. animations: Nullable<Array<Animation>>;
  96733. /**
  96734. * An event triggered when the material is disposed
  96735. */
  96736. onDisposeObservable: Observable<Material>;
  96737. /**
  96738. * An observer which watches for dispose events
  96739. */
  96740. private _onDisposeObserver;
  96741. private _onUnBindObservable;
  96742. /**
  96743. * Called during a dispose event
  96744. */
  96745. set onDispose(callback: () => void);
  96746. private _onBindObservable;
  96747. /**
  96748. * An event triggered when the material is bound
  96749. */
  96750. get onBindObservable(): Observable<AbstractMesh>;
  96751. /**
  96752. * An observer which watches for bind events
  96753. */
  96754. private _onBindObserver;
  96755. /**
  96756. * Called during a bind event
  96757. */
  96758. set onBind(callback: (Mesh: AbstractMesh) => void);
  96759. /**
  96760. * An event triggered when the material is unbound
  96761. */
  96762. get onUnBindObservable(): Observable<Material>;
  96763. protected _onEffectCreatedObservable: Nullable<Observable<{
  96764. effect: Effect;
  96765. subMesh: Nullable<SubMesh>;
  96766. }>>;
  96767. /**
  96768. * An event triggered when the effect is (re)created
  96769. */
  96770. get onEffectCreatedObservable(): Observable<{
  96771. effect: Effect;
  96772. subMesh: Nullable<SubMesh>;
  96773. }>;
  96774. /**
  96775. * Stores the value of the alpha mode
  96776. */
  96777. private _alphaMode;
  96778. /**
  96779. * Sets the value of the alpha mode.
  96780. *
  96781. * | Value | Type | Description |
  96782. * | --- | --- | --- |
  96783. * | 0 | ALPHA_DISABLE | |
  96784. * | 1 | ALPHA_ADD | |
  96785. * | 2 | ALPHA_COMBINE | |
  96786. * | 3 | ALPHA_SUBTRACT | |
  96787. * | 4 | ALPHA_MULTIPLY | |
  96788. * | 5 | ALPHA_MAXIMIZED | |
  96789. * | 6 | ALPHA_ONEONE | |
  96790. * | 7 | ALPHA_PREMULTIPLIED | |
  96791. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  96792. * | 9 | ALPHA_INTERPOLATE | |
  96793. * | 10 | ALPHA_SCREENMODE | |
  96794. *
  96795. */
  96796. set alphaMode(value: number);
  96797. /**
  96798. * Gets the value of the alpha mode
  96799. */
  96800. get alphaMode(): number;
  96801. /**
  96802. * Stores the state of the need depth pre-pass value
  96803. */
  96804. private _needDepthPrePass;
  96805. /**
  96806. * Sets the need depth pre-pass value
  96807. */
  96808. set needDepthPrePass(value: boolean);
  96809. /**
  96810. * Gets the depth pre-pass value
  96811. */
  96812. get needDepthPrePass(): boolean;
  96813. /**
  96814. * Specifies if depth writing should be disabled
  96815. */
  96816. disableDepthWrite: boolean;
  96817. /**
  96818. * Specifies if color writing should be disabled
  96819. */
  96820. disableColorWrite: boolean;
  96821. /**
  96822. * Specifies if depth writing should be forced
  96823. */
  96824. forceDepthWrite: boolean;
  96825. /**
  96826. * Specifies the depth function that should be used. 0 means the default engine function
  96827. */
  96828. depthFunction: number;
  96829. /**
  96830. * Specifies if there should be a separate pass for culling
  96831. */
  96832. separateCullingPass: boolean;
  96833. /**
  96834. * Stores the state specifing if fog should be enabled
  96835. */
  96836. private _fogEnabled;
  96837. /**
  96838. * Sets the state for enabling fog
  96839. */
  96840. set fogEnabled(value: boolean);
  96841. /**
  96842. * Gets the value of the fog enabled state
  96843. */
  96844. get fogEnabled(): boolean;
  96845. /**
  96846. * Stores the size of points
  96847. */
  96848. pointSize: number;
  96849. /**
  96850. * Stores the z offset value
  96851. */
  96852. zOffset: number;
  96853. get wireframe(): boolean;
  96854. /**
  96855. * Sets the state of wireframe mode
  96856. */
  96857. set wireframe(value: boolean);
  96858. /**
  96859. * Gets the value specifying if point clouds are enabled
  96860. */
  96861. get pointsCloud(): boolean;
  96862. /**
  96863. * Sets the state of point cloud mode
  96864. */
  96865. set pointsCloud(value: boolean);
  96866. /**
  96867. * Gets the material fill mode
  96868. */
  96869. get fillMode(): number;
  96870. /**
  96871. * Sets the material fill mode
  96872. */
  96873. set fillMode(value: number);
  96874. /**
  96875. * @hidden
  96876. * Stores the effects for the material
  96877. */
  96878. _effect: Nullable<Effect>;
  96879. /**
  96880. * Specifies if uniform buffers should be used
  96881. */
  96882. private _useUBO;
  96883. /**
  96884. * Stores a reference to the scene
  96885. */
  96886. private _scene;
  96887. /**
  96888. * Stores the fill mode state
  96889. */
  96890. private _fillMode;
  96891. /**
  96892. * Specifies if the depth write state should be cached
  96893. */
  96894. private _cachedDepthWriteState;
  96895. /**
  96896. * Specifies if the color write state should be cached
  96897. */
  96898. private _cachedColorWriteState;
  96899. /**
  96900. * Specifies if the depth function state should be cached
  96901. */
  96902. private _cachedDepthFunctionState;
  96903. /**
  96904. * Stores the uniform buffer
  96905. */
  96906. protected _uniformBuffer: UniformBuffer;
  96907. /** @hidden */
  96908. _indexInSceneMaterialArray: number;
  96909. /** @hidden */
  96910. meshMap: Nullable<{
  96911. [id: string]: AbstractMesh | undefined;
  96912. }>;
  96913. /**
  96914. * Creates a material instance
  96915. * @param name defines the name of the material
  96916. * @param scene defines the scene to reference
  96917. * @param doNotAdd specifies if the material should be added to the scene
  96918. */
  96919. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  96920. /**
  96921. * Returns a string representation of the current material
  96922. * @param fullDetails defines a boolean indicating which levels of logging is desired
  96923. * @returns a string with material information
  96924. */
  96925. toString(fullDetails?: boolean): string;
  96926. /**
  96927. * Gets the class name of the material
  96928. * @returns a string with the class name of the material
  96929. */
  96930. getClassName(): string;
  96931. /**
  96932. * Specifies if updates for the material been locked
  96933. */
  96934. get isFrozen(): boolean;
  96935. /**
  96936. * Locks updates for the material
  96937. */
  96938. freeze(): void;
  96939. /**
  96940. * Unlocks updates for the material
  96941. */
  96942. unfreeze(): void;
  96943. /**
  96944. * Specifies if the material is ready to be used
  96945. * @param mesh defines the mesh to check
  96946. * @param useInstances specifies if instances should be used
  96947. * @returns a boolean indicating if the material is ready to be used
  96948. */
  96949. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  96950. /**
  96951. * Specifies that the submesh is ready to be used
  96952. * @param mesh defines the mesh to check
  96953. * @param subMesh defines which submesh to check
  96954. * @param useInstances specifies that instances should be used
  96955. * @returns a boolean indicating that the submesh is ready or not
  96956. */
  96957. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  96958. /**
  96959. * Returns the material effect
  96960. * @returns the effect associated with the material
  96961. */
  96962. getEffect(): Nullable<Effect>;
  96963. /**
  96964. * Returns the current scene
  96965. * @returns a Scene
  96966. */
  96967. getScene(): Scene;
  96968. /**
  96969. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  96970. */
  96971. protected _forceAlphaTest: boolean;
  96972. /**
  96973. * The transparency mode of the material.
  96974. */
  96975. protected _transparencyMode: Nullable<number>;
  96976. /**
  96977. * Gets the current transparency mode.
  96978. */
  96979. get transparencyMode(): Nullable<number>;
  96980. /**
  96981. * Sets the transparency mode of the material.
  96982. *
  96983. * | Value | Type | Description |
  96984. * | ----- | ----------------------------------- | ----------- |
  96985. * | 0 | OPAQUE | |
  96986. * | 1 | ALPHATEST | |
  96987. * | 2 | ALPHABLEND | |
  96988. * | 3 | ALPHATESTANDBLEND | |
  96989. *
  96990. */
  96991. set transparencyMode(value: Nullable<number>);
  96992. /**
  96993. * Returns true if alpha blending should be disabled.
  96994. */
  96995. protected get _disableAlphaBlending(): boolean;
  96996. /**
  96997. * Specifies whether or not this material should be rendered in alpha blend mode.
  96998. * @returns a boolean specifying if alpha blending is needed
  96999. */
  97000. needAlphaBlending(): boolean;
  97001. /**
  97002. * Specifies if the mesh will require alpha blending
  97003. * @param mesh defines the mesh to check
  97004. * @returns a boolean specifying if alpha blending is needed for the mesh
  97005. */
  97006. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  97007. /**
  97008. * Specifies whether or not this material should be rendered in alpha test mode.
  97009. * @returns a boolean specifying if an alpha test is needed.
  97010. */
  97011. needAlphaTesting(): boolean;
  97012. /**
  97013. * Specifies if material alpha testing should be turned on for the mesh
  97014. * @param mesh defines the mesh to check
  97015. */
  97016. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  97017. /**
  97018. * Gets the texture used for the alpha test
  97019. * @returns the texture to use for alpha testing
  97020. */
  97021. getAlphaTestTexture(): Nullable<BaseTexture>;
  97022. /**
  97023. * Marks the material to indicate that it needs to be re-calculated
  97024. */
  97025. markDirty(): void;
  97026. /** @hidden */
  97027. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  97028. /**
  97029. * Binds the material to the mesh
  97030. * @param world defines the world transformation matrix
  97031. * @param mesh defines the mesh to bind the material to
  97032. */
  97033. bind(world: Matrix, mesh?: Mesh): void;
  97034. /**
  97035. * Binds the submesh to the material
  97036. * @param world defines the world transformation matrix
  97037. * @param mesh defines the mesh containing the submesh
  97038. * @param subMesh defines the submesh to bind the material to
  97039. */
  97040. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  97041. /**
  97042. * Binds the world matrix to the material
  97043. * @param world defines the world transformation matrix
  97044. */
  97045. bindOnlyWorldMatrix(world: Matrix): void;
  97046. /**
  97047. * Binds the scene's uniform buffer to the effect.
  97048. * @param effect defines the effect to bind to the scene uniform buffer
  97049. * @param sceneUbo defines the uniform buffer storing scene data
  97050. */
  97051. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  97052. /**
  97053. * Binds the view matrix to the effect
  97054. * @param effect defines the effect to bind the view matrix to
  97055. */
  97056. bindView(effect: Effect): void;
  97057. /**
  97058. * Binds the view projection matrix to the effect
  97059. * @param effect defines the effect to bind the view projection matrix to
  97060. */
  97061. bindViewProjection(effect: Effect): void;
  97062. /**
  97063. * Processes to execute after binding the material to a mesh
  97064. * @param mesh defines the rendered mesh
  97065. */
  97066. protected _afterBind(mesh?: Mesh): void;
  97067. /**
  97068. * Unbinds the material from the mesh
  97069. */
  97070. unbind(): void;
  97071. /**
  97072. * Gets the active textures from the material
  97073. * @returns an array of textures
  97074. */
  97075. getActiveTextures(): BaseTexture[];
  97076. /**
  97077. * Specifies if the material uses a texture
  97078. * @param texture defines the texture to check against the material
  97079. * @returns a boolean specifying if the material uses the texture
  97080. */
  97081. hasTexture(texture: BaseTexture): boolean;
  97082. /**
  97083. * Makes a duplicate of the material, and gives it a new name
  97084. * @param name defines the new name for the duplicated material
  97085. * @returns the cloned material
  97086. */
  97087. clone(name: string): Nullable<Material>;
  97088. /**
  97089. * Gets the meshes bound to the material
  97090. * @returns an array of meshes bound to the material
  97091. */
  97092. getBindedMeshes(): AbstractMesh[];
  97093. /**
  97094. * Force shader compilation
  97095. * @param mesh defines the mesh associated with this material
  97096. * @param onCompiled defines a function to execute once the material is compiled
  97097. * @param options defines the options to configure the compilation
  97098. * @param onError defines a function to execute if the material fails compiling
  97099. */
  97100. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  97101. /**
  97102. * Force shader compilation
  97103. * @param mesh defines the mesh that will use this material
  97104. * @param options defines additional options for compiling the shaders
  97105. * @returns a promise that resolves when the compilation completes
  97106. */
  97107. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  97108. private static readonly _AllDirtyCallBack;
  97109. private static readonly _ImageProcessingDirtyCallBack;
  97110. private static readonly _TextureDirtyCallBack;
  97111. private static readonly _FresnelDirtyCallBack;
  97112. private static readonly _MiscDirtyCallBack;
  97113. private static readonly _LightsDirtyCallBack;
  97114. private static readonly _AttributeDirtyCallBack;
  97115. private static _FresnelAndMiscDirtyCallBack;
  97116. private static _TextureAndMiscDirtyCallBack;
  97117. private static readonly _DirtyCallbackArray;
  97118. private static readonly _RunDirtyCallBacks;
  97119. /**
  97120. * Marks a define in the material to indicate that it needs to be re-computed
  97121. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  97122. */
  97123. markAsDirty(flag: number): void;
  97124. /**
  97125. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  97126. * @param func defines a function which checks material defines against the submeshes
  97127. */
  97128. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  97129. /**
  97130. * Indicates that we need to re-calculated for all submeshes
  97131. */
  97132. protected _markAllSubMeshesAsAllDirty(): void;
  97133. /**
  97134. * Indicates that image processing needs to be re-calculated for all submeshes
  97135. */
  97136. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  97137. /**
  97138. * Indicates that textures need to be re-calculated for all submeshes
  97139. */
  97140. protected _markAllSubMeshesAsTexturesDirty(): void;
  97141. /**
  97142. * Indicates that fresnel needs to be re-calculated for all submeshes
  97143. */
  97144. protected _markAllSubMeshesAsFresnelDirty(): void;
  97145. /**
  97146. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  97147. */
  97148. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  97149. /**
  97150. * Indicates that lights need to be re-calculated for all submeshes
  97151. */
  97152. protected _markAllSubMeshesAsLightsDirty(): void;
  97153. /**
  97154. * Indicates that attributes need to be re-calculated for all submeshes
  97155. */
  97156. protected _markAllSubMeshesAsAttributesDirty(): void;
  97157. /**
  97158. * Indicates that misc needs to be re-calculated for all submeshes
  97159. */
  97160. protected _markAllSubMeshesAsMiscDirty(): void;
  97161. /**
  97162. * Indicates that textures and misc need to be re-calculated for all submeshes
  97163. */
  97164. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  97165. /**
  97166. * Disposes the material
  97167. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  97168. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  97169. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  97170. */
  97171. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  97172. /** @hidden */
  97173. private releaseVertexArrayObject;
  97174. /**
  97175. * Serializes this material
  97176. * @returns the serialized material object
  97177. */
  97178. serialize(): any;
  97179. /**
  97180. * Creates a material from parsed material data
  97181. * @param parsedMaterial defines parsed material data
  97182. * @param scene defines the hosting scene
  97183. * @param rootUrl defines the root URL to use to load textures
  97184. * @returns a new material
  97185. */
  97186. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  97187. }
  97188. }
  97189. declare module BABYLON {
  97190. /**
  97191. * A multi-material is used to apply different materials to different parts of the same object without the need of
  97192. * separate meshes. This can be use to improve performances.
  97193. * @see http://doc.babylonjs.com/how_to/multi_materials
  97194. */
  97195. export class MultiMaterial extends Material {
  97196. private _subMaterials;
  97197. /**
  97198. * Gets or Sets the list of Materials used within the multi material.
  97199. * They need to be ordered according to the submeshes order in the associated mesh
  97200. */
  97201. get subMaterials(): Nullable<Material>[];
  97202. set subMaterials(value: Nullable<Material>[]);
  97203. /**
  97204. * Function used to align with Node.getChildren()
  97205. * @returns the list of Materials used within the multi material
  97206. */
  97207. getChildren(): Nullable<Material>[];
  97208. /**
  97209. * Instantiates a new Multi Material
  97210. * A multi-material is used to apply different materials to different parts of the same object without the need of
  97211. * separate meshes. This can be use to improve performances.
  97212. * @see http://doc.babylonjs.com/how_to/multi_materials
  97213. * @param name Define the name in the scene
  97214. * @param scene Define the scene the material belongs to
  97215. */
  97216. constructor(name: string, scene: Scene);
  97217. private _hookArray;
  97218. /**
  97219. * Get one of the submaterial by its index in the submaterials array
  97220. * @param index The index to look the sub material at
  97221. * @returns The Material if the index has been defined
  97222. */
  97223. getSubMaterial(index: number): Nullable<Material>;
  97224. /**
  97225. * Get the list of active textures for the whole sub materials list.
  97226. * @returns All the textures that will be used during the rendering
  97227. */
  97228. getActiveTextures(): BaseTexture[];
  97229. /**
  97230. * Gets the current class name of the material e.g. "MultiMaterial"
  97231. * Mainly use in serialization.
  97232. * @returns the class name
  97233. */
  97234. getClassName(): string;
  97235. /**
  97236. * Checks if the material is ready to render the requested sub mesh
  97237. * @param mesh Define the mesh the submesh belongs to
  97238. * @param subMesh Define the sub mesh to look readyness for
  97239. * @param useInstances Define whether or not the material is used with instances
  97240. * @returns true if ready, otherwise false
  97241. */
  97242. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  97243. /**
  97244. * Clones the current material and its related sub materials
  97245. * @param name Define the name of the newly cloned material
  97246. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  97247. * @returns the cloned material
  97248. */
  97249. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  97250. /**
  97251. * Serializes the materials into a JSON representation.
  97252. * @returns the JSON representation
  97253. */
  97254. serialize(): any;
  97255. /**
  97256. * Dispose the material and release its associated resources
  97257. * @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)
  97258. * @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)
  97259. * @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)
  97260. */
  97261. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  97262. /**
  97263. * Creates a MultiMaterial from parsed MultiMaterial data.
  97264. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  97265. * @param scene defines the hosting scene
  97266. * @returns a new MultiMaterial
  97267. */
  97268. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  97269. }
  97270. }
  97271. declare module BABYLON {
  97272. /**
  97273. * Base class for submeshes
  97274. */
  97275. export class BaseSubMesh {
  97276. /** @hidden */
  97277. _materialDefines: Nullable<MaterialDefines>;
  97278. /** @hidden */
  97279. _materialEffect: Nullable<Effect>;
  97280. /** @hidden */
  97281. _effectOverride: Nullable<Effect>;
  97282. /**
  97283. * Gets material defines used by the effect associated to the sub mesh
  97284. */
  97285. get materialDefines(): Nullable<MaterialDefines>;
  97286. /**
  97287. * Sets material defines used by the effect associated to the sub mesh
  97288. */
  97289. set materialDefines(defines: Nullable<MaterialDefines>);
  97290. /**
  97291. * Gets associated effect
  97292. */
  97293. get effect(): Nullable<Effect>;
  97294. /**
  97295. * Sets associated effect (effect used to render this submesh)
  97296. * @param effect defines the effect to associate with
  97297. * @param defines defines the set of defines used to compile this effect
  97298. */
  97299. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  97300. }
  97301. /**
  97302. * Defines a subdivision inside a mesh
  97303. */
  97304. export class SubMesh extends BaseSubMesh implements ICullable {
  97305. /** the material index to use */
  97306. materialIndex: number;
  97307. /** vertex index start */
  97308. verticesStart: number;
  97309. /** vertices count */
  97310. verticesCount: number;
  97311. /** index start */
  97312. indexStart: number;
  97313. /** indices count */
  97314. indexCount: number;
  97315. /** @hidden */
  97316. _linesIndexCount: number;
  97317. private _mesh;
  97318. private _renderingMesh;
  97319. private _boundingInfo;
  97320. private _linesIndexBuffer;
  97321. /** @hidden */
  97322. _lastColliderWorldVertices: Nullable<Vector3[]>;
  97323. /** @hidden */
  97324. _trianglePlanes: Plane[];
  97325. /** @hidden */
  97326. _lastColliderTransformMatrix: Nullable<Matrix>;
  97327. /** @hidden */
  97328. _renderId: number;
  97329. /** @hidden */
  97330. _alphaIndex: number;
  97331. /** @hidden */
  97332. _distanceToCamera: number;
  97333. /** @hidden */
  97334. _id: number;
  97335. private _currentMaterial;
  97336. /**
  97337. * Add a new submesh to a mesh
  97338. * @param materialIndex defines the material index to use
  97339. * @param verticesStart defines vertex index start
  97340. * @param verticesCount defines vertices count
  97341. * @param indexStart defines index start
  97342. * @param indexCount defines indices count
  97343. * @param mesh defines the parent mesh
  97344. * @param renderingMesh defines an optional rendering mesh
  97345. * @param createBoundingBox defines if bounding box should be created for this submesh
  97346. * @returns the new submesh
  97347. */
  97348. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  97349. /**
  97350. * Creates a new submesh
  97351. * @param materialIndex defines the material index to use
  97352. * @param verticesStart defines vertex index start
  97353. * @param verticesCount defines vertices count
  97354. * @param indexStart defines index start
  97355. * @param indexCount defines indices count
  97356. * @param mesh defines the parent mesh
  97357. * @param renderingMesh defines an optional rendering mesh
  97358. * @param createBoundingBox defines if bounding box should be created for this submesh
  97359. */
  97360. constructor(
  97361. /** the material index to use */
  97362. materialIndex: number,
  97363. /** vertex index start */
  97364. verticesStart: number,
  97365. /** vertices count */
  97366. verticesCount: number,
  97367. /** index start */
  97368. indexStart: number,
  97369. /** indices count */
  97370. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  97371. /**
  97372. * Returns true if this submesh covers the entire parent mesh
  97373. * @ignorenaming
  97374. */
  97375. get IsGlobal(): boolean;
  97376. /**
  97377. * Returns the submesh BoudingInfo object
  97378. * @returns current bounding info (or mesh's one if the submesh is global)
  97379. */
  97380. getBoundingInfo(): BoundingInfo;
  97381. /**
  97382. * Sets the submesh BoundingInfo
  97383. * @param boundingInfo defines the new bounding info to use
  97384. * @returns the SubMesh
  97385. */
  97386. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  97387. /**
  97388. * Returns the mesh of the current submesh
  97389. * @return the parent mesh
  97390. */
  97391. getMesh(): AbstractMesh;
  97392. /**
  97393. * Returns the rendering mesh of the submesh
  97394. * @returns the rendering mesh (could be different from parent mesh)
  97395. */
  97396. getRenderingMesh(): Mesh;
  97397. /**
  97398. * Returns the submesh material
  97399. * @returns null or the current material
  97400. */
  97401. getMaterial(): Nullable<Material>;
  97402. /**
  97403. * Sets a new updated BoundingInfo object to the submesh
  97404. * @param data defines an optional position array to use to determine the bounding info
  97405. * @returns the SubMesh
  97406. */
  97407. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  97408. /** @hidden */
  97409. _checkCollision(collider: Collider): boolean;
  97410. /**
  97411. * Updates the submesh BoundingInfo
  97412. * @param world defines the world matrix to use to update the bounding info
  97413. * @returns the submesh
  97414. */
  97415. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  97416. /**
  97417. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  97418. * @param frustumPlanes defines the frustum planes
  97419. * @returns true if the submesh is intersecting with the frustum
  97420. */
  97421. isInFrustum(frustumPlanes: Plane[]): boolean;
  97422. /**
  97423. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  97424. * @param frustumPlanes defines the frustum planes
  97425. * @returns true if the submesh is inside the frustum
  97426. */
  97427. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  97428. /**
  97429. * Renders the submesh
  97430. * @param enableAlphaMode defines if alpha needs to be used
  97431. * @returns the submesh
  97432. */
  97433. render(enableAlphaMode: boolean): SubMesh;
  97434. /**
  97435. * @hidden
  97436. */
  97437. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  97438. /**
  97439. * Checks if the submesh intersects with a ray
  97440. * @param ray defines the ray to test
  97441. * @returns true is the passed ray intersects the submesh bounding box
  97442. */
  97443. canIntersects(ray: Ray): boolean;
  97444. /**
  97445. * Intersects current submesh with a ray
  97446. * @param ray defines the ray to test
  97447. * @param positions defines mesh's positions array
  97448. * @param indices defines mesh's indices array
  97449. * @param fastCheck defines if the first intersection will be used (and not the closest)
  97450. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  97451. * @returns intersection info or null if no intersection
  97452. */
  97453. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  97454. /** @hidden */
  97455. private _intersectLines;
  97456. /** @hidden */
  97457. private _intersectUnIndexedLines;
  97458. /** @hidden */
  97459. private _intersectTriangles;
  97460. /** @hidden */
  97461. private _intersectUnIndexedTriangles;
  97462. /** @hidden */
  97463. _rebuild(): void;
  97464. /**
  97465. * Creates a new submesh from the passed mesh
  97466. * @param newMesh defines the new hosting mesh
  97467. * @param newRenderingMesh defines an optional rendering mesh
  97468. * @returns the new submesh
  97469. */
  97470. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  97471. /**
  97472. * Release associated resources
  97473. */
  97474. dispose(): void;
  97475. /**
  97476. * Gets the class name
  97477. * @returns the string "SubMesh".
  97478. */
  97479. getClassName(): string;
  97480. /**
  97481. * Creates a new submesh from indices data
  97482. * @param materialIndex the index of the main mesh material
  97483. * @param startIndex the index where to start the copy in the mesh indices array
  97484. * @param indexCount the number of indices to copy then from the startIndex
  97485. * @param mesh the main mesh to create the submesh from
  97486. * @param renderingMesh the optional rendering mesh
  97487. * @returns a new submesh
  97488. */
  97489. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  97490. }
  97491. }
  97492. declare module BABYLON {
  97493. /**
  97494. * Class used to represent data loading progression
  97495. */
  97496. export class SceneLoaderFlags {
  97497. private static _ForceFullSceneLoadingForIncremental;
  97498. private static _ShowLoadingScreen;
  97499. private static _CleanBoneMatrixWeights;
  97500. private static _loggingLevel;
  97501. /**
  97502. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  97503. */
  97504. static get ForceFullSceneLoadingForIncremental(): boolean;
  97505. static set ForceFullSceneLoadingForIncremental(value: boolean);
  97506. /**
  97507. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  97508. */
  97509. static get ShowLoadingScreen(): boolean;
  97510. static set ShowLoadingScreen(value: boolean);
  97511. /**
  97512. * Defines the current logging level (while loading the scene)
  97513. * @ignorenaming
  97514. */
  97515. static get loggingLevel(): number;
  97516. static set loggingLevel(value: number);
  97517. /**
  97518. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  97519. */
  97520. static get CleanBoneMatrixWeights(): boolean;
  97521. static set CleanBoneMatrixWeights(value: boolean);
  97522. }
  97523. }
  97524. declare module BABYLON {
  97525. /**
  97526. * Class used to store geometry data (vertex buffers + index buffer)
  97527. */
  97528. export class Geometry implements IGetSetVerticesData {
  97529. /**
  97530. * Gets or sets the ID of the geometry
  97531. */
  97532. id: string;
  97533. /**
  97534. * Gets or sets the unique ID of the geometry
  97535. */
  97536. uniqueId: number;
  97537. /**
  97538. * Gets the delay loading state of the geometry (none by default which means not delayed)
  97539. */
  97540. delayLoadState: number;
  97541. /**
  97542. * Gets the file containing the data to load when running in delay load state
  97543. */
  97544. delayLoadingFile: Nullable<string>;
  97545. /**
  97546. * Callback called when the geometry is updated
  97547. */
  97548. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  97549. private _scene;
  97550. private _engine;
  97551. private _meshes;
  97552. private _totalVertices;
  97553. /** @hidden */
  97554. _indices: IndicesArray;
  97555. /** @hidden */
  97556. _vertexBuffers: {
  97557. [key: string]: VertexBuffer;
  97558. };
  97559. private _isDisposed;
  97560. private _extend;
  97561. private _boundingBias;
  97562. /** @hidden */
  97563. _delayInfo: Array<string>;
  97564. private _indexBuffer;
  97565. private _indexBufferIsUpdatable;
  97566. /** @hidden */
  97567. _boundingInfo: Nullable<BoundingInfo>;
  97568. /** @hidden */
  97569. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  97570. /** @hidden */
  97571. _softwareSkinningFrameId: number;
  97572. private _vertexArrayObjects;
  97573. private _updatable;
  97574. /** @hidden */
  97575. _positions: Nullable<Vector3[]>;
  97576. /**
  97577. * 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
  97578. */
  97579. get boundingBias(): Vector2;
  97580. /**
  97581. * 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
  97582. */
  97583. set boundingBias(value: Vector2);
  97584. /**
  97585. * Static function used to attach a new empty geometry to a mesh
  97586. * @param mesh defines the mesh to attach the geometry to
  97587. * @returns the new Geometry
  97588. */
  97589. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  97590. /** Get the list of meshes using this geometry */
  97591. get meshes(): Mesh[];
  97592. /**
  97593. * Creates a new geometry
  97594. * @param id defines the unique ID
  97595. * @param scene defines the hosting scene
  97596. * @param vertexData defines the VertexData used to get geometry data
  97597. * @param updatable defines if geometry must be updatable (false by default)
  97598. * @param mesh defines the mesh that will be associated with the geometry
  97599. */
  97600. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  97601. /**
  97602. * Gets the current extend of the geometry
  97603. */
  97604. get extend(): {
  97605. minimum: Vector3;
  97606. maximum: Vector3;
  97607. };
  97608. /**
  97609. * Gets the hosting scene
  97610. * @returns the hosting Scene
  97611. */
  97612. getScene(): Scene;
  97613. /**
  97614. * Gets the hosting engine
  97615. * @returns the hosting Engine
  97616. */
  97617. getEngine(): Engine;
  97618. /**
  97619. * Defines if the geometry is ready to use
  97620. * @returns true if the geometry is ready to be used
  97621. */
  97622. isReady(): boolean;
  97623. /**
  97624. * Gets a value indicating that the geometry should not be serialized
  97625. */
  97626. get doNotSerialize(): boolean;
  97627. /** @hidden */
  97628. _rebuild(): void;
  97629. /**
  97630. * Affects all geometry data in one call
  97631. * @param vertexData defines the geometry data
  97632. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  97633. */
  97634. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  97635. /**
  97636. * Set specific vertex data
  97637. * @param kind defines the data kind (Position, normal, etc...)
  97638. * @param data defines the vertex data to use
  97639. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  97640. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  97641. */
  97642. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  97643. /**
  97644. * Removes a specific vertex data
  97645. * @param kind defines the data kind (Position, normal, etc...)
  97646. */
  97647. removeVerticesData(kind: string): void;
  97648. /**
  97649. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  97650. * @param buffer defines the vertex buffer to use
  97651. * @param totalVertices defines the total number of vertices for position kind (could be null)
  97652. */
  97653. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  97654. /**
  97655. * Update a specific vertex buffer
  97656. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  97657. * It will do nothing if the buffer is not updatable
  97658. * @param kind defines the data kind (Position, normal, etc...)
  97659. * @param data defines the data to use
  97660. * @param offset defines the offset in the target buffer where to store the data
  97661. * @param useBytes set to true if the offset is in bytes
  97662. */
  97663. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  97664. /**
  97665. * Update a specific vertex buffer
  97666. * This function will create a new buffer if the current one is not updatable
  97667. * @param kind defines the data kind (Position, normal, etc...)
  97668. * @param data defines the data to use
  97669. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  97670. */
  97671. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  97672. private _updateBoundingInfo;
  97673. /** @hidden */
  97674. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  97675. /**
  97676. * Gets total number of vertices
  97677. * @returns the total number of vertices
  97678. */
  97679. getTotalVertices(): number;
  97680. /**
  97681. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  97682. * @param kind defines the data kind (Position, normal, etc...)
  97683. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  97684. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  97685. * @returns a float array containing vertex data
  97686. */
  97687. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  97688. /**
  97689. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  97690. * @param kind defines the data kind (Position, normal, etc...)
  97691. * @returns true if the vertex buffer with the specified kind is updatable
  97692. */
  97693. isVertexBufferUpdatable(kind: string): boolean;
  97694. /**
  97695. * Gets a specific vertex buffer
  97696. * @param kind defines the data kind (Position, normal, etc...)
  97697. * @returns a VertexBuffer
  97698. */
  97699. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  97700. /**
  97701. * Returns all vertex buffers
  97702. * @return an object holding all vertex buffers indexed by kind
  97703. */
  97704. getVertexBuffers(): Nullable<{
  97705. [key: string]: VertexBuffer;
  97706. }>;
  97707. /**
  97708. * Gets a boolean indicating if specific vertex buffer is present
  97709. * @param kind defines the data kind (Position, normal, etc...)
  97710. * @returns true if data is present
  97711. */
  97712. isVerticesDataPresent(kind: string): boolean;
  97713. /**
  97714. * Gets a list of all attached data kinds (Position, normal, etc...)
  97715. * @returns a list of string containing all kinds
  97716. */
  97717. getVerticesDataKinds(): string[];
  97718. /**
  97719. * Update index buffer
  97720. * @param indices defines the indices to store in the index buffer
  97721. * @param offset defines the offset in the target buffer where to store the data
  97722. * @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)
  97723. */
  97724. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  97725. /**
  97726. * Creates a new index buffer
  97727. * @param indices defines the indices to store in the index buffer
  97728. * @param totalVertices defines the total number of vertices (could be null)
  97729. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  97730. */
  97731. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  97732. /**
  97733. * Return the total number of indices
  97734. * @returns the total number of indices
  97735. */
  97736. getTotalIndices(): number;
  97737. /**
  97738. * Gets the index buffer array
  97739. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  97740. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  97741. * @returns the index buffer array
  97742. */
  97743. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  97744. /**
  97745. * Gets the index buffer
  97746. * @return the index buffer
  97747. */
  97748. getIndexBuffer(): Nullable<DataBuffer>;
  97749. /** @hidden */
  97750. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  97751. /**
  97752. * Release the associated resources for a specific mesh
  97753. * @param mesh defines the source mesh
  97754. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  97755. */
  97756. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  97757. /**
  97758. * Apply current geometry to a given mesh
  97759. * @param mesh defines the mesh to apply geometry to
  97760. */
  97761. applyToMesh(mesh: Mesh): void;
  97762. private _updateExtend;
  97763. private _applyToMesh;
  97764. private notifyUpdate;
  97765. /**
  97766. * Load the geometry if it was flagged as delay loaded
  97767. * @param scene defines the hosting scene
  97768. * @param onLoaded defines a callback called when the geometry is loaded
  97769. */
  97770. load(scene: Scene, onLoaded?: () => void): void;
  97771. private _queueLoad;
  97772. /**
  97773. * Invert the geometry to move from a right handed system to a left handed one.
  97774. */
  97775. toLeftHanded(): void;
  97776. /** @hidden */
  97777. _resetPointsArrayCache(): void;
  97778. /** @hidden */
  97779. _generatePointsArray(): boolean;
  97780. /**
  97781. * Gets a value indicating if the geometry is disposed
  97782. * @returns true if the geometry was disposed
  97783. */
  97784. isDisposed(): boolean;
  97785. private _disposeVertexArrayObjects;
  97786. /**
  97787. * Free all associated resources
  97788. */
  97789. dispose(): void;
  97790. /**
  97791. * Clone the current geometry into a new geometry
  97792. * @param id defines the unique ID of the new geometry
  97793. * @returns a new geometry object
  97794. */
  97795. copy(id: string): Geometry;
  97796. /**
  97797. * Serialize the current geometry info (and not the vertices data) into a JSON object
  97798. * @return a JSON representation of the current geometry data (without the vertices data)
  97799. */
  97800. serialize(): any;
  97801. private toNumberArray;
  97802. /**
  97803. * Serialize all vertices data into a JSON oject
  97804. * @returns a JSON representation of the current geometry data
  97805. */
  97806. serializeVerticeData(): any;
  97807. /**
  97808. * Extracts a clone of a mesh geometry
  97809. * @param mesh defines the source mesh
  97810. * @param id defines the unique ID of the new geometry object
  97811. * @returns the new geometry object
  97812. */
  97813. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  97814. /**
  97815. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  97816. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  97817. * Be aware Math.random() could cause collisions, but:
  97818. * "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"
  97819. * @returns a string containing a new GUID
  97820. */
  97821. static RandomId(): string;
  97822. /** @hidden */
  97823. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  97824. private static _CleanMatricesWeights;
  97825. /**
  97826. * Create a new geometry from persisted data (Using .babylon file format)
  97827. * @param parsedVertexData defines the persisted data
  97828. * @param scene defines the hosting scene
  97829. * @param rootUrl defines the root url to use to load assets (like delayed data)
  97830. * @returns the new geometry object
  97831. */
  97832. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  97833. }
  97834. }
  97835. declare module BABYLON {
  97836. /**
  97837. * Define an interface for all classes that will get and set the data on vertices
  97838. */
  97839. export interface IGetSetVerticesData {
  97840. /**
  97841. * Gets a boolean indicating if specific vertex data is present
  97842. * @param kind defines the vertex data kind to use
  97843. * @returns true is data kind is present
  97844. */
  97845. isVerticesDataPresent(kind: string): boolean;
  97846. /**
  97847. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  97848. * @param kind defines the data kind (Position, normal, etc...)
  97849. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  97850. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  97851. * @returns a float array containing vertex data
  97852. */
  97853. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  97854. /**
  97855. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  97856. * @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.
  97857. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  97858. * @returns the indices array or an empty array if the mesh has no geometry
  97859. */
  97860. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  97861. /**
  97862. * Set specific vertex data
  97863. * @param kind defines the data kind (Position, normal, etc...)
  97864. * @param data defines the vertex data to use
  97865. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  97866. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  97867. */
  97868. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  97869. /**
  97870. * Update a specific associated vertex buffer
  97871. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  97872. * - VertexBuffer.PositionKind
  97873. * - VertexBuffer.UVKind
  97874. * - VertexBuffer.UV2Kind
  97875. * - VertexBuffer.UV3Kind
  97876. * - VertexBuffer.UV4Kind
  97877. * - VertexBuffer.UV5Kind
  97878. * - VertexBuffer.UV6Kind
  97879. * - VertexBuffer.ColorKind
  97880. * - VertexBuffer.MatricesIndicesKind
  97881. * - VertexBuffer.MatricesIndicesExtraKind
  97882. * - VertexBuffer.MatricesWeightsKind
  97883. * - VertexBuffer.MatricesWeightsExtraKind
  97884. * @param data defines the data source
  97885. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  97886. * @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)
  97887. */
  97888. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  97889. /**
  97890. * Creates a new index buffer
  97891. * @param indices defines the indices to store in the index buffer
  97892. * @param totalVertices defines the total number of vertices (could be null)
  97893. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  97894. */
  97895. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  97896. }
  97897. /**
  97898. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  97899. */
  97900. export class VertexData {
  97901. /**
  97902. * Mesh side orientation : usually the external or front surface
  97903. */
  97904. static readonly FRONTSIDE: number;
  97905. /**
  97906. * Mesh side orientation : usually the internal or back surface
  97907. */
  97908. static readonly BACKSIDE: number;
  97909. /**
  97910. * Mesh side orientation : both internal and external or front and back surfaces
  97911. */
  97912. static readonly DOUBLESIDE: number;
  97913. /**
  97914. * Mesh side orientation : by default, `FRONTSIDE`
  97915. */
  97916. static readonly DEFAULTSIDE: number;
  97917. /**
  97918. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  97919. */
  97920. positions: Nullable<FloatArray>;
  97921. /**
  97922. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  97923. */
  97924. normals: Nullable<FloatArray>;
  97925. /**
  97926. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  97927. */
  97928. tangents: Nullable<FloatArray>;
  97929. /**
  97930. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  97931. */
  97932. uvs: Nullable<FloatArray>;
  97933. /**
  97934. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  97935. */
  97936. uvs2: Nullable<FloatArray>;
  97937. /**
  97938. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  97939. */
  97940. uvs3: Nullable<FloatArray>;
  97941. /**
  97942. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  97943. */
  97944. uvs4: Nullable<FloatArray>;
  97945. /**
  97946. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  97947. */
  97948. uvs5: Nullable<FloatArray>;
  97949. /**
  97950. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  97951. */
  97952. uvs6: Nullable<FloatArray>;
  97953. /**
  97954. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  97955. */
  97956. colors: Nullable<FloatArray>;
  97957. /**
  97958. * 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).
  97959. */
  97960. matricesIndices: Nullable<FloatArray>;
  97961. /**
  97962. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  97963. */
  97964. matricesWeights: Nullable<FloatArray>;
  97965. /**
  97966. * An array extending the number of possible indices
  97967. */
  97968. matricesIndicesExtra: Nullable<FloatArray>;
  97969. /**
  97970. * An array extending the number of possible weights when the number of indices is extended
  97971. */
  97972. matricesWeightsExtra: Nullable<FloatArray>;
  97973. /**
  97974. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  97975. */
  97976. indices: Nullable<IndicesArray>;
  97977. /**
  97978. * Uses the passed data array to set the set the values for the specified kind of data
  97979. * @param data a linear array of floating numbers
  97980. * @param kind the type of data that is being set, eg positions, colors etc
  97981. */
  97982. set(data: FloatArray, kind: string): void;
  97983. /**
  97984. * Associates the vertexData to the passed Mesh.
  97985. * Sets it as updatable or not (default `false`)
  97986. * @param mesh the mesh the vertexData is applied to
  97987. * @param updatable when used and having the value true allows new data to update the vertexData
  97988. * @returns the VertexData
  97989. */
  97990. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  97991. /**
  97992. * Associates the vertexData to the passed Geometry.
  97993. * Sets it as updatable or not (default `false`)
  97994. * @param geometry the geometry the vertexData is applied to
  97995. * @param updatable when used and having the value true allows new data to update the vertexData
  97996. * @returns VertexData
  97997. */
  97998. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  97999. /**
  98000. * Updates the associated mesh
  98001. * @param mesh the mesh to be updated
  98002. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  98003. * @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
  98004. * @returns VertexData
  98005. */
  98006. updateMesh(mesh: Mesh): VertexData;
  98007. /**
  98008. * Updates the associated geometry
  98009. * @param geometry the geometry to be updated
  98010. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  98011. * @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
  98012. * @returns VertexData.
  98013. */
  98014. updateGeometry(geometry: Geometry): VertexData;
  98015. private _applyTo;
  98016. private _update;
  98017. /**
  98018. * Transforms each position and each normal of the vertexData according to the passed Matrix
  98019. * @param matrix the transforming matrix
  98020. * @returns the VertexData
  98021. */
  98022. transform(matrix: Matrix): VertexData;
  98023. /**
  98024. * Merges the passed VertexData into the current one
  98025. * @param other the VertexData to be merged into the current one
  98026. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  98027. * @returns the modified VertexData
  98028. */
  98029. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  98030. private _mergeElement;
  98031. private _validate;
  98032. /**
  98033. * Serializes the VertexData
  98034. * @returns a serialized object
  98035. */
  98036. serialize(): any;
  98037. /**
  98038. * Extracts the vertexData from a mesh
  98039. * @param mesh the mesh from which to extract the VertexData
  98040. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  98041. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  98042. * @returns the object VertexData associated to the passed mesh
  98043. */
  98044. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  98045. /**
  98046. * Extracts the vertexData from the geometry
  98047. * @param geometry the geometry from which to extract the VertexData
  98048. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  98049. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  98050. * @returns the object VertexData associated to the passed mesh
  98051. */
  98052. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  98053. private static _ExtractFrom;
  98054. /**
  98055. * Creates the VertexData for a Ribbon
  98056. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  98057. * * pathArray array of paths, each of which an array of successive Vector3
  98058. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  98059. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  98060. * * 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
  98061. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  98062. * * 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)
  98063. * * 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)
  98064. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  98065. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  98066. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  98067. * @returns the VertexData of the ribbon
  98068. */
  98069. static CreateRibbon(options: {
  98070. pathArray: Vector3[][];
  98071. closeArray?: boolean;
  98072. closePath?: boolean;
  98073. offset?: number;
  98074. sideOrientation?: number;
  98075. frontUVs?: Vector4;
  98076. backUVs?: Vector4;
  98077. invertUV?: boolean;
  98078. uvs?: Vector2[];
  98079. colors?: Color4[];
  98080. }): VertexData;
  98081. /**
  98082. * Creates the VertexData for a box
  98083. * @param options an object used to set the following optional parameters for the box, required but can be empty
  98084. * * size sets the width, height and depth of the box to the value of size, optional default 1
  98085. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  98086. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  98087. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  98088. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  98089. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  98090. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  98091. * * 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)
  98092. * * 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)
  98093. * @returns the VertexData of the box
  98094. */
  98095. static CreateBox(options: {
  98096. size?: number;
  98097. width?: number;
  98098. height?: number;
  98099. depth?: number;
  98100. faceUV?: Vector4[];
  98101. faceColors?: Color4[];
  98102. sideOrientation?: number;
  98103. frontUVs?: Vector4;
  98104. backUVs?: Vector4;
  98105. }): VertexData;
  98106. /**
  98107. * Creates the VertexData for a tiled box
  98108. * @param options an object used to set the following optional parameters for the box, required but can be empty
  98109. * * faceTiles sets the pattern, tile size and number of tiles for a face
  98110. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  98111. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  98112. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  98113. * @returns the VertexData of the box
  98114. */
  98115. static CreateTiledBox(options: {
  98116. pattern?: number;
  98117. width?: number;
  98118. height?: number;
  98119. depth?: number;
  98120. tileSize?: number;
  98121. tileWidth?: number;
  98122. tileHeight?: number;
  98123. alignHorizontal?: number;
  98124. alignVertical?: number;
  98125. faceUV?: Vector4[];
  98126. faceColors?: Color4[];
  98127. sideOrientation?: number;
  98128. }): VertexData;
  98129. /**
  98130. * Creates the VertexData for a tiled plane
  98131. * @param options an object used to set the following optional parameters for the box, required but can be empty
  98132. * * pattern a limited pattern arrangement depending on the number
  98133. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  98134. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  98135. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  98136. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  98137. * * 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)
  98138. * * 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)
  98139. * @returns the VertexData of the tiled plane
  98140. */
  98141. static CreateTiledPlane(options: {
  98142. pattern?: number;
  98143. tileSize?: number;
  98144. tileWidth?: number;
  98145. tileHeight?: number;
  98146. size?: number;
  98147. width?: number;
  98148. height?: number;
  98149. alignHorizontal?: number;
  98150. alignVertical?: number;
  98151. sideOrientation?: number;
  98152. frontUVs?: Vector4;
  98153. backUVs?: Vector4;
  98154. }): VertexData;
  98155. /**
  98156. * Creates the VertexData for an ellipsoid, defaults to a sphere
  98157. * @param options an object used to set the following optional parameters for the box, required but can be empty
  98158. * * segments sets the number of horizontal strips optional, default 32
  98159. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  98160. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  98161. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  98162. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  98163. * * 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
  98164. * * 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
  98165. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  98166. * * 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)
  98167. * * 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)
  98168. * @returns the VertexData of the ellipsoid
  98169. */
  98170. static CreateSphere(options: {
  98171. segments?: number;
  98172. diameter?: number;
  98173. diameterX?: number;
  98174. diameterY?: number;
  98175. diameterZ?: number;
  98176. arc?: number;
  98177. slice?: number;
  98178. sideOrientation?: number;
  98179. frontUVs?: Vector4;
  98180. backUVs?: Vector4;
  98181. }): VertexData;
  98182. /**
  98183. * Creates the VertexData for a cylinder, cone or prism
  98184. * @param options an object used to set the following optional parameters for the box, required but can be empty
  98185. * * height sets the height (y direction) of the cylinder, optional, default 2
  98186. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  98187. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  98188. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  98189. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  98190. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  98191. * * 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
  98192. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  98193. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  98194. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  98195. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  98196. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  98197. * * 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)
  98198. * * 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)
  98199. * @returns the VertexData of the cylinder, cone or prism
  98200. */
  98201. static CreateCylinder(options: {
  98202. height?: number;
  98203. diameterTop?: number;
  98204. diameterBottom?: number;
  98205. diameter?: number;
  98206. tessellation?: number;
  98207. subdivisions?: number;
  98208. arc?: number;
  98209. faceColors?: Color4[];
  98210. faceUV?: Vector4[];
  98211. hasRings?: boolean;
  98212. enclose?: boolean;
  98213. sideOrientation?: number;
  98214. frontUVs?: Vector4;
  98215. backUVs?: Vector4;
  98216. }): VertexData;
  98217. /**
  98218. * Creates the VertexData for a torus
  98219. * @param options an object used to set the following optional parameters for the box, required but can be empty
  98220. * * diameter the diameter of the torus, optional default 1
  98221. * * thickness the diameter of the tube forming the torus, optional default 0.5
  98222. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  98223. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  98224. * * 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)
  98225. * * 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)
  98226. * @returns the VertexData of the torus
  98227. */
  98228. static CreateTorus(options: {
  98229. diameter?: number;
  98230. thickness?: number;
  98231. tessellation?: number;
  98232. sideOrientation?: number;
  98233. frontUVs?: Vector4;
  98234. backUVs?: Vector4;
  98235. }): VertexData;
  98236. /**
  98237. * Creates the VertexData of the LineSystem
  98238. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  98239. * - lines an array of lines, each line being an array of successive Vector3
  98240. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  98241. * @returns the VertexData of the LineSystem
  98242. */
  98243. static CreateLineSystem(options: {
  98244. lines: Vector3[][];
  98245. colors?: Nullable<Color4[][]>;
  98246. }): VertexData;
  98247. /**
  98248. * Create the VertexData for a DashedLines
  98249. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  98250. * - points an array successive Vector3
  98251. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  98252. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  98253. * - dashNb the intended total number of dashes, optional, default 200
  98254. * @returns the VertexData for the DashedLines
  98255. */
  98256. static CreateDashedLines(options: {
  98257. points: Vector3[];
  98258. dashSize?: number;
  98259. gapSize?: number;
  98260. dashNb?: number;
  98261. }): VertexData;
  98262. /**
  98263. * Creates the VertexData for a Ground
  98264. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  98265. * - width the width (x direction) of the ground, optional, default 1
  98266. * - height the height (z direction) of the ground, optional, default 1
  98267. * - subdivisions the number of subdivisions per side, optional, default 1
  98268. * @returns the VertexData of the Ground
  98269. */
  98270. static CreateGround(options: {
  98271. width?: number;
  98272. height?: number;
  98273. subdivisions?: number;
  98274. subdivisionsX?: number;
  98275. subdivisionsY?: number;
  98276. }): VertexData;
  98277. /**
  98278. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  98279. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  98280. * * xmin the ground minimum X coordinate, optional, default -1
  98281. * * zmin the ground minimum Z coordinate, optional, default -1
  98282. * * xmax the ground maximum X coordinate, optional, default 1
  98283. * * zmax the ground maximum Z coordinate, optional, default 1
  98284. * * 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}
  98285. * * 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}
  98286. * @returns the VertexData of the TiledGround
  98287. */
  98288. static CreateTiledGround(options: {
  98289. xmin: number;
  98290. zmin: number;
  98291. xmax: number;
  98292. zmax: number;
  98293. subdivisions?: {
  98294. w: number;
  98295. h: number;
  98296. };
  98297. precision?: {
  98298. w: number;
  98299. h: number;
  98300. };
  98301. }): VertexData;
  98302. /**
  98303. * Creates the VertexData of the Ground designed from a heightmap
  98304. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  98305. * * width the width (x direction) of the ground
  98306. * * height the height (z direction) of the ground
  98307. * * subdivisions the number of subdivisions per side
  98308. * * minHeight the minimum altitude on the ground, optional, default 0
  98309. * * maxHeight the maximum altitude on the ground, optional default 1
  98310. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  98311. * * buffer the array holding the image color data
  98312. * * bufferWidth the width of image
  98313. * * bufferHeight the height of image
  98314. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  98315. * @returns the VertexData of the Ground designed from a heightmap
  98316. */
  98317. static CreateGroundFromHeightMap(options: {
  98318. width: number;
  98319. height: number;
  98320. subdivisions: number;
  98321. minHeight: number;
  98322. maxHeight: number;
  98323. colorFilter: Color3;
  98324. buffer: Uint8Array;
  98325. bufferWidth: number;
  98326. bufferHeight: number;
  98327. alphaFilter: number;
  98328. }): VertexData;
  98329. /**
  98330. * Creates the VertexData for a Plane
  98331. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  98332. * * size sets the width and height of the plane to the value of size, optional default 1
  98333. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  98334. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  98335. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  98336. * * 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)
  98337. * * 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)
  98338. * @returns the VertexData of the box
  98339. */
  98340. static CreatePlane(options: {
  98341. size?: number;
  98342. width?: number;
  98343. height?: number;
  98344. sideOrientation?: number;
  98345. frontUVs?: Vector4;
  98346. backUVs?: Vector4;
  98347. }): VertexData;
  98348. /**
  98349. * Creates the VertexData of the Disc or regular Polygon
  98350. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  98351. * * radius the radius of the disc, optional default 0.5
  98352. * * tessellation the number of polygon sides, optional, default 64
  98353. * * 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
  98354. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  98355. * * 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)
  98356. * * 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)
  98357. * @returns the VertexData of the box
  98358. */
  98359. static CreateDisc(options: {
  98360. radius?: number;
  98361. tessellation?: number;
  98362. arc?: number;
  98363. sideOrientation?: number;
  98364. frontUVs?: Vector4;
  98365. backUVs?: Vector4;
  98366. }): VertexData;
  98367. /**
  98368. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  98369. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  98370. * @param polygon a mesh built from polygonTriangulation.build()
  98371. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  98372. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  98373. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  98374. * @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)
  98375. * @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)
  98376. * @param wrap a boolean, default false, when true and fUVs used texture is wrapped around all sides, when false texture is applied side
  98377. * @returns the VertexData of the Polygon
  98378. */
  98379. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4, wrap?: boolean): VertexData;
  98380. /**
  98381. * Creates the VertexData of the IcoSphere
  98382. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  98383. * * radius the radius of the IcoSphere, optional default 1
  98384. * * radiusX allows stretching in the x direction, optional, default radius
  98385. * * radiusY allows stretching in the y direction, optional, default radius
  98386. * * radiusZ allows stretching in the z direction, optional, default radius
  98387. * * flat when true creates a flat shaded mesh, optional, default true
  98388. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  98389. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  98390. * * 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)
  98391. * * 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)
  98392. * @returns the VertexData of the IcoSphere
  98393. */
  98394. static CreateIcoSphere(options: {
  98395. radius?: number;
  98396. radiusX?: number;
  98397. radiusY?: number;
  98398. radiusZ?: number;
  98399. flat?: boolean;
  98400. subdivisions?: number;
  98401. sideOrientation?: number;
  98402. frontUVs?: Vector4;
  98403. backUVs?: Vector4;
  98404. }): VertexData;
  98405. /**
  98406. * Creates the VertexData for a Polyhedron
  98407. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  98408. * * type provided types are:
  98409. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  98410. * * 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)
  98411. * * size the size of the IcoSphere, optional default 1
  98412. * * sizeX allows stretching in the x direction, optional, default size
  98413. * * sizeY allows stretching in the y direction, optional, default size
  98414. * * sizeZ allows stretching in the z direction, optional, default size
  98415. * * 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
  98416. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  98417. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  98418. * * flat when true creates a flat shaded mesh, optional, default true
  98419. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  98420. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  98421. * * 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)
  98422. * * 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)
  98423. * @returns the VertexData of the Polyhedron
  98424. */
  98425. static CreatePolyhedron(options: {
  98426. type?: number;
  98427. size?: number;
  98428. sizeX?: number;
  98429. sizeY?: number;
  98430. sizeZ?: number;
  98431. custom?: any;
  98432. faceUV?: Vector4[];
  98433. faceColors?: Color4[];
  98434. flat?: boolean;
  98435. sideOrientation?: number;
  98436. frontUVs?: Vector4;
  98437. backUVs?: Vector4;
  98438. }): VertexData;
  98439. /**
  98440. * Creates the VertexData for a TorusKnot
  98441. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  98442. * * radius the radius of the torus knot, optional, default 2
  98443. * * tube the thickness of the tube, optional, default 0.5
  98444. * * radialSegments the number of sides on each tube segments, optional, default 32
  98445. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  98446. * * p the number of windings around the z axis, optional, default 2
  98447. * * q the number of windings around the x axis, optional, default 3
  98448. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  98449. * * 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)
  98450. * * 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)
  98451. * @returns the VertexData of the Torus Knot
  98452. */
  98453. static CreateTorusKnot(options: {
  98454. radius?: number;
  98455. tube?: number;
  98456. radialSegments?: number;
  98457. tubularSegments?: number;
  98458. p?: number;
  98459. q?: number;
  98460. sideOrientation?: number;
  98461. frontUVs?: Vector4;
  98462. backUVs?: Vector4;
  98463. }): VertexData;
  98464. /**
  98465. * Compute normals for given positions and indices
  98466. * @param positions an array of vertex positions, [...., x, y, z, ......]
  98467. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  98468. * @param normals an array of vertex normals, [...., x, y, z, ......]
  98469. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  98470. * * facetNormals : optional array of facet normals (vector3)
  98471. * * facetPositions : optional array of facet positions (vector3)
  98472. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  98473. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  98474. * * bInfo : optional bounding info, required for facetPartitioning computation
  98475. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  98476. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  98477. * * useRightHandedSystem: optional boolean to for right handed system computation
  98478. * * depthSort : optional boolean to enable the facet depth sort computation
  98479. * * distanceTo : optional Vector3 to compute the facet depth from this location
  98480. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  98481. */
  98482. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  98483. facetNormals?: any;
  98484. facetPositions?: any;
  98485. facetPartitioning?: any;
  98486. ratio?: number;
  98487. bInfo?: any;
  98488. bbSize?: Vector3;
  98489. subDiv?: any;
  98490. useRightHandedSystem?: boolean;
  98491. depthSort?: boolean;
  98492. distanceTo?: Vector3;
  98493. depthSortedFacets?: any;
  98494. }): void;
  98495. /** @hidden */
  98496. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  98497. /**
  98498. * Applies VertexData created from the imported parameters to the geometry
  98499. * @param parsedVertexData the parsed data from an imported file
  98500. * @param geometry the geometry to apply the VertexData to
  98501. */
  98502. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  98503. }
  98504. }
  98505. declare module BABYLON {
  98506. /**
  98507. * Defines a target to use with MorphTargetManager
  98508. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  98509. */
  98510. export class MorphTarget implements IAnimatable {
  98511. /** defines the name of the target */
  98512. name: string;
  98513. /**
  98514. * Gets or sets the list of animations
  98515. */
  98516. animations: Animation[];
  98517. private _scene;
  98518. private _positions;
  98519. private _normals;
  98520. private _tangents;
  98521. private _uvs;
  98522. private _influence;
  98523. private _uniqueId;
  98524. /**
  98525. * Observable raised when the influence changes
  98526. */
  98527. onInfluenceChanged: Observable<boolean>;
  98528. /** @hidden */
  98529. _onDataLayoutChanged: Observable<void>;
  98530. /**
  98531. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  98532. */
  98533. get influence(): number;
  98534. set influence(influence: number);
  98535. /**
  98536. * Gets or sets the id of the morph Target
  98537. */
  98538. id: string;
  98539. private _animationPropertiesOverride;
  98540. /**
  98541. * Gets or sets the animation properties override
  98542. */
  98543. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  98544. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  98545. /**
  98546. * Creates a new MorphTarget
  98547. * @param name defines the name of the target
  98548. * @param influence defines the influence to use
  98549. * @param scene defines the scene the morphtarget belongs to
  98550. */
  98551. constructor(
  98552. /** defines the name of the target */
  98553. name: string, influence?: number, scene?: Nullable<Scene>);
  98554. /**
  98555. * Gets the unique ID of this manager
  98556. */
  98557. get uniqueId(): number;
  98558. /**
  98559. * Gets a boolean defining if the target contains position data
  98560. */
  98561. get hasPositions(): boolean;
  98562. /**
  98563. * Gets a boolean defining if the target contains normal data
  98564. */
  98565. get hasNormals(): boolean;
  98566. /**
  98567. * Gets a boolean defining if the target contains tangent data
  98568. */
  98569. get hasTangents(): boolean;
  98570. /**
  98571. * Gets a boolean defining if the target contains texture coordinates data
  98572. */
  98573. get hasUVs(): boolean;
  98574. /**
  98575. * Affects position data to this target
  98576. * @param data defines the position data to use
  98577. */
  98578. setPositions(data: Nullable<FloatArray>): void;
  98579. /**
  98580. * Gets the position data stored in this target
  98581. * @returns a FloatArray containing the position data (or null if not present)
  98582. */
  98583. getPositions(): Nullable<FloatArray>;
  98584. /**
  98585. * Affects normal data to this target
  98586. * @param data defines the normal data to use
  98587. */
  98588. setNormals(data: Nullable<FloatArray>): void;
  98589. /**
  98590. * Gets the normal data stored in this target
  98591. * @returns a FloatArray containing the normal data (or null if not present)
  98592. */
  98593. getNormals(): Nullable<FloatArray>;
  98594. /**
  98595. * Affects tangent data to this target
  98596. * @param data defines the tangent data to use
  98597. */
  98598. setTangents(data: Nullable<FloatArray>): void;
  98599. /**
  98600. * Gets the tangent data stored in this target
  98601. * @returns a FloatArray containing the tangent data (or null if not present)
  98602. */
  98603. getTangents(): Nullable<FloatArray>;
  98604. /**
  98605. * Affects texture coordinates data to this target
  98606. * @param data defines the texture coordinates data to use
  98607. */
  98608. setUVs(data: Nullable<FloatArray>): void;
  98609. /**
  98610. * Gets the texture coordinates data stored in this target
  98611. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  98612. */
  98613. getUVs(): Nullable<FloatArray>;
  98614. /**
  98615. * Clone the current target
  98616. * @returns a new MorphTarget
  98617. */
  98618. clone(): MorphTarget;
  98619. /**
  98620. * Serializes the current target into a Serialization object
  98621. * @returns the serialized object
  98622. */
  98623. serialize(): any;
  98624. /**
  98625. * Returns the string "MorphTarget"
  98626. * @returns "MorphTarget"
  98627. */
  98628. getClassName(): string;
  98629. /**
  98630. * Creates a new target from serialized data
  98631. * @param serializationObject defines the serialized data to use
  98632. * @returns a new MorphTarget
  98633. */
  98634. static Parse(serializationObject: any): MorphTarget;
  98635. /**
  98636. * Creates a MorphTarget from mesh data
  98637. * @param mesh defines the source mesh
  98638. * @param name defines the name to use for the new target
  98639. * @param influence defines the influence to attach to the target
  98640. * @returns a new MorphTarget
  98641. */
  98642. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  98643. }
  98644. }
  98645. declare module BABYLON {
  98646. /**
  98647. * This class is used to deform meshes using morphing between different targets
  98648. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  98649. */
  98650. export class MorphTargetManager {
  98651. private _targets;
  98652. private _targetInfluenceChangedObservers;
  98653. private _targetDataLayoutChangedObservers;
  98654. private _activeTargets;
  98655. private _scene;
  98656. private _influences;
  98657. private _supportsNormals;
  98658. private _supportsTangents;
  98659. private _supportsUVs;
  98660. private _vertexCount;
  98661. private _uniqueId;
  98662. private _tempInfluences;
  98663. /**
  98664. * Gets or sets a boolean indicating if normals must be morphed
  98665. */
  98666. enableNormalMorphing: boolean;
  98667. /**
  98668. * Gets or sets a boolean indicating if tangents must be morphed
  98669. */
  98670. enableTangentMorphing: boolean;
  98671. /**
  98672. * Gets or sets a boolean indicating if UV must be morphed
  98673. */
  98674. enableUVMorphing: boolean;
  98675. /**
  98676. * Creates a new MorphTargetManager
  98677. * @param scene defines the current scene
  98678. */
  98679. constructor(scene?: Nullable<Scene>);
  98680. /**
  98681. * Gets the unique ID of this manager
  98682. */
  98683. get uniqueId(): number;
  98684. /**
  98685. * Gets the number of vertices handled by this manager
  98686. */
  98687. get vertexCount(): number;
  98688. /**
  98689. * Gets a boolean indicating if this manager supports morphing of normals
  98690. */
  98691. get supportsNormals(): boolean;
  98692. /**
  98693. * Gets a boolean indicating if this manager supports morphing of tangents
  98694. */
  98695. get supportsTangents(): boolean;
  98696. /**
  98697. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  98698. */
  98699. get supportsUVs(): boolean;
  98700. /**
  98701. * Gets the number of targets stored in this manager
  98702. */
  98703. get numTargets(): number;
  98704. /**
  98705. * Gets the number of influencers (ie. the number of targets with influences > 0)
  98706. */
  98707. get numInfluencers(): number;
  98708. /**
  98709. * Gets the list of influences (one per target)
  98710. */
  98711. get influences(): Float32Array;
  98712. /**
  98713. * Gets the active target at specified index. An active target is a target with an influence > 0
  98714. * @param index defines the index to check
  98715. * @returns the requested target
  98716. */
  98717. getActiveTarget(index: number): MorphTarget;
  98718. /**
  98719. * Gets the target at specified index
  98720. * @param index defines the index to check
  98721. * @returns the requested target
  98722. */
  98723. getTarget(index: number): MorphTarget;
  98724. /**
  98725. * Add a new target to this manager
  98726. * @param target defines the target to add
  98727. */
  98728. addTarget(target: MorphTarget): void;
  98729. /**
  98730. * Removes a target from the manager
  98731. * @param target defines the target to remove
  98732. */
  98733. removeTarget(target: MorphTarget): void;
  98734. /**
  98735. * Clone the current manager
  98736. * @returns a new MorphTargetManager
  98737. */
  98738. clone(): MorphTargetManager;
  98739. /**
  98740. * Serializes the current manager into a Serialization object
  98741. * @returns the serialized object
  98742. */
  98743. serialize(): any;
  98744. private _syncActiveTargets;
  98745. /**
  98746. * Syncrhonize the targets with all the meshes using this morph target manager
  98747. */
  98748. synchronize(): void;
  98749. /**
  98750. * Creates a new MorphTargetManager from serialized data
  98751. * @param serializationObject defines the serialized data
  98752. * @param scene defines the hosting scene
  98753. * @returns the new MorphTargetManager
  98754. */
  98755. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  98756. }
  98757. }
  98758. declare module BABYLON {
  98759. /**
  98760. * Class used to represent a specific level of detail of a mesh
  98761. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  98762. */
  98763. export class MeshLODLevel {
  98764. /** Defines the distance where this level should start being displayed */
  98765. distance: number;
  98766. /** Defines the mesh to use to render this level */
  98767. mesh: Nullable<Mesh>;
  98768. /**
  98769. * Creates a new LOD level
  98770. * @param distance defines the distance where this level should star being displayed
  98771. * @param mesh defines the mesh to use to render this level
  98772. */
  98773. constructor(
  98774. /** Defines the distance where this level should start being displayed */
  98775. distance: number,
  98776. /** Defines the mesh to use to render this level */
  98777. mesh: Nullable<Mesh>);
  98778. }
  98779. }
  98780. declare module BABYLON {
  98781. /**
  98782. * Mesh representing the gorund
  98783. */
  98784. export class GroundMesh extends Mesh {
  98785. /** If octree should be generated */
  98786. generateOctree: boolean;
  98787. private _heightQuads;
  98788. /** @hidden */
  98789. _subdivisionsX: number;
  98790. /** @hidden */
  98791. _subdivisionsY: number;
  98792. /** @hidden */
  98793. _width: number;
  98794. /** @hidden */
  98795. _height: number;
  98796. /** @hidden */
  98797. _minX: number;
  98798. /** @hidden */
  98799. _maxX: number;
  98800. /** @hidden */
  98801. _minZ: number;
  98802. /** @hidden */
  98803. _maxZ: number;
  98804. constructor(name: string, scene: Scene);
  98805. /**
  98806. * "GroundMesh"
  98807. * @returns "GroundMesh"
  98808. */
  98809. getClassName(): string;
  98810. /**
  98811. * The minimum of x and y subdivisions
  98812. */
  98813. get subdivisions(): number;
  98814. /**
  98815. * X subdivisions
  98816. */
  98817. get subdivisionsX(): number;
  98818. /**
  98819. * Y subdivisions
  98820. */
  98821. get subdivisionsY(): number;
  98822. /**
  98823. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  98824. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  98825. * @param chunksCount the number of subdivisions for x and y
  98826. * @param octreeBlocksSize (Default: 32)
  98827. */
  98828. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  98829. /**
  98830. * Returns a height (y) value in the Worl system :
  98831. * the ground altitude at the coordinates (x, z) expressed in the World system.
  98832. * @param x x coordinate
  98833. * @param z z coordinate
  98834. * @returns the ground y position if (x, z) are outside the ground surface.
  98835. */
  98836. getHeightAtCoordinates(x: number, z: number): number;
  98837. /**
  98838. * Returns a normalized vector (Vector3) orthogonal to the ground
  98839. * at the ground coordinates (x, z) expressed in the World system.
  98840. * @param x x coordinate
  98841. * @param z z coordinate
  98842. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  98843. */
  98844. getNormalAtCoordinates(x: number, z: number): Vector3;
  98845. /**
  98846. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  98847. * at the ground coordinates (x, z) expressed in the World system.
  98848. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  98849. * @param x x coordinate
  98850. * @param z z coordinate
  98851. * @param ref vector to store the result
  98852. * @returns the GroundMesh.
  98853. */
  98854. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  98855. /**
  98856. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  98857. * if the ground has been updated.
  98858. * This can be used in the render loop.
  98859. * @returns the GroundMesh.
  98860. */
  98861. updateCoordinateHeights(): GroundMesh;
  98862. private _getFacetAt;
  98863. private _initHeightQuads;
  98864. private _computeHeightQuads;
  98865. /**
  98866. * Serializes this ground mesh
  98867. * @param serializationObject object to write serialization to
  98868. */
  98869. serialize(serializationObject: any): void;
  98870. /**
  98871. * Parses a serialized ground mesh
  98872. * @param parsedMesh the serialized mesh
  98873. * @param scene the scene to create the ground mesh in
  98874. * @returns the created ground mesh
  98875. */
  98876. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  98877. }
  98878. }
  98879. declare module BABYLON {
  98880. /**
  98881. * Interface for Physics-Joint data
  98882. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  98883. */
  98884. export interface PhysicsJointData {
  98885. /**
  98886. * The main pivot of the joint
  98887. */
  98888. mainPivot?: Vector3;
  98889. /**
  98890. * The connected pivot of the joint
  98891. */
  98892. connectedPivot?: Vector3;
  98893. /**
  98894. * The main axis of the joint
  98895. */
  98896. mainAxis?: Vector3;
  98897. /**
  98898. * The connected axis of the joint
  98899. */
  98900. connectedAxis?: Vector3;
  98901. /**
  98902. * The collision of the joint
  98903. */
  98904. collision?: boolean;
  98905. /**
  98906. * Native Oimo/Cannon/Energy data
  98907. */
  98908. nativeParams?: any;
  98909. }
  98910. /**
  98911. * This is a holder class for the physics joint created by the physics plugin
  98912. * It holds a set of functions to control the underlying joint
  98913. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  98914. */
  98915. export class PhysicsJoint {
  98916. /**
  98917. * The type of the physics joint
  98918. */
  98919. type: number;
  98920. /**
  98921. * The data for the physics joint
  98922. */
  98923. jointData: PhysicsJointData;
  98924. private _physicsJoint;
  98925. protected _physicsPlugin: IPhysicsEnginePlugin;
  98926. /**
  98927. * Initializes the physics joint
  98928. * @param type The type of the physics joint
  98929. * @param jointData The data for the physics joint
  98930. */
  98931. constructor(
  98932. /**
  98933. * The type of the physics joint
  98934. */
  98935. type: number,
  98936. /**
  98937. * The data for the physics joint
  98938. */
  98939. jointData: PhysicsJointData);
  98940. /**
  98941. * Gets the physics joint
  98942. */
  98943. get physicsJoint(): any;
  98944. /**
  98945. * Sets the physics joint
  98946. */
  98947. set physicsJoint(newJoint: any);
  98948. /**
  98949. * Sets the physics plugin
  98950. */
  98951. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  98952. /**
  98953. * Execute a function that is physics-plugin specific.
  98954. * @param {Function} func the function that will be executed.
  98955. * It accepts two parameters: the physics world and the physics joint
  98956. */
  98957. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  98958. /**
  98959. * Distance-Joint type
  98960. */
  98961. static DistanceJoint: number;
  98962. /**
  98963. * Hinge-Joint type
  98964. */
  98965. static HingeJoint: number;
  98966. /**
  98967. * Ball-and-Socket joint type
  98968. */
  98969. static BallAndSocketJoint: number;
  98970. /**
  98971. * Wheel-Joint type
  98972. */
  98973. static WheelJoint: number;
  98974. /**
  98975. * Slider-Joint type
  98976. */
  98977. static SliderJoint: number;
  98978. /**
  98979. * Prismatic-Joint type
  98980. */
  98981. static PrismaticJoint: number;
  98982. /**
  98983. * Universal-Joint type
  98984. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  98985. */
  98986. static UniversalJoint: number;
  98987. /**
  98988. * Hinge-Joint 2 type
  98989. */
  98990. static Hinge2Joint: number;
  98991. /**
  98992. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  98993. */
  98994. static PointToPointJoint: number;
  98995. /**
  98996. * Spring-Joint type
  98997. */
  98998. static SpringJoint: number;
  98999. /**
  99000. * Lock-Joint type
  99001. */
  99002. static LockJoint: number;
  99003. }
  99004. /**
  99005. * A class representing a physics distance joint
  99006. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  99007. */
  99008. export class DistanceJoint extends PhysicsJoint {
  99009. /**
  99010. *
  99011. * @param jointData The data for the Distance-Joint
  99012. */
  99013. constructor(jointData: DistanceJointData);
  99014. /**
  99015. * Update the predefined distance.
  99016. * @param maxDistance The maximum preferred distance
  99017. * @param minDistance The minimum preferred distance
  99018. */
  99019. updateDistance(maxDistance: number, minDistance?: number): void;
  99020. }
  99021. /**
  99022. * Represents a Motor-Enabled Joint
  99023. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  99024. */
  99025. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  99026. /**
  99027. * Initializes the Motor-Enabled Joint
  99028. * @param type The type of the joint
  99029. * @param jointData The physica joint data for the joint
  99030. */
  99031. constructor(type: number, jointData: PhysicsJointData);
  99032. /**
  99033. * Set the motor values.
  99034. * Attention, this function is plugin specific. Engines won't react 100% the same.
  99035. * @param force the force to apply
  99036. * @param maxForce max force for this motor.
  99037. */
  99038. setMotor(force?: number, maxForce?: number): void;
  99039. /**
  99040. * Set the motor's limits.
  99041. * Attention, this function is plugin specific. Engines won't react 100% the same.
  99042. * @param upperLimit The upper limit of the motor
  99043. * @param lowerLimit The lower limit of the motor
  99044. */
  99045. setLimit(upperLimit: number, lowerLimit?: number): void;
  99046. }
  99047. /**
  99048. * This class represents a single physics Hinge-Joint
  99049. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  99050. */
  99051. export class HingeJoint extends MotorEnabledJoint {
  99052. /**
  99053. * Initializes the Hinge-Joint
  99054. * @param jointData The joint data for the Hinge-Joint
  99055. */
  99056. constructor(jointData: PhysicsJointData);
  99057. /**
  99058. * Set the motor values.
  99059. * Attention, this function is plugin specific. Engines won't react 100% the same.
  99060. * @param {number} force the force to apply
  99061. * @param {number} maxForce max force for this motor.
  99062. */
  99063. setMotor(force?: number, maxForce?: number): void;
  99064. /**
  99065. * Set the motor's limits.
  99066. * Attention, this function is plugin specific. Engines won't react 100% the same.
  99067. * @param upperLimit The upper limit of the motor
  99068. * @param lowerLimit The lower limit of the motor
  99069. */
  99070. setLimit(upperLimit: number, lowerLimit?: number): void;
  99071. }
  99072. /**
  99073. * This class represents a dual hinge physics joint (same as wheel joint)
  99074. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  99075. */
  99076. export class Hinge2Joint extends MotorEnabledJoint {
  99077. /**
  99078. * Initializes the Hinge2-Joint
  99079. * @param jointData The joint data for the Hinge2-Joint
  99080. */
  99081. constructor(jointData: PhysicsJointData);
  99082. /**
  99083. * Set the motor values.
  99084. * Attention, this function is plugin specific. Engines won't react 100% the same.
  99085. * @param {number} targetSpeed the speed the motor is to reach
  99086. * @param {number} maxForce max force for this motor.
  99087. * @param {motorIndex} the motor's index, 0 or 1.
  99088. */
  99089. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  99090. /**
  99091. * Set the motor limits.
  99092. * Attention, this function is plugin specific. Engines won't react 100% the same.
  99093. * @param {number} upperLimit the upper limit
  99094. * @param {number} lowerLimit lower limit
  99095. * @param {motorIndex} the motor's index, 0 or 1.
  99096. */
  99097. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  99098. }
  99099. /**
  99100. * Interface for a motor enabled joint
  99101. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  99102. */
  99103. export interface IMotorEnabledJoint {
  99104. /**
  99105. * Physics joint
  99106. */
  99107. physicsJoint: any;
  99108. /**
  99109. * Sets the motor of the motor-enabled joint
  99110. * @param force The force of the motor
  99111. * @param maxForce The maximum force of the motor
  99112. * @param motorIndex The index of the motor
  99113. */
  99114. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  99115. /**
  99116. * Sets the limit of the motor
  99117. * @param upperLimit The upper limit of the motor
  99118. * @param lowerLimit The lower limit of the motor
  99119. * @param motorIndex The index of the motor
  99120. */
  99121. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  99122. }
  99123. /**
  99124. * Joint data for a Distance-Joint
  99125. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  99126. */
  99127. export interface DistanceJointData extends PhysicsJointData {
  99128. /**
  99129. * Max distance the 2 joint objects can be apart
  99130. */
  99131. maxDistance: number;
  99132. }
  99133. /**
  99134. * Joint data from a spring joint
  99135. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  99136. */
  99137. export interface SpringJointData extends PhysicsJointData {
  99138. /**
  99139. * Length of the spring
  99140. */
  99141. length: number;
  99142. /**
  99143. * Stiffness of the spring
  99144. */
  99145. stiffness: number;
  99146. /**
  99147. * Damping of the spring
  99148. */
  99149. damping: number;
  99150. /** this callback will be called when applying the force to the impostors. */
  99151. forceApplicationCallback: () => void;
  99152. }
  99153. }
  99154. declare module BABYLON {
  99155. /**
  99156. * Holds the data for the raycast result
  99157. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  99158. */
  99159. export class PhysicsRaycastResult {
  99160. private _hasHit;
  99161. private _hitDistance;
  99162. private _hitNormalWorld;
  99163. private _hitPointWorld;
  99164. private _rayFromWorld;
  99165. private _rayToWorld;
  99166. /**
  99167. * Gets if there was a hit
  99168. */
  99169. get hasHit(): boolean;
  99170. /**
  99171. * Gets the distance from the hit
  99172. */
  99173. get hitDistance(): number;
  99174. /**
  99175. * Gets the hit normal/direction in the world
  99176. */
  99177. get hitNormalWorld(): Vector3;
  99178. /**
  99179. * Gets the hit point in the world
  99180. */
  99181. get hitPointWorld(): Vector3;
  99182. /**
  99183. * Gets the ray "start point" of the ray in the world
  99184. */
  99185. get rayFromWorld(): Vector3;
  99186. /**
  99187. * Gets the ray "end point" of the ray in the world
  99188. */
  99189. get rayToWorld(): Vector3;
  99190. /**
  99191. * Sets the hit data (normal & point in world space)
  99192. * @param hitNormalWorld defines the normal in world space
  99193. * @param hitPointWorld defines the point in world space
  99194. */
  99195. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  99196. /**
  99197. * Sets the distance from the start point to the hit point
  99198. * @param distance
  99199. */
  99200. setHitDistance(distance: number): void;
  99201. /**
  99202. * Calculates the distance manually
  99203. */
  99204. calculateHitDistance(): void;
  99205. /**
  99206. * Resets all the values to default
  99207. * @param from The from point on world space
  99208. * @param to The to point on world space
  99209. */
  99210. reset(from?: Vector3, to?: Vector3): void;
  99211. }
  99212. /**
  99213. * Interface for the size containing width and height
  99214. */
  99215. interface IXYZ {
  99216. /**
  99217. * X
  99218. */
  99219. x: number;
  99220. /**
  99221. * Y
  99222. */
  99223. y: number;
  99224. /**
  99225. * Z
  99226. */
  99227. z: number;
  99228. }
  99229. }
  99230. declare module BABYLON {
  99231. /**
  99232. * Interface used to describe a physics joint
  99233. */
  99234. export interface PhysicsImpostorJoint {
  99235. /** Defines the main impostor to which the joint is linked */
  99236. mainImpostor: PhysicsImpostor;
  99237. /** Defines the impostor that is connected to the main impostor using this joint */
  99238. connectedImpostor: PhysicsImpostor;
  99239. /** Defines the joint itself */
  99240. joint: PhysicsJoint;
  99241. }
  99242. /** @hidden */
  99243. export interface IPhysicsEnginePlugin {
  99244. world: any;
  99245. name: string;
  99246. setGravity(gravity: Vector3): void;
  99247. setTimeStep(timeStep: number): void;
  99248. getTimeStep(): number;
  99249. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  99250. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  99251. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  99252. generatePhysicsBody(impostor: PhysicsImpostor): void;
  99253. removePhysicsBody(impostor: PhysicsImpostor): void;
  99254. generateJoint(joint: PhysicsImpostorJoint): void;
  99255. removeJoint(joint: PhysicsImpostorJoint): void;
  99256. isSupported(): boolean;
  99257. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  99258. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  99259. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  99260. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  99261. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  99262. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  99263. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  99264. getBodyMass(impostor: PhysicsImpostor): number;
  99265. getBodyFriction(impostor: PhysicsImpostor): number;
  99266. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  99267. getBodyRestitution(impostor: PhysicsImpostor): number;
  99268. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  99269. getBodyPressure?(impostor: PhysicsImpostor): number;
  99270. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  99271. getBodyStiffness?(impostor: PhysicsImpostor): number;
  99272. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  99273. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  99274. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  99275. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  99276. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  99277. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  99278. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  99279. sleepBody(impostor: PhysicsImpostor): void;
  99280. wakeUpBody(impostor: PhysicsImpostor): void;
  99281. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  99282. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  99283. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  99284. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  99285. getRadius(impostor: PhysicsImpostor): number;
  99286. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  99287. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  99288. dispose(): void;
  99289. }
  99290. /**
  99291. * Interface used to define a physics engine
  99292. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  99293. */
  99294. export interface IPhysicsEngine {
  99295. /**
  99296. * Gets the gravity vector used by the simulation
  99297. */
  99298. gravity: Vector3;
  99299. /**
  99300. * Sets the gravity vector used by the simulation
  99301. * @param gravity defines the gravity vector to use
  99302. */
  99303. setGravity(gravity: Vector3): void;
  99304. /**
  99305. * Set the time step of the physics engine.
  99306. * Default is 1/60.
  99307. * To slow it down, enter 1/600 for example.
  99308. * To speed it up, 1/30
  99309. * @param newTimeStep the new timestep to apply to this world.
  99310. */
  99311. setTimeStep(newTimeStep: number): void;
  99312. /**
  99313. * Get the time step of the physics engine.
  99314. * @returns the current time step
  99315. */
  99316. getTimeStep(): number;
  99317. /**
  99318. * Set the sub time step of the physics engine.
  99319. * Default is 0 meaning there is no sub steps
  99320. * To increase physics resolution precision, set a small value (like 1 ms)
  99321. * @param subTimeStep defines the new sub timestep used for physics resolution.
  99322. */
  99323. setSubTimeStep(subTimeStep: number): void;
  99324. /**
  99325. * Get the sub time step of the physics engine.
  99326. * @returns the current sub time step
  99327. */
  99328. getSubTimeStep(): number;
  99329. /**
  99330. * Release all resources
  99331. */
  99332. dispose(): void;
  99333. /**
  99334. * Gets the name of the current physics plugin
  99335. * @returns the name of the plugin
  99336. */
  99337. getPhysicsPluginName(): string;
  99338. /**
  99339. * Adding a new impostor for the impostor tracking.
  99340. * This will be done by the impostor itself.
  99341. * @param impostor the impostor to add
  99342. */
  99343. addImpostor(impostor: PhysicsImpostor): void;
  99344. /**
  99345. * Remove an impostor from the engine.
  99346. * This impostor and its mesh will not longer be updated by the physics engine.
  99347. * @param impostor the impostor to remove
  99348. */
  99349. removeImpostor(impostor: PhysicsImpostor): void;
  99350. /**
  99351. * Add a joint to the physics engine
  99352. * @param mainImpostor defines the main impostor to which the joint is added.
  99353. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  99354. * @param joint defines the joint that will connect both impostors.
  99355. */
  99356. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  99357. /**
  99358. * Removes a joint from the simulation
  99359. * @param mainImpostor defines the impostor used with the joint
  99360. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  99361. * @param joint defines the joint to remove
  99362. */
  99363. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  99364. /**
  99365. * Gets the current plugin used to run the simulation
  99366. * @returns current plugin
  99367. */
  99368. getPhysicsPlugin(): IPhysicsEnginePlugin;
  99369. /**
  99370. * Gets the list of physic impostors
  99371. * @returns an array of PhysicsImpostor
  99372. */
  99373. getImpostors(): Array<PhysicsImpostor>;
  99374. /**
  99375. * Gets the impostor for a physics enabled object
  99376. * @param object defines the object impersonated by the impostor
  99377. * @returns the PhysicsImpostor or null if not found
  99378. */
  99379. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  99380. /**
  99381. * Gets the impostor for a physics body object
  99382. * @param body defines physics body used by the impostor
  99383. * @returns the PhysicsImpostor or null if not found
  99384. */
  99385. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  99386. /**
  99387. * Does a raycast in the physics world
  99388. * @param from when should the ray start?
  99389. * @param to when should the ray end?
  99390. * @returns PhysicsRaycastResult
  99391. */
  99392. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  99393. /**
  99394. * Called by the scene. No need to call it.
  99395. * @param delta defines the timespam between frames
  99396. */
  99397. _step(delta: number): void;
  99398. }
  99399. }
  99400. declare module BABYLON {
  99401. /**
  99402. * The interface for the physics imposter parameters
  99403. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  99404. */
  99405. export interface PhysicsImpostorParameters {
  99406. /**
  99407. * The mass of the physics imposter
  99408. */
  99409. mass: number;
  99410. /**
  99411. * The friction of the physics imposter
  99412. */
  99413. friction?: number;
  99414. /**
  99415. * The coefficient of restitution of the physics imposter
  99416. */
  99417. restitution?: number;
  99418. /**
  99419. * The native options of the physics imposter
  99420. */
  99421. nativeOptions?: any;
  99422. /**
  99423. * Specifies if the parent should be ignored
  99424. */
  99425. ignoreParent?: boolean;
  99426. /**
  99427. * Specifies if bi-directional transformations should be disabled
  99428. */
  99429. disableBidirectionalTransformation?: boolean;
  99430. /**
  99431. * The pressure inside the physics imposter, soft object only
  99432. */
  99433. pressure?: number;
  99434. /**
  99435. * The stiffness the physics imposter, soft object only
  99436. */
  99437. stiffness?: number;
  99438. /**
  99439. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  99440. */
  99441. velocityIterations?: number;
  99442. /**
  99443. * The number of iterations used in maintaining consistent vertex positions, soft object only
  99444. */
  99445. positionIterations?: number;
  99446. /**
  99447. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  99448. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  99449. * Add to fix multiple points
  99450. */
  99451. fixedPoints?: number;
  99452. /**
  99453. * The collision margin around a soft object
  99454. */
  99455. margin?: number;
  99456. /**
  99457. * The collision margin around a soft object
  99458. */
  99459. damping?: number;
  99460. /**
  99461. * The path for a rope based on an extrusion
  99462. */
  99463. path?: any;
  99464. /**
  99465. * The shape of an extrusion used for a rope based on an extrusion
  99466. */
  99467. shape?: any;
  99468. }
  99469. /**
  99470. * Interface for a physics-enabled object
  99471. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  99472. */
  99473. export interface IPhysicsEnabledObject {
  99474. /**
  99475. * The position of the physics-enabled object
  99476. */
  99477. position: Vector3;
  99478. /**
  99479. * The rotation of the physics-enabled object
  99480. */
  99481. rotationQuaternion: Nullable<Quaternion>;
  99482. /**
  99483. * The scale of the physics-enabled object
  99484. */
  99485. scaling: Vector3;
  99486. /**
  99487. * The rotation of the physics-enabled object
  99488. */
  99489. rotation?: Vector3;
  99490. /**
  99491. * The parent of the physics-enabled object
  99492. */
  99493. parent?: any;
  99494. /**
  99495. * The bounding info of the physics-enabled object
  99496. * @returns The bounding info of the physics-enabled object
  99497. */
  99498. getBoundingInfo(): BoundingInfo;
  99499. /**
  99500. * Computes the world matrix
  99501. * @param force Specifies if the world matrix should be computed by force
  99502. * @returns A world matrix
  99503. */
  99504. computeWorldMatrix(force: boolean): Matrix;
  99505. /**
  99506. * Gets the world matrix
  99507. * @returns A world matrix
  99508. */
  99509. getWorldMatrix?(): Matrix;
  99510. /**
  99511. * Gets the child meshes
  99512. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  99513. * @returns An array of abstract meshes
  99514. */
  99515. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  99516. /**
  99517. * Gets the vertex data
  99518. * @param kind The type of vertex data
  99519. * @returns A nullable array of numbers, or a float32 array
  99520. */
  99521. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  99522. /**
  99523. * Gets the indices from the mesh
  99524. * @returns A nullable array of index arrays
  99525. */
  99526. getIndices?(): Nullable<IndicesArray>;
  99527. /**
  99528. * Gets the scene from the mesh
  99529. * @returns the indices array or null
  99530. */
  99531. getScene?(): Scene;
  99532. /**
  99533. * Gets the absolute position from the mesh
  99534. * @returns the absolute position
  99535. */
  99536. getAbsolutePosition(): Vector3;
  99537. /**
  99538. * Gets the absolute pivot point from the mesh
  99539. * @returns the absolute pivot point
  99540. */
  99541. getAbsolutePivotPoint(): Vector3;
  99542. /**
  99543. * Rotates the mesh
  99544. * @param axis The axis of rotation
  99545. * @param amount The amount of rotation
  99546. * @param space The space of the rotation
  99547. * @returns The rotation transform node
  99548. */
  99549. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  99550. /**
  99551. * Translates the mesh
  99552. * @param axis The axis of translation
  99553. * @param distance The distance of translation
  99554. * @param space The space of the translation
  99555. * @returns The transform node
  99556. */
  99557. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  99558. /**
  99559. * Sets the absolute position of the mesh
  99560. * @param absolutePosition The absolute position of the mesh
  99561. * @returns The transform node
  99562. */
  99563. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  99564. /**
  99565. * Gets the class name of the mesh
  99566. * @returns The class name
  99567. */
  99568. getClassName(): string;
  99569. }
  99570. /**
  99571. * Represents a physics imposter
  99572. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  99573. */
  99574. export class PhysicsImpostor {
  99575. /**
  99576. * The physics-enabled object used as the physics imposter
  99577. */
  99578. object: IPhysicsEnabledObject;
  99579. /**
  99580. * The type of the physics imposter
  99581. */
  99582. type: number;
  99583. private _options;
  99584. private _scene?;
  99585. /**
  99586. * The default object size of the imposter
  99587. */
  99588. static DEFAULT_OBJECT_SIZE: Vector3;
  99589. /**
  99590. * The identity quaternion of the imposter
  99591. */
  99592. static IDENTITY_QUATERNION: Quaternion;
  99593. /** @hidden */
  99594. _pluginData: any;
  99595. private _physicsEngine;
  99596. private _physicsBody;
  99597. private _bodyUpdateRequired;
  99598. private _onBeforePhysicsStepCallbacks;
  99599. private _onAfterPhysicsStepCallbacks;
  99600. /** @hidden */
  99601. _onPhysicsCollideCallbacks: Array<{
  99602. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  99603. otherImpostors: Array<PhysicsImpostor>;
  99604. }>;
  99605. private _deltaPosition;
  99606. private _deltaRotation;
  99607. private _deltaRotationConjugated;
  99608. /** @hidden */
  99609. _isFromLine: boolean;
  99610. private _parent;
  99611. private _isDisposed;
  99612. private static _tmpVecs;
  99613. private static _tmpQuat;
  99614. /**
  99615. * Specifies if the physics imposter is disposed
  99616. */
  99617. get isDisposed(): boolean;
  99618. /**
  99619. * Gets the mass of the physics imposter
  99620. */
  99621. get mass(): number;
  99622. set mass(value: number);
  99623. /**
  99624. * Gets the coefficient of friction
  99625. */
  99626. get friction(): number;
  99627. /**
  99628. * Sets the coefficient of friction
  99629. */
  99630. set friction(value: number);
  99631. /**
  99632. * Gets the coefficient of restitution
  99633. */
  99634. get restitution(): number;
  99635. /**
  99636. * Sets the coefficient of restitution
  99637. */
  99638. set restitution(value: number);
  99639. /**
  99640. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  99641. */
  99642. get pressure(): number;
  99643. /**
  99644. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  99645. */
  99646. set pressure(value: number);
  99647. /**
  99648. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  99649. */
  99650. get stiffness(): number;
  99651. /**
  99652. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  99653. */
  99654. set stiffness(value: number);
  99655. /**
  99656. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  99657. */
  99658. get velocityIterations(): number;
  99659. /**
  99660. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  99661. */
  99662. set velocityIterations(value: number);
  99663. /**
  99664. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  99665. */
  99666. get positionIterations(): number;
  99667. /**
  99668. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  99669. */
  99670. set positionIterations(value: number);
  99671. /**
  99672. * The unique id of the physics imposter
  99673. * set by the physics engine when adding this impostor to the array
  99674. */
  99675. uniqueId: number;
  99676. /**
  99677. * @hidden
  99678. */
  99679. soft: boolean;
  99680. /**
  99681. * @hidden
  99682. */
  99683. segments: number;
  99684. private _joints;
  99685. /**
  99686. * Initializes the physics imposter
  99687. * @param object The physics-enabled object used as the physics imposter
  99688. * @param type The type of the physics imposter
  99689. * @param _options The options for the physics imposter
  99690. * @param _scene The Babylon scene
  99691. */
  99692. constructor(
  99693. /**
  99694. * The physics-enabled object used as the physics imposter
  99695. */
  99696. object: IPhysicsEnabledObject,
  99697. /**
  99698. * The type of the physics imposter
  99699. */
  99700. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  99701. /**
  99702. * This function will completly initialize this impostor.
  99703. * It will create a new body - but only if this mesh has no parent.
  99704. * If it has, this impostor will not be used other than to define the impostor
  99705. * of the child mesh.
  99706. * @hidden
  99707. */
  99708. _init(): void;
  99709. private _getPhysicsParent;
  99710. /**
  99711. * Should a new body be generated.
  99712. * @returns boolean specifying if body initialization is required
  99713. */
  99714. isBodyInitRequired(): boolean;
  99715. /**
  99716. * Sets the updated scaling
  99717. * @param updated Specifies if the scaling is updated
  99718. */
  99719. setScalingUpdated(): void;
  99720. /**
  99721. * Force a regeneration of this or the parent's impostor's body.
  99722. * Use under cautious - This will remove all joints already implemented.
  99723. */
  99724. forceUpdate(): void;
  99725. /**
  99726. * Gets the body that holds this impostor. Either its own, or its parent.
  99727. */
  99728. get physicsBody(): any;
  99729. /**
  99730. * Get the parent of the physics imposter
  99731. * @returns Physics imposter or null
  99732. */
  99733. get parent(): Nullable<PhysicsImpostor>;
  99734. /**
  99735. * Sets the parent of the physics imposter
  99736. */
  99737. set parent(value: Nullable<PhysicsImpostor>);
  99738. /**
  99739. * Set the physics body. Used mainly by the physics engine/plugin
  99740. */
  99741. set physicsBody(physicsBody: any);
  99742. /**
  99743. * Resets the update flags
  99744. */
  99745. resetUpdateFlags(): void;
  99746. /**
  99747. * Gets the object extend size
  99748. * @returns the object extend size
  99749. */
  99750. getObjectExtendSize(): Vector3;
  99751. /**
  99752. * Gets the object center
  99753. * @returns The object center
  99754. */
  99755. getObjectCenter(): Vector3;
  99756. /**
  99757. * Get a specific parameter from the options parameters
  99758. * @param paramName The object parameter name
  99759. * @returns The object parameter
  99760. */
  99761. getParam(paramName: string): any;
  99762. /**
  99763. * Sets a specific parameter in the options given to the physics plugin
  99764. * @param paramName The parameter name
  99765. * @param value The value of the parameter
  99766. */
  99767. setParam(paramName: string, value: number): void;
  99768. /**
  99769. * Specifically change the body's mass option. Won't recreate the physics body object
  99770. * @param mass The mass of the physics imposter
  99771. */
  99772. setMass(mass: number): void;
  99773. /**
  99774. * Gets the linear velocity
  99775. * @returns linear velocity or null
  99776. */
  99777. getLinearVelocity(): Nullable<Vector3>;
  99778. /**
  99779. * Sets the linear velocity
  99780. * @param velocity linear velocity or null
  99781. */
  99782. setLinearVelocity(velocity: Nullable<Vector3>): void;
  99783. /**
  99784. * Gets the angular velocity
  99785. * @returns angular velocity or null
  99786. */
  99787. getAngularVelocity(): Nullable<Vector3>;
  99788. /**
  99789. * Sets the angular velocity
  99790. * @param velocity The velocity or null
  99791. */
  99792. setAngularVelocity(velocity: Nullable<Vector3>): void;
  99793. /**
  99794. * Execute a function with the physics plugin native code
  99795. * Provide a function the will have two variables - the world object and the physics body object
  99796. * @param func The function to execute with the physics plugin native code
  99797. */
  99798. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  99799. /**
  99800. * Register a function that will be executed before the physics world is stepping forward
  99801. * @param func The function to execute before the physics world is stepped forward
  99802. */
  99803. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  99804. /**
  99805. * Unregister a function that will be executed before the physics world is stepping forward
  99806. * @param func The function to execute before the physics world is stepped forward
  99807. */
  99808. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  99809. /**
  99810. * Register a function that will be executed after the physics step
  99811. * @param func The function to execute after physics step
  99812. */
  99813. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  99814. /**
  99815. * Unregisters a function that will be executed after the physics step
  99816. * @param func The function to execute after physics step
  99817. */
  99818. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  99819. /**
  99820. * register a function that will be executed when this impostor collides against a different body
  99821. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  99822. * @param func Callback that is executed on collision
  99823. */
  99824. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  99825. /**
  99826. * Unregisters the physics imposter on contact
  99827. * @param collideAgainst The physics object to collide against
  99828. * @param func Callback to execute on collision
  99829. */
  99830. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  99831. private _tmpQuat;
  99832. private _tmpQuat2;
  99833. /**
  99834. * Get the parent rotation
  99835. * @returns The parent rotation
  99836. */
  99837. getParentsRotation(): Quaternion;
  99838. /**
  99839. * this function is executed by the physics engine.
  99840. */
  99841. beforeStep: () => void;
  99842. /**
  99843. * this function is executed by the physics engine
  99844. */
  99845. afterStep: () => void;
  99846. /**
  99847. * Legacy collision detection event support
  99848. */
  99849. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  99850. /**
  99851. * event and body object due to cannon's event-based architecture.
  99852. */
  99853. onCollide: (e: {
  99854. body: any;
  99855. }) => void;
  99856. /**
  99857. * Apply a force
  99858. * @param force The force to apply
  99859. * @param contactPoint The contact point for the force
  99860. * @returns The physics imposter
  99861. */
  99862. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  99863. /**
  99864. * Apply an impulse
  99865. * @param force The impulse force
  99866. * @param contactPoint The contact point for the impulse force
  99867. * @returns The physics imposter
  99868. */
  99869. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  99870. /**
  99871. * A help function to create a joint
  99872. * @param otherImpostor A physics imposter used to create a joint
  99873. * @param jointType The type of joint
  99874. * @param jointData The data for the joint
  99875. * @returns The physics imposter
  99876. */
  99877. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  99878. /**
  99879. * Add a joint to this impostor with a different impostor
  99880. * @param otherImpostor A physics imposter used to add a joint
  99881. * @param joint The joint to add
  99882. * @returns The physics imposter
  99883. */
  99884. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  99885. /**
  99886. * Add an anchor to a cloth impostor
  99887. * @param otherImpostor rigid impostor to anchor to
  99888. * @param width ratio across width from 0 to 1
  99889. * @param height ratio up height from 0 to 1
  99890. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  99891. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  99892. * @returns impostor the soft imposter
  99893. */
  99894. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  99895. /**
  99896. * Add a hook to a rope impostor
  99897. * @param otherImpostor rigid impostor to anchor to
  99898. * @param length ratio across rope from 0 to 1
  99899. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  99900. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  99901. * @returns impostor the rope imposter
  99902. */
  99903. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  99904. /**
  99905. * Will keep this body still, in a sleep mode.
  99906. * @returns the physics imposter
  99907. */
  99908. sleep(): PhysicsImpostor;
  99909. /**
  99910. * Wake the body up.
  99911. * @returns The physics imposter
  99912. */
  99913. wakeUp(): PhysicsImpostor;
  99914. /**
  99915. * Clones the physics imposter
  99916. * @param newObject The physics imposter clones to this physics-enabled object
  99917. * @returns A nullable physics imposter
  99918. */
  99919. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  99920. /**
  99921. * Disposes the physics imposter
  99922. */
  99923. dispose(): void;
  99924. /**
  99925. * Sets the delta position
  99926. * @param position The delta position amount
  99927. */
  99928. setDeltaPosition(position: Vector3): void;
  99929. /**
  99930. * Sets the delta rotation
  99931. * @param rotation The delta rotation amount
  99932. */
  99933. setDeltaRotation(rotation: Quaternion): void;
  99934. /**
  99935. * Gets the box size of the physics imposter and stores the result in the input parameter
  99936. * @param result Stores the box size
  99937. * @returns The physics imposter
  99938. */
  99939. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  99940. /**
  99941. * Gets the radius of the physics imposter
  99942. * @returns Radius of the physics imposter
  99943. */
  99944. getRadius(): number;
  99945. /**
  99946. * Sync a bone with this impostor
  99947. * @param bone The bone to sync to the impostor.
  99948. * @param boneMesh The mesh that the bone is influencing.
  99949. * @param jointPivot The pivot of the joint / bone in local space.
  99950. * @param distToJoint Optional distance from the impostor to the joint.
  99951. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  99952. */
  99953. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  99954. /**
  99955. * Sync impostor to a bone
  99956. * @param bone The bone that the impostor will be synced to.
  99957. * @param boneMesh The mesh that the bone is influencing.
  99958. * @param jointPivot The pivot of the joint / bone in local space.
  99959. * @param distToJoint Optional distance from the impostor to the joint.
  99960. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  99961. * @param boneAxis Optional vector3 axis the bone is aligned with
  99962. */
  99963. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  99964. /**
  99965. * No-Imposter type
  99966. */
  99967. static NoImpostor: number;
  99968. /**
  99969. * Sphere-Imposter type
  99970. */
  99971. static SphereImpostor: number;
  99972. /**
  99973. * Box-Imposter type
  99974. */
  99975. static BoxImpostor: number;
  99976. /**
  99977. * Plane-Imposter type
  99978. */
  99979. static PlaneImpostor: number;
  99980. /**
  99981. * Mesh-imposter type
  99982. */
  99983. static MeshImpostor: number;
  99984. /**
  99985. * Capsule-Impostor type (Ammo.js plugin only)
  99986. */
  99987. static CapsuleImpostor: number;
  99988. /**
  99989. * Cylinder-Imposter type
  99990. */
  99991. static CylinderImpostor: number;
  99992. /**
  99993. * Particle-Imposter type
  99994. */
  99995. static ParticleImpostor: number;
  99996. /**
  99997. * Heightmap-Imposter type
  99998. */
  99999. static HeightmapImpostor: number;
  100000. /**
  100001. * ConvexHull-Impostor type (Ammo.js plugin only)
  100002. */
  100003. static ConvexHullImpostor: number;
  100004. /**
  100005. * Custom-Imposter type (Ammo.js plugin only)
  100006. */
  100007. static CustomImpostor: number;
  100008. /**
  100009. * Rope-Imposter type
  100010. */
  100011. static RopeImpostor: number;
  100012. /**
  100013. * Cloth-Imposter type
  100014. */
  100015. static ClothImpostor: number;
  100016. /**
  100017. * Softbody-Imposter type
  100018. */
  100019. static SoftbodyImpostor: number;
  100020. }
  100021. }
  100022. declare module BABYLON {
  100023. /**
  100024. * @hidden
  100025. **/
  100026. export class _CreationDataStorage {
  100027. closePath?: boolean;
  100028. closeArray?: boolean;
  100029. idx: number[];
  100030. dashSize: number;
  100031. gapSize: number;
  100032. path3D: Path3D;
  100033. pathArray: Vector3[][];
  100034. arc: number;
  100035. radius: number;
  100036. cap: number;
  100037. tessellation: number;
  100038. }
  100039. /**
  100040. * @hidden
  100041. **/
  100042. class _InstanceDataStorage {
  100043. visibleInstances: any;
  100044. batchCache: _InstancesBatch;
  100045. instancesBufferSize: number;
  100046. instancesBuffer: Nullable<Buffer>;
  100047. instancesData: Float32Array;
  100048. overridenInstanceCount: number;
  100049. isFrozen: boolean;
  100050. previousBatch: Nullable<_InstancesBatch>;
  100051. hardwareInstancedRendering: boolean;
  100052. sideOrientation: number;
  100053. manualUpdate: boolean;
  100054. }
  100055. /**
  100056. * @hidden
  100057. **/
  100058. export class _InstancesBatch {
  100059. mustReturn: boolean;
  100060. visibleInstances: Nullable<InstancedMesh[]>[];
  100061. renderSelf: boolean[];
  100062. hardwareInstancedRendering: boolean[];
  100063. }
  100064. /**
  100065. * Class used to represent renderable models
  100066. */
  100067. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  100068. /**
  100069. * Mesh side orientation : usually the external or front surface
  100070. */
  100071. static readonly FRONTSIDE: number;
  100072. /**
  100073. * Mesh side orientation : usually the internal or back surface
  100074. */
  100075. static readonly BACKSIDE: number;
  100076. /**
  100077. * Mesh side orientation : both internal and external or front and back surfaces
  100078. */
  100079. static readonly DOUBLESIDE: number;
  100080. /**
  100081. * Mesh side orientation : by default, `FRONTSIDE`
  100082. */
  100083. static readonly DEFAULTSIDE: number;
  100084. /**
  100085. * Mesh cap setting : no cap
  100086. */
  100087. static readonly NO_CAP: number;
  100088. /**
  100089. * Mesh cap setting : one cap at the beginning of the mesh
  100090. */
  100091. static readonly CAP_START: number;
  100092. /**
  100093. * Mesh cap setting : one cap at the end of the mesh
  100094. */
  100095. static readonly CAP_END: number;
  100096. /**
  100097. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  100098. */
  100099. static readonly CAP_ALL: number;
  100100. /**
  100101. * Mesh pattern setting : no flip or rotate
  100102. */
  100103. static readonly NO_FLIP: number;
  100104. /**
  100105. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  100106. */
  100107. static readonly FLIP_TILE: number;
  100108. /**
  100109. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  100110. */
  100111. static readonly ROTATE_TILE: number;
  100112. /**
  100113. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  100114. */
  100115. static readonly FLIP_ROW: number;
  100116. /**
  100117. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  100118. */
  100119. static readonly ROTATE_ROW: number;
  100120. /**
  100121. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  100122. */
  100123. static readonly FLIP_N_ROTATE_TILE: number;
  100124. /**
  100125. * Mesh pattern setting : rotate pattern and rotate
  100126. */
  100127. static readonly FLIP_N_ROTATE_ROW: number;
  100128. /**
  100129. * Mesh tile positioning : part tiles same on left/right or top/bottom
  100130. */
  100131. static readonly CENTER: number;
  100132. /**
  100133. * Mesh tile positioning : part tiles on left
  100134. */
  100135. static readonly LEFT: number;
  100136. /**
  100137. * Mesh tile positioning : part tiles on right
  100138. */
  100139. static readonly RIGHT: number;
  100140. /**
  100141. * Mesh tile positioning : part tiles on top
  100142. */
  100143. static readonly TOP: number;
  100144. /**
  100145. * Mesh tile positioning : part tiles on bottom
  100146. */
  100147. static readonly BOTTOM: number;
  100148. /**
  100149. * Gets the default side orientation.
  100150. * @param orientation the orientation to value to attempt to get
  100151. * @returns the default orientation
  100152. * @hidden
  100153. */
  100154. static _GetDefaultSideOrientation(orientation?: number): number;
  100155. private _internalMeshDataInfo;
  100156. /**
  100157. * An event triggered before rendering the mesh
  100158. */
  100159. get onBeforeRenderObservable(): Observable<Mesh>;
  100160. /**
  100161. * An event triggered before binding the mesh
  100162. */
  100163. get onBeforeBindObservable(): Observable<Mesh>;
  100164. /**
  100165. * An event triggered after rendering the mesh
  100166. */
  100167. get onAfterRenderObservable(): Observable<Mesh>;
  100168. /**
  100169. * An event triggered before drawing the mesh
  100170. */
  100171. get onBeforeDrawObservable(): Observable<Mesh>;
  100172. private _onBeforeDrawObserver;
  100173. /**
  100174. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  100175. */
  100176. set onBeforeDraw(callback: () => void);
  100177. get hasInstances(): boolean;
  100178. /**
  100179. * Gets the delay loading state of the mesh (when delay loading is turned on)
  100180. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  100181. */
  100182. delayLoadState: number;
  100183. /**
  100184. * Gets the list of instances created from this mesh
  100185. * it is not supposed to be modified manually.
  100186. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  100187. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  100188. */
  100189. instances: InstancedMesh[];
  100190. /**
  100191. * Gets the file containing delay loading data for this mesh
  100192. */
  100193. delayLoadingFile: string;
  100194. /** @hidden */
  100195. _binaryInfo: any;
  100196. /**
  100197. * User defined function used to change how LOD level selection is done
  100198. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  100199. */
  100200. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  100201. /**
  100202. * Gets or sets the morph target manager
  100203. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  100204. */
  100205. get morphTargetManager(): Nullable<MorphTargetManager>;
  100206. set morphTargetManager(value: Nullable<MorphTargetManager>);
  100207. /** @hidden */
  100208. _creationDataStorage: Nullable<_CreationDataStorage>;
  100209. /** @hidden */
  100210. _geometry: Nullable<Geometry>;
  100211. /** @hidden */
  100212. _delayInfo: Array<string>;
  100213. /** @hidden */
  100214. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  100215. /** @hidden */
  100216. _instanceDataStorage: _InstanceDataStorage;
  100217. private _effectiveMaterial;
  100218. /** @hidden */
  100219. _shouldGenerateFlatShading: boolean;
  100220. /** @hidden */
  100221. _originalBuilderSideOrientation: number;
  100222. /**
  100223. * Use this property to change the original side orientation defined at construction time
  100224. */
  100225. overrideMaterialSideOrientation: Nullable<number>;
  100226. /**
  100227. * Gets the source mesh (the one used to clone this one from)
  100228. */
  100229. get source(): Nullable<Mesh>;
  100230. /**
  100231. * Gets or sets a boolean indicating that this mesh does not use index buffer
  100232. */
  100233. get isUnIndexed(): boolean;
  100234. set isUnIndexed(value: boolean);
  100235. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  100236. get worldMatrixInstancedBuffer(): Float32Array;
  100237. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  100238. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  100239. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  100240. /**
  100241. * @constructor
  100242. * @param name The value used by scene.getMeshByName() to do a lookup.
  100243. * @param scene The scene to add this mesh to.
  100244. * @param parent The parent of this mesh, if it has one
  100245. * @param source An optional Mesh from which geometry is shared, cloned.
  100246. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  100247. * When false, achieved by calling a clone(), also passing False.
  100248. * This will make creation of children, recursive.
  100249. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  100250. */
  100251. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  100252. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  100253. doNotInstantiate: boolean;
  100254. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  100255. /**
  100256. * Gets the class name
  100257. * @returns the string "Mesh".
  100258. */
  100259. getClassName(): string;
  100260. /** @hidden */
  100261. get _isMesh(): boolean;
  100262. /**
  100263. * Returns a description of this mesh
  100264. * @param fullDetails define if full details about this mesh must be used
  100265. * @returns a descriptive string representing this mesh
  100266. */
  100267. toString(fullDetails?: boolean): string;
  100268. /** @hidden */
  100269. _unBindEffect(): void;
  100270. /**
  100271. * Gets a boolean indicating if this mesh has LOD
  100272. */
  100273. get hasLODLevels(): boolean;
  100274. /**
  100275. * Gets the list of MeshLODLevel associated with the current mesh
  100276. * @returns an array of MeshLODLevel
  100277. */
  100278. getLODLevels(): MeshLODLevel[];
  100279. private _sortLODLevels;
  100280. /**
  100281. * Add a mesh as LOD level triggered at the given distance.
  100282. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  100283. * @param distance The distance from the center of the object to show this level
  100284. * @param mesh The mesh to be added as LOD level (can be null)
  100285. * @return This mesh (for chaining)
  100286. */
  100287. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  100288. /**
  100289. * Returns the LOD level mesh at the passed distance or null if not found.
  100290. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  100291. * @param distance The distance from the center of the object to show this level
  100292. * @returns a Mesh or `null`
  100293. */
  100294. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  100295. /**
  100296. * Remove a mesh from the LOD array
  100297. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  100298. * @param mesh defines the mesh to be removed
  100299. * @return This mesh (for chaining)
  100300. */
  100301. removeLODLevel(mesh: Mesh): Mesh;
  100302. /**
  100303. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  100304. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  100305. * @param camera defines the camera to use to compute distance
  100306. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  100307. * @return This mesh (for chaining)
  100308. */
  100309. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  100310. /**
  100311. * Gets the mesh internal Geometry object
  100312. */
  100313. get geometry(): Nullable<Geometry>;
  100314. /**
  100315. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  100316. * @returns the total number of vertices
  100317. */
  100318. getTotalVertices(): number;
  100319. /**
  100320. * Returns the content of an associated vertex buffer
  100321. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  100322. * - VertexBuffer.PositionKind
  100323. * - VertexBuffer.UVKind
  100324. * - VertexBuffer.UV2Kind
  100325. * - VertexBuffer.UV3Kind
  100326. * - VertexBuffer.UV4Kind
  100327. * - VertexBuffer.UV5Kind
  100328. * - VertexBuffer.UV6Kind
  100329. * - VertexBuffer.ColorKind
  100330. * - VertexBuffer.MatricesIndicesKind
  100331. * - VertexBuffer.MatricesIndicesExtraKind
  100332. * - VertexBuffer.MatricesWeightsKind
  100333. * - VertexBuffer.MatricesWeightsExtraKind
  100334. * @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
  100335. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  100336. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  100337. */
  100338. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  100339. /**
  100340. * Returns the mesh VertexBuffer object from the requested `kind`
  100341. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  100342. * - VertexBuffer.PositionKind
  100343. * - VertexBuffer.NormalKind
  100344. * - VertexBuffer.UVKind
  100345. * - VertexBuffer.UV2Kind
  100346. * - VertexBuffer.UV3Kind
  100347. * - VertexBuffer.UV4Kind
  100348. * - VertexBuffer.UV5Kind
  100349. * - VertexBuffer.UV6Kind
  100350. * - VertexBuffer.ColorKind
  100351. * - VertexBuffer.MatricesIndicesKind
  100352. * - VertexBuffer.MatricesIndicesExtraKind
  100353. * - VertexBuffer.MatricesWeightsKind
  100354. * - VertexBuffer.MatricesWeightsExtraKind
  100355. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  100356. */
  100357. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  100358. /**
  100359. * Tests if a specific vertex buffer is associated with this mesh
  100360. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  100361. * - VertexBuffer.PositionKind
  100362. * - VertexBuffer.NormalKind
  100363. * - VertexBuffer.UVKind
  100364. * - VertexBuffer.UV2Kind
  100365. * - VertexBuffer.UV3Kind
  100366. * - VertexBuffer.UV4Kind
  100367. * - VertexBuffer.UV5Kind
  100368. * - VertexBuffer.UV6Kind
  100369. * - VertexBuffer.ColorKind
  100370. * - VertexBuffer.MatricesIndicesKind
  100371. * - VertexBuffer.MatricesIndicesExtraKind
  100372. * - VertexBuffer.MatricesWeightsKind
  100373. * - VertexBuffer.MatricesWeightsExtraKind
  100374. * @returns a boolean
  100375. */
  100376. isVerticesDataPresent(kind: string): boolean;
  100377. /**
  100378. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  100379. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  100380. * - VertexBuffer.PositionKind
  100381. * - VertexBuffer.UVKind
  100382. * - VertexBuffer.UV2Kind
  100383. * - VertexBuffer.UV3Kind
  100384. * - VertexBuffer.UV4Kind
  100385. * - VertexBuffer.UV5Kind
  100386. * - VertexBuffer.UV6Kind
  100387. * - VertexBuffer.ColorKind
  100388. * - VertexBuffer.MatricesIndicesKind
  100389. * - VertexBuffer.MatricesIndicesExtraKind
  100390. * - VertexBuffer.MatricesWeightsKind
  100391. * - VertexBuffer.MatricesWeightsExtraKind
  100392. * @returns a boolean
  100393. */
  100394. isVertexBufferUpdatable(kind: string): boolean;
  100395. /**
  100396. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  100397. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  100398. * - VertexBuffer.PositionKind
  100399. * - VertexBuffer.NormalKind
  100400. * - VertexBuffer.UVKind
  100401. * - VertexBuffer.UV2Kind
  100402. * - VertexBuffer.UV3Kind
  100403. * - VertexBuffer.UV4Kind
  100404. * - VertexBuffer.UV5Kind
  100405. * - VertexBuffer.UV6Kind
  100406. * - VertexBuffer.ColorKind
  100407. * - VertexBuffer.MatricesIndicesKind
  100408. * - VertexBuffer.MatricesIndicesExtraKind
  100409. * - VertexBuffer.MatricesWeightsKind
  100410. * - VertexBuffer.MatricesWeightsExtraKind
  100411. * @returns an array of strings
  100412. */
  100413. getVerticesDataKinds(): string[];
  100414. /**
  100415. * Returns a positive integer : the total number of indices in this mesh geometry.
  100416. * @returns the numner of indices or zero if the mesh has no geometry.
  100417. */
  100418. getTotalIndices(): number;
  100419. /**
  100420. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  100421. * @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.
  100422. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  100423. * @returns the indices array or an empty array if the mesh has no geometry
  100424. */
  100425. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  100426. get isBlocked(): boolean;
  100427. /**
  100428. * Determine if the current mesh is ready to be rendered
  100429. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  100430. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  100431. * @returns true if all associated assets are ready (material, textures, shaders)
  100432. */
  100433. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  100434. /**
  100435. * 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.
  100436. */
  100437. get areNormalsFrozen(): boolean;
  100438. /**
  100439. * 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.
  100440. * @returns the current mesh
  100441. */
  100442. freezeNormals(): Mesh;
  100443. /**
  100444. * 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
  100445. * @returns the current mesh
  100446. */
  100447. unfreezeNormals(): Mesh;
  100448. /**
  100449. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  100450. */
  100451. set overridenInstanceCount(count: number);
  100452. /** @hidden */
  100453. _preActivate(): Mesh;
  100454. /** @hidden */
  100455. _preActivateForIntermediateRendering(renderId: number): Mesh;
  100456. /** @hidden */
  100457. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  100458. /**
  100459. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  100460. * This means the mesh underlying bounding box and sphere are recomputed.
  100461. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  100462. * @returns the current mesh
  100463. */
  100464. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  100465. /** @hidden */
  100466. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  100467. /**
  100468. * This function will subdivide the mesh into multiple submeshes
  100469. * @param count defines the expected number of submeshes
  100470. */
  100471. subdivide(count: number): void;
  100472. /**
  100473. * Copy a FloatArray into a specific associated vertex buffer
  100474. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  100475. * - VertexBuffer.PositionKind
  100476. * - VertexBuffer.UVKind
  100477. * - VertexBuffer.UV2Kind
  100478. * - VertexBuffer.UV3Kind
  100479. * - VertexBuffer.UV4Kind
  100480. * - VertexBuffer.UV5Kind
  100481. * - VertexBuffer.UV6Kind
  100482. * - VertexBuffer.ColorKind
  100483. * - VertexBuffer.MatricesIndicesKind
  100484. * - VertexBuffer.MatricesIndicesExtraKind
  100485. * - VertexBuffer.MatricesWeightsKind
  100486. * - VertexBuffer.MatricesWeightsExtraKind
  100487. * @param data defines the data source
  100488. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  100489. * @param stride defines the data stride size (can be null)
  100490. * @returns the current mesh
  100491. */
  100492. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  100493. /**
  100494. * Delete a vertex buffer associated with this mesh
  100495. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  100496. * - VertexBuffer.PositionKind
  100497. * - VertexBuffer.UVKind
  100498. * - VertexBuffer.UV2Kind
  100499. * - VertexBuffer.UV3Kind
  100500. * - VertexBuffer.UV4Kind
  100501. * - VertexBuffer.UV5Kind
  100502. * - VertexBuffer.UV6Kind
  100503. * - VertexBuffer.ColorKind
  100504. * - VertexBuffer.MatricesIndicesKind
  100505. * - VertexBuffer.MatricesIndicesExtraKind
  100506. * - VertexBuffer.MatricesWeightsKind
  100507. * - VertexBuffer.MatricesWeightsExtraKind
  100508. */
  100509. removeVerticesData(kind: string): void;
  100510. /**
  100511. * Flags an associated vertex buffer as updatable
  100512. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  100513. * - VertexBuffer.PositionKind
  100514. * - VertexBuffer.UVKind
  100515. * - VertexBuffer.UV2Kind
  100516. * - VertexBuffer.UV3Kind
  100517. * - VertexBuffer.UV4Kind
  100518. * - VertexBuffer.UV5Kind
  100519. * - VertexBuffer.UV6Kind
  100520. * - VertexBuffer.ColorKind
  100521. * - VertexBuffer.MatricesIndicesKind
  100522. * - VertexBuffer.MatricesIndicesExtraKind
  100523. * - VertexBuffer.MatricesWeightsKind
  100524. * - VertexBuffer.MatricesWeightsExtraKind
  100525. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  100526. */
  100527. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  100528. /**
  100529. * Sets the mesh global Vertex Buffer
  100530. * @param buffer defines the buffer to use
  100531. * @returns the current mesh
  100532. */
  100533. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  100534. /**
  100535. * Update a specific associated vertex buffer
  100536. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  100537. * - VertexBuffer.PositionKind
  100538. * - VertexBuffer.UVKind
  100539. * - VertexBuffer.UV2Kind
  100540. * - VertexBuffer.UV3Kind
  100541. * - VertexBuffer.UV4Kind
  100542. * - VertexBuffer.UV5Kind
  100543. * - VertexBuffer.UV6Kind
  100544. * - VertexBuffer.ColorKind
  100545. * - VertexBuffer.MatricesIndicesKind
  100546. * - VertexBuffer.MatricesIndicesExtraKind
  100547. * - VertexBuffer.MatricesWeightsKind
  100548. * - VertexBuffer.MatricesWeightsExtraKind
  100549. * @param data defines the data source
  100550. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  100551. * @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)
  100552. * @returns the current mesh
  100553. */
  100554. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  100555. /**
  100556. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  100557. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  100558. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  100559. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  100560. * @returns the current mesh
  100561. */
  100562. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  100563. /**
  100564. * Creates a un-shared specific occurence of the geometry for the mesh.
  100565. * @returns the current mesh
  100566. */
  100567. makeGeometryUnique(): Mesh;
  100568. /**
  100569. * Set the index buffer of this mesh
  100570. * @param indices defines the source data
  100571. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  100572. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  100573. * @returns the current mesh
  100574. */
  100575. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  100576. /**
  100577. * Update the current index buffer
  100578. * @param indices defines the source data
  100579. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  100580. * @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)
  100581. * @returns the current mesh
  100582. */
  100583. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  100584. /**
  100585. * Invert the geometry to move from a right handed system to a left handed one.
  100586. * @returns the current mesh
  100587. */
  100588. toLeftHanded(): Mesh;
  100589. /** @hidden */
  100590. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  100591. /** @hidden */
  100592. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  100593. /**
  100594. * Registers for this mesh a javascript function called just before the rendering process
  100595. * @param func defines the function to call before rendering this mesh
  100596. * @returns the current mesh
  100597. */
  100598. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  100599. /**
  100600. * Disposes a previously registered javascript function called before the rendering
  100601. * @param func defines the function to remove
  100602. * @returns the current mesh
  100603. */
  100604. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  100605. /**
  100606. * Registers for this mesh a javascript function called just after the rendering is complete
  100607. * @param func defines the function to call after rendering this mesh
  100608. * @returns the current mesh
  100609. */
  100610. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  100611. /**
  100612. * Disposes a previously registered javascript function called after the rendering.
  100613. * @param func defines the function to remove
  100614. * @returns the current mesh
  100615. */
  100616. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  100617. /** @hidden */
  100618. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  100619. /** @hidden */
  100620. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  100621. /** @hidden */
  100622. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  100623. /** @hidden */
  100624. _processRendering(renderingMesh: AbstractMesh, subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  100625. /** @hidden */
  100626. _rebuild(): void;
  100627. /** @hidden */
  100628. _freeze(): void;
  100629. /** @hidden */
  100630. _unFreeze(): void;
  100631. /**
  100632. * 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
  100633. * @param subMesh defines the subMesh to render
  100634. * @param enableAlphaMode defines if alpha mode can be changed
  100635. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  100636. * @returns the current mesh
  100637. */
  100638. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  100639. private _onBeforeDraw;
  100640. /**
  100641. * Renormalize the mesh and patch it up if there are no weights
  100642. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  100643. * However in the case of zero weights then we set just a single influence to 1.
  100644. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  100645. */
  100646. cleanMatrixWeights(): void;
  100647. private normalizeSkinFourWeights;
  100648. private normalizeSkinWeightsAndExtra;
  100649. /**
  100650. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  100651. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  100652. * the user know there was an issue with importing the mesh
  100653. * @returns a validation object with skinned, valid and report string
  100654. */
  100655. validateSkinning(): {
  100656. skinned: boolean;
  100657. valid: boolean;
  100658. report: string;
  100659. };
  100660. /** @hidden */
  100661. _checkDelayState(): Mesh;
  100662. private _queueLoad;
  100663. /**
  100664. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  100665. * A mesh is in the frustum if its bounding box intersects the frustum
  100666. * @param frustumPlanes defines the frustum to test
  100667. * @returns true if the mesh is in the frustum planes
  100668. */
  100669. isInFrustum(frustumPlanes: Plane[]): boolean;
  100670. /**
  100671. * Sets the mesh material by the material or multiMaterial `id` property
  100672. * @param id is a string identifying the material or the multiMaterial
  100673. * @returns the current mesh
  100674. */
  100675. setMaterialByID(id: string): Mesh;
  100676. /**
  100677. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  100678. * @returns an array of IAnimatable
  100679. */
  100680. getAnimatables(): IAnimatable[];
  100681. /**
  100682. * Modifies the mesh geometry according to the passed transformation matrix.
  100683. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  100684. * The mesh normals are modified using the same transformation.
  100685. * Note that, under the hood, this method sets a new VertexBuffer each call.
  100686. * @param transform defines the transform matrix to use
  100687. * @see http://doc.babylonjs.com/resources/baking_transformations
  100688. * @returns the current mesh
  100689. */
  100690. bakeTransformIntoVertices(transform: Matrix): Mesh;
  100691. /**
  100692. * Modifies the mesh geometry according to its own current World Matrix.
  100693. * The mesh World Matrix is then reset.
  100694. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  100695. * Note that, under the hood, this method sets a new VertexBuffer each call.
  100696. * @see http://doc.babylonjs.com/resources/baking_transformations
  100697. * @param bakeIndependenlyOfChildren indicates whether to preserve all child nodes' World Matrix during baking
  100698. * @returns the current mesh
  100699. */
  100700. bakeCurrentTransformIntoVertices(bakeIndependenlyOfChildren?: boolean): Mesh;
  100701. /** @hidden */
  100702. get _positions(): Nullable<Vector3[]>;
  100703. /** @hidden */
  100704. _resetPointsArrayCache(): Mesh;
  100705. /** @hidden */
  100706. _generatePointsArray(): boolean;
  100707. /**
  100708. * Returns a new Mesh object generated from the current mesh properties.
  100709. * This method must not get confused with createInstance()
  100710. * @param name is a string, the name given to the new mesh
  100711. * @param newParent can be any Node object (default `null`)
  100712. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  100713. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  100714. * @returns a new mesh
  100715. */
  100716. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  100717. /**
  100718. * Releases resources associated with this mesh.
  100719. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  100720. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  100721. */
  100722. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  100723. /** @hidden */
  100724. _disposeInstanceSpecificData(): void;
  100725. /**
  100726. * Modifies the mesh geometry according to a displacement map.
  100727. * 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.
  100728. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  100729. * @param url is a string, the URL from the image file is to be downloaded.
  100730. * @param minHeight is the lower limit of the displacement.
  100731. * @param maxHeight is the upper limit of the displacement.
  100732. * @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.
  100733. * @param uvOffset is an optional vector2 used to offset UV.
  100734. * @param uvScale is an optional vector2 used to scale UV.
  100735. * @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.
  100736. * @returns the Mesh.
  100737. */
  100738. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  100739. /**
  100740. * Modifies the mesh geometry according to a displacementMap buffer.
  100741. * 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.
  100742. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  100743. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  100744. * @param heightMapWidth is the width of the buffer image.
  100745. * @param heightMapHeight is the height of the buffer image.
  100746. * @param minHeight is the lower limit of the displacement.
  100747. * @param maxHeight is the upper limit of the displacement.
  100748. * @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.
  100749. * @param uvOffset is an optional vector2 used to offset UV.
  100750. * @param uvScale is an optional vector2 used to scale UV.
  100751. * @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.
  100752. * @returns the Mesh.
  100753. */
  100754. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  100755. /**
  100756. * Modify the mesh to get a flat shading rendering.
  100757. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  100758. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  100759. * @returns current mesh
  100760. */
  100761. convertToFlatShadedMesh(): Mesh;
  100762. /**
  100763. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  100764. * In other words, more vertices, no more indices and a single bigger VBO.
  100765. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  100766. * @returns current mesh
  100767. */
  100768. convertToUnIndexedMesh(): Mesh;
  100769. /**
  100770. * Inverses facet orientations.
  100771. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  100772. * @param flipNormals will also inverts the normals
  100773. * @returns current mesh
  100774. */
  100775. flipFaces(flipNormals?: boolean): Mesh;
  100776. /**
  100777. * Increase the number of facets and hence vertices in a mesh
  100778. * Vertex normals are interpolated from existing vertex normals
  100779. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  100780. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  100781. */
  100782. increaseVertices(numberPerEdge: number): void;
  100783. /**
  100784. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  100785. * This will undo any application of covertToFlatShadedMesh
  100786. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  100787. */
  100788. forceSharedVertices(): void;
  100789. /** @hidden */
  100790. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  100791. /** @hidden */
  100792. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  100793. /**
  100794. * Creates a new InstancedMesh object from the mesh model.
  100795. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  100796. * @param name defines the name of the new instance
  100797. * @returns a new InstancedMesh
  100798. */
  100799. createInstance(name: string): InstancedMesh;
  100800. /**
  100801. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  100802. * After this call, all the mesh instances have the same submeshes than the current mesh.
  100803. * @returns the current mesh
  100804. */
  100805. synchronizeInstances(): Mesh;
  100806. /**
  100807. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  100808. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  100809. * This should be used together with the simplification to avoid disappearing triangles.
  100810. * @param successCallback an optional success callback to be called after the optimization finished.
  100811. * @returns the current mesh
  100812. */
  100813. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  100814. /**
  100815. * Serialize current mesh
  100816. * @param serializationObject defines the object which will receive the serialization data
  100817. */
  100818. serialize(serializationObject: any): void;
  100819. /** @hidden */
  100820. _syncGeometryWithMorphTargetManager(): void;
  100821. /** @hidden */
  100822. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  100823. /**
  100824. * Returns a new Mesh object parsed from the source provided.
  100825. * @param parsedMesh is the source
  100826. * @param scene defines the hosting scene
  100827. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  100828. * @returns a new Mesh
  100829. */
  100830. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  100831. /**
  100832. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  100833. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  100834. * @param name defines the name of the mesh to create
  100835. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  100836. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  100837. * @param closePath creates a seam between the first and the last points of each path of the path array
  100838. * @param offset is taken in account only if the `pathArray` is containing a single path
  100839. * @param scene defines the hosting scene
  100840. * @param updatable defines if the mesh must be flagged as updatable
  100841. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  100842. * @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)
  100843. * @returns a new Mesh
  100844. */
  100845. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  100846. /**
  100847. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  100848. * @param name defines the name of the mesh to create
  100849. * @param radius sets the radius size (float) of the polygon (default 0.5)
  100850. * @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
  100851. * @param scene defines the hosting scene
  100852. * @param updatable defines if the mesh must be flagged as updatable
  100853. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  100854. * @returns a new Mesh
  100855. */
  100856. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  100857. /**
  100858. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  100859. * @param name defines the name of the mesh to create
  100860. * @param size sets the size (float) of each box side (default 1)
  100861. * @param scene defines the hosting scene
  100862. * @param updatable defines if the mesh must be flagged as updatable
  100863. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  100864. * @returns a new Mesh
  100865. */
  100866. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  100867. /**
  100868. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  100869. * @param name defines the name of the mesh to create
  100870. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  100871. * @param diameter sets the diameter size (float) of the sphere (default 1)
  100872. * @param scene defines the hosting scene
  100873. * @param updatable defines if the mesh must be flagged as updatable
  100874. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  100875. * @returns a new Mesh
  100876. */
  100877. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  100878. /**
  100879. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  100880. * @param name defines the name of the mesh to create
  100881. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  100882. * @param diameter sets the diameter size (float) of the sphere (default 1)
  100883. * @param scene defines the hosting scene
  100884. * @returns a new Mesh
  100885. */
  100886. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  100887. /**
  100888. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  100889. * @param name defines the name of the mesh to create
  100890. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  100891. * @param diameterTop set the top cap diameter (floats, default 1)
  100892. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  100893. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  100894. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  100895. * @param scene defines the hosting scene
  100896. * @param updatable defines if the mesh must be flagged as updatable
  100897. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  100898. * @returns a new Mesh
  100899. */
  100900. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  100901. /**
  100902. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  100903. * @param name defines the name of the mesh to create
  100904. * @param diameter sets the diameter size (float) of the torus (default 1)
  100905. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  100906. * @param tessellation sets the number of torus sides (postive integer, default 16)
  100907. * @param scene defines the hosting scene
  100908. * @param updatable defines if the mesh must be flagged as updatable
  100909. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  100910. * @returns a new Mesh
  100911. */
  100912. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  100913. /**
  100914. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  100915. * @param name defines the name of the mesh to create
  100916. * @param radius sets the global radius size (float) of the torus knot (default 2)
  100917. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  100918. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  100919. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  100920. * @param p the number of windings on X axis (positive integers, default 2)
  100921. * @param q the number of windings on Y axis (positive integers, default 3)
  100922. * @param scene defines the hosting scene
  100923. * @param updatable defines if the mesh must be flagged as updatable
  100924. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  100925. * @returns a new Mesh
  100926. */
  100927. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  100928. /**
  100929. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  100930. * @param name defines the name of the mesh to create
  100931. * @param points is an array successive Vector3
  100932. * @param scene defines the hosting scene
  100933. * @param updatable defines if the mesh must be flagged as updatable
  100934. * @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).
  100935. * @returns a new Mesh
  100936. */
  100937. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  100938. /**
  100939. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  100940. * @param name defines the name of the mesh to create
  100941. * @param points is an array successive Vector3
  100942. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  100943. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  100944. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  100945. * @param scene defines the hosting scene
  100946. * @param updatable defines if the mesh must be flagged as updatable
  100947. * @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)
  100948. * @returns a new Mesh
  100949. */
  100950. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  100951. /**
  100952. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  100953. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  100954. * 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.
  100955. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  100956. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  100957. * Remember you can only change the shape positions, not their number when updating a polygon.
  100958. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  100959. * @param name defines the name of the mesh to create
  100960. * @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
  100961. * @param scene defines the hosting scene
  100962. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  100963. * @param updatable defines if the mesh must be flagged as updatable
  100964. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  100965. * @param earcutInjection can be used to inject your own earcut reference
  100966. * @returns a new Mesh
  100967. */
  100968. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  100969. /**
  100970. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  100971. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  100972. * @param name defines the name of the mesh to create
  100973. * @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
  100974. * @param depth defines the height of extrusion
  100975. * @param scene defines the hosting scene
  100976. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  100977. * @param updatable defines if the mesh must be flagged as updatable
  100978. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  100979. * @param earcutInjection can be used to inject your own earcut reference
  100980. * @returns a new Mesh
  100981. */
  100982. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  100983. /**
  100984. * Creates an extruded shape mesh.
  100985. * 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
  100986. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  100987. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  100988. * @param name defines the name of the mesh to create
  100989. * @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
  100990. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  100991. * @param scale is the value to scale the shape
  100992. * @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
  100993. * @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
  100994. * @param scene defines the hosting scene
  100995. * @param updatable defines if the mesh must be flagged as updatable
  100996. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  100997. * @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)
  100998. * @returns a new Mesh
  100999. */
  101000. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  101001. /**
  101002. * Creates an custom extruded shape mesh.
  101003. * The custom extrusion is a parametric shape.
  101004. * It has no predefined shape. Its final shape will depend on the input parameters.
  101005. * Please consider using the same method from the MeshBuilder class instead
  101006. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  101007. * @param name defines the name of the mesh to create
  101008. * @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
  101009. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  101010. * @param scaleFunction is a custom Javascript function called on each path point
  101011. * @param rotationFunction is a custom Javascript function called on each path point
  101012. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  101013. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  101014. * @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
  101015. * @param scene defines the hosting scene
  101016. * @param updatable defines if the mesh must be flagged as updatable
  101017. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  101018. * @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)
  101019. * @returns a new Mesh
  101020. */
  101021. 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;
  101022. /**
  101023. * Creates lathe mesh.
  101024. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  101025. * Please consider using the same method from the MeshBuilder class instead
  101026. * @param name defines the name of the mesh to create
  101027. * @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
  101028. * @param radius is the radius value of the lathe
  101029. * @param tessellation is the side number of the lathe.
  101030. * @param scene defines the hosting scene
  101031. * @param updatable defines if the mesh must be flagged as updatable
  101032. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  101033. * @returns a new Mesh
  101034. */
  101035. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  101036. /**
  101037. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  101038. * @param name defines the name of the mesh to create
  101039. * @param size sets the size (float) of both sides of the plane at once (default 1)
  101040. * @param scene defines the hosting scene
  101041. * @param updatable defines if the mesh must be flagged as updatable
  101042. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  101043. * @returns a new Mesh
  101044. */
  101045. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  101046. /**
  101047. * Creates a ground mesh.
  101048. * Please consider using the same method from the MeshBuilder class instead
  101049. * @param name defines the name of the mesh to create
  101050. * @param width set the width of the ground
  101051. * @param height set the height of the ground
  101052. * @param subdivisions sets the number of subdivisions per side
  101053. * @param scene defines the hosting scene
  101054. * @param updatable defines if the mesh must be flagged as updatable
  101055. * @returns a new Mesh
  101056. */
  101057. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  101058. /**
  101059. * Creates a tiled ground mesh.
  101060. * Please consider using the same method from the MeshBuilder class instead
  101061. * @param name defines the name of the mesh to create
  101062. * @param xmin set the ground minimum X coordinate
  101063. * @param zmin set the ground minimum Y coordinate
  101064. * @param xmax set the ground maximum X coordinate
  101065. * @param zmax set the ground maximum Z coordinate
  101066. * @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
  101067. * @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
  101068. * @param scene defines the hosting scene
  101069. * @param updatable defines if the mesh must be flagged as updatable
  101070. * @returns a new Mesh
  101071. */
  101072. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  101073. w: number;
  101074. h: number;
  101075. }, precision: {
  101076. w: number;
  101077. h: number;
  101078. }, scene: Scene, updatable?: boolean): Mesh;
  101079. /**
  101080. * Creates a ground mesh from a height map.
  101081. * Please consider using the same method from the MeshBuilder class instead
  101082. * @see http://doc.babylonjs.com/babylon101/height_map
  101083. * @param name defines the name of the mesh to create
  101084. * @param url sets the URL of the height map image resource
  101085. * @param width set the ground width size
  101086. * @param height set the ground height size
  101087. * @param subdivisions sets the number of subdivision per side
  101088. * @param minHeight is the minimum altitude on the ground
  101089. * @param maxHeight is the maximum altitude on the ground
  101090. * @param scene defines the hosting scene
  101091. * @param updatable defines if the mesh must be flagged as updatable
  101092. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  101093. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  101094. * @returns a new Mesh
  101095. */
  101096. 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;
  101097. /**
  101098. * Creates a tube mesh.
  101099. * The tube is a parametric shape.
  101100. * It has no predefined shape. Its final shape will depend on the input parameters.
  101101. * Please consider using the same method from the MeshBuilder class instead
  101102. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  101103. * @param name defines the name of the mesh to create
  101104. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  101105. * @param radius sets the tube radius size
  101106. * @param tessellation is the number of sides on the tubular surface
  101107. * @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
  101108. * @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
  101109. * @param scene defines the hosting scene
  101110. * @param updatable defines if the mesh must be flagged as updatable
  101111. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  101112. * @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)
  101113. * @returns a new Mesh
  101114. */
  101115. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  101116. (i: number, distance: number): number;
  101117. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  101118. /**
  101119. * Creates a polyhedron mesh.
  101120. * Please consider using the same method from the MeshBuilder class instead.
  101121. * * 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
  101122. * * The parameter `size` (positive float, default 1) sets the polygon size
  101123. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  101124. * * 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`
  101125. * * 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
  101126. * * 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)`)
  101127. * * 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
  101128. * * 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
  101129. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  101130. * * If you create a double-sided mesh, you can choose what parts of 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
  101131. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  101132. * @param name defines the name of the mesh to create
  101133. * @param options defines the options used to create the mesh
  101134. * @param scene defines the hosting scene
  101135. * @returns a new Mesh
  101136. */
  101137. static CreatePolyhedron(name: string, options: {
  101138. type?: number;
  101139. size?: number;
  101140. sizeX?: number;
  101141. sizeY?: number;
  101142. sizeZ?: number;
  101143. custom?: any;
  101144. faceUV?: Vector4[];
  101145. faceColors?: Color4[];
  101146. updatable?: boolean;
  101147. sideOrientation?: number;
  101148. }, scene: Scene): Mesh;
  101149. /**
  101150. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  101151. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  101152. * * 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`)
  101153. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  101154. * * 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
  101155. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  101156. * * If you create a double-sided mesh, you can choose what parts of 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
  101157. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  101158. * @param name defines the name of the mesh
  101159. * @param options defines the options used to create the mesh
  101160. * @param scene defines the hosting scene
  101161. * @returns a new Mesh
  101162. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  101163. */
  101164. static CreateIcoSphere(name: string, options: {
  101165. radius?: number;
  101166. flat?: boolean;
  101167. subdivisions?: number;
  101168. sideOrientation?: number;
  101169. updatable?: boolean;
  101170. }, scene: Scene): Mesh;
  101171. /**
  101172. * Creates a decal mesh.
  101173. * Please consider using the same method from the MeshBuilder class instead.
  101174. * A decal is a mesh usually applied as a model onto the surface of another mesh
  101175. * @param name defines the name of the mesh
  101176. * @param sourceMesh defines the mesh receiving the decal
  101177. * @param position sets the position of the decal in world coordinates
  101178. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  101179. * @param size sets the decal scaling
  101180. * @param angle sets the angle to rotate the decal
  101181. * @returns a new Mesh
  101182. */
  101183. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  101184. /**
  101185. * Prepare internal position array for software CPU skinning
  101186. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  101187. */
  101188. setPositionsForCPUSkinning(): Float32Array;
  101189. /**
  101190. * Prepare internal normal array for software CPU skinning
  101191. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  101192. */
  101193. setNormalsForCPUSkinning(): Float32Array;
  101194. /**
  101195. * Updates the vertex buffer by applying transformation from the bones
  101196. * @param skeleton defines the skeleton to apply to current mesh
  101197. * @returns the current mesh
  101198. */
  101199. applySkeleton(skeleton: Skeleton): Mesh;
  101200. /**
  101201. * 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
  101202. * @param meshes defines the list of meshes to scan
  101203. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  101204. */
  101205. static MinMax(meshes: AbstractMesh[]): {
  101206. min: Vector3;
  101207. max: Vector3;
  101208. };
  101209. /**
  101210. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  101211. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  101212. * @returns a vector3
  101213. */
  101214. static Center(meshesOrMinMaxVector: {
  101215. min: Vector3;
  101216. max: Vector3;
  101217. } | AbstractMesh[]): Vector3;
  101218. /**
  101219. * Merge the array of meshes into a single mesh for performance reasons.
  101220. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  101221. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  101222. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  101223. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  101224. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  101225. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  101226. * @returns a new mesh
  101227. */
  101228. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  101229. /** @hidden */
  101230. addInstance(instance: InstancedMesh): void;
  101231. /** @hidden */
  101232. removeInstance(instance: InstancedMesh): void;
  101233. }
  101234. }
  101235. declare module BABYLON {
  101236. /**
  101237. * This is the base class of all the camera used in the application.
  101238. * @see http://doc.babylonjs.com/features/cameras
  101239. */
  101240. export class Camera extends Node {
  101241. /** @hidden */
  101242. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  101243. /**
  101244. * This is the default projection mode used by the cameras.
  101245. * It helps recreating a feeling of perspective and better appreciate depth.
  101246. * This is the best way to simulate real life cameras.
  101247. */
  101248. static readonly PERSPECTIVE_CAMERA: number;
  101249. /**
  101250. * This helps creating camera with an orthographic mode.
  101251. * 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.
  101252. */
  101253. static readonly ORTHOGRAPHIC_CAMERA: number;
  101254. /**
  101255. * This is the default FOV mode for perspective cameras.
  101256. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  101257. */
  101258. static readonly FOVMODE_VERTICAL_FIXED: number;
  101259. /**
  101260. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  101261. */
  101262. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  101263. /**
  101264. * This specifies ther is no need for a camera rig.
  101265. * Basically only one eye is rendered corresponding to the camera.
  101266. */
  101267. static readonly RIG_MODE_NONE: number;
  101268. /**
  101269. * Simulates a camera Rig with one blue eye and one red eye.
  101270. * This can be use with 3d blue and red glasses.
  101271. */
  101272. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  101273. /**
  101274. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  101275. */
  101276. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  101277. /**
  101278. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  101279. */
  101280. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  101281. /**
  101282. * Defines that both eyes of the camera will be rendered over under each other.
  101283. */
  101284. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  101285. /**
  101286. * Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.
  101287. */
  101288. static readonly RIG_MODE_STEREOSCOPIC_INTERLACED: number;
  101289. /**
  101290. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  101291. */
  101292. static readonly RIG_MODE_VR: number;
  101293. /**
  101294. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  101295. */
  101296. static readonly RIG_MODE_WEBVR: number;
  101297. /**
  101298. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  101299. */
  101300. static readonly RIG_MODE_CUSTOM: number;
  101301. /**
  101302. * Defines if by default attaching controls should prevent the default javascript event to continue.
  101303. */
  101304. static ForceAttachControlToAlwaysPreventDefault: boolean;
  101305. /**
  101306. * Define the input manager associated with the camera.
  101307. */
  101308. inputs: CameraInputsManager<Camera>;
  101309. /** @hidden */
  101310. _position: Vector3;
  101311. /**
  101312. * Define the current local position of the camera in the scene
  101313. */
  101314. get position(): Vector3;
  101315. set position(newPosition: Vector3);
  101316. /**
  101317. * The vector the camera should consider as up.
  101318. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  101319. */
  101320. upVector: Vector3;
  101321. /**
  101322. * Define the current limit on the left side for an orthographic camera
  101323. * In scene unit
  101324. */
  101325. orthoLeft: Nullable<number>;
  101326. /**
  101327. * Define the current limit on the right side for an orthographic camera
  101328. * In scene unit
  101329. */
  101330. orthoRight: Nullable<number>;
  101331. /**
  101332. * Define the current limit on the bottom side for an orthographic camera
  101333. * In scene unit
  101334. */
  101335. orthoBottom: Nullable<number>;
  101336. /**
  101337. * Define the current limit on the top side for an orthographic camera
  101338. * In scene unit
  101339. */
  101340. orthoTop: Nullable<number>;
  101341. /**
  101342. * Field Of View is set in Radians. (default is 0.8)
  101343. */
  101344. fov: number;
  101345. /**
  101346. * Define the minimum distance the camera can see from.
  101347. * This is important to note that the depth buffer are not infinite and the closer it starts
  101348. * the more your scene might encounter depth fighting issue.
  101349. */
  101350. minZ: number;
  101351. /**
  101352. * Define the maximum distance the camera can see to.
  101353. * This is important to note that the depth buffer are not infinite and the further it end
  101354. * the more your scene might encounter depth fighting issue.
  101355. */
  101356. maxZ: number;
  101357. /**
  101358. * Define the default inertia of the camera.
  101359. * This helps giving a smooth feeling to the camera movement.
  101360. */
  101361. inertia: number;
  101362. /**
  101363. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  101364. */
  101365. mode: number;
  101366. /**
  101367. * Define whether the camera is intermediate.
  101368. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  101369. */
  101370. isIntermediate: boolean;
  101371. /**
  101372. * Define the viewport of the camera.
  101373. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  101374. */
  101375. viewport: Viewport;
  101376. /**
  101377. * Restricts the camera to viewing objects with the same layerMask.
  101378. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  101379. */
  101380. layerMask: number;
  101381. /**
  101382. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  101383. */
  101384. fovMode: number;
  101385. /**
  101386. * Rig mode of the camera.
  101387. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  101388. * This is normally controlled byt the camera themselves as internal use.
  101389. */
  101390. cameraRigMode: number;
  101391. /**
  101392. * Defines the distance between both "eyes" in case of a RIG
  101393. */
  101394. interaxialDistance: number;
  101395. /**
  101396. * Defines if stereoscopic rendering is done side by side or over under.
  101397. */
  101398. isStereoscopicSideBySide: boolean;
  101399. /**
  101400. * 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
  101401. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  101402. * else in the scene. (Eg. security camera)
  101403. *
  101404. * 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)
  101405. */
  101406. customRenderTargets: RenderTargetTexture[];
  101407. /**
  101408. * When set, the camera will render to this render target instead of the default canvas
  101409. *
  101410. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  101411. */
  101412. outputRenderTarget: Nullable<RenderTargetTexture>;
  101413. /**
  101414. * Observable triggered when the camera view matrix has changed.
  101415. */
  101416. onViewMatrixChangedObservable: Observable<Camera>;
  101417. /**
  101418. * Observable triggered when the camera Projection matrix has changed.
  101419. */
  101420. onProjectionMatrixChangedObservable: Observable<Camera>;
  101421. /**
  101422. * Observable triggered when the inputs have been processed.
  101423. */
  101424. onAfterCheckInputsObservable: Observable<Camera>;
  101425. /**
  101426. * Observable triggered when reset has been called and applied to the camera.
  101427. */
  101428. onRestoreStateObservable: Observable<Camera>;
  101429. /**
  101430. * Is this camera a part of a rig system?
  101431. */
  101432. isRigCamera: boolean;
  101433. /**
  101434. * If isRigCamera set to true this will be set with the parent camera.
  101435. * The parent camera is not (!) necessarily the .parent of this camera (like in the case of XR)
  101436. */
  101437. rigParent?: Camera;
  101438. /** @hidden */
  101439. _cameraRigParams: any;
  101440. /** @hidden */
  101441. _rigCameras: Camera[];
  101442. /** @hidden */
  101443. _rigPostProcess: Nullable<PostProcess>;
  101444. protected _webvrViewMatrix: Matrix;
  101445. /** @hidden */
  101446. _skipRendering: boolean;
  101447. /** @hidden */
  101448. _projectionMatrix: Matrix;
  101449. /** @hidden */
  101450. _postProcesses: Nullable<PostProcess>[];
  101451. /** @hidden */
  101452. _activeMeshes: SmartArray<AbstractMesh>;
  101453. protected _globalPosition: Vector3;
  101454. /** @hidden */
  101455. _computedViewMatrix: Matrix;
  101456. private _doNotComputeProjectionMatrix;
  101457. private _transformMatrix;
  101458. private _frustumPlanes;
  101459. private _refreshFrustumPlanes;
  101460. private _storedFov;
  101461. private _stateStored;
  101462. /**
  101463. * Instantiates a new camera object.
  101464. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  101465. * @see http://doc.babylonjs.com/features/cameras
  101466. * @param name Defines the name of the camera in the scene
  101467. * @param position Defines the position of the camera
  101468. * @param scene Defines the scene the camera belongs too
  101469. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  101470. */
  101471. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  101472. /**
  101473. * Store current camera state (fov, position, etc..)
  101474. * @returns the camera
  101475. */
  101476. storeState(): Camera;
  101477. /**
  101478. * Restores the camera state values if it has been stored. You must call storeState() first
  101479. */
  101480. protected _restoreStateValues(): boolean;
  101481. /**
  101482. * Restored camera state. You must call storeState() first.
  101483. * @returns true if restored and false otherwise
  101484. */
  101485. restoreState(): boolean;
  101486. /**
  101487. * Gets the class name of the camera.
  101488. * @returns the class name
  101489. */
  101490. getClassName(): string;
  101491. /** @hidden */
  101492. readonly _isCamera: boolean;
  101493. /**
  101494. * Gets a string representation of the camera useful for debug purpose.
  101495. * @param fullDetails Defines that a more verboe level of logging is required
  101496. * @returns the string representation
  101497. */
  101498. toString(fullDetails?: boolean): string;
  101499. /**
  101500. * Gets the current world space position of the camera.
  101501. */
  101502. get globalPosition(): Vector3;
  101503. /**
  101504. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  101505. * @returns the active meshe list
  101506. */
  101507. getActiveMeshes(): SmartArray<AbstractMesh>;
  101508. /**
  101509. * Check whether a mesh is part of the current active mesh list of the camera
  101510. * @param mesh Defines the mesh to check
  101511. * @returns true if active, false otherwise
  101512. */
  101513. isActiveMesh(mesh: Mesh): boolean;
  101514. /**
  101515. * Is this camera ready to be used/rendered
  101516. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  101517. * @return true if the camera is ready
  101518. */
  101519. isReady(completeCheck?: boolean): boolean;
  101520. /** @hidden */
  101521. _initCache(): void;
  101522. /** @hidden */
  101523. _updateCache(ignoreParentClass?: boolean): void;
  101524. /** @hidden */
  101525. _isSynchronized(): boolean;
  101526. /** @hidden */
  101527. _isSynchronizedViewMatrix(): boolean;
  101528. /** @hidden */
  101529. _isSynchronizedProjectionMatrix(): boolean;
  101530. /**
  101531. * Attach the input controls to a specific dom element to get the input from.
  101532. * @param element Defines the element the controls should be listened from
  101533. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  101534. */
  101535. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  101536. /**
  101537. * Detach the current controls from the specified dom element.
  101538. * @param element Defines the element to stop listening the inputs from
  101539. */
  101540. detachControl(element: HTMLElement): void;
  101541. /**
  101542. * Update the camera state according to the different inputs gathered during the frame.
  101543. */
  101544. update(): void;
  101545. /** @hidden */
  101546. _checkInputs(): void;
  101547. /** @hidden */
  101548. get rigCameras(): Camera[];
  101549. /**
  101550. * Gets the post process used by the rig cameras
  101551. */
  101552. get rigPostProcess(): Nullable<PostProcess>;
  101553. /**
  101554. * Internal, gets the first post proces.
  101555. * @returns the first post process to be run on this camera.
  101556. */
  101557. _getFirstPostProcess(): Nullable<PostProcess>;
  101558. private _cascadePostProcessesToRigCams;
  101559. /**
  101560. * Attach a post process to the camera.
  101561. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  101562. * @param postProcess The post process to attach to the camera
  101563. * @param insertAt The position of the post process in case several of them are in use in the scene
  101564. * @returns the position the post process has been inserted at
  101565. */
  101566. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  101567. /**
  101568. * Detach a post process to the camera.
  101569. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  101570. * @param postProcess The post process to detach from the camera
  101571. */
  101572. detachPostProcess(postProcess: PostProcess): void;
  101573. /**
  101574. * Gets the current world matrix of the camera
  101575. */
  101576. getWorldMatrix(): Matrix;
  101577. /** @hidden */
  101578. _getViewMatrix(): Matrix;
  101579. /**
  101580. * Gets the current view matrix of the camera.
  101581. * @param force forces the camera to recompute the matrix without looking at the cached state
  101582. * @returns the view matrix
  101583. */
  101584. getViewMatrix(force?: boolean): Matrix;
  101585. /**
  101586. * Freeze the projection matrix.
  101587. * It will prevent the cache check of the camera projection compute and can speed up perf
  101588. * if no parameter of the camera are meant to change
  101589. * @param projection Defines manually a projection if necessary
  101590. */
  101591. freezeProjectionMatrix(projection?: Matrix): void;
  101592. /**
  101593. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  101594. */
  101595. unfreezeProjectionMatrix(): void;
  101596. /**
  101597. * Gets the current projection matrix of the camera.
  101598. * @param force forces the camera to recompute the matrix without looking at the cached state
  101599. * @returns the projection matrix
  101600. */
  101601. getProjectionMatrix(force?: boolean): Matrix;
  101602. /**
  101603. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  101604. * @returns a Matrix
  101605. */
  101606. getTransformationMatrix(): Matrix;
  101607. private _updateFrustumPlanes;
  101608. /**
  101609. * Checks if a cullable object (mesh...) is in the camera frustum
  101610. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  101611. * @param target The object to check
  101612. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  101613. * @returns true if the object is in frustum otherwise false
  101614. */
  101615. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  101616. /**
  101617. * Checks if a cullable object (mesh...) is in the camera frustum
  101618. * Unlike isInFrustum this cheks the full bounding box
  101619. * @param target The object to check
  101620. * @returns true if the object is in frustum otherwise false
  101621. */
  101622. isCompletelyInFrustum(target: ICullable): boolean;
  101623. /**
  101624. * Gets a ray in the forward direction from the camera.
  101625. * @param length Defines the length of the ray to create
  101626. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  101627. * @param origin Defines the start point of the ray which defaults to the camera position
  101628. * @returns the forward ray
  101629. */
  101630. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  101631. /**
  101632. * Releases resources associated with this node.
  101633. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  101634. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  101635. */
  101636. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  101637. /** @hidden */
  101638. _isLeftCamera: boolean;
  101639. /**
  101640. * Gets the left camera of a rig setup in case of Rigged Camera
  101641. */
  101642. get isLeftCamera(): boolean;
  101643. /** @hidden */
  101644. _isRightCamera: boolean;
  101645. /**
  101646. * Gets the right camera of a rig setup in case of Rigged Camera
  101647. */
  101648. get isRightCamera(): boolean;
  101649. /**
  101650. * Gets the left camera of a rig setup in case of Rigged Camera
  101651. */
  101652. get leftCamera(): Nullable<FreeCamera>;
  101653. /**
  101654. * Gets the right camera of a rig setup in case of Rigged Camera
  101655. */
  101656. get rightCamera(): Nullable<FreeCamera>;
  101657. /**
  101658. * Gets the left camera target of a rig setup in case of Rigged Camera
  101659. * @returns the target position
  101660. */
  101661. getLeftTarget(): Nullable<Vector3>;
  101662. /**
  101663. * Gets the right camera target of a rig setup in case of Rigged Camera
  101664. * @returns the target position
  101665. */
  101666. getRightTarget(): Nullable<Vector3>;
  101667. /**
  101668. * @hidden
  101669. */
  101670. setCameraRigMode(mode: number, rigParams: any): void;
  101671. /** @hidden */
  101672. static _setStereoscopicRigMode(camera: Camera): void;
  101673. /** @hidden */
  101674. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  101675. /** @hidden */
  101676. static _setVRRigMode(camera: Camera, rigParams: any): void;
  101677. /** @hidden */
  101678. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  101679. /** @hidden */
  101680. _getVRProjectionMatrix(): Matrix;
  101681. protected _updateCameraRotationMatrix(): void;
  101682. protected _updateWebVRCameraRotationMatrix(): void;
  101683. /**
  101684. * This function MUST be overwritten by the different WebVR cameras available.
  101685. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  101686. * @hidden
  101687. */
  101688. _getWebVRProjectionMatrix(): Matrix;
  101689. /**
  101690. * This function MUST be overwritten by the different WebVR cameras available.
  101691. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  101692. * @hidden
  101693. */
  101694. _getWebVRViewMatrix(): Matrix;
  101695. /** @hidden */
  101696. setCameraRigParameter(name: string, value: any): void;
  101697. /**
  101698. * needs to be overridden by children so sub has required properties to be copied
  101699. * @hidden
  101700. */
  101701. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  101702. /**
  101703. * May need to be overridden by children
  101704. * @hidden
  101705. */
  101706. _updateRigCameras(): void;
  101707. /** @hidden */
  101708. _setupInputs(): void;
  101709. /**
  101710. * Serialiaze the camera setup to a json represention
  101711. * @returns the JSON representation
  101712. */
  101713. serialize(): any;
  101714. /**
  101715. * Clones the current camera.
  101716. * @param name The cloned camera name
  101717. * @returns the cloned camera
  101718. */
  101719. clone(name: string): Camera;
  101720. /**
  101721. * Gets the direction of the camera relative to a given local axis.
  101722. * @param localAxis Defines the reference axis to provide a relative direction.
  101723. * @return the direction
  101724. */
  101725. getDirection(localAxis: Vector3): Vector3;
  101726. /**
  101727. * Returns the current camera absolute rotation
  101728. */
  101729. get absoluteRotation(): Quaternion;
  101730. /**
  101731. * Gets the direction of the camera relative to a given local axis into a passed vector.
  101732. * @param localAxis Defines the reference axis to provide a relative direction.
  101733. * @param result Defines the vector to store the result in
  101734. */
  101735. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  101736. /**
  101737. * Gets a camera constructor for a given camera type
  101738. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  101739. * @param name The name of the camera the result will be able to instantiate
  101740. * @param scene The scene the result will construct the camera in
  101741. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  101742. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  101743. * @returns a factory method to construc the camera
  101744. */
  101745. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  101746. /**
  101747. * Compute the world matrix of the camera.
  101748. * @returns the camera world matrix
  101749. */
  101750. computeWorldMatrix(): Matrix;
  101751. /**
  101752. * Parse a JSON and creates the camera from the parsed information
  101753. * @param parsedCamera The JSON to parse
  101754. * @param scene The scene to instantiate the camera in
  101755. * @returns the newly constructed camera
  101756. */
  101757. static Parse(parsedCamera: any, scene: Scene): Camera;
  101758. }
  101759. }
  101760. declare module BABYLON {
  101761. /**
  101762. * Class containing static functions to help procedurally build meshes
  101763. */
  101764. export class DiscBuilder {
  101765. /**
  101766. * Creates a plane polygonal mesh. By default, this is a disc
  101767. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  101768. * * 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
  101769. * * 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
  101770. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  101771. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  101772. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  101773. * @param name defines the name of the mesh
  101774. * @param options defines the options used to create the mesh
  101775. * @param scene defines the hosting scene
  101776. * @returns the plane polygonal mesh
  101777. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  101778. */
  101779. static CreateDisc(name: string, options: {
  101780. radius?: number;
  101781. tessellation?: number;
  101782. arc?: number;
  101783. updatable?: boolean;
  101784. sideOrientation?: number;
  101785. frontUVs?: Vector4;
  101786. backUVs?: Vector4;
  101787. }, scene?: Nullable<Scene>): Mesh;
  101788. }
  101789. }
  101790. declare module BABYLON {
  101791. /**
  101792. * Options to be used when creating a FresnelParameters.
  101793. */
  101794. export type IFresnelParametersCreationOptions = {
  101795. /**
  101796. * Define the color used on edges (grazing angle)
  101797. */
  101798. leftColor?: Color3;
  101799. /**
  101800. * Define the color used on center
  101801. */
  101802. rightColor?: Color3;
  101803. /**
  101804. * Define bias applied to computed fresnel term
  101805. */
  101806. bias?: number;
  101807. /**
  101808. * Defined the power exponent applied to fresnel term
  101809. */
  101810. power?: number;
  101811. /**
  101812. * Define if the fresnel effect is enable or not.
  101813. */
  101814. isEnabled?: boolean;
  101815. };
  101816. /**
  101817. * Serialized format for FresnelParameters.
  101818. */
  101819. export type IFresnelParametersSerialized = {
  101820. /**
  101821. * Define the color used on edges (grazing angle) [as an array]
  101822. */
  101823. leftColor: number[];
  101824. /**
  101825. * Define the color used on center [as an array]
  101826. */
  101827. rightColor: number[];
  101828. /**
  101829. * Define bias applied to computed fresnel term
  101830. */
  101831. bias: number;
  101832. /**
  101833. * Defined the power exponent applied to fresnel term
  101834. */
  101835. power?: number;
  101836. /**
  101837. * Define if the fresnel effect is enable or not.
  101838. */
  101839. isEnabled: boolean;
  101840. };
  101841. /**
  101842. * This represents all the required information to add a fresnel effect on a material:
  101843. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  101844. */
  101845. export class FresnelParameters {
  101846. private _isEnabled;
  101847. /**
  101848. * Define if the fresnel effect is enable or not.
  101849. */
  101850. get isEnabled(): boolean;
  101851. set isEnabled(value: boolean);
  101852. /**
  101853. * Define the color used on edges (grazing angle)
  101854. */
  101855. leftColor: Color3;
  101856. /**
  101857. * Define the color used on center
  101858. */
  101859. rightColor: Color3;
  101860. /**
  101861. * Define bias applied to computed fresnel term
  101862. */
  101863. bias: number;
  101864. /**
  101865. * Defined the power exponent applied to fresnel term
  101866. */
  101867. power: number;
  101868. /**
  101869. * Creates a new FresnelParameters object.
  101870. *
  101871. * @param options provide your own settings to optionally to override defaults
  101872. */
  101873. constructor(options?: IFresnelParametersCreationOptions);
  101874. /**
  101875. * Clones the current fresnel and its valuues
  101876. * @returns a clone fresnel configuration
  101877. */
  101878. clone(): FresnelParameters;
  101879. /**
  101880. * Determines equality between FresnelParameters objects
  101881. * @param otherFresnelParameters defines the second operand
  101882. * @returns true if the power, bias, leftColor, rightColor and isEnabled values are equal to the given ones
  101883. */
  101884. equals(otherFresnelParameters: DeepImmutable<FresnelParameters>): boolean;
  101885. /**
  101886. * Serializes the current fresnel parameters to a JSON representation.
  101887. * @return the JSON serialization
  101888. */
  101889. serialize(): IFresnelParametersSerialized;
  101890. /**
  101891. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  101892. * @param parsedFresnelParameters Define the JSON representation
  101893. * @returns the parsed parameters
  101894. */
  101895. static Parse(parsedFresnelParameters: IFresnelParametersSerialized): FresnelParameters;
  101896. }
  101897. }
  101898. declare module BABYLON {
  101899. /**
  101900. * Base class of materials working in push mode in babylon JS
  101901. * @hidden
  101902. */
  101903. export class PushMaterial extends Material {
  101904. protected _activeEffect: Effect;
  101905. protected _normalMatrix: Matrix;
  101906. /**
  101907. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  101908. * This means that the material can keep using a previous shader while a new one is being compiled.
  101909. * This is mostly used when shader parallel compilation is supported (true by default)
  101910. */
  101911. allowShaderHotSwapping: boolean;
  101912. constructor(name: string, scene: Scene);
  101913. getEffect(): Effect;
  101914. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  101915. protected _isReadyForSubMesh(subMesh: SubMesh): boolean;
  101916. /**
  101917. * Binds the given world matrix to the active effect
  101918. *
  101919. * @param world the matrix to bind
  101920. */
  101921. bindOnlyWorldMatrix(world: Matrix): void;
  101922. /**
  101923. * Binds the given normal matrix to the active effect
  101924. *
  101925. * @param normalMatrix the matrix to bind
  101926. */
  101927. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  101928. bind(world: Matrix, mesh?: Mesh): void;
  101929. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  101930. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  101931. }
  101932. }
  101933. declare module BABYLON {
  101934. /**
  101935. * This groups all the flags used to control the materials channel.
  101936. */
  101937. export class MaterialFlags {
  101938. private static _DiffuseTextureEnabled;
  101939. /**
  101940. * Are diffuse textures enabled in the application.
  101941. */
  101942. static get DiffuseTextureEnabled(): boolean;
  101943. static set DiffuseTextureEnabled(value: boolean);
  101944. private static _AmbientTextureEnabled;
  101945. /**
  101946. * Are ambient textures enabled in the application.
  101947. */
  101948. static get AmbientTextureEnabled(): boolean;
  101949. static set AmbientTextureEnabled(value: boolean);
  101950. private static _OpacityTextureEnabled;
  101951. /**
  101952. * Are opacity textures enabled in the application.
  101953. */
  101954. static get OpacityTextureEnabled(): boolean;
  101955. static set OpacityTextureEnabled(value: boolean);
  101956. private static _ReflectionTextureEnabled;
  101957. /**
  101958. * Are reflection textures enabled in the application.
  101959. */
  101960. static get ReflectionTextureEnabled(): boolean;
  101961. static set ReflectionTextureEnabled(value: boolean);
  101962. private static _EmissiveTextureEnabled;
  101963. /**
  101964. * Are emissive textures enabled in the application.
  101965. */
  101966. static get EmissiveTextureEnabled(): boolean;
  101967. static set EmissiveTextureEnabled(value: boolean);
  101968. private static _SpecularTextureEnabled;
  101969. /**
  101970. * Are specular textures enabled in the application.
  101971. */
  101972. static get SpecularTextureEnabled(): boolean;
  101973. static set SpecularTextureEnabled(value: boolean);
  101974. private static _BumpTextureEnabled;
  101975. /**
  101976. * Are bump textures enabled in the application.
  101977. */
  101978. static get BumpTextureEnabled(): boolean;
  101979. static set BumpTextureEnabled(value: boolean);
  101980. private static _LightmapTextureEnabled;
  101981. /**
  101982. * Are lightmap textures enabled in the application.
  101983. */
  101984. static get LightmapTextureEnabled(): boolean;
  101985. static set LightmapTextureEnabled(value: boolean);
  101986. private static _RefractionTextureEnabled;
  101987. /**
  101988. * Are refraction textures enabled in the application.
  101989. */
  101990. static get RefractionTextureEnabled(): boolean;
  101991. static set RefractionTextureEnabled(value: boolean);
  101992. private static _ColorGradingTextureEnabled;
  101993. /**
  101994. * Are color grading textures enabled in the application.
  101995. */
  101996. static get ColorGradingTextureEnabled(): boolean;
  101997. static set ColorGradingTextureEnabled(value: boolean);
  101998. private static _FresnelEnabled;
  101999. /**
  102000. * Are fresnels enabled in the application.
  102001. */
  102002. static get FresnelEnabled(): boolean;
  102003. static set FresnelEnabled(value: boolean);
  102004. private static _ClearCoatTextureEnabled;
  102005. /**
  102006. * Are clear coat textures enabled in the application.
  102007. */
  102008. static get ClearCoatTextureEnabled(): boolean;
  102009. static set ClearCoatTextureEnabled(value: boolean);
  102010. private static _ClearCoatBumpTextureEnabled;
  102011. /**
  102012. * Are clear coat bump textures enabled in the application.
  102013. */
  102014. static get ClearCoatBumpTextureEnabled(): boolean;
  102015. static set ClearCoatBumpTextureEnabled(value: boolean);
  102016. private static _ClearCoatTintTextureEnabled;
  102017. /**
  102018. * Are clear coat tint textures enabled in the application.
  102019. */
  102020. static get ClearCoatTintTextureEnabled(): boolean;
  102021. static set ClearCoatTintTextureEnabled(value: boolean);
  102022. private static _SheenTextureEnabled;
  102023. /**
  102024. * Are sheen textures enabled in the application.
  102025. */
  102026. static get SheenTextureEnabled(): boolean;
  102027. static set SheenTextureEnabled(value: boolean);
  102028. private static _AnisotropicTextureEnabled;
  102029. /**
  102030. * Are anisotropic textures enabled in the application.
  102031. */
  102032. static get AnisotropicTextureEnabled(): boolean;
  102033. static set AnisotropicTextureEnabled(value: boolean);
  102034. private static _ThicknessTextureEnabled;
  102035. /**
  102036. * Are thickness textures enabled in the application.
  102037. */
  102038. static get ThicknessTextureEnabled(): boolean;
  102039. static set ThicknessTextureEnabled(value: boolean);
  102040. }
  102041. }
  102042. declare module BABYLON {
  102043. /** @hidden */
  102044. export var defaultFragmentDeclaration: {
  102045. name: string;
  102046. shader: string;
  102047. };
  102048. }
  102049. declare module BABYLON {
  102050. /** @hidden */
  102051. export var defaultUboDeclaration: {
  102052. name: string;
  102053. shader: string;
  102054. };
  102055. }
  102056. declare module BABYLON {
  102057. /** @hidden */
  102058. export var lightFragmentDeclaration: {
  102059. name: string;
  102060. shader: string;
  102061. };
  102062. }
  102063. declare module BABYLON {
  102064. /** @hidden */
  102065. export var lightUboDeclaration: {
  102066. name: string;
  102067. shader: string;
  102068. };
  102069. }
  102070. declare module BABYLON {
  102071. /** @hidden */
  102072. export var lightsFragmentFunctions: {
  102073. name: string;
  102074. shader: string;
  102075. };
  102076. }
  102077. declare module BABYLON {
  102078. /** @hidden */
  102079. export var shadowsFragmentFunctions: {
  102080. name: string;
  102081. shader: string;
  102082. };
  102083. }
  102084. declare module BABYLON {
  102085. /** @hidden */
  102086. export var fresnelFunction: {
  102087. name: string;
  102088. shader: string;
  102089. };
  102090. }
  102091. declare module BABYLON {
  102092. /** @hidden */
  102093. export var reflectionFunction: {
  102094. name: string;
  102095. shader: string;
  102096. };
  102097. }
  102098. declare module BABYLON {
  102099. /** @hidden */
  102100. export var bumpFragmentMainFunctions: {
  102101. name: string;
  102102. shader: string;
  102103. };
  102104. }
  102105. declare module BABYLON {
  102106. /** @hidden */
  102107. export var bumpFragmentFunctions: {
  102108. name: string;
  102109. shader: string;
  102110. };
  102111. }
  102112. declare module BABYLON {
  102113. /** @hidden */
  102114. export var logDepthDeclaration: {
  102115. name: string;
  102116. shader: string;
  102117. };
  102118. }
  102119. declare module BABYLON {
  102120. /** @hidden */
  102121. export var bumpFragment: {
  102122. name: string;
  102123. shader: string;
  102124. };
  102125. }
  102126. declare module BABYLON {
  102127. /** @hidden */
  102128. export var depthPrePass: {
  102129. name: string;
  102130. shader: string;
  102131. };
  102132. }
  102133. declare module BABYLON {
  102134. /** @hidden */
  102135. export var lightFragment: {
  102136. name: string;
  102137. shader: string;
  102138. };
  102139. }
  102140. declare module BABYLON {
  102141. /** @hidden */
  102142. export var logDepthFragment: {
  102143. name: string;
  102144. shader: string;
  102145. };
  102146. }
  102147. declare module BABYLON {
  102148. /** @hidden */
  102149. export var defaultPixelShader: {
  102150. name: string;
  102151. shader: string;
  102152. };
  102153. }
  102154. declare module BABYLON {
  102155. /** @hidden */
  102156. export var defaultVertexDeclaration: {
  102157. name: string;
  102158. shader: string;
  102159. };
  102160. }
  102161. declare module BABYLON {
  102162. /** @hidden */
  102163. export var bumpVertexDeclaration: {
  102164. name: string;
  102165. shader: string;
  102166. };
  102167. }
  102168. declare module BABYLON {
  102169. /** @hidden */
  102170. export var bumpVertex: {
  102171. name: string;
  102172. shader: string;
  102173. };
  102174. }
  102175. declare module BABYLON {
  102176. /** @hidden */
  102177. export var fogVertex: {
  102178. name: string;
  102179. shader: string;
  102180. };
  102181. }
  102182. declare module BABYLON {
  102183. /** @hidden */
  102184. export var shadowsVertex: {
  102185. name: string;
  102186. shader: string;
  102187. };
  102188. }
  102189. declare module BABYLON {
  102190. /** @hidden */
  102191. export var pointCloudVertex: {
  102192. name: string;
  102193. shader: string;
  102194. };
  102195. }
  102196. declare module BABYLON {
  102197. /** @hidden */
  102198. export var logDepthVertex: {
  102199. name: string;
  102200. shader: string;
  102201. };
  102202. }
  102203. declare module BABYLON {
  102204. /** @hidden */
  102205. export var defaultVertexShader: {
  102206. name: string;
  102207. shader: string;
  102208. };
  102209. }
  102210. declare module BABYLON {
  102211. /** @hidden */
  102212. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  102213. MAINUV1: boolean;
  102214. MAINUV2: boolean;
  102215. DIFFUSE: boolean;
  102216. DIFFUSEDIRECTUV: number;
  102217. AMBIENT: boolean;
  102218. AMBIENTDIRECTUV: number;
  102219. OPACITY: boolean;
  102220. OPACITYDIRECTUV: number;
  102221. OPACITYRGB: boolean;
  102222. REFLECTION: boolean;
  102223. EMISSIVE: boolean;
  102224. EMISSIVEDIRECTUV: number;
  102225. SPECULAR: boolean;
  102226. SPECULARDIRECTUV: number;
  102227. BUMP: boolean;
  102228. BUMPDIRECTUV: number;
  102229. PARALLAX: boolean;
  102230. PARALLAXOCCLUSION: boolean;
  102231. SPECULAROVERALPHA: boolean;
  102232. CLIPPLANE: boolean;
  102233. CLIPPLANE2: boolean;
  102234. CLIPPLANE3: boolean;
  102235. CLIPPLANE4: boolean;
  102236. CLIPPLANE5: boolean;
  102237. CLIPPLANE6: boolean;
  102238. ALPHATEST: boolean;
  102239. DEPTHPREPASS: boolean;
  102240. ALPHAFROMDIFFUSE: boolean;
  102241. POINTSIZE: boolean;
  102242. FOG: boolean;
  102243. SPECULARTERM: boolean;
  102244. DIFFUSEFRESNEL: boolean;
  102245. OPACITYFRESNEL: boolean;
  102246. REFLECTIONFRESNEL: boolean;
  102247. REFRACTIONFRESNEL: boolean;
  102248. EMISSIVEFRESNEL: boolean;
  102249. FRESNEL: boolean;
  102250. NORMAL: boolean;
  102251. UV1: boolean;
  102252. UV2: boolean;
  102253. VERTEXCOLOR: boolean;
  102254. VERTEXALPHA: boolean;
  102255. NUM_BONE_INFLUENCERS: number;
  102256. BonesPerMesh: number;
  102257. BONETEXTURE: boolean;
  102258. INSTANCES: boolean;
  102259. GLOSSINESS: boolean;
  102260. ROUGHNESS: boolean;
  102261. EMISSIVEASILLUMINATION: boolean;
  102262. LINKEMISSIVEWITHDIFFUSE: boolean;
  102263. REFLECTIONFRESNELFROMSPECULAR: boolean;
  102264. LIGHTMAP: boolean;
  102265. LIGHTMAPDIRECTUV: number;
  102266. OBJECTSPACE_NORMALMAP: boolean;
  102267. USELIGHTMAPASSHADOWMAP: boolean;
  102268. REFLECTIONMAP_3D: boolean;
  102269. REFLECTIONMAP_SPHERICAL: boolean;
  102270. REFLECTIONMAP_PLANAR: boolean;
  102271. REFLECTIONMAP_CUBIC: boolean;
  102272. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  102273. REFLECTIONMAP_PROJECTION: boolean;
  102274. REFLECTIONMAP_SKYBOX: boolean;
  102275. REFLECTIONMAP_EXPLICIT: boolean;
  102276. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  102277. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  102278. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  102279. INVERTCUBICMAP: boolean;
  102280. LOGARITHMICDEPTH: boolean;
  102281. REFRACTION: boolean;
  102282. REFRACTIONMAP_3D: boolean;
  102283. REFLECTIONOVERALPHA: boolean;
  102284. TWOSIDEDLIGHTING: boolean;
  102285. SHADOWFLOAT: boolean;
  102286. MORPHTARGETS: boolean;
  102287. MORPHTARGETS_NORMAL: boolean;
  102288. MORPHTARGETS_TANGENT: boolean;
  102289. MORPHTARGETS_UV: boolean;
  102290. NUM_MORPH_INFLUENCERS: number;
  102291. NONUNIFORMSCALING: boolean;
  102292. PREMULTIPLYALPHA: boolean;
  102293. ALPHATEST_AFTERALLALPHACOMPUTATIONS: boolean;
  102294. ALPHABLEND: boolean;
  102295. IMAGEPROCESSING: boolean;
  102296. VIGNETTE: boolean;
  102297. VIGNETTEBLENDMODEMULTIPLY: boolean;
  102298. VIGNETTEBLENDMODEOPAQUE: boolean;
  102299. TONEMAPPING: boolean;
  102300. TONEMAPPING_ACES: boolean;
  102301. CONTRAST: boolean;
  102302. COLORCURVES: boolean;
  102303. COLORGRADING: boolean;
  102304. COLORGRADING3D: boolean;
  102305. SAMPLER3DGREENDEPTH: boolean;
  102306. SAMPLER3DBGRMAP: boolean;
  102307. IMAGEPROCESSINGPOSTPROCESS: boolean;
  102308. MULTIVIEW: boolean;
  102309. /**
  102310. * If the reflection texture on this material is in linear color space
  102311. * @hidden
  102312. */
  102313. IS_REFLECTION_LINEAR: boolean;
  102314. /**
  102315. * If the refraction texture on this material is in linear color space
  102316. * @hidden
  102317. */
  102318. IS_REFRACTION_LINEAR: boolean;
  102319. EXPOSURE: boolean;
  102320. constructor();
  102321. setReflectionMode(modeToEnable: string): void;
  102322. }
  102323. /**
  102324. * This is the default material used in Babylon. It is the best trade off between quality
  102325. * and performances.
  102326. * @see http://doc.babylonjs.com/babylon101/materials
  102327. */
  102328. export class StandardMaterial extends PushMaterial {
  102329. private _diffuseTexture;
  102330. /**
  102331. * The basic texture of the material as viewed under a light.
  102332. */
  102333. diffuseTexture: Nullable<BaseTexture>;
  102334. private _ambientTexture;
  102335. /**
  102336. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  102337. */
  102338. ambientTexture: Nullable<BaseTexture>;
  102339. private _opacityTexture;
  102340. /**
  102341. * Define the transparency of the material from a texture.
  102342. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  102343. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  102344. */
  102345. opacityTexture: Nullable<BaseTexture>;
  102346. private _reflectionTexture;
  102347. /**
  102348. * Define the texture used to display the reflection.
  102349. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  102350. */
  102351. reflectionTexture: Nullable<BaseTexture>;
  102352. private _emissiveTexture;
  102353. /**
  102354. * Define texture of the material as if self lit.
  102355. * This will be mixed in the final result even in the absence of light.
  102356. */
  102357. emissiveTexture: Nullable<BaseTexture>;
  102358. private _specularTexture;
  102359. /**
  102360. * Define how the color and intensity of the highlight given by the light in the material.
  102361. */
  102362. specularTexture: Nullable<BaseTexture>;
  102363. private _bumpTexture;
  102364. /**
  102365. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  102366. * 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.
  102367. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  102368. */
  102369. bumpTexture: Nullable<BaseTexture>;
  102370. private _lightmapTexture;
  102371. /**
  102372. * Complex lighting can be computationally expensive to compute at runtime.
  102373. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  102374. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  102375. */
  102376. lightmapTexture: Nullable<BaseTexture>;
  102377. private _refractionTexture;
  102378. /**
  102379. * Define the texture used to display the refraction.
  102380. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  102381. */
  102382. refractionTexture: Nullable<BaseTexture>;
  102383. /**
  102384. * The color of the material lit by the environmental background lighting.
  102385. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  102386. */
  102387. ambientColor: Color3;
  102388. /**
  102389. * The basic color of the material as viewed under a light.
  102390. */
  102391. diffuseColor: Color3;
  102392. /**
  102393. * Define how the color and intensity of the highlight given by the light in the material.
  102394. */
  102395. specularColor: Color3;
  102396. /**
  102397. * Define the color of the material as if self lit.
  102398. * This will be mixed in the final result even in the absence of light.
  102399. */
  102400. emissiveColor: Color3;
  102401. /**
  102402. * Defines how sharp are the highlights in the material.
  102403. * The bigger the value the sharper giving a more glossy feeling to the result.
  102404. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  102405. */
  102406. specularPower: number;
  102407. private _useAlphaFromDiffuseTexture;
  102408. /**
  102409. * Does the transparency come from the diffuse texture alpha channel.
  102410. */
  102411. useAlphaFromDiffuseTexture: boolean;
  102412. private _useEmissiveAsIllumination;
  102413. /**
  102414. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  102415. */
  102416. useEmissiveAsIllumination: boolean;
  102417. private _linkEmissiveWithDiffuse;
  102418. /**
  102419. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  102420. * the emissive level when the final color is close to one.
  102421. */
  102422. linkEmissiveWithDiffuse: boolean;
  102423. private _useSpecularOverAlpha;
  102424. /**
  102425. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  102426. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  102427. */
  102428. useSpecularOverAlpha: boolean;
  102429. private _useReflectionOverAlpha;
  102430. /**
  102431. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  102432. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  102433. */
  102434. useReflectionOverAlpha: boolean;
  102435. private _disableLighting;
  102436. /**
  102437. * Does lights from the scene impacts this material.
  102438. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  102439. */
  102440. disableLighting: boolean;
  102441. private _useObjectSpaceNormalMap;
  102442. /**
  102443. * Allows using an object space normal map (instead of tangent space).
  102444. */
  102445. useObjectSpaceNormalMap: boolean;
  102446. private _useParallax;
  102447. /**
  102448. * Is parallax enabled or not.
  102449. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  102450. */
  102451. useParallax: boolean;
  102452. private _useParallaxOcclusion;
  102453. /**
  102454. * Is parallax occlusion enabled or not.
  102455. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  102456. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  102457. */
  102458. useParallaxOcclusion: boolean;
  102459. /**
  102460. * 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.
  102461. */
  102462. parallaxScaleBias: number;
  102463. private _roughness;
  102464. /**
  102465. * Helps to define how blurry the reflections should appears in the material.
  102466. */
  102467. roughness: number;
  102468. /**
  102469. * In case of refraction, define the value of the index of refraction.
  102470. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  102471. */
  102472. indexOfRefraction: number;
  102473. /**
  102474. * Invert the refraction texture alongside the y axis.
  102475. * It can be useful with procedural textures or probe for instance.
  102476. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  102477. */
  102478. invertRefractionY: boolean;
  102479. /**
  102480. * Defines the alpha limits in alpha test mode.
  102481. */
  102482. alphaCutOff: number;
  102483. private _useLightmapAsShadowmap;
  102484. /**
  102485. * In case of light mapping, define whether the map contains light or shadow informations.
  102486. */
  102487. useLightmapAsShadowmap: boolean;
  102488. private _diffuseFresnelParameters;
  102489. /**
  102490. * Define the diffuse fresnel parameters of the material.
  102491. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  102492. */
  102493. diffuseFresnelParameters: FresnelParameters;
  102494. private _opacityFresnelParameters;
  102495. /**
  102496. * Define the opacity fresnel parameters of the material.
  102497. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  102498. */
  102499. opacityFresnelParameters: FresnelParameters;
  102500. private _reflectionFresnelParameters;
  102501. /**
  102502. * Define the reflection fresnel parameters of the material.
  102503. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  102504. */
  102505. reflectionFresnelParameters: FresnelParameters;
  102506. private _refractionFresnelParameters;
  102507. /**
  102508. * Define the refraction fresnel parameters of the material.
  102509. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  102510. */
  102511. refractionFresnelParameters: FresnelParameters;
  102512. private _emissiveFresnelParameters;
  102513. /**
  102514. * Define the emissive fresnel parameters of the material.
  102515. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  102516. */
  102517. emissiveFresnelParameters: FresnelParameters;
  102518. private _useReflectionFresnelFromSpecular;
  102519. /**
  102520. * If true automatically deducts the fresnels values from the material specularity.
  102521. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  102522. */
  102523. useReflectionFresnelFromSpecular: boolean;
  102524. private _useGlossinessFromSpecularMapAlpha;
  102525. /**
  102526. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  102527. */
  102528. useGlossinessFromSpecularMapAlpha: boolean;
  102529. private _maxSimultaneousLights;
  102530. /**
  102531. * Defines the maximum number of lights that can be used in the material
  102532. */
  102533. maxSimultaneousLights: number;
  102534. private _invertNormalMapX;
  102535. /**
  102536. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  102537. */
  102538. invertNormalMapX: boolean;
  102539. private _invertNormalMapY;
  102540. /**
  102541. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  102542. */
  102543. invertNormalMapY: boolean;
  102544. private _twoSidedLighting;
  102545. /**
  102546. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  102547. */
  102548. twoSidedLighting: boolean;
  102549. /**
  102550. * Default configuration related to image processing available in the standard Material.
  102551. */
  102552. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  102553. /**
  102554. * Gets the image processing configuration used either in this material.
  102555. */
  102556. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  102557. /**
  102558. * Sets the Default image processing configuration used either in the this material.
  102559. *
  102560. * If sets to null, the scene one is in use.
  102561. */
  102562. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  102563. /**
  102564. * Keep track of the image processing observer to allow dispose and replace.
  102565. */
  102566. private _imageProcessingObserver;
  102567. /**
  102568. * Attaches a new image processing configuration to the Standard Material.
  102569. * @param configuration
  102570. */
  102571. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  102572. /**
  102573. * Gets wether the color curves effect is enabled.
  102574. */
  102575. get cameraColorCurvesEnabled(): boolean;
  102576. /**
  102577. * Sets wether the color curves effect is enabled.
  102578. */
  102579. set cameraColorCurvesEnabled(value: boolean);
  102580. /**
  102581. * Gets wether the color grading effect is enabled.
  102582. */
  102583. get cameraColorGradingEnabled(): boolean;
  102584. /**
  102585. * Gets wether the color grading effect is enabled.
  102586. */
  102587. set cameraColorGradingEnabled(value: boolean);
  102588. /**
  102589. * Gets wether tonemapping is enabled or not.
  102590. */
  102591. get cameraToneMappingEnabled(): boolean;
  102592. /**
  102593. * Sets wether tonemapping is enabled or not
  102594. */
  102595. set cameraToneMappingEnabled(value: boolean);
  102596. /**
  102597. * The camera exposure used on this material.
  102598. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  102599. * This corresponds to a photographic exposure.
  102600. */
  102601. get cameraExposure(): number;
  102602. /**
  102603. * The camera exposure used on this material.
  102604. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  102605. * This corresponds to a photographic exposure.
  102606. */
  102607. set cameraExposure(value: number);
  102608. /**
  102609. * Gets The camera contrast used on this material.
  102610. */
  102611. get cameraContrast(): number;
  102612. /**
  102613. * Sets The camera contrast used on this material.
  102614. */
  102615. set cameraContrast(value: number);
  102616. /**
  102617. * Gets the Color Grading 2D Lookup Texture.
  102618. */
  102619. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  102620. /**
  102621. * Sets the Color Grading 2D Lookup Texture.
  102622. */
  102623. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  102624. /**
  102625. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  102626. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  102627. * 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;
  102628. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  102629. */
  102630. get cameraColorCurves(): Nullable<ColorCurves>;
  102631. /**
  102632. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  102633. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  102634. * 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;
  102635. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  102636. */
  102637. set cameraColorCurves(value: Nullable<ColorCurves>);
  102638. protected _renderTargets: SmartArray<RenderTargetTexture>;
  102639. protected _worldViewProjectionMatrix: Matrix;
  102640. protected _globalAmbientColor: Color3;
  102641. protected _useLogarithmicDepth: boolean;
  102642. protected _rebuildInParallel: boolean;
  102643. /**
  102644. * Instantiates a new standard material.
  102645. * This is the default material used in Babylon. It is the best trade off between quality
  102646. * and performances.
  102647. * @see http://doc.babylonjs.com/babylon101/materials
  102648. * @param name Define the name of the material in the scene
  102649. * @param scene Define the scene the material belong to
  102650. */
  102651. constructor(name: string, scene: Scene);
  102652. /**
  102653. * Gets a boolean indicating that current material needs to register RTT
  102654. */
  102655. get hasRenderTargetTextures(): boolean;
  102656. /**
  102657. * Gets the current class name of the material e.g. "StandardMaterial"
  102658. * Mainly use in serialization.
  102659. * @returns the class name
  102660. */
  102661. getClassName(): string;
  102662. /**
  102663. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  102664. * You can try switching to logarithmic depth.
  102665. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  102666. */
  102667. get useLogarithmicDepth(): boolean;
  102668. set useLogarithmicDepth(value: boolean);
  102669. /**
  102670. * Specifies if the material will require alpha blending
  102671. * @returns a boolean specifying if alpha blending is needed
  102672. */
  102673. needAlphaBlending(): boolean;
  102674. /**
  102675. * Specifies if this material should be rendered in alpha test mode
  102676. * @returns a boolean specifying if an alpha test is needed.
  102677. */
  102678. needAlphaTesting(): boolean;
  102679. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  102680. /**
  102681. * Get the texture used for alpha test purpose.
  102682. * @returns the diffuse texture in case of the standard material.
  102683. */
  102684. getAlphaTestTexture(): Nullable<BaseTexture>;
  102685. /**
  102686. * Get if the submesh is ready to be used and all its information available.
  102687. * Child classes can use it to update shaders
  102688. * @param mesh defines the mesh to check
  102689. * @param subMesh defines which submesh to check
  102690. * @param useInstances specifies that instances should be used
  102691. * @returns a boolean indicating that the submesh is ready or not
  102692. */
  102693. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  102694. /**
  102695. * Builds the material UBO layouts.
  102696. * Used internally during the effect preparation.
  102697. */
  102698. buildUniformLayout(): void;
  102699. /**
  102700. * Unbinds the material from the mesh
  102701. */
  102702. unbind(): void;
  102703. /**
  102704. * Binds the submesh to this material by preparing the effect and shader to draw
  102705. * @param world defines the world transformation matrix
  102706. * @param mesh defines the mesh containing the submesh
  102707. * @param subMesh defines the submesh to bind the material to
  102708. */
  102709. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  102710. /**
  102711. * Get the list of animatables in the material.
  102712. * @returns the list of animatables object used in the material
  102713. */
  102714. getAnimatables(): IAnimatable[];
  102715. /**
  102716. * Gets the active textures from the material
  102717. * @returns an array of textures
  102718. */
  102719. getActiveTextures(): BaseTexture[];
  102720. /**
  102721. * Specifies if the material uses a texture
  102722. * @param texture defines the texture to check against the material
  102723. * @returns a boolean specifying if the material uses the texture
  102724. */
  102725. hasTexture(texture: BaseTexture): boolean;
  102726. /**
  102727. * Disposes the material
  102728. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  102729. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  102730. */
  102731. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  102732. /**
  102733. * Makes a duplicate of the material, and gives it a new name
  102734. * @param name defines the new name for the duplicated material
  102735. * @returns the cloned material
  102736. */
  102737. clone(name: string): StandardMaterial;
  102738. /**
  102739. * Serializes this material in a JSON representation
  102740. * @returns the serialized material object
  102741. */
  102742. serialize(): any;
  102743. /**
  102744. * Creates a standard material from parsed material data
  102745. * @param source defines the JSON representation of the material
  102746. * @param scene defines the hosting scene
  102747. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  102748. * @returns a new standard material
  102749. */
  102750. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  102751. /**
  102752. * Are diffuse textures enabled in the application.
  102753. */
  102754. static get DiffuseTextureEnabled(): boolean;
  102755. static set DiffuseTextureEnabled(value: boolean);
  102756. /**
  102757. * Are ambient textures enabled in the application.
  102758. */
  102759. static get AmbientTextureEnabled(): boolean;
  102760. static set AmbientTextureEnabled(value: boolean);
  102761. /**
  102762. * Are opacity textures enabled in the application.
  102763. */
  102764. static get OpacityTextureEnabled(): boolean;
  102765. static set OpacityTextureEnabled(value: boolean);
  102766. /**
  102767. * Are reflection textures enabled in the application.
  102768. */
  102769. static get ReflectionTextureEnabled(): boolean;
  102770. static set ReflectionTextureEnabled(value: boolean);
  102771. /**
  102772. * Are emissive textures enabled in the application.
  102773. */
  102774. static get EmissiveTextureEnabled(): boolean;
  102775. static set EmissiveTextureEnabled(value: boolean);
  102776. /**
  102777. * Are specular textures enabled in the application.
  102778. */
  102779. static get SpecularTextureEnabled(): boolean;
  102780. static set SpecularTextureEnabled(value: boolean);
  102781. /**
  102782. * Are bump textures enabled in the application.
  102783. */
  102784. static get BumpTextureEnabled(): boolean;
  102785. static set BumpTextureEnabled(value: boolean);
  102786. /**
  102787. * Are lightmap textures enabled in the application.
  102788. */
  102789. static get LightmapTextureEnabled(): boolean;
  102790. static set LightmapTextureEnabled(value: boolean);
  102791. /**
  102792. * Are refraction textures enabled in the application.
  102793. */
  102794. static get RefractionTextureEnabled(): boolean;
  102795. static set RefractionTextureEnabled(value: boolean);
  102796. /**
  102797. * Are color grading textures enabled in the application.
  102798. */
  102799. static get ColorGradingTextureEnabled(): boolean;
  102800. static set ColorGradingTextureEnabled(value: boolean);
  102801. /**
  102802. * Are fresnels enabled in the application.
  102803. */
  102804. static get FresnelEnabled(): boolean;
  102805. static set FresnelEnabled(value: boolean);
  102806. }
  102807. }
  102808. declare module BABYLON {
  102809. /**
  102810. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  102811. *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.
  102812. * The SPS is also a particle system. It provides some methods to manage the particles.
  102813. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  102814. *
  102815. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  102816. */
  102817. export class SolidParticleSystem implements IDisposable {
  102818. /**
  102819. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  102820. * Example : var p = SPS.particles[i];
  102821. */
  102822. particles: SolidParticle[];
  102823. /**
  102824. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  102825. */
  102826. nbParticles: number;
  102827. /**
  102828. * If the particles must ever face the camera (default false). Useful for planar particles.
  102829. */
  102830. billboard: boolean;
  102831. /**
  102832. * Recompute normals when adding a shape
  102833. */
  102834. recomputeNormals: boolean;
  102835. /**
  102836. * This a counter ofr your own usage. It's not set by any SPS functions.
  102837. */
  102838. counter: number;
  102839. /**
  102840. * The SPS name. This name is also given to the underlying mesh.
  102841. */
  102842. name: string;
  102843. /**
  102844. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  102845. */
  102846. mesh: Mesh;
  102847. /**
  102848. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  102849. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  102850. */
  102851. vars: any;
  102852. /**
  102853. * This array is populated when the SPS is set as 'pickable'.
  102854. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  102855. * Each element of this array is an object `{idx: int, faceId: int}`.
  102856. * `idx` is the picked particle index in the `SPS.particles` array
  102857. * `faceId` is the picked face index counted within this particle.
  102858. * This array is the first element of the pickedBySubMesh array : sps.pickBySubMesh[0].
  102859. * It's not pertinent to use it when using a SPS with the support for MultiMaterial enabled.
  102860. * Use the method SPS.pickedParticle(pickingInfo) instead.
  102861. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  102862. */
  102863. pickedParticles: {
  102864. idx: number;
  102865. faceId: number;
  102866. }[];
  102867. /**
  102868. * This array is populated when the SPS is set as 'pickable'
  102869. * Each key of this array is a submesh index.
  102870. * Each element of this array is a second array defined like this :
  102871. * Each key of this second array is a `faceId` value that you can get from a pickResult object.
  102872. * Each element of this second array is an object `{idx: int, faceId: int}`.
  102873. * `idx` is the picked particle index in the `SPS.particles` array
  102874. * `faceId` is the picked face index counted within this particle.
  102875. * It's better to use the method SPS.pickedParticle(pickingInfo) rather than using directly this array.
  102876. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  102877. */
  102878. pickedBySubMesh: {
  102879. idx: number;
  102880. faceId: number;
  102881. }[][];
  102882. /**
  102883. * This array is populated when `enableDepthSort` is set to true.
  102884. * Each element of this array is an instance of the class DepthSortedParticle.
  102885. */
  102886. depthSortedParticles: DepthSortedParticle[];
  102887. /**
  102888. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  102889. * @hidden
  102890. */
  102891. _bSphereOnly: boolean;
  102892. /**
  102893. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  102894. * @hidden
  102895. */
  102896. _bSphereRadiusFactor: number;
  102897. private _scene;
  102898. private _positions;
  102899. private _indices;
  102900. private _normals;
  102901. private _colors;
  102902. private _uvs;
  102903. private _indices32;
  102904. private _positions32;
  102905. private _normals32;
  102906. private _fixedNormal32;
  102907. private _colors32;
  102908. private _uvs32;
  102909. private _index;
  102910. private _updatable;
  102911. private _pickable;
  102912. private _isVisibilityBoxLocked;
  102913. private _alwaysVisible;
  102914. private _depthSort;
  102915. private _expandable;
  102916. private _shapeCounter;
  102917. private _copy;
  102918. private _color;
  102919. private _computeParticleColor;
  102920. private _computeParticleTexture;
  102921. private _computeParticleRotation;
  102922. private _computeParticleVertex;
  102923. private _computeBoundingBox;
  102924. private _depthSortParticles;
  102925. private _camera;
  102926. private _mustUnrotateFixedNormals;
  102927. private _particlesIntersect;
  102928. private _needs32Bits;
  102929. private _isNotBuilt;
  102930. private _lastParticleId;
  102931. private _idxOfId;
  102932. private _multimaterialEnabled;
  102933. private _useModelMaterial;
  102934. private _indicesByMaterial;
  102935. private _materialIndexes;
  102936. private _depthSortFunction;
  102937. private _materialSortFunction;
  102938. private _materials;
  102939. private _multimaterial;
  102940. private _materialIndexesById;
  102941. private _defaultMaterial;
  102942. private _autoUpdateSubMeshes;
  102943. /**
  102944. * Creates a SPS (Solid Particle System) object.
  102945. * @param name (String) is the SPS name, this will be the underlying mesh name.
  102946. * @param scene (Scene) is the scene in which the SPS is added.
  102947. * @param options defines the options of the sps e.g.
  102948. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  102949. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  102950. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  102951. * * 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.
  102952. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  102953. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  102954. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  102955. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  102956. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  102957. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  102958. */
  102959. constructor(name: string, scene: Scene, options?: {
  102960. updatable?: boolean;
  102961. isPickable?: boolean;
  102962. enableDepthSort?: boolean;
  102963. particleIntersection?: boolean;
  102964. boundingSphereOnly?: boolean;
  102965. bSphereRadiusFactor?: number;
  102966. expandable?: boolean;
  102967. useModelMaterial?: boolean;
  102968. enableMultiMaterial?: boolean;
  102969. });
  102970. /**
  102971. * Builds the SPS underlying mesh. Returns a standard Mesh.
  102972. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  102973. * @returns the created mesh
  102974. */
  102975. buildMesh(): Mesh;
  102976. /**
  102977. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  102978. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  102979. * Thus the particles generated from `digest()` have their property `position` set yet.
  102980. * @param mesh ( Mesh ) is the mesh to be digested
  102981. * @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
  102982. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  102983. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  102984. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  102985. * @returns the current SPS
  102986. */
  102987. digest(mesh: Mesh, options?: {
  102988. facetNb?: number;
  102989. number?: number;
  102990. delta?: number;
  102991. storage?: [];
  102992. }): SolidParticleSystem;
  102993. /**
  102994. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  102995. * @hidden
  102996. */
  102997. private _unrotateFixedNormals;
  102998. /**
  102999. * Resets the temporary working copy particle
  103000. * @hidden
  103001. */
  103002. private _resetCopy;
  103003. /**
  103004. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  103005. * @param p the current index in the positions array to be updated
  103006. * @param ind the current index in the indices array
  103007. * @param shape a Vector3 array, the shape geometry
  103008. * @param positions the positions array to be updated
  103009. * @param meshInd the shape indices array
  103010. * @param indices the indices array to be updated
  103011. * @param meshUV the shape uv array
  103012. * @param uvs the uv array to be updated
  103013. * @param meshCol the shape color array
  103014. * @param colors the color array to be updated
  103015. * @param meshNor the shape normals array
  103016. * @param normals the normals array to be updated
  103017. * @param idx the particle index
  103018. * @param idxInShape the particle index in its shape
  103019. * @param options the addShape() method passed options
  103020. * @model the particle model
  103021. * @hidden
  103022. */
  103023. private _meshBuilder;
  103024. /**
  103025. * Returns a shape Vector3 array from positions float array
  103026. * @param positions float array
  103027. * @returns a vector3 array
  103028. * @hidden
  103029. */
  103030. private _posToShape;
  103031. /**
  103032. * Returns a shapeUV array from a float uvs (array deep copy)
  103033. * @param uvs as a float array
  103034. * @returns a shapeUV array
  103035. * @hidden
  103036. */
  103037. private _uvsToShapeUV;
  103038. /**
  103039. * Adds a new particle object in the particles array
  103040. * @param idx particle index in particles array
  103041. * @param id particle id
  103042. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  103043. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  103044. * @param model particle ModelShape object
  103045. * @param shapeId model shape identifier
  103046. * @param idxInShape index of the particle in the current model
  103047. * @param bInfo model bounding info object
  103048. * @param storage target storage array, if any
  103049. * @hidden
  103050. */
  103051. private _addParticle;
  103052. /**
  103053. * Adds some particles to the SPS from the model shape. Returns the shape id.
  103054. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  103055. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  103056. * @param nb (positive integer) the number of particles to be created from this model
  103057. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  103058. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  103059. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  103060. * @returns the number of shapes in the system
  103061. */
  103062. addShape(mesh: Mesh, nb: number, options?: {
  103063. positionFunction?: any;
  103064. vertexFunction?: any;
  103065. storage?: [];
  103066. }): number;
  103067. /**
  103068. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  103069. * @hidden
  103070. */
  103071. private _rebuildParticle;
  103072. /**
  103073. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  103074. * @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.
  103075. * @returns the SPS.
  103076. */
  103077. rebuildMesh(reset?: boolean): SolidParticleSystem;
  103078. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  103079. * Returns an array with the removed particles.
  103080. * 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.
  103081. * The SPS can't be empty so at least one particle needs to remain in place.
  103082. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  103083. * @param start index of the first particle to remove
  103084. * @param end index of the last particle to remove (included)
  103085. * @returns an array populated with the removed particles
  103086. */
  103087. removeParticles(start: number, end: number): SolidParticle[];
  103088. /**
  103089. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  103090. * @param solidParticleArray an array populated with Solid Particles objects
  103091. * @returns the SPS
  103092. */
  103093. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  103094. /**
  103095. * Creates a new particle and modifies the SPS mesh geometry :
  103096. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  103097. * - calls _addParticle() to populate the particle array
  103098. * factorized code from addShape() and insertParticlesFromArray()
  103099. * @param idx particle index in the particles array
  103100. * @param i particle index in its shape
  103101. * @param modelShape particle ModelShape object
  103102. * @param shape shape vertex array
  103103. * @param meshInd shape indices array
  103104. * @param meshUV shape uv array
  103105. * @param meshCol shape color array
  103106. * @param meshNor shape normals array
  103107. * @param bbInfo shape bounding info
  103108. * @param storage target particle storage
  103109. * @options addShape() passed options
  103110. * @hidden
  103111. */
  103112. private _insertNewParticle;
  103113. /**
  103114. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  103115. * This method calls `updateParticle()` for each particle of the SPS.
  103116. * For an animated SPS, it is usually called within the render loop.
  103117. * 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.
  103118. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  103119. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  103120. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  103121. * @returns the SPS.
  103122. */
  103123. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  103124. /**
  103125. * Disposes the SPS.
  103126. */
  103127. dispose(): void;
  103128. /** Returns an object {idx: numbern faceId: number} for the picked particle from the passed pickingInfo object.
  103129. * idx is the particle index in the SPS
  103130. * faceId is the picked face index counted within this particle.
  103131. * Returns null if the pickInfo can't identify a picked particle.
  103132. * @param pickingInfo (PickingInfo object)
  103133. * @returns {idx: number, faceId: number} or null
  103134. */
  103135. pickedParticle(pickingInfo: PickingInfo): Nullable<{
  103136. idx: number;
  103137. faceId: number;
  103138. }>;
  103139. /**
  103140. * Returns a SolidParticle object from its identifier : particle.id
  103141. * @param id (integer) the particle Id
  103142. * @returns the searched particle or null if not found in the SPS.
  103143. */
  103144. getParticleById(id: number): Nullable<SolidParticle>;
  103145. /**
  103146. * Returns a new array populated with the particles having the passed shapeId.
  103147. * @param shapeId (integer) the shape identifier
  103148. * @returns a new solid particle array
  103149. */
  103150. getParticlesByShapeId(shapeId: number): SolidParticle[];
  103151. /**
  103152. * Populates the passed array "ref" with the particles having the passed shapeId.
  103153. * @param shapeId the shape identifier
  103154. * @returns the SPS
  103155. * @param ref
  103156. */
  103157. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  103158. /**
  103159. * Computes the required SubMeshes according the materials assigned to the particles.
  103160. * @returns the solid particle system.
  103161. * Does nothing if called before the SPS mesh is built.
  103162. */
  103163. computeSubMeshes(): SolidParticleSystem;
  103164. /**
  103165. * Sorts the solid particles by material when MultiMaterial is enabled.
  103166. * Updates the indices32 array.
  103167. * Updates the indicesByMaterial array.
  103168. * Updates the mesh indices array.
  103169. * @returns the SPS
  103170. * @hidden
  103171. */
  103172. private _sortParticlesByMaterial;
  103173. /**
  103174. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  103175. * @hidden
  103176. */
  103177. private _setMaterialIndexesById;
  103178. /**
  103179. * Returns an array with unique values of Materials from the passed array
  103180. * @param array the material array to be checked and filtered
  103181. * @hidden
  103182. */
  103183. private _filterUniqueMaterialId;
  103184. /**
  103185. * Sets a new Standard Material as _defaultMaterial if not already set.
  103186. * @hidden
  103187. */
  103188. private _setDefaultMaterial;
  103189. /**
  103190. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  103191. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  103192. * @returns the SPS.
  103193. */
  103194. refreshVisibleSize(): SolidParticleSystem;
  103195. /**
  103196. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  103197. * @param size the size (float) of the visibility box
  103198. * note : this doesn't lock the SPS mesh bounding box.
  103199. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  103200. */
  103201. setVisibilityBox(size: number): void;
  103202. /**
  103203. * Gets whether the SPS as always visible or not
  103204. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  103205. */
  103206. get isAlwaysVisible(): boolean;
  103207. /**
  103208. * Sets the SPS as always visible or not
  103209. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  103210. */
  103211. set isAlwaysVisible(val: boolean);
  103212. /**
  103213. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  103214. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  103215. */
  103216. set isVisibilityBoxLocked(val: boolean);
  103217. /**
  103218. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  103219. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  103220. */
  103221. get isVisibilityBoxLocked(): boolean;
  103222. /**
  103223. * Tells to `setParticles()` to compute the particle rotations or not.
  103224. * Default value : true. The SPS is faster when it's set to false.
  103225. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  103226. */
  103227. set computeParticleRotation(val: boolean);
  103228. /**
  103229. * Tells to `setParticles()` to compute the particle colors or not.
  103230. * Default value : true. The SPS is faster when it's set to false.
  103231. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  103232. */
  103233. set computeParticleColor(val: boolean);
  103234. set computeParticleTexture(val: boolean);
  103235. /**
  103236. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  103237. * Default value : false. The SPS is faster when it's set to false.
  103238. * Note : the particle custom vertex positions aren't stored values.
  103239. */
  103240. set computeParticleVertex(val: boolean);
  103241. /**
  103242. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  103243. */
  103244. set computeBoundingBox(val: boolean);
  103245. /**
  103246. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  103247. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  103248. * Default : `true`
  103249. */
  103250. set depthSortParticles(val: boolean);
  103251. /**
  103252. * Gets if `setParticles()` computes the particle rotations or not.
  103253. * Default value : true. The SPS is faster when it's set to false.
  103254. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  103255. */
  103256. get computeParticleRotation(): boolean;
  103257. /**
  103258. * Gets if `setParticles()` computes the particle colors or not.
  103259. * Default value : true. The SPS is faster when it's set to false.
  103260. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  103261. */
  103262. get computeParticleColor(): boolean;
  103263. /**
  103264. * Gets if `setParticles()` computes the particle textures or not.
  103265. * Default value : true. The SPS is faster when it's set to false.
  103266. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  103267. */
  103268. get computeParticleTexture(): boolean;
  103269. /**
  103270. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  103271. * Default value : false. The SPS is faster when it's set to false.
  103272. * Note : the particle custom vertex positions aren't stored values.
  103273. */
  103274. get computeParticleVertex(): boolean;
  103275. /**
  103276. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  103277. */
  103278. get computeBoundingBox(): boolean;
  103279. /**
  103280. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  103281. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  103282. * Default : `true`
  103283. */
  103284. get depthSortParticles(): boolean;
  103285. /**
  103286. * Gets if the SPS is created as expandable at construction time.
  103287. * Default : `false`
  103288. */
  103289. get expandable(): boolean;
  103290. /**
  103291. * Gets if the SPS supports the Multi Materials
  103292. */
  103293. get multimaterialEnabled(): boolean;
  103294. /**
  103295. * Gets if the SPS uses the model materials for its own multimaterial.
  103296. */
  103297. get useModelMaterial(): boolean;
  103298. /**
  103299. * The SPS used material array.
  103300. */
  103301. get materials(): Material[];
  103302. /**
  103303. * Sets the SPS MultiMaterial from the passed materials.
  103304. * Note : the passed array is internally copied and not used then by reference.
  103305. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  103306. */
  103307. setMultiMaterial(materials: Material[]): void;
  103308. /**
  103309. * The SPS computed multimaterial object
  103310. */
  103311. get multimaterial(): MultiMaterial;
  103312. set multimaterial(mm: MultiMaterial);
  103313. /**
  103314. * If the subMeshes must be updated on the next call to setParticles()
  103315. */
  103316. get autoUpdateSubMeshes(): boolean;
  103317. set autoUpdateSubMeshes(val: boolean);
  103318. /**
  103319. * This function does nothing. It may be overwritten to set all the particle first values.
  103320. * The SPS doesn't call this function, you may have to call it by your own.
  103321. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  103322. */
  103323. initParticles(): void;
  103324. /**
  103325. * This function does nothing. It may be overwritten to recycle a particle.
  103326. * The SPS doesn't call this function, you may have to call it by your own.
  103327. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  103328. * @param particle The particle to recycle
  103329. * @returns the recycled particle
  103330. */
  103331. recycleParticle(particle: SolidParticle): SolidParticle;
  103332. /**
  103333. * Updates a particle : this function should be overwritten by the user.
  103334. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  103335. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  103336. * @example : just set a particle position or velocity and recycle conditions
  103337. * @param particle The particle to update
  103338. * @returns the updated particle
  103339. */
  103340. updateParticle(particle: SolidParticle): SolidParticle;
  103341. /**
  103342. * Updates a vertex of a particle : it can be overwritten by the user.
  103343. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  103344. * @param particle the current particle
  103345. * @param vertex the current index of the current particle
  103346. * @param pt the index of the current vertex in the particle shape
  103347. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  103348. * @example : just set a vertex particle position
  103349. * @returns the updated vertex
  103350. */
  103351. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  103352. /**
  103353. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  103354. * This does nothing and may be overwritten by the user.
  103355. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  103356. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  103357. * @param update the boolean update value actually passed to setParticles()
  103358. */
  103359. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  103360. /**
  103361. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  103362. * This will be passed three parameters.
  103363. * This does nothing and may be overwritten by the user.
  103364. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  103365. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  103366. * @param update the boolean update value actually passed to setParticles()
  103367. */
  103368. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  103369. }
  103370. }
  103371. declare module BABYLON {
  103372. /**
  103373. * Represents one particle of a solid particle system.
  103374. */
  103375. export class SolidParticle {
  103376. /**
  103377. * particle global index
  103378. */
  103379. idx: number;
  103380. /**
  103381. * particle identifier
  103382. */
  103383. id: number;
  103384. /**
  103385. * The color of the particle
  103386. */
  103387. color: Nullable<Color4>;
  103388. /**
  103389. * The world space position of the particle.
  103390. */
  103391. position: Vector3;
  103392. /**
  103393. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  103394. */
  103395. rotation: Vector3;
  103396. /**
  103397. * The world space rotation quaternion of the particle.
  103398. */
  103399. rotationQuaternion: Nullable<Quaternion>;
  103400. /**
  103401. * The scaling of the particle.
  103402. */
  103403. scaling: Vector3;
  103404. /**
  103405. * The uvs of the particle.
  103406. */
  103407. uvs: Vector4;
  103408. /**
  103409. * The current speed of the particle.
  103410. */
  103411. velocity: Vector3;
  103412. /**
  103413. * The pivot point in the particle local space.
  103414. */
  103415. pivot: Vector3;
  103416. /**
  103417. * Must the particle be translated from its pivot point in its local space ?
  103418. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  103419. * Default : false
  103420. */
  103421. translateFromPivot: boolean;
  103422. /**
  103423. * Is the particle active or not ?
  103424. */
  103425. alive: boolean;
  103426. /**
  103427. * Is the particle visible or not ?
  103428. */
  103429. isVisible: boolean;
  103430. /**
  103431. * Index of this particle in the global "positions" array (Internal use)
  103432. * @hidden
  103433. */
  103434. _pos: number;
  103435. /**
  103436. * @hidden Index of this particle in the global "indices" array (Internal use)
  103437. */
  103438. _ind: number;
  103439. /**
  103440. * @hidden ModelShape of this particle (Internal use)
  103441. */
  103442. _model: ModelShape;
  103443. /**
  103444. * ModelShape id of this particle
  103445. */
  103446. shapeId: number;
  103447. /**
  103448. * Index of the particle in its shape id
  103449. */
  103450. idxInShape: number;
  103451. /**
  103452. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  103453. */
  103454. _modelBoundingInfo: BoundingInfo;
  103455. /**
  103456. * @hidden Particle BoundingInfo object (Internal use)
  103457. */
  103458. _boundingInfo: BoundingInfo;
  103459. /**
  103460. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  103461. */
  103462. _sps: SolidParticleSystem;
  103463. /**
  103464. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  103465. */
  103466. _stillInvisible: boolean;
  103467. /**
  103468. * @hidden Last computed particle rotation matrix
  103469. */
  103470. _rotationMatrix: number[];
  103471. /**
  103472. * Parent particle Id, if any.
  103473. * Default null.
  103474. */
  103475. parentId: Nullable<number>;
  103476. /**
  103477. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  103478. */
  103479. materialIndex: Nullable<number>;
  103480. /**
  103481. * Custom object or properties.
  103482. */
  103483. props: Nullable<any>;
  103484. /**
  103485. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  103486. * The possible values are :
  103487. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  103488. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  103489. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  103490. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  103491. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  103492. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  103493. * */
  103494. cullingStrategy: number;
  103495. /**
  103496. * @hidden Internal global position in the SPS.
  103497. */
  103498. _globalPosition: Vector3;
  103499. /**
  103500. * Creates a Solid Particle object.
  103501. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  103502. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  103503. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  103504. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  103505. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  103506. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  103507. * @param shapeId (integer) is the model shape identifier in the SPS.
  103508. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  103509. * @param sps defines the sps it is associated to
  103510. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  103511. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  103512. */
  103513. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  103514. /**
  103515. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  103516. * @param target the particle target
  103517. * @returns the current particle
  103518. */
  103519. copyToRef(target: SolidParticle): SolidParticle;
  103520. /**
  103521. * Legacy support, changed scale to scaling
  103522. */
  103523. get scale(): Vector3;
  103524. /**
  103525. * Legacy support, changed scale to scaling
  103526. */
  103527. set scale(scale: Vector3);
  103528. /**
  103529. * Legacy support, changed quaternion to rotationQuaternion
  103530. */
  103531. get quaternion(): Nullable<Quaternion>;
  103532. /**
  103533. * Legacy support, changed quaternion to rotationQuaternion
  103534. */
  103535. set quaternion(q: Nullable<Quaternion>);
  103536. /**
  103537. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  103538. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  103539. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  103540. * @returns true if it intersects
  103541. */
  103542. intersectsMesh(target: Mesh | SolidParticle): boolean;
  103543. /**
  103544. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  103545. * A particle is in the frustum if its bounding box intersects the frustum
  103546. * @param frustumPlanes defines the frustum to test
  103547. * @returns true if the particle is in the frustum planes
  103548. */
  103549. isInFrustum(frustumPlanes: Plane[]): boolean;
  103550. /**
  103551. * get the rotation matrix of the particle
  103552. * @hidden
  103553. */
  103554. getRotationMatrix(m: Matrix): void;
  103555. }
  103556. /**
  103557. * Represents the shape of the model used by one particle of a solid particle system.
  103558. * SPS internal tool, don't use it manually.
  103559. */
  103560. export class ModelShape {
  103561. /**
  103562. * The shape id
  103563. * @hidden
  103564. */
  103565. shapeID: number;
  103566. /**
  103567. * flat array of model positions (internal use)
  103568. * @hidden
  103569. */
  103570. _shape: Vector3[];
  103571. /**
  103572. * flat array of model UVs (internal use)
  103573. * @hidden
  103574. */
  103575. _shapeUV: number[];
  103576. /**
  103577. * color array of the model
  103578. * @hidden
  103579. */
  103580. _shapeColors: number[];
  103581. /**
  103582. * indices array of the model
  103583. * @hidden
  103584. */
  103585. _indices: number[];
  103586. /**
  103587. * normals array of the model
  103588. * @hidden
  103589. */
  103590. _normals: number[];
  103591. /**
  103592. * length of the shape in the model indices array (internal use)
  103593. * @hidden
  103594. */
  103595. _indicesLength: number;
  103596. /**
  103597. * Custom position function (internal use)
  103598. * @hidden
  103599. */
  103600. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  103601. /**
  103602. * Custom vertex function (internal use)
  103603. * @hidden
  103604. */
  103605. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  103606. /**
  103607. * Model material (internal use)
  103608. * @hidden
  103609. */
  103610. _material: Nullable<Material>;
  103611. /**
  103612. * 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.
  103613. * SPS internal tool, don't use it manually.
  103614. * @hidden
  103615. */
  103616. 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>);
  103617. }
  103618. /**
  103619. * Represents a Depth Sorted Particle in the solid particle system.
  103620. * @hidden
  103621. */
  103622. export class DepthSortedParticle {
  103623. /**
  103624. * Particle index
  103625. */
  103626. idx: number;
  103627. /**
  103628. * Index of the particle in the "indices" array
  103629. */
  103630. ind: number;
  103631. /**
  103632. * Length of the particle shape in the "indices" array
  103633. */
  103634. indicesLength: number;
  103635. /**
  103636. * Squared distance from the particle to the camera
  103637. */
  103638. sqDistance: number;
  103639. /**
  103640. * Material index when used with MultiMaterials
  103641. */
  103642. materialIndex: number;
  103643. /**
  103644. * Creates a new sorted particle
  103645. * @param materialIndex
  103646. */
  103647. constructor(idx: number, ind: number, indLength: number, materialIndex: number);
  103648. }
  103649. }
  103650. declare module BABYLON {
  103651. /**
  103652. * @hidden
  103653. */
  103654. export class _MeshCollisionData {
  103655. _checkCollisions: boolean;
  103656. _collisionMask: number;
  103657. _collisionGroup: number;
  103658. _surroundingMeshes: Nullable<AbstractMesh[]>;
  103659. _collider: Nullable<Collider>;
  103660. _oldPositionForCollisions: Vector3;
  103661. _diffPositionForCollisions: Vector3;
  103662. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  103663. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  103664. }
  103665. }
  103666. declare module BABYLON {
  103667. /** @hidden */
  103668. class _FacetDataStorage {
  103669. facetPositions: Vector3[];
  103670. facetNormals: Vector3[];
  103671. facetPartitioning: number[][];
  103672. facetNb: number;
  103673. partitioningSubdivisions: number;
  103674. partitioningBBoxRatio: number;
  103675. facetDataEnabled: boolean;
  103676. facetParameters: any;
  103677. bbSize: Vector3;
  103678. subDiv: {
  103679. max: number;
  103680. X: number;
  103681. Y: number;
  103682. Z: number;
  103683. };
  103684. facetDepthSort: boolean;
  103685. facetDepthSortEnabled: boolean;
  103686. depthSortedIndices: IndicesArray;
  103687. depthSortedFacets: {
  103688. ind: number;
  103689. sqDistance: number;
  103690. }[];
  103691. facetDepthSortFunction: (f1: {
  103692. ind: number;
  103693. sqDistance: number;
  103694. }, f2: {
  103695. ind: number;
  103696. sqDistance: number;
  103697. }) => number;
  103698. facetDepthSortFrom: Vector3;
  103699. facetDepthSortOrigin: Vector3;
  103700. invertedMatrix: Matrix;
  103701. }
  103702. /**
  103703. * @hidden
  103704. **/
  103705. class _InternalAbstractMeshDataInfo {
  103706. _hasVertexAlpha: boolean;
  103707. _useVertexColors: boolean;
  103708. _numBoneInfluencers: number;
  103709. _applyFog: boolean;
  103710. _receiveShadows: boolean;
  103711. _facetData: _FacetDataStorage;
  103712. _visibility: number;
  103713. _skeleton: Nullable<Skeleton>;
  103714. _layerMask: number;
  103715. _computeBonesUsingShaders: boolean;
  103716. _isActive: boolean;
  103717. _onlyForInstances: boolean;
  103718. _isActiveIntermediate: boolean;
  103719. _onlyForInstancesIntermediate: boolean;
  103720. _actAsRegularMesh: boolean;
  103721. }
  103722. /**
  103723. * Class used to store all common mesh properties
  103724. */
  103725. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  103726. /** No occlusion */
  103727. static OCCLUSION_TYPE_NONE: number;
  103728. /** Occlusion set to optimisitic */
  103729. static OCCLUSION_TYPE_OPTIMISTIC: number;
  103730. /** Occlusion set to strict */
  103731. static OCCLUSION_TYPE_STRICT: number;
  103732. /** Use an accurante occlusion algorithm */
  103733. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  103734. /** Use a conservative occlusion algorithm */
  103735. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  103736. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  103737. * Test order :
  103738. * Is the bounding sphere outside the frustum ?
  103739. * If not, are the bounding box vertices outside the frustum ?
  103740. * It not, then the cullable object is in the frustum.
  103741. */
  103742. static readonly CULLINGSTRATEGY_STANDARD: number;
  103743. /** Culling strategy : Bounding Sphere Only.
  103744. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  103745. * It's also less accurate than the standard because some not visible objects can still be selected.
  103746. * Test : is the bounding sphere outside the frustum ?
  103747. * If not, then the cullable object is in the frustum.
  103748. */
  103749. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  103750. /** Culling strategy : Optimistic Inclusion.
  103751. * This in an inclusion test first, then the standard exclusion test.
  103752. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  103753. * 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.
  103754. * Anyway, it's as accurate as the standard strategy.
  103755. * Test :
  103756. * Is the cullable object bounding sphere center in the frustum ?
  103757. * If not, apply the default culling strategy.
  103758. */
  103759. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  103760. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  103761. * This in an inclusion test first, then the bounding sphere only exclusion test.
  103762. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  103763. * 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.
  103764. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  103765. * Test :
  103766. * Is the cullable object bounding sphere center in the frustum ?
  103767. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  103768. */
  103769. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  103770. /**
  103771. * No billboard
  103772. */
  103773. static get BILLBOARDMODE_NONE(): number;
  103774. /** Billboard on X axis */
  103775. static get BILLBOARDMODE_X(): number;
  103776. /** Billboard on Y axis */
  103777. static get BILLBOARDMODE_Y(): number;
  103778. /** Billboard on Z axis */
  103779. static get BILLBOARDMODE_Z(): number;
  103780. /** Billboard on all axes */
  103781. static get BILLBOARDMODE_ALL(): number;
  103782. /** Billboard on using position instead of orientation */
  103783. static get BILLBOARDMODE_USE_POSITION(): number;
  103784. /** @hidden */
  103785. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  103786. /**
  103787. * The culling strategy to use to check whether the mesh must be rendered or not.
  103788. * This value can be changed at any time and will be used on the next render mesh selection.
  103789. * The possible values are :
  103790. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  103791. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  103792. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  103793. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  103794. * Please read each static variable documentation to get details about the culling process.
  103795. * */
  103796. cullingStrategy: number;
  103797. /**
  103798. * Gets the number of facets in the mesh
  103799. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  103800. */
  103801. get facetNb(): number;
  103802. /**
  103803. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  103804. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  103805. */
  103806. get partitioningSubdivisions(): number;
  103807. set partitioningSubdivisions(nb: number);
  103808. /**
  103809. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  103810. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  103811. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  103812. */
  103813. get partitioningBBoxRatio(): number;
  103814. set partitioningBBoxRatio(ratio: number);
  103815. /**
  103816. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  103817. * Works only for updatable meshes.
  103818. * Doesn't work with multi-materials
  103819. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  103820. */
  103821. get mustDepthSortFacets(): boolean;
  103822. set mustDepthSortFacets(sort: boolean);
  103823. /**
  103824. * The location (Vector3) where the facet depth sort must be computed from.
  103825. * By default, the active camera position.
  103826. * Used only when facet depth sort is enabled
  103827. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  103828. */
  103829. get facetDepthSortFrom(): Vector3;
  103830. set facetDepthSortFrom(location: Vector3);
  103831. /**
  103832. * gets a boolean indicating if facetData is enabled
  103833. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  103834. */
  103835. get isFacetDataEnabled(): boolean;
  103836. /** @hidden */
  103837. _updateNonUniformScalingState(value: boolean): boolean;
  103838. /**
  103839. * An event triggered when this mesh collides with another one
  103840. */
  103841. onCollideObservable: Observable<AbstractMesh>;
  103842. /** Set a function to call when this mesh collides with another one */
  103843. set onCollide(callback: () => void);
  103844. /**
  103845. * An event triggered when the collision's position changes
  103846. */
  103847. onCollisionPositionChangeObservable: Observable<Vector3>;
  103848. /** Set a function to call when the collision's position changes */
  103849. set onCollisionPositionChange(callback: () => void);
  103850. /**
  103851. * An event triggered when material is changed
  103852. */
  103853. onMaterialChangedObservable: Observable<AbstractMesh>;
  103854. /**
  103855. * Gets or sets the orientation for POV movement & rotation
  103856. */
  103857. definedFacingForward: boolean;
  103858. /** @hidden */
  103859. _occlusionQuery: Nullable<WebGLQuery>;
  103860. /** @hidden */
  103861. _renderingGroup: Nullable<RenderingGroup>;
  103862. /**
  103863. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  103864. */
  103865. get visibility(): number;
  103866. /**
  103867. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  103868. */
  103869. set visibility(value: number);
  103870. /** Gets or sets the alpha index used to sort transparent meshes
  103871. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  103872. */
  103873. alphaIndex: number;
  103874. /**
  103875. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  103876. */
  103877. isVisible: boolean;
  103878. /**
  103879. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  103880. */
  103881. isPickable: boolean;
  103882. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  103883. showSubMeshesBoundingBox: boolean;
  103884. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  103885. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  103886. */
  103887. isBlocker: boolean;
  103888. /**
  103889. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  103890. */
  103891. enablePointerMoveEvents: boolean;
  103892. /**
  103893. * Specifies the rendering group id for this mesh (0 by default)
  103894. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  103895. */
  103896. renderingGroupId: number;
  103897. private _material;
  103898. /** Gets or sets current material */
  103899. get material(): Nullable<Material>;
  103900. set material(value: Nullable<Material>);
  103901. /**
  103902. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  103903. * @see http://doc.babylonjs.com/babylon101/shadows
  103904. */
  103905. get receiveShadows(): boolean;
  103906. set receiveShadows(value: boolean);
  103907. /** Defines color to use when rendering outline */
  103908. outlineColor: Color3;
  103909. /** Define width to use when rendering outline */
  103910. outlineWidth: number;
  103911. /** Defines color to use when rendering overlay */
  103912. overlayColor: Color3;
  103913. /** Defines alpha to use when rendering overlay */
  103914. overlayAlpha: number;
  103915. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  103916. get hasVertexAlpha(): boolean;
  103917. set hasVertexAlpha(value: boolean);
  103918. /** 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) */
  103919. get useVertexColors(): boolean;
  103920. set useVertexColors(value: boolean);
  103921. /**
  103922. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  103923. */
  103924. get computeBonesUsingShaders(): boolean;
  103925. set computeBonesUsingShaders(value: boolean);
  103926. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  103927. get numBoneInfluencers(): number;
  103928. set numBoneInfluencers(value: number);
  103929. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  103930. get applyFog(): boolean;
  103931. set applyFog(value: boolean);
  103932. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  103933. useOctreeForRenderingSelection: boolean;
  103934. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  103935. useOctreeForPicking: boolean;
  103936. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  103937. useOctreeForCollisions: boolean;
  103938. /**
  103939. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  103940. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  103941. */
  103942. get layerMask(): number;
  103943. set layerMask(value: number);
  103944. /**
  103945. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  103946. */
  103947. alwaysSelectAsActiveMesh: boolean;
  103948. /**
  103949. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  103950. */
  103951. doNotSyncBoundingInfo: boolean;
  103952. /**
  103953. * Gets or sets the current action manager
  103954. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  103955. */
  103956. actionManager: Nullable<AbstractActionManager>;
  103957. private _meshCollisionData;
  103958. /**
  103959. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  103960. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  103961. */
  103962. ellipsoid: Vector3;
  103963. /**
  103964. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  103965. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  103966. */
  103967. ellipsoidOffset: Vector3;
  103968. /**
  103969. * Gets or sets a collision mask used to mask collisions (default is -1).
  103970. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  103971. */
  103972. get collisionMask(): number;
  103973. set collisionMask(mask: number);
  103974. /**
  103975. * Gets or sets the current collision group mask (-1 by default).
  103976. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  103977. */
  103978. get collisionGroup(): number;
  103979. set collisionGroup(mask: number);
  103980. /**
  103981. * Gets or sets current surrounding meshes (null by default).
  103982. *
  103983. * By default collision detection is tested against every mesh in the scene.
  103984. * It is possible to set surroundingMeshes to a defined list of meshes and then only these specified
  103985. * meshes will be tested for the collision.
  103986. *
  103987. * Note: if set to an empty array no collision will happen when this mesh is moved.
  103988. */
  103989. get surroundingMeshes(): Nullable<AbstractMesh[]>;
  103990. set surroundingMeshes(meshes: Nullable<AbstractMesh[]>);
  103991. /**
  103992. * Defines edge width used when edgesRenderer is enabled
  103993. * @see https://www.babylonjs-playground.com/#10OJSG#13
  103994. */
  103995. edgesWidth: number;
  103996. /**
  103997. * Defines edge color used when edgesRenderer is enabled
  103998. * @see https://www.babylonjs-playground.com/#10OJSG#13
  103999. */
  104000. edgesColor: Color4;
  104001. /** @hidden */
  104002. _edgesRenderer: Nullable<IEdgesRenderer>;
  104003. /** @hidden */
  104004. _masterMesh: Nullable<AbstractMesh>;
  104005. /** @hidden */
  104006. _boundingInfo: Nullable<BoundingInfo>;
  104007. /** @hidden */
  104008. _renderId: number;
  104009. /**
  104010. * Gets or sets the list of subMeshes
  104011. * @see http://doc.babylonjs.com/how_to/multi_materials
  104012. */
  104013. subMeshes: SubMesh[];
  104014. /** @hidden */
  104015. _intersectionsInProgress: AbstractMesh[];
  104016. /** @hidden */
  104017. _unIndexed: boolean;
  104018. /** @hidden */
  104019. _lightSources: Light[];
  104020. /** Gets the list of lights affecting that mesh */
  104021. get lightSources(): Light[];
  104022. /** @hidden */
  104023. get _positions(): Nullable<Vector3[]>;
  104024. /** @hidden */
  104025. _waitingData: {
  104026. lods: Nullable<any>;
  104027. actions: Nullable<any>;
  104028. freezeWorldMatrix: Nullable<boolean>;
  104029. };
  104030. /** @hidden */
  104031. _bonesTransformMatrices: Nullable<Float32Array>;
  104032. /** @hidden */
  104033. _transformMatrixTexture: Nullable<RawTexture>;
  104034. /**
  104035. * Gets or sets a skeleton to apply skining transformations
  104036. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  104037. */
  104038. set skeleton(value: Nullable<Skeleton>);
  104039. get skeleton(): Nullable<Skeleton>;
  104040. /**
  104041. * An event triggered when the mesh is rebuilt.
  104042. */
  104043. onRebuildObservable: Observable<AbstractMesh>;
  104044. /**
  104045. * Creates a new AbstractMesh
  104046. * @param name defines the name of the mesh
  104047. * @param scene defines the hosting scene
  104048. */
  104049. constructor(name: string, scene?: Nullable<Scene>);
  104050. /**
  104051. * Returns the string "AbstractMesh"
  104052. * @returns "AbstractMesh"
  104053. */
  104054. getClassName(): string;
  104055. /**
  104056. * Gets a string representation of the current mesh
  104057. * @param fullDetails defines a boolean indicating if full details must be included
  104058. * @returns a string representation of the current mesh
  104059. */
  104060. toString(fullDetails?: boolean): string;
  104061. /**
  104062. * @hidden
  104063. */
  104064. protected _getEffectiveParent(): Nullable<Node>;
  104065. /** @hidden */
  104066. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  104067. /** @hidden */
  104068. _rebuild(): void;
  104069. /** @hidden */
  104070. _resyncLightSources(): void;
  104071. /** @hidden */
  104072. _resyncLightSource(light: Light): void;
  104073. /** @hidden */
  104074. _unBindEffect(): void;
  104075. /** @hidden */
  104076. _removeLightSource(light: Light, dispose: boolean): void;
  104077. private _markSubMeshesAsDirty;
  104078. /** @hidden */
  104079. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  104080. /** @hidden */
  104081. _markSubMeshesAsAttributesDirty(): void;
  104082. /** @hidden */
  104083. _markSubMeshesAsMiscDirty(): void;
  104084. /**
  104085. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  104086. */
  104087. get scaling(): Vector3;
  104088. set scaling(newScaling: Vector3);
  104089. /**
  104090. * Returns true if the mesh is blocked. Implemented by child classes
  104091. */
  104092. get isBlocked(): boolean;
  104093. /**
  104094. * Returns the mesh itself by default. Implemented by child classes
  104095. * @param camera defines the camera to use to pick the right LOD level
  104096. * @returns the currentAbstractMesh
  104097. */
  104098. getLOD(camera: Camera): Nullable<AbstractMesh>;
  104099. /**
  104100. * Returns 0 by default. Implemented by child classes
  104101. * @returns an integer
  104102. */
  104103. getTotalVertices(): number;
  104104. /**
  104105. * Returns a positive integer : the total number of indices in this mesh geometry.
  104106. * @returns the numner of indices or zero if the mesh has no geometry.
  104107. */
  104108. getTotalIndices(): number;
  104109. /**
  104110. * Returns null by default. Implemented by child classes
  104111. * @returns null
  104112. */
  104113. getIndices(): Nullable<IndicesArray>;
  104114. /**
  104115. * Returns the array of the requested vertex data kind. Implemented by child classes
  104116. * @param kind defines the vertex data kind to use
  104117. * @returns null
  104118. */
  104119. getVerticesData(kind: string): Nullable<FloatArray>;
  104120. /**
  104121. * Sets the vertex data of the mesh geometry for the requested `kind`.
  104122. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  104123. * Note that a new underlying VertexBuffer object is created each call.
  104124. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  104125. * @param kind defines vertex data kind:
  104126. * * VertexBuffer.PositionKind
  104127. * * VertexBuffer.UVKind
  104128. * * VertexBuffer.UV2Kind
  104129. * * VertexBuffer.UV3Kind
  104130. * * VertexBuffer.UV4Kind
  104131. * * VertexBuffer.UV5Kind
  104132. * * VertexBuffer.UV6Kind
  104133. * * VertexBuffer.ColorKind
  104134. * * VertexBuffer.MatricesIndicesKind
  104135. * * VertexBuffer.MatricesIndicesExtraKind
  104136. * * VertexBuffer.MatricesWeightsKind
  104137. * * VertexBuffer.MatricesWeightsExtraKind
  104138. * @param data defines the data source
  104139. * @param updatable defines if the data must be flagged as updatable (or static)
  104140. * @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
  104141. * @returns the current mesh
  104142. */
  104143. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  104144. /**
  104145. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  104146. * If the mesh has no geometry, it is simply returned as it is.
  104147. * @param kind defines vertex data kind:
  104148. * * VertexBuffer.PositionKind
  104149. * * VertexBuffer.UVKind
  104150. * * VertexBuffer.UV2Kind
  104151. * * VertexBuffer.UV3Kind
  104152. * * VertexBuffer.UV4Kind
  104153. * * VertexBuffer.UV5Kind
  104154. * * VertexBuffer.UV6Kind
  104155. * * VertexBuffer.ColorKind
  104156. * * VertexBuffer.MatricesIndicesKind
  104157. * * VertexBuffer.MatricesIndicesExtraKind
  104158. * * VertexBuffer.MatricesWeightsKind
  104159. * * VertexBuffer.MatricesWeightsExtraKind
  104160. * @param data defines the data source
  104161. * @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
  104162. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  104163. * @returns the current mesh
  104164. */
  104165. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  104166. /**
  104167. * Sets the mesh indices,
  104168. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  104169. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  104170. * @param totalVertices Defines the total number of vertices
  104171. * @returns the current mesh
  104172. */
  104173. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  104174. /**
  104175. * Gets a boolean indicating if specific vertex data is present
  104176. * @param kind defines the vertex data kind to use
  104177. * @returns true is data kind is present
  104178. */
  104179. isVerticesDataPresent(kind: string): boolean;
  104180. /**
  104181. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  104182. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  104183. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  104184. * @returns a BoundingInfo
  104185. */
  104186. getBoundingInfo(): BoundingInfo;
  104187. /**
  104188. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  104189. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  104190. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  104191. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  104192. * @returns the current mesh
  104193. */
  104194. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  104195. /**
  104196. * Overwrite the current bounding info
  104197. * @param boundingInfo defines the new bounding info
  104198. * @returns the current mesh
  104199. */
  104200. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  104201. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  104202. get useBones(): boolean;
  104203. /** @hidden */
  104204. _preActivate(): void;
  104205. /** @hidden */
  104206. _preActivateForIntermediateRendering(renderId: number): void;
  104207. /** @hidden */
  104208. _activate(renderId: number, intermediateRendering: boolean): boolean;
  104209. /** @hidden */
  104210. _postActivate(): void;
  104211. /** @hidden */
  104212. _freeze(): void;
  104213. /** @hidden */
  104214. _unFreeze(): void;
  104215. /**
  104216. * Gets the current world matrix
  104217. * @returns a Matrix
  104218. */
  104219. getWorldMatrix(): Matrix;
  104220. /** @hidden */
  104221. _getWorldMatrixDeterminant(): number;
  104222. /**
  104223. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  104224. */
  104225. get isAnInstance(): boolean;
  104226. /**
  104227. * Gets a boolean indicating if this mesh has instances
  104228. */
  104229. get hasInstances(): boolean;
  104230. /**
  104231. * Perform relative position change from the point of view of behind the front of the mesh.
  104232. * This is performed taking into account the meshes current rotation, so you do not have to care.
  104233. * Supports definition of mesh facing forward or backward
  104234. * @param amountRight defines the distance on the right axis
  104235. * @param amountUp defines the distance on the up axis
  104236. * @param amountForward defines the distance on the forward axis
  104237. * @returns the current mesh
  104238. */
  104239. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  104240. /**
  104241. * Calculate relative position change from the point of view of behind the front of the mesh.
  104242. * This is performed taking into account the meshes current rotation, so you do not have to care.
  104243. * Supports definition of mesh facing forward or backward
  104244. * @param amountRight defines the distance on the right axis
  104245. * @param amountUp defines the distance on the up axis
  104246. * @param amountForward defines the distance on the forward axis
  104247. * @returns the new displacement vector
  104248. */
  104249. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  104250. /**
  104251. * Perform relative rotation change from the point of view of behind the front of the mesh.
  104252. * Supports definition of mesh facing forward or backward
  104253. * @param flipBack defines the flip
  104254. * @param twirlClockwise defines the twirl
  104255. * @param tiltRight defines the tilt
  104256. * @returns the current mesh
  104257. */
  104258. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  104259. /**
  104260. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  104261. * Supports definition of mesh facing forward or backward.
  104262. * @param flipBack defines the flip
  104263. * @param twirlClockwise defines the twirl
  104264. * @param tiltRight defines the tilt
  104265. * @returns the new rotation vector
  104266. */
  104267. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  104268. /**
  104269. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  104270. * This means the mesh underlying bounding box and sphere are recomputed.
  104271. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  104272. * @returns the current mesh
  104273. */
  104274. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  104275. /** @hidden */
  104276. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  104277. /** @hidden */
  104278. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  104279. /** @hidden */
  104280. _updateBoundingInfo(): AbstractMesh;
  104281. /** @hidden */
  104282. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  104283. /** @hidden */
  104284. protected _afterComputeWorldMatrix(): void;
  104285. /** @hidden */
  104286. get _effectiveMesh(): AbstractMesh;
  104287. /**
  104288. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  104289. * A mesh is in the frustum if its bounding box intersects the frustum
  104290. * @param frustumPlanes defines the frustum to test
  104291. * @returns true if the mesh is in the frustum planes
  104292. */
  104293. isInFrustum(frustumPlanes: Plane[]): boolean;
  104294. /**
  104295. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  104296. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  104297. * @param frustumPlanes defines the frustum to test
  104298. * @returns true if the mesh is completely in the frustum planes
  104299. */
  104300. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  104301. /**
  104302. * True if the mesh intersects another mesh or a SolidParticle object
  104303. * @param mesh defines a target mesh or SolidParticle to test
  104304. * @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)
  104305. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  104306. * @returns true if there is an intersection
  104307. */
  104308. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  104309. /**
  104310. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  104311. * @param point defines the point to test
  104312. * @returns true if there is an intersection
  104313. */
  104314. intersectsPoint(point: Vector3): boolean;
  104315. /**
  104316. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  104317. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  104318. */
  104319. get checkCollisions(): boolean;
  104320. set checkCollisions(collisionEnabled: boolean);
  104321. /**
  104322. * Gets Collider object used to compute collisions (not physics)
  104323. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  104324. */
  104325. get collider(): Nullable<Collider>;
  104326. /**
  104327. * Move the mesh using collision engine
  104328. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  104329. * @param displacement defines the requested displacement vector
  104330. * @returns the current mesh
  104331. */
  104332. moveWithCollisions(displacement: Vector3): AbstractMesh;
  104333. private _onCollisionPositionChange;
  104334. /** @hidden */
  104335. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  104336. /** @hidden */
  104337. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  104338. /** @hidden */
  104339. _checkCollision(collider: Collider): AbstractMesh;
  104340. /** @hidden */
  104341. _generatePointsArray(): boolean;
  104342. /**
  104343. * Checks if the passed Ray intersects with the mesh
  104344. * @param ray defines the ray to use
  104345. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  104346. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  104347. * @param onlyBoundingInfo defines a boolean indicating if picking should only happen using bounding info (false by default)
  104348. * @returns the picking info
  104349. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  104350. */
  104351. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate, onlyBoundingInfo?: boolean): PickingInfo;
  104352. /**
  104353. * Clones the current mesh
  104354. * @param name defines the mesh name
  104355. * @param newParent defines the new mesh parent
  104356. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  104357. * @returns the new mesh
  104358. */
  104359. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  104360. /**
  104361. * Disposes all the submeshes of the current meshnp
  104362. * @returns the current mesh
  104363. */
  104364. releaseSubMeshes(): AbstractMesh;
  104365. /**
  104366. * Releases resources associated with this abstract mesh.
  104367. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  104368. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  104369. */
  104370. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  104371. /**
  104372. * Adds the passed mesh as a child to the current mesh
  104373. * @param mesh defines the child mesh
  104374. * @returns the current mesh
  104375. */
  104376. addChild(mesh: AbstractMesh): AbstractMesh;
  104377. /**
  104378. * Removes the passed mesh from the current mesh children list
  104379. * @param mesh defines the child mesh
  104380. * @returns the current mesh
  104381. */
  104382. removeChild(mesh: AbstractMesh): AbstractMesh;
  104383. /** @hidden */
  104384. private _initFacetData;
  104385. /**
  104386. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  104387. * This method can be called within the render loop.
  104388. * 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
  104389. * @returns the current mesh
  104390. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  104391. */
  104392. updateFacetData(): AbstractMesh;
  104393. /**
  104394. * Returns the facetLocalNormals array.
  104395. * The normals are expressed in the mesh local spac
  104396. * @returns an array of Vector3
  104397. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  104398. */
  104399. getFacetLocalNormals(): Vector3[];
  104400. /**
  104401. * Returns the facetLocalPositions array.
  104402. * The facet positions are expressed in the mesh local space
  104403. * @returns an array of Vector3
  104404. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  104405. */
  104406. getFacetLocalPositions(): Vector3[];
  104407. /**
  104408. * Returns the facetLocalPartioning array
  104409. * @returns an array of array of numbers
  104410. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  104411. */
  104412. getFacetLocalPartitioning(): number[][];
  104413. /**
  104414. * Returns the i-th facet position in the world system.
  104415. * This method allocates a new Vector3 per call
  104416. * @param i defines the facet index
  104417. * @returns a new Vector3
  104418. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  104419. */
  104420. getFacetPosition(i: number): Vector3;
  104421. /**
  104422. * Sets the reference Vector3 with the i-th facet position in the world system
  104423. * @param i defines the facet index
  104424. * @param ref defines the target vector
  104425. * @returns the current mesh
  104426. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  104427. */
  104428. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  104429. /**
  104430. * Returns the i-th facet normal in the world system.
  104431. * This method allocates a new Vector3 per call
  104432. * @param i defines the facet index
  104433. * @returns a new Vector3
  104434. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  104435. */
  104436. getFacetNormal(i: number): Vector3;
  104437. /**
  104438. * Sets the reference Vector3 with the i-th facet normal in the world system
  104439. * @param i defines the facet index
  104440. * @param ref defines the target vector
  104441. * @returns the current mesh
  104442. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  104443. */
  104444. getFacetNormalToRef(i: number, ref: Vector3): this;
  104445. /**
  104446. * 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)
  104447. * @param x defines x coordinate
  104448. * @param y defines y coordinate
  104449. * @param z defines z coordinate
  104450. * @returns the array of facet indexes
  104451. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  104452. */
  104453. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  104454. /**
  104455. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  104456. * @param projected sets as the (x,y,z) world projection on the facet
  104457. * @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
  104458. * @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
  104459. * @param x defines x coordinate
  104460. * @param y defines y coordinate
  104461. * @param z defines z coordinate
  104462. * @returns the face index if found (or null instead)
  104463. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  104464. */
  104465. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  104466. /**
  104467. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  104468. * @param projected sets as the (x,y,z) local projection on the facet
  104469. * @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
  104470. * @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
  104471. * @param x defines x coordinate
  104472. * @param y defines y coordinate
  104473. * @param z defines z coordinate
  104474. * @returns the face index if found (or null instead)
  104475. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  104476. */
  104477. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  104478. /**
  104479. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  104480. * @returns the parameters
  104481. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  104482. */
  104483. getFacetDataParameters(): any;
  104484. /**
  104485. * Disables the feature FacetData and frees the related memory
  104486. * @returns the current mesh
  104487. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  104488. */
  104489. disableFacetData(): AbstractMesh;
  104490. /**
  104491. * Updates the AbstractMesh indices array
  104492. * @param indices defines the data source
  104493. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  104494. * @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)
  104495. * @returns the current mesh
  104496. */
  104497. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  104498. /**
  104499. * Creates new normals data for the mesh
  104500. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  104501. * @returns the current mesh
  104502. */
  104503. createNormals(updatable: boolean): AbstractMesh;
  104504. /**
  104505. * Align the mesh with a normal
  104506. * @param normal defines the normal to use
  104507. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  104508. * @returns the current mesh
  104509. */
  104510. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  104511. /** @hidden */
  104512. _checkOcclusionQuery(): boolean;
  104513. /**
  104514. * Disables the mesh edge rendering mode
  104515. * @returns the currentAbstractMesh
  104516. */
  104517. disableEdgesRendering(): AbstractMesh;
  104518. /**
  104519. * Enables the edge rendering mode on the mesh.
  104520. * This mode makes the mesh edges visible
  104521. * @param epsilon defines the maximal distance between two angles to detect a face
  104522. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  104523. * @returns the currentAbstractMesh
  104524. * @see https://www.babylonjs-playground.com/#19O9TU#0
  104525. */
  104526. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  104527. }
  104528. }
  104529. declare module BABYLON {
  104530. /**
  104531. * Interface used to define ActionEvent
  104532. */
  104533. export interface IActionEvent {
  104534. /** The mesh or sprite that triggered the action */
  104535. source: any;
  104536. /** The X mouse cursor position at the time of the event */
  104537. pointerX: number;
  104538. /** The Y mouse cursor position at the time of the event */
  104539. pointerY: number;
  104540. /** The mesh that is currently pointed at (can be null) */
  104541. meshUnderPointer: Nullable<AbstractMesh>;
  104542. /** the original (browser) event that triggered the ActionEvent */
  104543. sourceEvent?: any;
  104544. /** additional data for the event */
  104545. additionalData?: any;
  104546. }
  104547. /**
  104548. * ActionEvent is the event being sent when an action is triggered.
  104549. */
  104550. export class ActionEvent implements IActionEvent {
  104551. /** The mesh or sprite that triggered the action */
  104552. source: any;
  104553. /** The X mouse cursor position at the time of the event */
  104554. pointerX: number;
  104555. /** The Y mouse cursor position at the time of the event */
  104556. pointerY: number;
  104557. /** The mesh that is currently pointed at (can be null) */
  104558. meshUnderPointer: Nullable<AbstractMesh>;
  104559. /** the original (browser) event that triggered the ActionEvent */
  104560. sourceEvent?: any;
  104561. /** additional data for the event */
  104562. additionalData?: any;
  104563. /**
  104564. * Creates a new ActionEvent
  104565. * @param source The mesh or sprite that triggered the action
  104566. * @param pointerX The X mouse cursor position at the time of the event
  104567. * @param pointerY The Y mouse cursor position at the time of the event
  104568. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  104569. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  104570. * @param additionalData additional data for the event
  104571. */
  104572. constructor(
  104573. /** The mesh or sprite that triggered the action */
  104574. source: any,
  104575. /** The X mouse cursor position at the time of the event */
  104576. pointerX: number,
  104577. /** The Y mouse cursor position at the time of the event */
  104578. pointerY: number,
  104579. /** The mesh that is currently pointed at (can be null) */
  104580. meshUnderPointer: Nullable<AbstractMesh>,
  104581. /** the original (browser) event that triggered the ActionEvent */
  104582. sourceEvent?: any,
  104583. /** additional data for the event */
  104584. additionalData?: any);
  104585. /**
  104586. * Helper function to auto-create an ActionEvent from a source mesh.
  104587. * @param source The source mesh that triggered the event
  104588. * @param evt The original (browser) event
  104589. * @param additionalData additional data for the event
  104590. * @returns the new ActionEvent
  104591. */
  104592. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  104593. /**
  104594. * Helper function to auto-create an ActionEvent from a source sprite
  104595. * @param source The source sprite that triggered the event
  104596. * @param scene Scene associated with the sprite
  104597. * @param evt The original (browser) event
  104598. * @param additionalData additional data for the event
  104599. * @returns the new ActionEvent
  104600. */
  104601. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  104602. /**
  104603. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  104604. * @param scene the scene where the event occurred
  104605. * @param evt The original (browser) event
  104606. * @returns the new ActionEvent
  104607. */
  104608. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  104609. /**
  104610. * Helper function to auto-create an ActionEvent from a primitive
  104611. * @param prim defines the target primitive
  104612. * @param pointerPos defines the pointer position
  104613. * @param evt The original (browser) event
  104614. * @param additionalData additional data for the event
  104615. * @returns the new ActionEvent
  104616. */
  104617. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  104618. }
  104619. }
  104620. declare module BABYLON {
  104621. /**
  104622. * Abstract class used to decouple action Manager from scene and meshes.
  104623. * Do not instantiate.
  104624. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  104625. */
  104626. export abstract class AbstractActionManager implements IDisposable {
  104627. /** Gets the list of active triggers */
  104628. static Triggers: {
  104629. [key: string]: number;
  104630. };
  104631. /** Gets the cursor to use when hovering items */
  104632. hoverCursor: string;
  104633. /** Gets the list of actions */
  104634. actions: IAction[];
  104635. /**
  104636. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  104637. */
  104638. isRecursive: boolean;
  104639. /**
  104640. * Releases all associated resources
  104641. */
  104642. abstract dispose(): void;
  104643. /**
  104644. * Does this action manager has pointer triggers
  104645. */
  104646. abstract get hasPointerTriggers(): boolean;
  104647. /**
  104648. * Does this action manager has pick triggers
  104649. */
  104650. abstract get hasPickTriggers(): boolean;
  104651. /**
  104652. * Process a specific trigger
  104653. * @param trigger defines the trigger to process
  104654. * @param evt defines the event details to be processed
  104655. */
  104656. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  104657. /**
  104658. * Does this action manager handles actions of any of the given triggers
  104659. * @param triggers defines the triggers to be tested
  104660. * @return a boolean indicating whether one (or more) of the triggers is handled
  104661. */
  104662. abstract hasSpecificTriggers(triggers: number[]): boolean;
  104663. /**
  104664. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  104665. * speed.
  104666. * @param triggerA defines the trigger to be tested
  104667. * @param triggerB defines the trigger to be tested
  104668. * @return a boolean indicating whether one (or more) of the triggers is handled
  104669. */
  104670. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  104671. /**
  104672. * Does this action manager handles actions of a given trigger
  104673. * @param trigger defines the trigger to be tested
  104674. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  104675. * @return whether the trigger is handled
  104676. */
  104677. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  104678. /**
  104679. * Serialize this manager to a JSON object
  104680. * @param name defines the property name to store this manager
  104681. * @returns a JSON representation of this manager
  104682. */
  104683. abstract serialize(name: string): any;
  104684. /**
  104685. * Registers an action to this action manager
  104686. * @param action defines the action to be registered
  104687. * @return the action amended (prepared) after registration
  104688. */
  104689. abstract registerAction(action: IAction): Nullable<IAction>;
  104690. /**
  104691. * Unregisters an action to this action manager
  104692. * @param action defines the action to be unregistered
  104693. * @return a boolean indicating whether the action has been unregistered
  104694. */
  104695. abstract unregisterAction(action: IAction): Boolean;
  104696. /**
  104697. * Does exist one action manager with at least one trigger
  104698. **/
  104699. static get HasTriggers(): boolean;
  104700. /**
  104701. * Does exist one action manager with at least one pick trigger
  104702. **/
  104703. static get HasPickTriggers(): boolean;
  104704. /**
  104705. * Does exist one action manager that handles actions of a given trigger
  104706. * @param trigger defines the trigger to be tested
  104707. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  104708. **/
  104709. static HasSpecificTrigger(trigger: number): boolean;
  104710. }
  104711. }
  104712. declare module BABYLON {
  104713. /**
  104714. * Defines how a node can be built from a string name.
  104715. */
  104716. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  104717. /**
  104718. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  104719. */
  104720. export class Node implements IBehaviorAware<Node> {
  104721. /** @hidden */
  104722. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  104723. private static _NodeConstructors;
  104724. /**
  104725. * Add a new node constructor
  104726. * @param type defines the type name of the node to construct
  104727. * @param constructorFunc defines the constructor function
  104728. */
  104729. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  104730. /**
  104731. * Returns a node constructor based on type name
  104732. * @param type defines the type name
  104733. * @param name defines the new node name
  104734. * @param scene defines the hosting scene
  104735. * @param options defines optional options to transmit to constructors
  104736. * @returns the new constructor or null
  104737. */
  104738. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  104739. /**
  104740. * Gets or sets the name of the node
  104741. */
  104742. name: string;
  104743. /**
  104744. * Gets or sets the id of the node
  104745. */
  104746. id: string;
  104747. /**
  104748. * Gets or sets the unique id of the node
  104749. */
  104750. uniqueId: number;
  104751. /**
  104752. * Gets or sets a string used to store user defined state for the node
  104753. */
  104754. state: string;
  104755. /**
  104756. * Gets or sets an object used to store user defined information for the node
  104757. */
  104758. metadata: any;
  104759. /**
  104760. * For internal use only. Please do not use.
  104761. */
  104762. reservedDataStore: any;
  104763. /**
  104764. * List of inspectable custom properties (used by the Inspector)
  104765. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  104766. */
  104767. inspectableCustomProperties: IInspectable[];
  104768. private _doNotSerialize;
  104769. /**
  104770. * Gets or sets a boolean used to define if the node must be serialized
  104771. */
  104772. get doNotSerialize(): boolean;
  104773. set doNotSerialize(value: boolean);
  104774. /** @hidden */
  104775. _isDisposed: boolean;
  104776. /**
  104777. * Gets a list of Animations associated with the node
  104778. */
  104779. animations: Animation[];
  104780. protected _ranges: {
  104781. [name: string]: Nullable<AnimationRange>;
  104782. };
  104783. /**
  104784. * Callback raised when the node is ready to be used
  104785. */
  104786. onReady: Nullable<(node: Node) => void>;
  104787. private _isEnabled;
  104788. private _isParentEnabled;
  104789. private _isReady;
  104790. /** @hidden */
  104791. _currentRenderId: number;
  104792. private _parentUpdateId;
  104793. /** @hidden */
  104794. _childUpdateId: number;
  104795. /** @hidden */
  104796. _waitingParentId: Nullable<string>;
  104797. /** @hidden */
  104798. _scene: Scene;
  104799. /** @hidden */
  104800. _cache: any;
  104801. private _parentNode;
  104802. private _children;
  104803. /** @hidden */
  104804. _worldMatrix: Matrix;
  104805. /** @hidden */
  104806. _worldMatrixDeterminant: number;
  104807. /** @hidden */
  104808. _worldMatrixDeterminantIsDirty: boolean;
  104809. /** @hidden */
  104810. private _sceneRootNodesIndex;
  104811. /**
  104812. * Gets a boolean indicating if the node has been disposed
  104813. * @returns true if the node was disposed
  104814. */
  104815. isDisposed(): boolean;
  104816. /**
  104817. * Gets or sets the parent of the node (without keeping the current position in the scene)
  104818. * @see https://doc.babylonjs.com/how_to/parenting
  104819. */
  104820. set parent(parent: Nullable<Node>);
  104821. get parent(): Nullable<Node>;
  104822. /** @hidden */
  104823. _addToSceneRootNodes(): void;
  104824. /** @hidden */
  104825. _removeFromSceneRootNodes(): void;
  104826. private _animationPropertiesOverride;
  104827. /**
  104828. * Gets or sets the animation properties override
  104829. */
  104830. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  104831. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  104832. /**
  104833. * Gets a string idenfifying the name of the class
  104834. * @returns "Node" string
  104835. */
  104836. getClassName(): string;
  104837. /** @hidden */
  104838. readonly _isNode: boolean;
  104839. /**
  104840. * An event triggered when the mesh is disposed
  104841. */
  104842. onDisposeObservable: Observable<Node>;
  104843. private _onDisposeObserver;
  104844. /**
  104845. * Sets a callback that will be raised when the node will be disposed
  104846. */
  104847. set onDispose(callback: () => void);
  104848. /**
  104849. * Creates a new Node
  104850. * @param name the name and id to be given to this node
  104851. * @param scene the scene this node will be added to
  104852. */
  104853. constructor(name: string, scene?: Nullable<Scene>);
  104854. /**
  104855. * Gets the scene of the node
  104856. * @returns a scene
  104857. */
  104858. getScene(): Scene;
  104859. /**
  104860. * Gets the engine of the node
  104861. * @returns a Engine
  104862. */
  104863. getEngine(): Engine;
  104864. private _behaviors;
  104865. /**
  104866. * Attach a behavior to the node
  104867. * @see http://doc.babylonjs.com/features/behaviour
  104868. * @param behavior defines the behavior to attach
  104869. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  104870. * @returns the current Node
  104871. */
  104872. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  104873. /**
  104874. * Remove an attached behavior
  104875. * @see http://doc.babylonjs.com/features/behaviour
  104876. * @param behavior defines the behavior to attach
  104877. * @returns the current Node
  104878. */
  104879. removeBehavior(behavior: Behavior<Node>): Node;
  104880. /**
  104881. * Gets the list of attached behaviors
  104882. * @see http://doc.babylonjs.com/features/behaviour
  104883. */
  104884. get behaviors(): Behavior<Node>[];
  104885. /**
  104886. * Gets an attached behavior by name
  104887. * @param name defines the name of the behavior to look for
  104888. * @see http://doc.babylonjs.com/features/behaviour
  104889. * @returns null if behavior was not found else the requested behavior
  104890. */
  104891. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  104892. /**
  104893. * Returns the latest update of the World matrix
  104894. * @returns a Matrix
  104895. */
  104896. getWorldMatrix(): Matrix;
  104897. /** @hidden */
  104898. _getWorldMatrixDeterminant(): number;
  104899. /**
  104900. * Returns directly the latest state of the mesh World matrix.
  104901. * A Matrix is returned.
  104902. */
  104903. get worldMatrixFromCache(): Matrix;
  104904. /** @hidden */
  104905. _initCache(): void;
  104906. /** @hidden */
  104907. updateCache(force?: boolean): void;
  104908. /** @hidden */
  104909. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  104910. /** @hidden */
  104911. _updateCache(ignoreParentClass?: boolean): void;
  104912. /** @hidden */
  104913. _isSynchronized(): boolean;
  104914. /** @hidden */
  104915. _markSyncedWithParent(): void;
  104916. /** @hidden */
  104917. isSynchronizedWithParent(): boolean;
  104918. /** @hidden */
  104919. isSynchronized(): boolean;
  104920. /**
  104921. * Is this node ready to be used/rendered
  104922. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  104923. * @return true if the node is ready
  104924. */
  104925. isReady(completeCheck?: boolean): boolean;
  104926. /**
  104927. * Is this node enabled?
  104928. * 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
  104929. * @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
  104930. * @return whether this node (and its parent) is enabled
  104931. */
  104932. isEnabled(checkAncestors?: boolean): boolean;
  104933. /** @hidden */
  104934. protected _syncParentEnabledState(): void;
  104935. /**
  104936. * Set the enabled state of this node
  104937. * @param value defines the new enabled state
  104938. */
  104939. setEnabled(value: boolean): void;
  104940. /**
  104941. * Is this node a descendant of the given node?
  104942. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  104943. * @param ancestor defines the parent node to inspect
  104944. * @returns a boolean indicating if this node is a descendant of the given node
  104945. */
  104946. isDescendantOf(ancestor: Node): boolean;
  104947. /** @hidden */
  104948. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  104949. /**
  104950. * Will return all nodes that have this node as ascendant
  104951. * @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
  104952. * @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
  104953. * @return all children nodes of all types
  104954. */
  104955. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  104956. /**
  104957. * Get all child-meshes of this node
  104958. * @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)
  104959. * @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
  104960. * @returns an array of AbstractMesh
  104961. */
  104962. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  104963. /**
  104964. * Get all direct children of this node
  104965. * @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
  104966. * @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)
  104967. * @returns an array of Node
  104968. */
  104969. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  104970. /** @hidden */
  104971. _setReady(state: boolean): void;
  104972. /**
  104973. * Get an animation by name
  104974. * @param name defines the name of the animation to look for
  104975. * @returns null if not found else the requested animation
  104976. */
  104977. getAnimationByName(name: string): Nullable<Animation>;
  104978. /**
  104979. * Creates an animation range for this node
  104980. * @param name defines the name of the range
  104981. * @param from defines the starting key
  104982. * @param to defines the end key
  104983. */
  104984. createAnimationRange(name: string, from: number, to: number): void;
  104985. /**
  104986. * Delete a specific animation range
  104987. * @param name defines the name of the range to delete
  104988. * @param deleteFrames defines if animation frames from the range must be deleted as well
  104989. */
  104990. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  104991. /**
  104992. * Get an animation range by name
  104993. * @param name defines the name of the animation range to look for
  104994. * @returns null if not found else the requested animation range
  104995. */
  104996. getAnimationRange(name: string): Nullable<AnimationRange>;
  104997. /**
  104998. * Gets the list of all animation ranges defined on this node
  104999. * @returns an array
  105000. */
  105001. getAnimationRanges(): Nullable<AnimationRange>[];
  105002. /**
  105003. * Will start the animation sequence
  105004. * @param name defines the range frames for animation sequence
  105005. * @param loop defines if the animation should loop (false by default)
  105006. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  105007. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  105008. * @returns the object created for this animation. If range does not exist, it will return null
  105009. */
  105010. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  105011. /**
  105012. * Serialize animation ranges into a JSON compatible object
  105013. * @returns serialization object
  105014. */
  105015. serializeAnimationRanges(): any;
  105016. /**
  105017. * Computes the world matrix of the node
  105018. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  105019. * @returns the world matrix
  105020. */
  105021. computeWorldMatrix(force?: boolean): Matrix;
  105022. /**
  105023. * Releases resources associated with this node.
  105024. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  105025. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  105026. */
  105027. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  105028. /**
  105029. * Parse animation range data from a serialization object and store them into a given node
  105030. * @param node defines where to store the animation ranges
  105031. * @param parsedNode defines the serialization object to read data from
  105032. * @param scene defines the hosting scene
  105033. */
  105034. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  105035. /**
  105036. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  105037. * @param includeDescendants Include bounding info from descendants as well (true by default)
  105038. * @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
  105039. * @returns the new bounding vectors
  105040. */
  105041. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  105042. min: Vector3;
  105043. max: Vector3;
  105044. };
  105045. }
  105046. }
  105047. declare module BABYLON {
  105048. /**
  105049. * @hidden
  105050. */
  105051. export class _IAnimationState {
  105052. key: number;
  105053. repeatCount: number;
  105054. workValue?: any;
  105055. loopMode?: number;
  105056. offsetValue?: any;
  105057. highLimitValue?: any;
  105058. }
  105059. /**
  105060. * Class used to store any kind of animation
  105061. */
  105062. export class Animation {
  105063. /**Name of the animation */
  105064. name: string;
  105065. /**Property to animate */
  105066. targetProperty: string;
  105067. /**The frames per second of the animation */
  105068. framePerSecond: number;
  105069. /**The data type of the animation */
  105070. dataType: number;
  105071. /**The loop mode of the animation */
  105072. loopMode?: number | undefined;
  105073. /**Specifies if blending should be enabled */
  105074. enableBlending?: boolean | undefined;
  105075. /**
  105076. * Use matrix interpolation instead of using direct key value when animating matrices
  105077. */
  105078. static AllowMatricesInterpolation: boolean;
  105079. /**
  105080. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  105081. */
  105082. static AllowMatrixDecomposeForInterpolation: boolean;
  105083. /**
  105084. * Stores the key frames of the animation
  105085. */
  105086. private _keys;
  105087. /**
  105088. * Stores the easing function of the animation
  105089. */
  105090. private _easingFunction;
  105091. /**
  105092. * @hidden Internal use only
  105093. */
  105094. _runtimeAnimations: RuntimeAnimation[];
  105095. /**
  105096. * The set of event that will be linked to this animation
  105097. */
  105098. private _events;
  105099. /**
  105100. * Stores an array of target property paths
  105101. */
  105102. targetPropertyPath: string[];
  105103. /**
  105104. * Stores the blending speed of the animation
  105105. */
  105106. blendingSpeed: number;
  105107. /**
  105108. * Stores the animation ranges for the animation
  105109. */
  105110. private _ranges;
  105111. /**
  105112. * @hidden Internal use
  105113. */
  105114. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  105115. /**
  105116. * Sets up an animation
  105117. * @param property The property to animate
  105118. * @param animationType The animation type to apply
  105119. * @param framePerSecond The frames per second of the animation
  105120. * @param easingFunction The easing function used in the animation
  105121. * @returns The created animation
  105122. */
  105123. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  105124. /**
  105125. * Create and start an animation on a node
  105126. * @param name defines the name of the global animation that will be run on all nodes
  105127. * @param node defines the root node where the animation will take place
  105128. * @param targetProperty defines property to animate
  105129. * @param framePerSecond defines the number of frame per second yo use
  105130. * @param totalFrame defines the number of frames in total
  105131. * @param from defines the initial value
  105132. * @param to defines the final value
  105133. * @param loopMode defines which loop mode you want to use (off by default)
  105134. * @param easingFunction defines the easing function to use (linear by default)
  105135. * @param onAnimationEnd defines the callback to call when animation end
  105136. * @returns the animatable created for this animation
  105137. */
  105138. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  105139. /**
  105140. * Create and start an animation on a node and its descendants
  105141. * @param name defines the name of the global animation that will be run on all nodes
  105142. * @param node defines the root node where the animation will take place
  105143. * @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
  105144. * @param targetProperty defines property to animate
  105145. * @param framePerSecond defines the number of frame per second to use
  105146. * @param totalFrame defines the number of frames in total
  105147. * @param from defines the initial value
  105148. * @param to defines the final value
  105149. * @param loopMode defines which loop mode you want to use (off by default)
  105150. * @param easingFunction defines the easing function to use (linear by default)
  105151. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  105152. * @returns the list of animatables created for all nodes
  105153. * @example https://www.babylonjs-playground.com/#MH0VLI
  105154. */
  105155. 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[]>;
  105156. /**
  105157. * Creates a new animation, merges it with the existing animations and starts it
  105158. * @param name Name of the animation
  105159. * @param node Node which contains the scene that begins the animations
  105160. * @param targetProperty Specifies which property to animate
  105161. * @param framePerSecond The frames per second of the animation
  105162. * @param totalFrame The total number of frames
  105163. * @param from The frame at the beginning of the animation
  105164. * @param to The frame at the end of the animation
  105165. * @param loopMode Specifies the loop mode of the animation
  105166. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  105167. * @param onAnimationEnd Callback to run once the animation is complete
  105168. * @returns Nullable animation
  105169. */
  105170. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  105171. /**
  105172. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  105173. * @param sourceAnimation defines the Animation containing keyframes to convert
  105174. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  105175. * @param range defines the name of the AnimationRange belonging to the Animation to convert
  105176. * @param cloneOriginal defines whether or not to clone the animation and convert the clone or convert the original animation (default is false)
  105177. * @param clonedName defines the name of the resulting cloned Animation if cloneOriginal is true
  105178. * @returns a new Animation if cloneOriginal is true or the original Animation if cloneOriginal is false
  105179. */
  105180. static MakeAnimationAdditive(sourceAnimation: Animation, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): Animation;
  105181. /**
  105182. * Transition property of an host to the target Value
  105183. * @param property The property to transition
  105184. * @param targetValue The target Value of the property
  105185. * @param host The object where the property to animate belongs
  105186. * @param scene Scene used to run the animation
  105187. * @param frameRate Framerate (in frame/s) to use
  105188. * @param transition The transition type we want to use
  105189. * @param duration The duration of the animation, in milliseconds
  105190. * @param onAnimationEnd Callback trigger at the end of the animation
  105191. * @returns Nullable animation
  105192. */
  105193. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  105194. /**
  105195. * Return the array of runtime animations currently using this animation
  105196. */
  105197. get runtimeAnimations(): RuntimeAnimation[];
  105198. /**
  105199. * Specifies if any of the runtime animations are currently running
  105200. */
  105201. get hasRunningRuntimeAnimations(): boolean;
  105202. /**
  105203. * Initializes the animation
  105204. * @param name Name of the animation
  105205. * @param targetProperty Property to animate
  105206. * @param framePerSecond The frames per second of the animation
  105207. * @param dataType The data type of the animation
  105208. * @param loopMode The loop mode of the animation
  105209. * @param enableBlending Specifies if blending should be enabled
  105210. */
  105211. constructor(
  105212. /**Name of the animation */
  105213. name: string,
  105214. /**Property to animate */
  105215. targetProperty: string,
  105216. /**The frames per second of the animation */
  105217. framePerSecond: number,
  105218. /**The data type of the animation */
  105219. dataType: number,
  105220. /**The loop mode of the animation */
  105221. loopMode?: number | undefined,
  105222. /**Specifies if blending should be enabled */
  105223. enableBlending?: boolean | undefined);
  105224. /**
  105225. * Converts the animation to a string
  105226. * @param fullDetails support for multiple levels of logging within scene loading
  105227. * @returns String form of the animation
  105228. */
  105229. toString(fullDetails?: boolean): string;
  105230. /**
  105231. * Add an event to this animation
  105232. * @param event Event to add
  105233. */
  105234. addEvent(event: AnimationEvent): void;
  105235. /**
  105236. * Remove all events found at the given frame
  105237. * @param frame The frame to remove events from
  105238. */
  105239. removeEvents(frame: number): void;
  105240. /**
  105241. * Retrieves all the events from the animation
  105242. * @returns Events from the animation
  105243. */
  105244. getEvents(): AnimationEvent[];
  105245. /**
  105246. * Creates an animation range
  105247. * @param name Name of the animation range
  105248. * @param from Starting frame of the animation range
  105249. * @param to Ending frame of the animation
  105250. */
  105251. createRange(name: string, from: number, to: number): void;
  105252. /**
  105253. * Deletes an animation range by name
  105254. * @param name Name of the animation range to delete
  105255. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  105256. */
  105257. deleteRange(name: string, deleteFrames?: boolean): void;
  105258. /**
  105259. * Gets the animation range by name, or null if not defined
  105260. * @param name Name of the animation range
  105261. * @returns Nullable animation range
  105262. */
  105263. getRange(name: string): Nullable<AnimationRange>;
  105264. /**
  105265. * Gets the key frames from the animation
  105266. * @returns The key frames of the animation
  105267. */
  105268. getKeys(): Array<IAnimationKey>;
  105269. /**
  105270. * Gets the highest frame rate of the animation
  105271. * @returns Highest frame rate of the animation
  105272. */
  105273. getHighestFrame(): number;
  105274. /**
  105275. * Gets the easing function of the animation
  105276. * @returns Easing function of the animation
  105277. */
  105278. getEasingFunction(): IEasingFunction;
  105279. /**
  105280. * Sets the easing function of the animation
  105281. * @param easingFunction A custom mathematical formula for animation
  105282. */
  105283. setEasingFunction(easingFunction: EasingFunction): void;
  105284. /**
  105285. * Interpolates a scalar linearly
  105286. * @param startValue Start value of the animation curve
  105287. * @param endValue End value of the animation curve
  105288. * @param gradient Scalar amount to interpolate
  105289. * @returns Interpolated scalar value
  105290. */
  105291. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  105292. /**
  105293. * Interpolates a scalar cubically
  105294. * @param startValue Start value of the animation curve
  105295. * @param outTangent End tangent of the animation
  105296. * @param endValue End value of the animation curve
  105297. * @param inTangent Start tangent of the animation curve
  105298. * @param gradient Scalar amount to interpolate
  105299. * @returns Interpolated scalar value
  105300. */
  105301. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  105302. /**
  105303. * Interpolates a quaternion using a spherical linear interpolation
  105304. * @param startValue Start value of the animation curve
  105305. * @param endValue End value of the animation curve
  105306. * @param gradient Scalar amount to interpolate
  105307. * @returns Interpolated quaternion value
  105308. */
  105309. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  105310. /**
  105311. * Interpolates a quaternion cubically
  105312. * @param startValue Start value of the animation curve
  105313. * @param outTangent End tangent of the animation curve
  105314. * @param endValue End value of the animation curve
  105315. * @param inTangent Start tangent of the animation curve
  105316. * @param gradient Scalar amount to interpolate
  105317. * @returns Interpolated quaternion value
  105318. */
  105319. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  105320. /**
  105321. * Interpolates a Vector3 linearl
  105322. * @param startValue Start value of the animation curve
  105323. * @param endValue End value of the animation curve
  105324. * @param gradient Scalar amount to interpolate
  105325. * @returns Interpolated scalar value
  105326. */
  105327. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  105328. /**
  105329. * Interpolates a Vector3 cubically
  105330. * @param startValue Start value of the animation curve
  105331. * @param outTangent End tangent of the animation
  105332. * @param endValue End value of the animation curve
  105333. * @param inTangent Start tangent of the animation curve
  105334. * @param gradient Scalar amount to interpolate
  105335. * @returns InterpolatedVector3 value
  105336. */
  105337. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  105338. /**
  105339. * Interpolates a Vector2 linearly
  105340. * @param startValue Start value of the animation curve
  105341. * @param endValue End value of the animation curve
  105342. * @param gradient Scalar amount to interpolate
  105343. * @returns Interpolated Vector2 value
  105344. */
  105345. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  105346. /**
  105347. * Interpolates a Vector2 cubically
  105348. * @param startValue Start value of the animation curve
  105349. * @param outTangent End tangent of the animation
  105350. * @param endValue End value of the animation curve
  105351. * @param inTangent Start tangent of the animation curve
  105352. * @param gradient Scalar amount to interpolate
  105353. * @returns Interpolated Vector2 value
  105354. */
  105355. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  105356. /**
  105357. * Interpolates a size linearly
  105358. * @param startValue Start value of the animation curve
  105359. * @param endValue End value of the animation curve
  105360. * @param gradient Scalar amount to interpolate
  105361. * @returns Interpolated Size value
  105362. */
  105363. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  105364. /**
  105365. * Interpolates a Color3 linearly
  105366. * @param startValue Start value of the animation curve
  105367. * @param endValue End value of the animation curve
  105368. * @param gradient Scalar amount to interpolate
  105369. * @returns Interpolated Color3 value
  105370. */
  105371. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  105372. /**
  105373. * Interpolates a Color4 linearly
  105374. * @param startValue Start value of the animation curve
  105375. * @param endValue End value of the animation curve
  105376. * @param gradient Scalar amount to interpolate
  105377. * @returns Interpolated Color3 value
  105378. */
  105379. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  105380. /**
  105381. * @hidden Internal use only
  105382. */
  105383. _getKeyValue(value: any): any;
  105384. /**
  105385. * @hidden Internal use only
  105386. */
  105387. _interpolate(currentFrame: number, state: _IAnimationState): any;
  105388. /**
  105389. * Defines the function to use to interpolate matrices
  105390. * @param startValue defines the start matrix
  105391. * @param endValue defines the end matrix
  105392. * @param gradient defines the gradient between both matrices
  105393. * @param result defines an optional target matrix where to store the interpolation
  105394. * @returns the interpolated matrix
  105395. */
  105396. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  105397. /**
  105398. * Makes a copy of the animation
  105399. * @returns Cloned animation
  105400. */
  105401. clone(): Animation;
  105402. /**
  105403. * Sets the key frames of the animation
  105404. * @param values The animation key frames to set
  105405. */
  105406. setKeys(values: Array<IAnimationKey>): void;
  105407. /**
  105408. * Serializes the animation to an object
  105409. * @returns Serialized object
  105410. */
  105411. serialize(): any;
  105412. /**
  105413. * Float animation type
  105414. */
  105415. static readonly ANIMATIONTYPE_FLOAT: number;
  105416. /**
  105417. * Vector3 animation type
  105418. */
  105419. static readonly ANIMATIONTYPE_VECTOR3: number;
  105420. /**
  105421. * Quaternion animation type
  105422. */
  105423. static readonly ANIMATIONTYPE_QUATERNION: number;
  105424. /**
  105425. * Matrix animation type
  105426. */
  105427. static readonly ANIMATIONTYPE_MATRIX: number;
  105428. /**
  105429. * Color3 animation type
  105430. */
  105431. static readonly ANIMATIONTYPE_COLOR3: number;
  105432. /**
  105433. * Color3 animation type
  105434. */
  105435. static readonly ANIMATIONTYPE_COLOR4: number;
  105436. /**
  105437. * Vector2 animation type
  105438. */
  105439. static readonly ANIMATIONTYPE_VECTOR2: number;
  105440. /**
  105441. * Size animation type
  105442. */
  105443. static readonly ANIMATIONTYPE_SIZE: number;
  105444. /**
  105445. * Relative Loop Mode
  105446. */
  105447. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  105448. /**
  105449. * Cycle Loop Mode
  105450. */
  105451. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  105452. /**
  105453. * Constant Loop Mode
  105454. */
  105455. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  105456. /** @hidden */
  105457. static _UniversalLerp(left: any, right: any, amount: number): any;
  105458. /**
  105459. * Parses an animation object and creates an animation
  105460. * @param parsedAnimation Parsed animation object
  105461. * @returns Animation object
  105462. */
  105463. static Parse(parsedAnimation: any): Animation;
  105464. /**
  105465. * Appends the serialized animations from the source animations
  105466. * @param source Source containing the animations
  105467. * @param destination Target to store the animations
  105468. */
  105469. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  105470. }
  105471. }
  105472. declare module BABYLON {
  105473. /**
  105474. * Interface containing an array of animations
  105475. */
  105476. export interface IAnimatable {
  105477. /**
  105478. * Array of animations
  105479. */
  105480. animations: Nullable<Array<Animation>>;
  105481. }
  105482. }
  105483. declare module BABYLON {
  105484. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  105485. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  105486. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  105487. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  105488. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  105489. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  105490. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  105491. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  105492. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  105493. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  105494. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  105495. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  105496. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  105497. /**
  105498. * Decorator used to define property that can be serialized as reference to a camera
  105499. * @param sourceName defines the name of the property to decorate
  105500. */
  105501. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  105502. /**
  105503. * Class used to help serialization objects
  105504. */
  105505. export class SerializationHelper {
  105506. /** @hidden */
  105507. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  105508. /** @hidden */
  105509. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  105510. /** @hidden */
  105511. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  105512. /** @hidden */
  105513. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  105514. /**
  105515. * Appends the serialized animations from the source animations
  105516. * @param source Source containing the animations
  105517. * @param destination Target to store the animations
  105518. */
  105519. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  105520. /**
  105521. * Static function used to serialized a specific entity
  105522. * @param entity defines the entity to serialize
  105523. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  105524. * @returns a JSON compatible object representing the serialization of the entity
  105525. */
  105526. static Serialize<T>(entity: T, serializationObject?: any): any;
  105527. /**
  105528. * Creates a new entity from a serialization data object
  105529. * @param creationFunction defines a function used to instanciated the new entity
  105530. * @param source defines the source serialization data
  105531. * @param scene defines the hosting scene
  105532. * @param rootUrl defines the root url for resources
  105533. * @returns a new entity
  105534. */
  105535. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  105536. /**
  105537. * Clones an object
  105538. * @param creationFunction defines the function used to instanciate the new object
  105539. * @param source defines the source object
  105540. * @returns the cloned object
  105541. */
  105542. static Clone<T>(creationFunction: () => T, source: T): T;
  105543. /**
  105544. * Instanciates a new object based on a source one (some data will be shared between both object)
  105545. * @param creationFunction defines the function used to instanciate the new object
  105546. * @param source defines the source object
  105547. * @returns the new object
  105548. */
  105549. static Instanciate<T>(creationFunction: () => T, source: T): T;
  105550. }
  105551. }
  105552. declare module BABYLON {
  105553. /**
  105554. * Base class of all the textures in babylon.
  105555. * It groups all the common properties the materials, post process, lights... might need
  105556. * in order to make a correct use of the texture.
  105557. */
  105558. export class BaseTexture implements IAnimatable {
  105559. /**
  105560. * Default anisotropic filtering level for the application.
  105561. * It is set to 4 as a good tradeoff between perf and quality.
  105562. */
  105563. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  105564. /**
  105565. * Gets or sets the unique id of the texture
  105566. */
  105567. uniqueId: number;
  105568. /**
  105569. * Define the name of the texture.
  105570. */
  105571. name: string;
  105572. /**
  105573. * Gets or sets an object used to store user defined information.
  105574. */
  105575. metadata: any;
  105576. /**
  105577. * For internal use only. Please do not use.
  105578. */
  105579. reservedDataStore: any;
  105580. private _hasAlpha;
  105581. /**
  105582. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  105583. */
  105584. set hasAlpha(value: boolean);
  105585. get hasAlpha(): boolean;
  105586. /**
  105587. * Defines if the alpha value should be determined via the rgb values.
  105588. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  105589. */
  105590. getAlphaFromRGB: boolean;
  105591. /**
  105592. * Intensity or strength of the texture.
  105593. * It is commonly used by materials to fine tune the intensity of the texture
  105594. */
  105595. level: number;
  105596. /**
  105597. * Define the UV chanel to use starting from 0 and defaulting to 0.
  105598. * This is part of the texture as textures usually maps to one uv set.
  105599. */
  105600. coordinatesIndex: number;
  105601. private _coordinatesMode;
  105602. /**
  105603. * How a texture is mapped.
  105604. *
  105605. * | Value | Type | Description |
  105606. * | ----- | ----------------------------------- | ----------- |
  105607. * | 0 | EXPLICIT_MODE | |
  105608. * | 1 | SPHERICAL_MODE | |
  105609. * | 2 | PLANAR_MODE | |
  105610. * | 3 | CUBIC_MODE | |
  105611. * | 4 | PROJECTION_MODE | |
  105612. * | 5 | SKYBOX_MODE | |
  105613. * | 6 | INVCUBIC_MODE | |
  105614. * | 7 | EQUIRECTANGULAR_MODE | |
  105615. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  105616. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  105617. */
  105618. set coordinatesMode(value: number);
  105619. get coordinatesMode(): number;
  105620. /**
  105621. * | Value | Type | Description |
  105622. * | ----- | ------------------ | ----------- |
  105623. * | 0 | CLAMP_ADDRESSMODE | |
  105624. * | 1 | WRAP_ADDRESSMODE | |
  105625. * | 2 | MIRROR_ADDRESSMODE | |
  105626. */
  105627. wrapU: number;
  105628. /**
  105629. * | Value | Type | Description |
  105630. * | ----- | ------------------ | ----------- |
  105631. * | 0 | CLAMP_ADDRESSMODE | |
  105632. * | 1 | WRAP_ADDRESSMODE | |
  105633. * | 2 | MIRROR_ADDRESSMODE | |
  105634. */
  105635. wrapV: number;
  105636. /**
  105637. * | Value | Type | Description |
  105638. * | ----- | ------------------ | ----------- |
  105639. * | 0 | CLAMP_ADDRESSMODE | |
  105640. * | 1 | WRAP_ADDRESSMODE | |
  105641. * | 2 | MIRROR_ADDRESSMODE | |
  105642. */
  105643. wrapR: number;
  105644. /**
  105645. * With compliant hardware and browser (supporting anisotropic filtering)
  105646. * this defines the level of anisotropic filtering in the texture.
  105647. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  105648. */
  105649. anisotropicFilteringLevel: number;
  105650. /**
  105651. * Define if the texture is a cube texture or if false a 2d texture.
  105652. */
  105653. get isCube(): boolean;
  105654. set isCube(value: boolean);
  105655. /**
  105656. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  105657. */
  105658. get is3D(): boolean;
  105659. set is3D(value: boolean);
  105660. /**
  105661. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  105662. */
  105663. get is2DArray(): boolean;
  105664. set is2DArray(value: boolean);
  105665. /**
  105666. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  105667. * HDR texture are usually stored in linear space.
  105668. * This only impacts the PBR and Background materials
  105669. */
  105670. gammaSpace: boolean;
  105671. /**
  105672. * Gets or sets whether or not the texture contains RGBD data.
  105673. */
  105674. get isRGBD(): boolean;
  105675. set isRGBD(value: boolean);
  105676. /**
  105677. * Is Z inverted in the texture (useful in a cube texture).
  105678. */
  105679. invertZ: boolean;
  105680. /**
  105681. * Are mip maps generated for this texture or not.
  105682. */
  105683. get noMipmap(): boolean;
  105684. /**
  105685. * @hidden
  105686. */
  105687. lodLevelInAlpha: boolean;
  105688. /**
  105689. * With prefiltered texture, defined the offset used during the prefiltering steps.
  105690. */
  105691. get lodGenerationOffset(): number;
  105692. set lodGenerationOffset(value: number);
  105693. /**
  105694. * With prefiltered texture, defined the scale used during the prefiltering steps.
  105695. */
  105696. get lodGenerationScale(): number;
  105697. set lodGenerationScale(value: number);
  105698. /**
  105699. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  105700. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  105701. * average roughness values.
  105702. */
  105703. get linearSpecularLOD(): boolean;
  105704. set linearSpecularLOD(value: boolean);
  105705. /**
  105706. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  105707. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  105708. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  105709. */
  105710. get irradianceTexture(): Nullable<BaseTexture>;
  105711. set irradianceTexture(value: Nullable<BaseTexture>);
  105712. /**
  105713. * Define if the texture is a render target.
  105714. */
  105715. isRenderTarget: boolean;
  105716. /**
  105717. * Define the unique id of the texture in the scene.
  105718. */
  105719. get uid(): string;
  105720. /**
  105721. * Return a string representation of the texture.
  105722. * @returns the texture as a string
  105723. */
  105724. toString(): string;
  105725. /**
  105726. * Get the class name of the texture.
  105727. * @returns "BaseTexture"
  105728. */
  105729. getClassName(): string;
  105730. /**
  105731. * Define the list of animation attached to the texture.
  105732. */
  105733. animations: Animation[];
  105734. /**
  105735. * An event triggered when the texture is disposed.
  105736. */
  105737. onDisposeObservable: Observable<BaseTexture>;
  105738. private _onDisposeObserver;
  105739. /**
  105740. * Callback triggered when the texture has been disposed.
  105741. * Kept for back compatibility, you can use the onDisposeObservable instead.
  105742. */
  105743. set onDispose(callback: () => void);
  105744. /**
  105745. * Define the current state of the loading sequence when in delayed load mode.
  105746. */
  105747. delayLoadState: number;
  105748. private _scene;
  105749. /** @hidden */
  105750. _texture: Nullable<InternalTexture>;
  105751. private _uid;
  105752. /**
  105753. * Define if the texture is preventinga material to render or not.
  105754. * If not and the texture is not ready, the engine will use a default black texture instead.
  105755. */
  105756. get isBlocking(): boolean;
  105757. /**
  105758. * Instantiates a new BaseTexture.
  105759. * Base class of all the textures in babylon.
  105760. * It groups all the common properties the materials, post process, lights... might need
  105761. * in order to make a correct use of the texture.
  105762. * @param scene Define the scene the texture blongs to
  105763. */
  105764. constructor(scene: Nullable<Scene>);
  105765. /**
  105766. * Get the scene the texture belongs to.
  105767. * @returns the scene or null if undefined
  105768. */
  105769. getScene(): Nullable<Scene>;
  105770. /**
  105771. * Get the texture transform matrix used to offset tile the texture for istance.
  105772. * @returns the transformation matrix
  105773. */
  105774. getTextureMatrix(): Matrix;
  105775. /**
  105776. * Get the texture reflection matrix used to rotate/transform the reflection.
  105777. * @returns the reflection matrix
  105778. */
  105779. getReflectionTextureMatrix(): Matrix;
  105780. /**
  105781. * Get the underlying lower level texture from Babylon.
  105782. * @returns the insternal texture
  105783. */
  105784. getInternalTexture(): Nullable<InternalTexture>;
  105785. /**
  105786. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  105787. * @returns true if ready or not blocking
  105788. */
  105789. isReadyOrNotBlocking(): boolean;
  105790. /**
  105791. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  105792. * @returns true if fully ready
  105793. */
  105794. isReady(): boolean;
  105795. private _cachedSize;
  105796. /**
  105797. * Get the size of the texture.
  105798. * @returns the texture size.
  105799. */
  105800. getSize(): ISize;
  105801. /**
  105802. * Get the base size of the texture.
  105803. * It can be different from the size if the texture has been resized for POT for instance
  105804. * @returns the base size
  105805. */
  105806. getBaseSize(): ISize;
  105807. /**
  105808. * Update the sampling mode of the texture.
  105809. * Default is Trilinear mode.
  105810. *
  105811. * | Value | Type | Description |
  105812. * | ----- | ------------------ | ----------- |
  105813. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  105814. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  105815. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  105816. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  105817. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  105818. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  105819. * | 7 | NEAREST_LINEAR | |
  105820. * | 8 | NEAREST_NEAREST | |
  105821. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  105822. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  105823. * | 11 | LINEAR_LINEAR | |
  105824. * | 12 | LINEAR_NEAREST | |
  105825. *
  105826. * > _mag_: magnification filter (close to the viewer)
  105827. * > _min_: minification filter (far from the viewer)
  105828. * > _mip_: filter used between mip map levels
  105829. *@param samplingMode Define the new sampling mode of the texture
  105830. */
  105831. updateSamplingMode(samplingMode: number): void;
  105832. /**
  105833. * Scales the texture if is `canRescale()`
  105834. * @param ratio the resize factor we want to use to rescale
  105835. */
  105836. scale(ratio: number): void;
  105837. /**
  105838. * Get if the texture can rescale.
  105839. */
  105840. get canRescale(): boolean;
  105841. /** @hidden */
  105842. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  105843. /** @hidden */
  105844. _rebuild(): void;
  105845. /**
  105846. * Triggers the load sequence in delayed load mode.
  105847. */
  105848. delayLoad(): void;
  105849. /**
  105850. * Clones the texture.
  105851. * @returns the cloned texture
  105852. */
  105853. clone(): Nullable<BaseTexture>;
  105854. /**
  105855. * Get the texture underlying type (INT, FLOAT...)
  105856. */
  105857. get textureType(): number;
  105858. /**
  105859. * Get the texture underlying format (RGB, RGBA...)
  105860. */
  105861. get textureFormat(): number;
  105862. /**
  105863. * Indicates that textures need to be re-calculated for all materials
  105864. */
  105865. protected _markAllSubMeshesAsTexturesDirty(): void;
  105866. /**
  105867. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  105868. * This will returns an RGBA array buffer containing either in values (0-255) or
  105869. * float values (0-1) depending of the underlying buffer type.
  105870. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  105871. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  105872. * @param buffer defines a user defined buffer to fill with data (can be null)
  105873. * @returns The Array buffer containing the pixels data.
  105874. */
  105875. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  105876. /**
  105877. * Release and destroy the underlying lower level texture aka internalTexture.
  105878. */
  105879. releaseInternalTexture(): void;
  105880. /** @hidden */
  105881. get _lodTextureHigh(): Nullable<BaseTexture>;
  105882. /** @hidden */
  105883. get _lodTextureMid(): Nullable<BaseTexture>;
  105884. /** @hidden */
  105885. get _lodTextureLow(): Nullable<BaseTexture>;
  105886. /**
  105887. * Dispose the texture and release its associated resources.
  105888. */
  105889. dispose(): void;
  105890. /**
  105891. * Serialize the texture into a JSON representation that can be parsed later on.
  105892. * @returns the JSON representation of the texture
  105893. */
  105894. serialize(): any;
  105895. /**
  105896. * Helper function to be called back once a list of texture contains only ready textures.
  105897. * @param textures Define the list of textures to wait for
  105898. * @param callback Define the callback triggered once the entire list will be ready
  105899. */
  105900. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  105901. }
  105902. }
  105903. declare module BABYLON {
  105904. /**
  105905. * Options to be used when creating an effect.
  105906. */
  105907. export interface IEffectCreationOptions {
  105908. /**
  105909. * Atrributes that will be used in the shader.
  105910. */
  105911. attributes: string[];
  105912. /**
  105913. * Uniform varible names that will be set in the shader.
  105914. */
  105915. uniformsNames: string[];
  105916. /**
  105917. * Uniform buffer variable names that will be set in the shader.
  105918. */
  105919. uniformBuffersNames: string[];
  105920. /**
  105921. * Sampler texture variable names that will be set in the shader.
  105922. */
  105923. samplers: string[];
  105924. /**
  105925. * Define statements that will be set in the shader.
  105926. */
  105927. defines: any;
  105928. /**
  105929. * Possible fallbacks for this effect to improve performance when needed.
  105930. */
  105931. fallbacks: Nullable<IEffectFallbacks>;
  105932. /**
  105933. * Callback that will be called when the shader is compiled.
  105934. */
  105935. onCompiled: Nullable<(effect: Effect) => void>;
  105936. /**
  105937. * Callback that will be called if an error occurs during shader compilation.
  105938. */
  105939. onError: Nullable<(effect: Effect, errors: string) => void>;
  105940. /**
  105941. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  105942. */
  105943. indexParameters?: any;
  105944. /**
  105945. * Max number of lights that can be used in the shader.
  105946. */
  105947. maxSimultaneousLights?: number;
  105948. /**
  105949. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  105950. */
  105951. transformFeedbackVaryings?: Nullable<string[]>;
  105952. }
  105953. /**
  105954. * Effect containing vertex and fragment shader that can be executed on an object.
  105955. */
  105956. export class Effect implements IDisposable {
  105957. /**
  105958. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  105959. */
  105960. static ShadersRepository: string;
  105961. /**
  105962. * Enable logging of the shader code when a compilation error occurs
  105963. */
  105964. static LogShaderCodeOnCompilationError: boolean;
  105965. /**
  105966. * Name of the effect.
  105967. */
  105968. name: any;
  105969. /**
  105970. * String container all the define statements that should be set on the shader.
  105971. */
  105972. defines: string;
  105973. /**
  105974. * Callback that will be called when the shader is compiled.
  105975. */
  105976. onCompiled: Nullable<(effect: Effect) => void>;
  105977. /**
  105978. * Callback that will be called if an error occurs during shader compilation.
  105979. */
  105980. onError: Nullable<(effect: Effect, errors: string) => void>;
  105981. /**
  105982. * Callback that will be called when effect is bound.
  105983. */
  105984. onBind: Nullable<(effect: Effect) => void>;
  105985. /**
  105986. * Unique ID of the effect.
  105987. */
  105988. uniqueId: number;
  105989. /**
  105990. * Observable that will be called when the shader is compiled.
  105991. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  105992. */
  105993. onCompileObservable: Observable<Effect>;
  105994. /**
  105995. * Observable that will be called if an error occurs during shader compilation.
  105996. */
  105997. onErrorObservable: Observable<Effect>;
  105998. /** @hidden */
  105999. _onBindObservable: Nullable<Observable<Effect>>;
  106000. /**
  106001. * @hidden
  106002. * Specifies if the effect was previously ready
  106003. */
  106004. _wasPreviouslyReady: boolean;
  106005. /**
  106006. * Observable that will be called when effect is bound.
  106007. */
  106008. get onBindObservable(): Observable<Effect>;
  106009. /** @hidden */
  106010. _bonesComputationForcedToCPU: boolean;
  106011. private static _uniqueIdSeed;
  106012. private _engine;
  106013. private _uniformBuffersNames;
  106014. private _uniformBuffersNamesList;
  106015. private _uniformsNames;
  106016. private _samplerList;
  106017. private _samplers;
  106018. private _isReady;
  106019. private _compilationError;
  106020. private _allFallbacksProcessed;
  106021. private _attributesNames;
  106022. private _attributes;
  106023. private _attributeLocationByName;
  106024. private _uniforms;
  106025. /**
  106026. * Key for the effect.
  106027. * @hidden
  106028. */
  106029. _key: string;
  106030. private _indexParameters;
  106031. private _fallbacks;
  106032. private _vertexSourceCode;
  106033. private _fragmentSourceCode;
  106034. private _vertexSourceCodeOverride;
  106035. private _fragmentSourceCodeOverride;
  106036. private _transformFeedbackVaryings;
  106037. /**
  106038. * Compiled shader to webGL program.
  106039. * @hidden
  106040. */
  106041. _pipelineContext: Nullable<IPipelineContext>;
  106042. private _valueCache;
  106043. private static _baseCache;
  106044. /**
  106045. * Instantiates an effect.
  106046. * An effect can be used to create/manage/execute vertex and fragment shaders.
  106047. * @param baseName Name of the effect.
  106048. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  106049. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  106050. * @param samplers List of sampler variables that will be passed to the shader.
  106051. * @param engine Engine to be used to render the effect
  106052. * @param defines Define statements to be added to the shader.
  106053. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  106054. * @param onCompiled Callback that will be called when the shader is compiled.
  106055. * @param onError Callback that will be called if an error occurs during shader compilation.
  106056. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  106057. */
  106058. 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);
  106059. private _useFinalCode;
  106060. /**
  106061. * Unique key for this effect
  106062. */
  106063. get key(): string;
  106064. /**
  106065. * If the effect has been compiled and prepared.
  106066. * @returns if the effect is compiled and prepared.
  106067. */
  106068. isReady(): boolean;
  106069. private _isReadyInternal;
  106070. /**
  106071. * The engine the effect was initialized with.
  106072. * @returns the engine.
  106073. */
  106074. getEngine(): Engine;
  106075. /**
  106076. * The pipeline context for this effect
  106077. * @returns the associated pipeline context
  106078. */
  106079. getPipelineContext(): Nullable<IPipelineContext>;
  106080. /**
  106081. * The set of names of attribute variables for the shader.
  106082. * @returns An array of attribute names.
  106083. */
  106084. getAttributesNames(): string[];
  106085. /**
  106086. * Returns the attribute at the given index.
  106087. * @param index The index of the attribute.
  106088. * @returns The location of the attribute.
  106089. */
  106090. getAttributeLocation(index: number): number;
  106091. /**
  106092. * Returns the attribute based on the name of the variable.
  106093. * @param name of the attribute to look up.
  106094. * @returns the attribute location.
  106095. */
  106096. getAttributeLocationByName(name: string): number;
  106097. /**
  106098. * The number of attributes.
  106099. * @returns the numnber of attributes.
  106100. */
  106101. getAttributesCount(): number;
  106102. /**
  106103. * Gets the index of a uniform variable.
  106104. * @param uniformName of the uniform to look up.
  106105. * @returns the index.
  106106. */
  106107. getUniformIndex(uniformName: string): number;
  106108. /**
  106109. * Returns the attribute based on the name of the variable.
  106110. * @param uniformName of the uniform to look up.
  106111. * @returns the location of the uniform.
  106112. */
  106113. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  106114. /**
  106115. * Returns an array of sampler variable names
  106116. * @returns The array of sampler variable names.
  106117. */
  106118. getSamplers(): string[];
  106119. /**
  106120. * Returns an array of uniform variable names
  106121. * @returns The array of uniform variable names.
  106122. */
  106123. getUniformNames(): string[];
  106124. /**
  106125. * Returns an array of uniform buffer variable names
  106126. * @returns The array of uniform buffer variable names.
  106127. */
  106128. getUniformBuffersNames(): string[];
  106129. /**
  106130. * Returns the index parameters used to create the effect
  106131. * @returns The index parameters object
  106132. */
  106133. getIndexParameters(): any;
  106134. /**
  106135. * The error from the last compilation.
  106136. * @returns the error string.
  106137. */
  106138. getCompilationError(): string;
  106139. /**
  106140. * Gets a boolean indicating that all fallbacks were used during compilation
  106141. * @returns true if all fallbacks were used
  106142. */
  106143. allFallbacksProcessed(): boolean;
  106144. /**
  106145. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  106146. * @param func The callback to be used.
  106147. */
  106148. executeWhenCompiled(func: (effect: Effect) => void): void;
  106149. private _checkIsReady;
  106150. private _loadShader;
  106151. /**
  106152. * Gets the vertex shader source code of this effect
  106153. */
  106154. get vertexSourceCode(): string;
  106155. /**
  106156. * Gets the fragment shader source code of this effect
  106157. */
  106158. get fragmentSourceCode(): string;
  106159. /**
  106160. * Recompiles the webGL program
  106161. * @param vertexSourceCode The source code for the vertex shader.
  106162. * @param fragmentSourceCode The source code for the fragment shader.
  106163. * @param onCompiled Callback called when completed.
  106164. * @param onError Callback called on error.
  106165. * @hidden
  106166. */
  106167. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  106168. /**
  106169. * Prepares the effect
  106170. * @hidden
  106171. */
  106172. _prepareEffect(): void;
  106173. private _getShaderCodeAndErrorLine;
  106174. private _processCompilationErrors;
  106175. /**
  106176. * Checks if the effect is supported. (Must be called after compilation)
  106177. */
  106178. get isSupported(): boolean;
  106179. /**
  106180. * Binds a texture to the engine to be used as output of the shader.
  106181. * @param channel Name of the output variable.
  106182. * @param texture Texture to bind.
  106183. * @hidden
  106184. */
  106185. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  106186. /**
  106187. * Sets a texture on the engine to be used in the shader.
  106188. * @param channel Name of the sampler variable.
  106189. * @param texture Texture to set.
  106190. */
  106191. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  106192. /**
  106193. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  106194. * @param channel Name of the sampler variable.
  106195. * @param texture Texture to set.
  106196. */
  106197. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  106198. /**
  106199. * Sets an array of textures on the engine to be used in the shader.
  106200. * @param channel Name of the variable.
  106201. * @param textures Textures to set.
  106202. */
  106203. setTextureArray(channel: string, textures: BaseTexture[]): void;
  106204. /**
  106205. * 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)
  106206. * @param channel Name of the sampler variable.
  106207. * @param postProcess Post process to get the input texture from.
  106208. */
  106209. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  106210. /**
  106211. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  106212. * 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)
  106213. * @param channel Name of the sampler variable.
  106214. * @param postProcess Post process to get the output texture from.
  106215. */
  106216. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  106217. /** @hidden */
  106218. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  106219. /** @hidden */
  106220. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  106221. /** @hidden */
  106222. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  106223. /** @hidden */
  106224. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  106225. /**
  106226. * Binds a buffer to a uniform.
  106227. * @param buffer Buffer to bind.
  106228. * @param name Name of the uniform variable to bind to.
  106229. */
  106230. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  106231. /**
  106232. * Binds block to a uniform.
  106233. * @param blockName Name of the block to bind.
  106234. * @param index Index to bind.
  106235. */
  106236. bindUniformBlock(blockName: string, index: number): void;
  106237. /**
  106238. * Sets an interger value on a uniform variable.
  106239. * @param uniformName Name of the variable.
  106240. * @param value Value to be set.
  106241. * @returns this effect.
  106242. */
  106243. setInt(uniformName: string, value: number): Effect;
  106244. /**
  106245. * Sets an int array on a uniform variable.
  106246. * @param uniformName Name of the variable.
  106247. * @param array array to be set.
  106248. * @returns this effect.
  106249. */
  106250. setIntArray(uniformName: string, array: Int32Array): Effect;
  106251. /**
  106252. * 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)
  106253. * @param uniformName Name of the variable.
  106254. * @param array array to be set.
  106255. * @returns this effect.
  106256. */
  106257. setIntArray2(uniformName: string, array: Int32Array): Effect;
  106258. /**
  106259. * 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)
  106260. * @param uniformName Name of the variable.
  106261. * @param array array to be set.
  106262. * @returns this effect.
  106263. */
  106264. setIntArray3(uniformName: string, array: Int32Array): Effect;
  106265. /**
  106266. * 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)
  106267. * @param uniformName Name of the variable.
  106268. * @param array array to be set.
  106269. * @returns this effect.
  106270. */
  106271. setIntArray4(uniformName: string, array: Int32Array): Effect;
  106272. /**
  106273. * Sets an float array on a uniform variable.
  106274. * @param uniformName Name of the variable.
  106275. * @param array array to be set.
  106276. * @returns this effect.
  106277. */
  106278. setFloatArray(uniformName: string, array: Float32Array): Effect;
  106279. /**
  106280. * 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)
  106281. * @param uniformName Name of the variable.
  106282. * @param array array to be set.
  106283. * @returns this effect.
  106284. */
  106285. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  106286. /**
  106287. * 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)
  106288. * @param uniformName Name of the variable.
  106289. * @param array array to be set.
  106290. * @returns this effect.
  106291. */
  106292. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  106293. /**
  106294. * 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)
  106295. * @param uniformName Name of the variable.
  106296. * @param array array to be set.
  106297. * @returns this effect.
  106298. */
  106299. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  106300. /**
  106301. * Sets an array on a uniform variable.
  106302. * @param uniformName Name of the variable.
  106303. * @param array array to be set.
  106304. * @returns this effect.
  106305. */
  106306. setArray(uniformName: string, array: number[]): Effect;
  106307. /**
  106308. * 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)
  106309. * @param uniformName Name of the variable.
  106310. * @param array array to be set.
  106311. * @returns this effect.
  106312. */
  106313. setArray2(uniformName: string, array: number[]): Effect;
  106314. /**
  106315. * 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)
  106316. * @param uniformName Name of the variable.
  106317. * @param array array to be set.
  106318. * @returns this effect.
  106319. */
  106320. setArray3(uniformName: string, array: number[]): Effect;
  106321. /**
  106322. * 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)
  106323. * @param uniformName Name of the variable.
  106324. * @param array array to be set.
  106325. * @returns this effect.
  106326. */
  106327. setArray4(uniformName: string, array: number[]): Effect;
  106328. /**
  106329. * Sets matrices on a uniform variable.
  106330. * @param uniformName Name of the variable.
  106331. * @param matrices matrices to be set.
  106332. * @returns this effect.
  106333. */
  106334. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  106335. /**
  106336. * Sets matrix on a uniform variable.
  106337. * @param uniformName Name of the variable.
  106338. * @param matrix matrix to be set.
  106339. * @returns this effect.
  106340. */
  106341. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  106342. /**
  106343. * 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)
  106344. * @param uniformName Name of the variable.
  106345. * @param matrix matrix to be set.
  106346. * @returns this effect.
  106347. */
  106348. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  106349. /**
  106350. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  106351. * @param uniformName Name of the variable.
  106352. * @param matrix matrix to be set.
  106353. * @returns this effect.
  106354. */
  106355. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  106356. /**
  106357. * Sets a float on a uniform variable.
  106358. * @param uniformName Name of the variable.
  106359. * @param value value to be set.
  106360. * @returns this effect.
  106361. */
  106362. setFloat(uniformName: string, value: number): Effect;
  106363. /**
  106364. * Sets a boolean on a uniform variable.
  106365. * @param uniformName Name of the variable.
  106366. * @param bool value to be set.
  106367. * @returns this effect.
  106368. */
  106369. setBool(uniformName: string, bool: boolean): Effect;
  106370. /**
  106371. * Sets a Vector2 on a uniform variable.
  106372. * @param uniformName Name of the variable.
  106373. * @param vector2 vector2 to be set.
  106374. * @returns this effect.
  106375. */
  106376. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  106377. /**
  106378. * Sets a float2 on a uniform variable.
  106379. * @param uniformName Name of the variable.
  106380. * @param x First float in float2.
  106381. * @param y Second float in float2.
  106382. * @returns this effect.
  106383. */
  106384. setFloat2(uniformName: string, x: number, y: number): Effect;
  106385. /**
  106386. * Sets a Vector3 on a uniform variable.
  106387. * @param uniformName Name of the variable.
  106388. * @param vector3 Value to be set.
  106389. * @returns this effect.
  106390. */
  106391. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  106392. /**
  106393. * Sets a float3 on a uniform variable.
  106394. * @param uniformName Name of the variable.
  106395. * @param x First float in float3.
  106396. * @param y Second float in float3.
  106397. * @param z Third float in float3.
  106398. * @returns this effect.
  106399. */
  106400. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  106401. /**
  106402. * Sets a Vector4 on a uniform variable.
  106403. * @param uniformName Name of the variable.
  106404. * @param vector4 Value to be set.
  106405. * @returns this effect.
  106406. */
  106407. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  106408. /**
  106409. * Sets a float4 on a uniform variable.
  106410. * @param uniformName Name of the variable.
  106411. * @param x First float in float4.
  106412. * @param y Second float in float4.
  106413. * @param z Third float in float4.
  106414. * @param w Fourth float in float4.
  106415. * @returns this effect.
  106416. */
  106417. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  106418. /**
  106419. * Sets a Color3 on a uniform variable.
  106420. * @param uniformName Name of the variable.
  106421. * @param color3 Value to be set.
  106422. * @returns this effect.
  106423. */
  106424. setColor3(uniformName: string, color3: IColor3Like): Effect;
  106425. /**
  106426. * Sets a Color4 on a uniform variable.
  106427. * @param uniformName Name of the variable.
  106428. * @param color3 Value to be set.
  106429. * @param alpha Alpha value to be set.
  106430. * @returns this effect.
  106431. */
  106432. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  106433. /**
  106434. * Sets a Color4 on a uniform variable
  106435. * @param uniformName defines the name of the variable
  106436. * @param color4 defines the value to be set
  106437. * @returns this effect.
  106438. */
  106439. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  106440. /** Release all associated resources */
  106441. dispose(): void;
  106442. /**
  106443. * This function will add a new shader to the shader store
  106444. * @param name the name of the shader
  106445. * @param pixelShader optional pixel shader content
  106446. * @param vertexShader optional vertex shader content
  106447. */
  106448. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  106449. /**
  106450. * Store of each shader (The can be looked up using effect.key)
  106451. */
  106452. static ShadersStore: {
  106453. [key: string]: string;
  106454. };
  106455. /**
  106456. * Store of each included file for a shader (The can be looked up using effect.key)
  106457. */
  106458. static IncludesShadersStore: {
  106459. [key: string]: string;
  106460. };
  106461. /**
  106462. * Resets the cache of effects.
  106463. */
  106464. static ResetCache(): void;
  106465. }
  106466. }
  106467. declare module BABYLON {
  106468. /**
  106469. * Interface used to describe the capabilities of the engine relatively to the current browser
  106470. */
  106471. export interface EngineCapabilities {
  106472. /** Maximum textures units per fragment shader */
  106473. maxTexturesImageUnits: number;
  106474. /** Maximum texture units per vertex shader */
  106475. maxVertexTextureImageUnits: number;
  106476. /** Maximum textures units in the entire pipeline */
  106477. maxCombinedTexturesImageUnits: number;
  106478. /** Maximum texture size */
  106479. maxTextureSize: number;
  106480. /** Maximum texture samples */
  106481. maxSamples?: number;
  106482. /** Maximum cube texture size */
  106483. maxCubemapTextureSize: number;
  106484. /** Maximum render texture size */
  106485. maxRenderTextureSize: number;
  106486. /** Maximum number of vertex attributes */
  106487. maxVertexAttribs: number;
  106488. /** Maximum number of varyings */
  106489. maxVaryingVectors: number;
  106490. /** Maximum number of uniforms per vertex shader */
  106491. maxVertexUniformVectors: number;
  106492. /** Maximum number of uniforms per fragment shader */
  106493. maxFragmentUniformVectors: number;
  106494. /** Defines if standard derivates (dx/dy) are supported */
  106495. standardDerivatives: boolean;
  106496. /** Defines if s3tc texture compression is supported */
  106497. s3tc?: WEBGL_compressed_texture_s3tc;
  106498. /** Defines if pvrtc texture compression is supported */
  106499. pvrtc: any;
  106500. /** Defines if etc1 texture compression is supported */
  106501. etc1: any;
  106502. /** Defines if etc2 texture compression is supported */
  106503. etc2: any;
  106504. /** Defines if astc texture compression is supported */
  106505. astc: any;
  106506. /** Defines if float textures are supported */
  106507. textureFloat: boolean;
  106508. /** Defines if vertex array objects are supported */
  106509. vertexArrayObject: boolean;
  106510. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  106511. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  106512. /** Gets the maximum level of anisotropy supported */
  106513. maxAnisotropy: number;
  106514. /** Defines if instancing is supported */
  106515. instancedArrays: boolean;
  106516. /** Defines if 32 bits indices are supported */
  106517. uintIndices: boolean;
  106518. /** Defines if high precision shaders are supported */
  106519. highPrecisionShaderSupported: boolean;
  106520. /** Defines if depth reading in the fragment shader is supported */
  106521. fragmentDepthSupported: boolean;
  106522. /** Defines if float texture linear filtering is supported*/
  106523. textureFloatLinearFiltering: boolean;
  106524. /** Defines if rendering to float textures is supported */
  106525. textureFloatRender: boolean;
  106526. /** Defines if half float textures are supported*/
  106527. textureHalfFloat: boolean;
  106528. /** Defines if half float texture linear filtering is supported*/
  106529. textureHalfFloatLinearFiltering: boolean;
  106530. /** Defines if rendering to half float textures is supported */
  106531. textureHalfFloatRender: boolean;
  106532. /** Defines if textureLOD shader command is supported */
  106533. textureLOD: boolean;
  106534. /** Defines if draw buffers extension is supported */
  106535. drawBuffersExtension: boolean;
  106536. /** Defines if depth textures are supported */
  106537. depthTextureExtension: boolean;
  106538. /** Defines if float color buffer are supported */
  106539. colorBufferFloat: boolean;
  106540. /** Gets disjoint timer query extension (null if not supported) */
  106541. timerQuery?: EXT_disjoint_timer_query;
  106542. /** Defines if timestamp can be used with timer query */
  106543. canUseTimestampForTimerQuery: boolean;
  106544. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  106545. multiview?: any;
  106546. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  106547. oculusMultiview?: any;
  106548. /** Function used to let the system compiles shaders in background */
  106549. parallelShaderCompile?: {
  106550. COMPLETION_STATUS_KHR: number;
  106551. };
  106552. /** Max number of texture samples for MSAA */
  106553. maxMSAASamples: number;
  106554. /** Defines if the blend min max extension is supported */
  106555. blendMinMax: boolean;
  106556. }
  106557. }
  106558. declare module BABYLON {
  106559. /**
  106560. * @hidden
  106561. **/
  106562. export class DepthCullingState {
  106563. private _isDepthTestDirty;
  106564. private _isDepthMaskDirty;
  106565. private _isDepthFuncDirty;
  106566. private _isCullFaceDirty;
  106567. private _isCullDirty;
  106568. private _isZOffsetDirty;
  106569. private _isFrontFaceDirty;
  106570. private _depthTest;
  106571. private _depthMask;
  106572. private _depthFunc;
  106573. private _cull;
  106574. private _cullFace;
  106575. private _zOffset;
  106576. private _frontFace;
  106577. /**
  106578. * Initializes the state.
  106579. */
  106580. constructor();
  106581. get isDirty(): boolean;
  106582. get zOffset(): number;
  106583. set zOffset(value: number);
  106584. get cullFace(): Nullable<number>;
  106585. set cullFace(value: Nullable<number>);
  106586. get cull(): Nullable<boolean>;
  106587. set cull(value: Nullable<boolean>);
  106588. get depthFunc(): Nullable<number>;
  106589. set depthFunc(value: Nullable<number>);
  106590. get depthMask(): boolean;
  106591. set depthMask(value: boolean);
  106592. get depthTest(): boolean;
  106593. set depthTest(value: boolean);
  106594. get frontFace(): Nullable<number>;
  106595. set frontFace(value: Nullable<number>);
  106596. reset(): void;
  106597. apply(gl: WebGLRenderingContext): void;
  106598. }
  106599. }
  106600. declare module BABYLON {
  106601. /**
  106602. * @hidden
  106603. **/
  106604. export class StencilState {
  106605. /** 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 */
  106606. static readonly ALWAYS: number;
  106607. /** Passed to stencilOperation to specify that stencil value must be kept */
  106608. static readonly KEEP: number;
  106609. /** Passed to stencilOperation to specify that stencil value must be replaced */
  106610. static readonly REPLACE: number;
  106611. private _isStencilTestDirty;
  106612. private _isStencilMaskDirty;
  106613. private _isStencilFuncDirty;
  106614. private _isStencilOpDirty;
  106615. private _stencilTest;
  106616. private _stencilMask;
  106617. private _stencilFunc;
  106618. private _stencilFuncRef;
  106619. private _stencilFuncMask;
  106620. private _stencilOpStencilFail;
  106621. private _stencilOpDepthFail;
  106622. private _stencilOpStencilDepthPass;
  106623. get isDirty(): boolean;
  106624. get stencilFunc(): number;
  106625. set stencilFunc(value: number);
  106626. get stencilFuncRef(): number;
  106627. set stencilFuncRef(value: number);
  106628. get stencilFuncMask(): number;
  106629. set stencilFuncMask(value: number);
  106630. get stencilOpStencilFail(): number;
  106631. set stencilOpStencilFail(value: number);
  106632. get stencilOpDepthFail(): number;
  106633. set stencilOpDepthFail(value: number);
  106634. get stencilOpStencilDepthPass(): number;
  106635. set stencilOpStencilDepthPass(value: number);
  106636. get stencilMask(): number;
  106637. set stencilMask(value: number);
  106638. get stencilTest(): boolean;
  106639. set stencilTest(value: boolean);
  106640. constructor();
  106641. reset(): void;
  106642. apply(gl: WebGLRenderingContext): void;
  106643. }
  106644. }
  106645. declare module BABYLON {
  106646. /**
  106647. * @hidden
  106648. **/
  106649. export class AlphaState {
  106650. private _isAlphaBlendDirty;
  106651. private _isBlendFunctionParametersDirty;
  106652. private _isBlendEquationParametersDirty;
  106653. private _isBlendConstantsDirty;
  106654. private _alphaBlend;
  106655. private _blendFunctionParameters;
  106656. private _blendEquationParameters;
  106657. private _blendConstants;
  106658. /**
  106659. * Initializes the state.
  106660. */
  106661. constructor();
  106662. get isDirty(): boolean;
  106663. get alphaBlend(): boolean;
  106664. set alphaBlend(value: boolean);
  106665. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  106666. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  106667. setAlphaEquationParameters(rgb: number, alpha: number): void;
  106668. reset(): void;
  106669. apply(gl: WebGLRenderingContext): void;
  106670. }
  106671. }
  106672. declare module BABYLON {
  106673. /** @hidden */
  106674. export class WebGL2ShaderProcessor implements IShaderProcessor {
  106675. attributeProcessor(attribute: string): string;
  106676. varyingProcessor(varying: string, isFragment: boolean): string;
  106677. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  106678. }
  106679. }
  106680. declare module BABYLON {
  106681. /**
  106682. * Interface for attribute information associated with buffer instanciation
  106683. */
  106684. export interface InstancingAttributeInfo {
  106685. /**
  106686. * Name of the GLSL attribute
  106687. * if attribute index is not specified, this is used to retrieve the index from the effect
  106688. */
  106689. attributeName: string;
  106690. /**
  106691. * Index/offset of the attribute in the vertex shader
  106692. * if not specified, this will be computes from the name.
  106693. */
  106694. index?: number;
  106695. /**
  106696. * size of the attribute, 1, 2, 3 or 4
  106697. */
  106698. attributeSize: number;
  106699. /**
  106700. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  106701. */
  106702. offset: number;
  106703. /**
  106704. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  106705. * default to 1
  106706. */
  106707. divisor?: number;
  106708. /**
  106709. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  106710. * default is FLOAT
  106711. */
  106712. attributeType?: number;
  106713. /**
  106714. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  106715. */
  106716. normalized?: boolean;
  106717. }
  106718. }
  106719. declare module BABYLON {
  106720. interface ThinEngine {
  106721. /**
  106722. * Update a video texture
  106723. * @param texture defines the texture to update
  106724. * @param video defines the video element to use
  106725. * @param invertY defines if data must be stored with Y axis inverted
  106726. */
  106727. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  106728. }
  106729. }
  106730. declare module BABYLON {
  106731. /**
  106732. * Settings for finer control over video usage
  106733. */
  106734. export interface VideoTextureSettings {
  106735. /**
  106736. * Applies `autoplay` to video, if specified
  106737. */
  106738. autoPlay?: boolean;
  106739. /**
  106740. * Applies `loop` to video, if specified
  106741. */
  106742. loop?: boolean;
  106743. /**
  106744. * Automatically updates internal texture from video at every frame in the render loop
  106745. */
  106746. autoUpdateTexture: boolean;
  106747. /**
  106748. * Image src displayed during the video loading or until the user interacts with the video.
  106749. */
  106750. poster?: string;
  106751. }
  106752. /**
  106753. * If you want to display a video in your scene, this is the special texture for that.
  106754. * This special texture works similar to other textures, with the exception of a few parameters.
  106755. * @see https://doc.babylonjs.com/how_to/video_texture
  106756. */
  106757. export class VideoTexture extends Texture {
  106758. /**
  106759. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  106760. */
  106761. readonly autoUpdateTexture: boolean;
  106762. /**
  106763. * The video instance used by the texture internally
  106764. */
  106765. readonly video: HTMLVideoElement;
  106766. private _onUserActionRequestedObservable;
  106767. /**
  106768. * Event triggerd when a dom action is required by the user to play the video.
  106769. * This happens due to recent changes in browser policies preventing video to auto start.
  106770. */
  106771. get onUserActionRequestedObservable(): Observable<Texture>;
  106772. private _generateMipMaps;
  106773. private _engine;
  106774. private _stillImageCaptured;
  106775. private _displayingPosterTexture;
  106776. private _settings;
  106777. private _createInternalTextureOnEvent;
  106778. private _frameId;
  106779. private _currentSrc;
  106780. /**
  106781. * Creates a video texture.
  106782. * If you want to display a video in your scene, this is the special texture for that.
  106783. * This special texture works similar to other textures, with the exception of a few parameters.
  106784. * @see https://doc.babylonjs.com/how_to/video_texture
  106785. * @param name optional name, will detect from video source, if not defined
  106786. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  106787. * @param scene is obviously the current scene.
  106788. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  106789. * @param invertY is false by default but can be used to invert video on Y axis
  106790. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  106791. * @param settings allows finer control over video usage
  106792. */
  106793. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  106794. private _getName;
  106795. private _getVideo;
  106796. private _createInternalTexture;
  106797. private reset;
  106798. /**
  106799. * @hidden Internal method to initiate `update`.
  106800. */
  106801. _rebuild(): void;
  106802. /**
  106803. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  106804. */
  106805. update(): void;
  106806. /**
  106807. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  106808. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  106809. */
  106810. updateTexture(isVisible: boolean): void;
  106811. protected _updateInternalTexture: () => void;
  106812. /**
  106813. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  106814. * @param url New url.
  106815. */
  106816. updateURL(url: string): void;
  106817. /**
  106818. * Clones the texture.
  106819. * @returns the cloned texture
  106820. */
  106821. clone(): VideoTexture;
  106822. /**
  106823. * Dispose the texture and release its associated resources.
  106824. */
  106825. dispose(): void;
  106826. /**
  106827. * Creates a video texture straight from a stream.
  106828. * @param scene Define the scene the texture should be created in
  106829. * @param stream Define the stream the texture should be created from
  106830. * @returns The created video texture as a promise
  106831. */
  106832. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  106833. /**
  106834. * Creates a video texture straight from your WebCam video feed.
  106835. * @param scene Define the scene the texture should be created in
  106836. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  106837. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  106838. * @returns The created video texture as a promise
  106839. */
  106840. static CreateFromWebCamAsync(scene: Scene, constraints: {
  106841. minWidth: number;
  106842. maxWidth: number;
  106843. minHeight: number;
  106844. maxHeight: number;
  106845. deviceId: string;
  106846. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  106847. /**
  106848. * Creates a video texture straight from your WebCam video feed.
  106849. * @param scene Define the scene the texture should be created in
  106850. * @param onReady Define a callback to triggered once the texture will be ready
  106851. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  106852. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  106853. */
  106854. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  106855. minWidth: number;
  106856. maxWidth: number;
  106857. minHeight: number;
  106858. maxHeight: number;
  106859. deviceId: string;
  106860. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  106861. }
  106862. }
  106863. declare module BABYLON {
  106864. /**
  106865. * Defines the interface used by objects working like Scene
  106866. * @hidden
  106867. */
  106868. export interface ISceneLike {
  106869. _addPendingData(data: any): void;
  106870. _removePendingData(data: any): void;
  106871. offlineProvider: IOfflineProvider;
  106872. }
  106873. /** Interface defining initialization parameters for Engine class */
  106874. export interface EngineOptions extends WebGLContextAttributes {
  106875. /**
  106876. * Defines if the engine should no exceed a specified device ratio
  106877. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  106878. */
  106879. limitDeviceRatio?: number;
  106880. /**
  106881. * Defines if webvr should be enabled automatically
  106882. * @see http://doc.babylonjs.com/how_to/webvr_camera
  106883. */
  106884. autoEnableWebVR?: boolean;
  106885. /**
  106886. * Defines if webgl2 should be turned off even if supported
  106887. * @see http://doc.babylonjs.com/features/webgl2
  106888. */
  106889. disableWebGL2Support?: boolean;
  106890. /**
  106891. * Defines if webaudio should be initialized as well
  106892. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  106893. */
  106894. audioEngine?: boolean;
  106895. /**
  106896. * Defines if animations should run using a deterministic lock step
  106897. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  106898. */
  106899. deterministicLockstep?: boolean;
  106900. /** Defines the maximum steps to use with deterministic lock step mode */
  106901. lockstepMaxSteps?: number;
  106902. /** Defines the seconds between each deterministic lock step */
  106903. timeStep?: number;
  106904. /**
  106905. * Defines that engine should ignore context lost events
  106906. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  106907. */
  106908. doNotHandleContextLost?: boolean;
  106909. /**
  106910. * Defines that engine should ignore modifying touch action attribute and style
  106911. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  106912. */
  106913. doNotHandleTouchAction?: boolean;
  106914. /**
  106915. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  106916. */
  106917. useHighPrecisionFloats?: boolean;
  106918. }
  106919. /**
  106920. * The base engine class (root of all engines)
  106921. */
  106922. export class ThinEngine {
  106923. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  106924. static ExceptionList: ({
  106925. key: string;
  106926. capture: string;
  106927. captureConstraint: number;
  106928. targets: string[];
  106929. } | {
  106930. key: string;
  106931. capture: null;
  106932. captureConstraint: null;
  106933. targets: string[];
  106934. })[];
  106935. /** @hidden */
  106936. static _TextureLoaders: IInternalTextureLoader[];
  106937. /**
  106938. * Returns the current npm package of the sdk
  106939. */
  106940. static get NpmPackage(): string;
  106941. /**
  106942. * Returns the current version of the framework
  106943. */
  106944. static get Version(): string;
  106945. /**
  106946. * Returns a string describing the current engine
  106947. */
  106948. get description(): string;
  106949. /**
  106950. * Gets or sets the epsilon value used by collision engine
  106951. */
  106952. static CollisionsEpsilon: number;
  106953. /**
  106954. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  106955. */
  106956. static get ShadersRepository(): string;
  106957. static set ShadersRepository(value: string);
  106958. /** @hidden */
  106959. _shaderProcessor: IShaderProcessor;
  106960. /**
  106961. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  106962. */
  106963. forcePOTTextures: boolean;
  106964. /**
  106965. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  106966. */
  106967. isFullscreen: boolean;
  106968. /**
  106969. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  106970. */
  106971. cullBackFaces: boolean;
  106972. /**
  106973. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  106974. */
  106975. renderEvenInBackground: boolean;
  106976. /**
  106977. * Gets or sets a boolean indicating that cache can be kept between frames
  106978. */
  106979. preventCacheWipeBetweenFrames: boolean;
  106980. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  106981. validateShaderPrograms: boolean;
  106982. /**
  106983. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  106984. * This can provide greater z depth for distant objects.
  106985. */
  106986. useReverseDepthBuffer: boolean;
  106987. /**
  106988. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  106989. */
  106990. disableUniformBuffers: boolean;
  106991. /** @hidden */
  106992. _uniformBuffers: UniformBuffer[];
  106993. /**
  106994. * Gets a boolean indicating that the engine supports uniform buffers
  106995. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  106996. */
  106997. get supportsUniformBuffers(): boolean;
  106998. /** @hidden */
  106999. _gl: WebGLRenderingContext;
  107000. /** @hidden */
  107001. _webGLVersion: number;
  107002. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  107003. protected _windowIsBackground: boolean;
  107004. protected _creationOptions: EngineOptions;
  107005. protected _highPrecisionShadersAllowed: boolean;
  107006. /** @hidden */
  107007. get _shouldUseHighPrecisionShader(): boolean;
  107008. /**
  107009. * Gets a boolean indicating that only power of 2 textures are supported
  107010. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  107011. */
  107012. get needPOTTextures(): boolean;
  107013. /** @hidden */
  107014. _badOS: boolean;
  107015. /** @hidden */
  107016. _badDesktopOS: boolean;
  107017. private _hardwareScalingLevel;
  107018. /** @hidden */
  107019. _caps: EngineCapabilities;
  107020. private _isStencilEnable;
  107021. private _glVersion;
  107022. private _glRenderer;
  107023. private _glVendor;
  107024. /** @hidden */
  107025. _videoTextureSupported: boolean;
  107026. protected _renderingQueueLaunched: boolean;
  107027. protected _activeRenderLoops: (() => void)[];
  107028. /**
  107029. * Observable signaled when a context lost event is raised
  107030. */
  107031. onContextLostObservable: Observable<ThinEngine>;
  107032. /**
  107033. * Observable signaled when a context restored event is raised
  107034. */
  107035. onContextRestoredObservable: Observable<ThinEngine>;
  107036. private _onContextLost;
  107037. private _onContextRestored;
  107038. protected _contextWasLost: boolean;
  107039. /** @hidden */
  107040. _doNotHandleContextLost: boolean;
  107041. /**
  107042. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  107043. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  107044. */
  107045. get doNotHandleContextLost(): boolean;
  107046. set doNotHandleContextLost(value: boolean);
  107047. /**
  107048. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  107049. */
  107050. disableVertexArrayObjects: boolean;
  107051. /** @hidden */
  107052. protected _colorWrite: boolean;
  107053. /** @hidden */
  107054. protected _colorWriteChanged: boolean;
  107055. /** @hidden */
  107056. protected _depthCullingState: DepthCullingState;
  107057. /** @hidden */
  107058. protected _stencilState: StencilState;
  107059. /** @hidden */
  107060. _alphaState: AlphaState;
  107061. /** @hidden */
  107062. _alphaMode: number;
  107063. /** @hidden */
  107064. _alphaEquation: number;
  107065. /** @hidden */
  107066. _internalTexturesCache: InternalTexture[];
  107067. /** @hidden */
  107068. protected _activeChannel: number;
  107069. private _currentTextureChannel;
  107070. /** @hidden */
  107071. protected _boundTexturesCache: {
  107072. [key: string]: Nullable<InternalTexture>;
  107073. };
  107074. /** @hidden */
  107075. protected _currentEffect: Nullable<Effect>;
  107076. /** @hidden */
  107077. protected _currentProgram: Nullable<WebGLProgram>;
  107078. private _compiledEffects;
  107079. private _vertexAttribArraysEnabled;
  107080. /** @hidden */
  107081. protected _cachedViewport: Nullable<IViewportLike>;
  107082. private _cachedVertexArrayObject;
  107083. /** @hidden */
  107084. protected _cachedVertexBuffers: any;
  107085. /** @hidden */
  107086. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  107087. /** @hidden */
  107088. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  107089. /** @hidden */
  107090. _currentRenderTarget: Nullable<InternalTexture>;
  107091. private _uintIndicesCurrentlySet;
  107092. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  107093. /** @hidden */
  107094. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  107095. private _currentBufferPointers;
  107096. private _currentInstanceLocations;
  107097. private _currentInstanceBuffers;
  107098. private _textureUnits;
  107099. /** @hidden */
  107100. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  107101. /** @hidden */
  107102. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  107103. /** @hidden */
  107104. _boundRenderFunction: any;
  107105. private _vaoRecordInProgress;
  107106. private _mustWipeVertexAttributes;
  107107. private _emptyTexture;
  107108. private _emptyCubeTexture;
  107109. private _emptyTexture3D;
  107110. private _emptyTexture2DArray;
  107111. /** @hidden */
  107112. _frameHandler: number;
  107113. private _nextFreeTextureSlots;
  107114. private _maxSimultaneousTextures;
  107115. private _activeRequests;
  107116. /** @hidden */
  107117. _transformTextureUrl: Nullable<(url: string) => string>;
  107118. protected get _supportsHardwareTextureRescaling(): boolean;
  107119. private _framebufferDimensionsObject;
  107120. /**
  107121. * sets the object from which width and height will be taken from when getting render width and height
  107122. * Will fallback to the gl object
  107123. * @param dimensions the framebuffer width and height that will be used.
  107124. */
  107125. set framebufferDimensionsObject(dimensions: Nullable<{
  107126. framebufferWidth: number;
  107127. framebufferHeight: number;
  107128. }>);
  107129. /**
  107130. * Gets the current viewport
  107131. */
  107132. get currentViewport(): Nullable<IViewportLike>;
  107133. /**
  107134. * Gets the default empty texture
  107135. */
  107136. get emptyTexture(): InternalTexture;
  107137. /**
  107138. * Gets the default empty 3D texture
  107139. */
  107140. get emptyTexture3D(): InternalTexture;
  107141. /**
  107142. * Gets the default empty 2D array texture
  107143. */
  107144. get emptyTexture2DArray(): InternalTexture;
  107145. /**
  107146. * Gets the default empty cube texture
  107147. */
  107148. get emptyCubeTexture(): InternalTexture;
  107149. /**
  107150. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  107151. */
  107152. readonly premultipliedAlpha: boolean;
  107153. /**
  107154. * Observable event triggered before each texture is initialized
  107155. */
  107156. onBeforeTextureInitObservable: Observable<Texture>;
  107157. /**
  107158. * Creates a new engine
  107159. * @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
  107160. * @param antialias defines enable antialiasing (default: false)
  107161. * @param options defines further options to be sent to the getContext() function
  107162. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  107163. */
  107164. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  107165. private _rebuildInternalTextures;
  107166. private _rebuildEffects;
  107167. /**
  107168. * Gets a boolean indicating if all created effects are ready
  107169. * @returns true if all effects are ready
  107170. */
  107171. areAllEffectsReady(): boolean;
  107172. protected _rebuildBuffers(): void;
  107173. protected _initGLContext(): void;
  107174. /**
  107175. * Gets version of the current webGL context
  107176. */
  107177. get webGLVersion(): number;
  107178. /**
  107179. * Gets a string idenfifying the name of the class
  107180. * @returns "Engine" string
  107181. */
  107182. getClassName(): string;
  107183. /**
  107184. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  107185. */
  107186. get isStencilEnable(): boolean;
  107187. /** @hidden */
  107188. _prepareWorkingCanvas(): void;
  107189. /**
  107190. * Reset the texture cache to empty state
  107191. */
  107192. resetTextureCache(): void;
  107193. /**
  107194. * Gets an object containing information about the current webGL context
  107195. * @returns an object containing the vender, the renderer and the version of the current webGL context
  107196. */
  107197. getGlInfo(): {
  107198. vendor: string;
  107199. renderer: string;
  107200. version: string;
  107201. };
  107202. /**
  107203. * Defines the hardware scaling level.
  107204. * By default the hardware scaling level is computed from the window device ratio.
  107205. * 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.
  107206. * @param level defines the level to use
  107207. */
  107208. setHardwareScalingLevel(level: number): void;
  107209. /**
  107210. * Gets the current hardware scaling level.
  107211. * By default the hardware scaling level is computed from the window device ratio.
  107212. * 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.
  107213. * @returns a number indicating the current hardware scaling level
  107214. */
  107215. getHardwareScalingLevel(): number;
  107216. /**
  107217. * Gets the list of loaded textures
  107218. * @returns an array containing all loaded textures
  107219. */
  107220. getLoadedTexturesCache(): InternalTexture[];
  107221. /**
  107222. * Gets the object containing all engine capabilities
  107223. * @returns the EngineCapabilities object
  107224. */
  107225. getCaps(): EngineCapabilities;
  107226. /**
  107227. * stop executing a render loop function and remove it from the execution array
  107228. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  107229. */
  107230. stopRenderLoop(renderFunction?: () => void): void;
  107231. /** @hidden */
  107232. _renderLoop(): void;
  107233. /**
  107234. * Gets the HTML canvas attached with the current webGL context
  107235. * @returns a HTML canvas
  107236. */
  107237. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  107238. /**
  107239. * Gets host window
  107240. * @returns the host window object
  107241. */
  107242. getHostWindow(): Nullable<Window>;
  107243. /**
  107244. * Gets the current render width
  107245. * @param useScreen defines if screen size must be used (or the current render target if any)
  107246. * @returns a number defining the current render width
  107247. */
  107248. getRenderWidth(useScreen?: boolean): number;
  107249. /**
  107250. * Gets the current render height
  107251. * @param useScreen defines if screen size must be used (or the current render target if any)
  107252. * @returns a number defining the current render height
  107253. */
  107254. getRenderHeight(useScreen?: boolean): number;
  107255. /**
  107256. * Can be used to override the current requestAnimationFrame requester.
  107257. * @hidden
  107258. */
  107259. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  107260. /**
  107261. * Register and execute a render loop. The engine can have more than one render function
  107262. * @param renderFunction defines the function to continuously execute
  107263. */
  107264. runRenderLoop(renderFunction: () => void): void;
  107265. /**
  107266. * Clear the current render buffer or the current render target (if any is set up)
  107267. * @param color defines the color to use
  107268. * @param backBuffer defines if the back buffer must be cleared
  107269. * @param depth defines if the depth buffer must be cleared
  107270. * @param stencil defines if the stencil buffer must be cleared
  107271. */
  107272. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  107273. private _viewportCached;
  107274. /** @hidden */
  107275. _viewport(x: number, y: number, width: number, height: number): void;
  107276. /**
  107277. * Set the WebGL's viewport
  107278. * @param viewport defines the viewport element to be used
  107279. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  107280. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  107281. */
  107282. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  107283. /**
  107284. * Begin a new frame
  107285. */
  107286. beginFrame(): void;
  107287. /**
  107288. * Enf the current frame
  107289. */
  107290. endFrame(): void;
  107291. /**
  107292. * Resize the view according to the canvas' size
  107293. */
  107294. resize(): void;
  107295. /**
  107296. * Force a specific size of the canvas
  107297. * @param width defines the new canvas' width
  107298. * @param height defines the new canvas' height
  107299. */
  107300. setSize(width: number, height: number): void;
  107301. /**
  107302. * Binds the frame buffer to the specified texture.
  107303. * @param texture The texture to render to or null for the default canvas
  107304. * @param faceIndex The face of the texture to render to in case of cube texture
  107305. * @param requiredWidth The width of the target to render to
  107306. * @param requiredHeight The height of the target to render to
  107307. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  107308. * @param lodLevel defines the lod level to bind to the frame buffer
  107309. * @param layer defines the 2d array index to bind to frame buffer to
  107310. */
  107311. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  107312. /** @hidden */
  107313. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  107314. /**
  107315. * Unbind the current render target texture from the webGL context
  107316. * @param texture defines the render target texture to unbind
  107317. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  107318. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  107319. */
  107320. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  107321. /**
  107322. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  107323. */
  107324. flushFramebuffer(): void;
  107325. /**
  107326. * Unbind the current render target and bind the default framebuffer
  107327. */
  107328. restoreDefaultFramebuffer(): void;
  107329. /** @hidden */
  107330. protected _resetVertexBufferBinding(): void;
  107331. /**
  107332. * Creates a vertex buffer
  107333. * @param data the data for the vertex buffer
  107334. * @returns the new WebGL static buffer
  107335. */
  107336. createVertexBuffer(data: DataArray): DataBuffer;
  107337. private _createVertexBuffer;
  107338. /**
  107339. * Creates a dynamic vertex buffer
  107340. * @param data the data for the dynamic vertex buffer
  107341. * @returns the new WebGL dynamic buffer
  107342. */
  107343. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  107344. protected _resetIndexBufferBinding(): void;
  107345. /**
  107346. * Creates a new index buffer
  107347. * @param indices defines the content of the index buffer
  107348. * @param updatable defines if the index buffer must be updatable
  107349. * @returns a new webGL buffer
  107350. */
  107351. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  107352. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  107353. /**
  107354. * Bind a webGL buffer to the webGL context
  107355. * @param buffer defines the buffer to bind
  107356. */
  107357. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  107358. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  107359. private bindBuffer;
  107360. /**
  107361. * update the bound buffer with the given data
  107362. * @param data defines the data to update
  107363. */
  107364. updateArrayBuffer(data: Float32Array): void;
  107365. private _vertexAttribPointer;
  107366. /** @hidden */
  107367. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  107368. private _bindVertexBuffersAttributes;
  107369. /**
  107370. * Records a vertex array object
  107371. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  107372. * @param vertexBuffers defines the list of vertex buffers to store
  107373. * @param indexBuffer defines the index buffer to store
  107374. * @param effect defines the effect to store
  107375. * @returns the new vertex array object
  107376. */
  107377. recordVertexArrayObject(vertexBuffers: {
  107378. [key: string]: VertexBuffer;
  107379. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  107380. /**
  107381. * Bind a specific vertex array object
  107382. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  107383. * @param vertexArrayObject defines the vertex array object to bind
  107384. * @param indexBuffer defines the index buffer to bind
  107385. */
  107386. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  107387. /**
  107388. * Bind webGl buffers directly to the webGL context
  107389. * @param vertexBuffer defines the vertex buffer to bind
  107390. * @param indexBuffer defines the index buffer to bind
  107391. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  107392. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  107393. * @param effect defines the effect associated with the vertex buffer
  107394. */
  107395. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  107396. private _unbindVertexArrayObject;
  107397. /**
  107398. * Bind a list of vertex buffers to the webGL context
  107399. * @param vertexBuffers defines the list of vertex buffers to bind
  107400. * @param indexBuffer defines the index buffer to bind
  107401. * @param effect defines the effect associated with the vertex buffers
  107402. */
  107403. bindBuffers(vertexBuffers: {
  107404. [key: string]: Nullable<VertexBuffer>;
  107405. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  107406. /**
  107407. * Unbind all instance attributes
  107408. */
  107409. unbindInstanceAttributes(): void;
  107410. /**
  107411. * Release and free the memory of a vertex array object
  107412. * @param vao defines the vertex array object to delete
  107413. */
  107414. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  107415. /** @hidden */
  107416. _releaseBuffer(buffer: DataBuffer): boolean;
  107417. protected _deleteBuffer(buffer: DataBuffer): void;
  107418. /**
  107419. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  107420. * @param instancesBuffer defines the webGL buffer to update and bind
  107421. * @param data defines the data to store in the buffer
  107422. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  107423. */
  107424. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  107425. /**
  107426. * Bind the content of a webGL buffer used with instantiation
  107427. * @param instancesBuffer defines the webGL buffer to bind
  107428. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  107429. * @param computeStride defines Whether to compute the strides from the info or use the default 0
  107430. */
  107431. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  107432. /**
  107433. * Disable the instance attribute corresponding to the name in parameter
  107434. * @param name defines the name of the attribute to disable
  107435. */
  107436. disableInstanceAttributeByName(name: string): void;
  107437. /**
  107438. * Disable the instance attribute corresponding to the location in parameter
  107439. * @param attributeLocation defines the attribute location of the attribute to disable
  107440. */
  107441. disableInstanceAttribute(attributeLocation: number): void;
  107442. /**
  107443. * Disable the attribute corresponding to the location in parameter
  107444. * @param attributeLocation defines the attribute location of the attribute to disable
  107445. */
  107446. disableAttributeByIndex(attributeLocation: number): void;
  107447. /**
  107448. * Send a draw order
  107449. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  107450. * @param indexStart defines the starting index
  107451. * @param indexCount defines the number of index to draw
  107452. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  107453. */
  107454. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  107455. /**
  107456. * Draw a list of points
  107457. * @param verticesStart defines the index of first vertex to draw
  107458. * @param verticesCount defines the count of vertices to draw
  107459. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  107460. */
  107461. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  107462. /**
  107463. * Draw a list of unindexed primitives
  107464. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  107465. * @param verticesStart defines the index of first vertex to draw
  107466. * @param verticesCount defines the count of vertices to draw
  107467. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  107468. */
  107469. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  107470. /**
  107471. * Draw a list of indexed primitives
  107472. * @param fillMode defines the primitive to use
  107473. * @param indexStart defines the starting index
  107474. * @param indexCount defines the number of index to draw
  107475. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  107476. */
  107477. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  107478. /**
  107479. * Draw a list of unindexed primitives
  107480. * @param fillMode defines the primitive to use
  107481. * @param verticesStart defines the index of first vertex to draw
  107482. * @param verticesCount defines the count of vertices to draw
  107483. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  107484. */
  107485. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  107486. private _drawMode;
  107487. /** @hidden */
  107488. protected _reportDrawCall(): void;
  107489. /** @hidden */
  107490. _releaseEffect(effect: Effect): void;
  107491. /** @hidden */
  107492. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  107493. /**
  107494. * Create a new effect (used to store vertex/fragment shaders)
  107495. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  107496. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  107497. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  107498. * @param samplers defines an array of string used to represent textures
  107499. * @param defines defines the string containing the defines to use to compile the shaders
  107500. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  107501. * @param onCompiled defines a function to call when the effect creation is successful
  107502. * @param onError defines a function to call when the effect creation has failed
  107503. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  107504. * @returns the new Effect
  107505. */
  107506. 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;
  107507. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  107508. private _compileShader;
  107509. private _compileRawShader;
  107510. /** @hidden */
  107511. _getShaderSource(shader: WebGLShader): Nullable<string>;
  107512. /**
  107513. * Directly creates a webGL program
  107514. * @param pipelineContext defines the pipeline context to attach to
  107515. * @param vertexCode defines the vertex shader code to use
  107516. * @param fragmentCode defines the fragment shader code to use
  107517. * @param context defines the webGL context to use (if not set, the current one will be used)
  107518. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  107519. * @returns the new webGL program
  107520. */
  107521. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  107522. /**
  107523. * Creates a webGL program
  107524. * @param pipelineContext defines the pipeline context to attach to
  107525. * @param vertexCode defines the vertex shader code to use
  107526. * @param fragmentCode defines the fragment shader code to use
  107527. * @param defines defines the string containing the defines to use to compile the shaders
  107528. * @param context defines the webGL context to use (if not set, the current one will be used)
  107529. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  107530. * @returns the new webGL program
  107531. */
  107532. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  107533. /**
  107534. * Creates a new pipeline context
  107535. * @returns the new pipeline
  107536. */
  107537. createPipelineContext(): IPipelineContext;
  107538. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  107539. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  107540. /** @hidden */
  107541. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  107542. /** @hidden */
  107543. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  107544. /** @hidden */
  107545. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  107546. /**
  107547. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  107548. * @param pipelineContext defines the pipeline context to use
  107549. * @param uniformsNames defines the list of uniform names
  107550. * @returns an array of webGL uniform locations
  107551. */
  107552. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  107553. /**
  107554. * Gets the lsit of active attributes for a given webGL program
  107555. * @param pipelineContext defines the pipeline context to use
  107556. * @param attributesNames defines the list of attribute names to get
  107557. * @returns an array of indices indicating the offset of each attribute
  107558. */
  107559. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  107560. /**
  107561. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  107562. * @param effect defines the effect to activate
  107563. */
  107564. enableEffect(effect: Nullable<Effect>): void;
  107565. /**
  107566. * Set the value of an uniform to a number (int)
  107567. * @param uniform defines the webGL uniform location where to store the value
  107568. * @param value defines the int number to store
  107569. */
  107570. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  107571. /**
  107572. * Set the value of an uniform to an array of int32
  107573. * @param uniform defines the webGL uniform location where to store the value
  107574. * @param array defines the array of int32 to store
  107575. */
  107576. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  107577. /**
  107578. * Set the value of an uniform to an array of int32 (stored as vec2)
  107579. * @param uniform defines the webGL uniform location where to store the value
  107580. * @param array defines the array of int32 to store
  107581. */
  107582. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  107583. /**
  107584. * Set the value of an uniform to an array of int32 (stored as vec3)
  107585. * @param uniform defines the webGL uniform location where to store the value
  107586. * @param array defines the array of int32 to store
  107587. */
  107588. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  107589. /**
  107590. * Set the value of an uniform to an array of int32 (stored as vec4)
  107591. * @param uniform defines the webGL uniform location where to store the value
  107592. * @param array defines the array of int32 to store
  107593. */
  107594. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  107595. /**
  107596. * Set the value of an uniform to an array of number
  107597. * @param uniform defines the webGL uniform location where to store the value
  107598. * @param array defines the array of number to store
  107599. */
  107600. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  107601. /**
  107602. * Set the value of an uniform to an array of number (stored as vec2)
  107603. * @param uniform defines the webGL uniform location where to store the value
  107604. * @param array defines the array of number to store
  107605. */
  107606. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  107607. /**
  107608. * Set the value of an uniform to an array of number (stored as vec3)
  107609. * @param uniform defines the webGL uniform location where to store the value
  107610. * @param array defines the array of number to store
  107611. */
  107612. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  107613. /**
  107614. * Set the value of an uniform to an array of number (stored as vec4)
  107615. * @param uniform defines the webGL uniform location where to store the value
  107616. * @param array defines the array of number to store
  107617. */
  107618. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  107619. /**
  107620. * Set the value of an uniform to an array of float32 (stored as matrices)
  107621. * @param uniform defines the webGL uniform location where to store the value
  107622. * @param matrices defines the array of float32 to store
  107623. */
  107624. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  107625. /**
  107626. * Set the value of an uniform to a matrix (3x3)
  107627. * @param uniform defines the webGL uniform location where to store the value
  107628. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  107629. */
  107630. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  107631. /**
  107632. * Set the value of an uniform to a matrix (2x2)
  107633. * @param uniform defines the webGL uniform location where to store the value
  107634. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  107635. */
  107636. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  107637. /**
  107638. * Set the value of an uniform to a number (float)
  107639. * @param uniform defines the webGL uniform location where to store the value
  107640. * @param value defines the float number to store
  107641. */
  107642. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  107643. /**
  107644. * Set the value of an uniform to a vec2
  107645. * @param uniform defines the webGL uniform location where to store the value
  107646. * @param x defines the 1st component of the value
  107647. * @param y defines the 2nd component of the value
  107648. */
  107649. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  107650. /**
  107651. * Set the value of an uniform to a vec3
  107652. * @param uniform defines the webGL uniform location where to store the value
  107653. * @param x defines the 1st component of the value
  107654. * @param y defines the 2nd component of the value
  107655. * @param z defines the 3rd component of the value
  107656. */
  107657. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  107658. /**
  107659. * Set the value of an uniform to a vec4
  107660. * @param uniform defines the webGL uniform location where to store the value
  107661. * @param x defines the 1st component of the value
  107662. * @param y defines the 2nd component of the value
  107663. * @param z defines the 3rd component of the value
  107664. * @param w defines the 4th component of the value
  107665. */
  107666. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  107667. /**
  107668. * Apply all cached states (depth, culling, stencil and alpha)
  107669. */
  107670. applyStates(): void;
  107671. /**
  107672. * Enable or disable color writing
  107673. * @param enable defines the state to set
  107674. */
  107675. setColorWrite(enable: boolean): void;
  107676. /**
  107677. * Gets a boolean indicating if color writing is enabled
  107678. * @returns the current color writing state
  107679. */
  107680. getColorWrite(): boolean;
  107681. /**
  107682. * Gets the depth culling state manager
  107683. */
  107684. get depthCullingState(): DepthCullingState;
  107685. /**
  107686. * Gets the alpha state manager
  107687. */
  107688. get alphaState(): AlphaState;
  107689. /**
  107690. * Gets the stencil state manager
  107691. */
  107692. get stencilState(): StencilState;
  107693. /**
  107694. * Clears the list of texture accessible through engine.
  107695. * This can help preventing texture load conflict due to name collision.
  107696. */
  107697. clearInternalTexturesCache(): void;
  107698. /**
  107699. * Force the entire cache to be cleared
  107700. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  107701. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  107702. */
  107703. wipeCaches(bruteForce?: boolean): void;
  107704. /** @hidden */
  107705. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  107706. min: number;
  107707. mag: number;
  107708. };
  107709. /** @hidden */
  107710. _createTexture(): WebGLTexture;
  107711. /**
  107712. * Usually called from Texture.ts.
  107713. * Passed information to create a WebGLTexture
  107714. * @param url defines a value which contains one of the following:
  107715. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  107716. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  107717. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  107718. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  107719. * @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)
  107720. * @param scene needed for loading to the correct scene
  107721. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  107722. * @param onLoad optional callback to be called upon successful completion
  107723. * @param onError optional callback to be called upon failure
  107724. * @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
  107725. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  107726. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  107727. * @param forcedExtension defines the extension to use to pick the right loader
  107728. * @param mimeType defines an optional mime type
  107729. * @returns a InternalTexture for assignment back into BABYLON.Texture
  107730. */
  107731. 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;
  107732. /**
  107733. * Loads an image as an HTMLImageElement.
  107734. * @param input url string, ArrayBuffer, or Blob to load
  107735. * @param onLoad callback called when the image successfully loads
  107736. * @param onError callback called when the image fails to load
  107737. * @param offlineProvider offline provider for caching
  107738. * @param mimeType optional mime type
  107739. * @returns the HTMLImageElement of the loaded image
  107740. * @hidden
  107741. */
  107742. 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>;
  107743. /**
  107744. * @hidden
  107745. */
  107746. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  107747. private _unpackFlipYCached;
  107748. /**
  107749. * In case you are sharing the context with other applications, it might
  107750. * be interested to not cache the unpack flip y state to ensure a consistent
  107751. * value would be set.
  107752. */
  107753. enableUnpackFlipYCached: boolean;
  107754. /** @hidden */
  107755. _unpackFlipY(value: boolean): void;
  107756. /** @hidden */
  107757. _getUnpackAlignement(): number;
  107758. private _getTextureTarget;
  107759. /**
  107760. * Update the sampling mode of a given texture
  107761. * @param samplingMode defines the required sampling mode
  107762. * @param texture defines the texture to update
  107763. * @param generateMipMaps defines whether to generate mipmaps for the texture
  107764. */
  107765. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  107766. /**
  107767. * Update the sampling mode of a given texture
  107768. * @param texture defines the texture to update
  107769. * @param wrapU defines the texture wrap mode of the u coordinates
  107770. * @param wrapV defines the texture wrap mode of the v coordinates
  107771. * @param wrapR defines the texture wrap mode of the r coordinates
  107772. */
  107773. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  107774. /** @hidden */
  107775. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  107776. width: number;
  107777. height: number;
  107778. layers?: number;
  107779. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  107780. /** @hidden */
  107781. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  107782. /** @hidden */
  107783. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  107784. /**
  107785. * Update a portion of an internal texture
  107786. * @param texture defines the texture to update
  107787. * @param imageData defines the data to store into the texture
  107788. * @param xOffset defines the x coordinates of the update rectangle
  107789. * @param yOffset defines the y coordinates of the update rectangle
  107790. * @param width defines the width of the update rectangle
  107791. * @param height defines the height of the update rectangle
  107792. * @param faceIndex defines the face index if texture is a cube (0 by default)
  107793. * @param lod defines the lod level to update (0 by default)
  107794. */
  107795. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  107796. /** @hidden */
  107797. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  107798. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  107799. private _prepareWebGLTexture;
  107800. /** @hidden */
  107801. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  107802. private _getDepthStencilBuffer;
  107803. /** @hidden */
  107804. _releaseFramebufferObjects(texture: InternalTexture): void;
  107805. /** @hidden */
  107806. _releaseTexture(texture: InternalTexture): void;
  107807. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  107808. protected _setProgram(program: WebGLProgram): void;
  107809. protected _boundUniforms: {
  107810. [key: number]: WebGLUniformLocation;
  107811. };
  107812. /**
  107813. * Binds an effect to the webGL context
  107814. * @param effect defines the effect to bind
  107815. */
  107816. bindSamplers(effect: Effect): void;
  107817. private _activateCurrentTexture;
  107818. /** @hidden */
  107819. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  107820. /** @hidden */
  107821. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  107822. /**
  107823. * Unbind all textures from the webGL context
  107824. */
  107825. unbindAllTextures(): void;
  107826. /**
  107827. * Sets a texture to the according uniform.
  107828. * @param channel The texture channel
  107829. * @param uniform The uniform to set
  107830. * @param texture The texture to apply
  107831. */
  107832. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  107833. private _bindSamplerUniformToChannel;
  107834. private _getTextureWrapMode;
  107835. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  107836. /**
  107837. * Sets an array of texture to the webGL context
  107838. * @param channel defines the channel where the texture array must be set
  107839. * @param uniform defines the associated uniform location
  107840. * @param textures defines the array of textures to bind
  107841. */
  107842. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  107843. /** @hidden */
  107844. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  107845. private _setTextureParameterFloat;
  107846. private _setTextureParameterInteger;
  107847. /**
  107848. * Unbind all vertex attributes from the webGL context
  107849. */
  107850. unbindAllAttributes(): void;
  107851. /**
  107852. * 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
  107853. */
  107854. releaseEffects(): void;
  107855. /**
  107856. * Dispose and release all associated resources
  107857. */
  107858. dispose(): void;
  107859. /**
  107860. * Attach a new callback raised when context lost event is fired
  107861. * @param callback defines the callback to call
  107862. */
  107863. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  107864. /**
  107865. * Attach a new callback raised when context restored event is fired
  107866. * @param callback defines the callback to call
  107867. */
  107868. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  107869. /**
  107870. * Get the current error code of the webGL context
  107871. * @returns the error code
  107872. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  107873. */
  107874. getError(): number;
  107875. private _canRenderToFloatFramebuffer;
  107876. private _canRenderToHalfFloatFramebuffer;
  107877. private _canRenderToFramebuffer;
  107878. /** @hidden */
  107879. _getWebGLTextureType(type: number): number;
  107880. /** @hidden */
  107881. _getInternalFormat(format: number): number;
  107882. /** @hidden */
  107883. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  107884. /** @hidden */
  107885. _getRGBAMultiSampleBufferFormat(type: number): number;
  107886. /** @hidden */
  107887. _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;
  107888. /**
  107889. * Loads a file from a url
  107890. * @param url url to load
  107891. * @param onSuccess callback called when the file successfully loads
  107892. * @param onProgress callback called while file is loading (if the server supports this mode)
  107893. * @param offlineProvider defines the offline provider for caching
  107894. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  107895. * @param onError callback called when the file fails to load
  107896. * @returns a file request object
  107897. * @hidden
  107898. */
  107899. 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;
  107900. /**
  107901. * Reads pixels from the current frame buffer. Please note that this function can be slow
  107902. * @param x defines the x coordinate of the rectangle where pixels must be read
  107903. * @param y defines the y coordinate of the rectangle where pixels must be read
  107904. * @param width defines the width of the rectangle where pixels must be read
  107905. * @param height defines the height of the rectangle where pixels must be read
  107906. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  107907. * @returns a Uint8Array containing RGBA colors
  107908. */
  107909. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  107910. private static _isSupported;
  107911. /**
  107912. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  107913. * @returns true if the engine can be created
  107914. * @ignorenaming
  107915. */
  107916. static isSupported(): boolean;
  107917. /**
  107918. * Find the next highest power of two.
  107919. * @param x Number to start search from.
  107920. * @return Next highest power of two.
  107921. */
  107922. static CeilingPOT(x: number): number;
  107923. /**
  107924. * Find the next lowest power of two.
  107925. * @param x Number to start search from.
  107926. * @return Next lowest power of two.
  107927. */
  107928. static FloorPOT(x: number): number;
  107929. /**
  107930. * Find the nearest power of two.
  107931. * @param x Number to start search from.
  107932. * @return Next nearest power of two.
  107933. */
  107934. static NearestPOT(x: number): number;
  107935. /**
  107936. * Get the closest exponent of two
  107937. * @param value defines the value to approximate
  107938. * @param max defines the maximum value to return
  107939. * @param mode defines how to define the closest value
  107940. * @returns closest exponent of two of the given value
  107941. */
  107942. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  107943. /**
  107944. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  107945. * @param func - the function to be called
  107946. * @param requester - the object that will request the next frame. Falls back to window.
  107947. * @returns frame number
  107948. */
  107949. static QueueNewFrame(func: () => void, requester?: any): number;
  107950. /**
  107951. * Gets host document
  107952. * @returns the host document object
  107953. */
  107954. getHostDocument(): Nullable<Document>;
  107955. }
  107956. }
  107957. declare module BABYLON {
  107958. /**
  107959. * Class representing spherical harmonics coefficients to the 3rd degree
  107960. */
  107961. export class SphericalHarmonics {
  107962. /**
  107963. * Defines whether or not the harmonics have been prescaled for rendering.
  107964. */
  107965. preScaled: boolean;
  107966. /**
  107967. * The l0,0 coefficients of the spherical harmonics
  107968. */
  107969. l00: Vector3;
  107970. /**
  107971. * The l1,-1 coefficients of the spherical harmonics
  107972. */
  107973. l1_1: Vector3;
  107974. /**
  107975. * The l1,0 coefficients of the spherical harmonics
  107976. */
  107977. l10: Vector3;
  107978. /**
  107979. * The l1,1 coefficients of the spherical harmonics
  107980. */
  107981. l11: Vector3;
  107982. /**
  107983. * The l2,-2 coefficients of the spherical harmonics
  107984. */
  107985. l2_2: Vector3;
  107986. /**
  107987. * The l2,-1 coefficients of the spherical harmonics
  107988. */
  107989. l2_1: Vector3;
  107990. /**
  107991. * The l2,0 coefficients of the spherical harmonics
  107992. */
  107993. l20: Vector3;
  107994. /**
  107995. * The l2,1 coefficients of the spherical harmonics
  107996. */
  107997. l21: Vector3;
  107998. /**
  107999. * The l2,2 coefficients of the spherical harmonics
  108000. */
  108001. l22: Vector3;
  108002. /**
  108003. * Adds a light to the spherical harmonics
  108004. * @param direction the direction of the light
  108005. * @param color the color of the light
  108006. * @param deltaSolidAngle the delta solid angle of the light
  108007. */
  108008. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  108009. /**
  108010. * Scales the spherical harmonics by the given amount
  108011. * @param scale the amount to scale
  108012. */
  108013. scaleInPlace(scale: number): void;
  108014. /**
  108015. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  108016. *
  108017. * ```
  108018. * E_lm = A_l * L_lm
  108019. * ```
  108020. *
  108021. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  108022. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  108023. * the scaling factors are given in equation 9.
  108024. */
  108025. convertIncidentRadianceToIrradiance(): void;
  108026. /**
  108027. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  108028. *
  108029. * ```
  108030. * L = (1/pi) * E * rho
  108031. * ```
  108032. *
  108033. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  108034. */
  108035. convertIrradianceToLambertianRadiance(): void;
  108036. /**
  108037. * Integrates the reconstruction coefficients directly in to the SH preventing further
  108038. * required operations at run time.
  108039. *
  108040. * This is simply done by scaling back the SH with Ylm constants parameter.
  108041. * The trigonometric part being applied by the shader at run time.
  108042. */
  108043. preScaleForRendering(): void;
  108044. /**
  108045. * Constructs a spherical harmonics from an array.
  108046. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  108047. * @returns the spherical harmonics
  108048. */
  108049. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  108050. /**
  108051. * Gets the spherical harmonics from polynomial
  108052. * @param polynomial the spherical polynomial
  108053. * @returns the spherical harmonics
  108054. */
  108055. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  108056. }
  108057. /**
  108058. * Class representing spherical polynomial coefficients to the 3rd degree
  108059. */
  108060. export class SphericalPolynomial {
  108061. private _harmonics;
  108062. /**
  108063. * The spherical harmonics used to create the polynomials.
  108064. */
  108065. get preScaledHarmonics(): SphericalHarmonics;
  108066. /**
  108067. * The x coefficients of the spherical polynomial
  108068. */
  108069. x: Vector3;
  108070. /**
  108071. * The y coefficients of the spherical polynomial
  108072. */
  108073. y: Vector3;
  108074. /**
  108075. * The z coefficients of the spherical polynomial
  108076. */
  108077. z: Vector3;
  108078. /**
  108079. * The xx coefficients of the spherical polynomial
  108080. */
  108081. xx: Vector3;
  108082. /**
  108083. * The yy coefficients of the spherical polynomial
  108084. */
  108085. yy: Vector3;
  108086. /**
  108087. * The zz coefficients of the spherical polynomial
  108088. */
  108089. zz: Vector3;
  108090. /**
  108091. * The xy coefficients of the spherical polynomial
  108092. */
  108093. xy: Vector3;
  108094. /**
  108095. * The yz coefficients of the spherical polynomial
  108096. */
  108097. yz: Vector3;
  108098. /**
  108099. * The zx coefficients of the spherical polynomial
  108100. */
  108101. zx: Vector3;
  108102. /**
  108103. * Adds an ambient color to the spherical polynomial
  108104. * @param color the color to add
  108105. */
  108106. addAmbient(color: Color3): void;
  108107. /**
  108108. * Scales the spherical polynomial by the given amount
  108109. * @param scale the amount to scale
  108110. */
  108111. scaleInPlace(scale: number): void;
  108112. /**
  108113. * Gets the spherical polynomial from harmonics
  108114. * @param harmonics the spherical harmonics
  108115. * @returns the spherical polynomial
  108116. */
  108117. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  108118. /**
  108119. * Constructs a spherical polynomial from an array.
  108120. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  108121. * @returns the spherical polynomial
  108122. */
  108123. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  108124. }
  108125. }
  108126. declare module BABYLON {
  108127. /**
  108128. * Defines the source of the internal texture
  108129. */
  108130. export enum InternalTextureSource {
  108131. /**
  108132. * The source of the texture data is unknown
  108133. */
  108134. Unknown = 0,
  108135. /**
  108136. * Texture data comes from an URL
  108137. */
  108138. Url = 1,
  108139. /**
  108140. * Texture data is only used for temporary storage
  108141. */
  108142. Temp = 2,
  108143. /**
  108144. * Texture data comes from raw data (ArrayBuffer)
  108145. */
  108146. Raw = 3,
  108147. /**
  108148. * Texture content is dynamic (video or dynamic texture)
  108149. */
  108150. Dynamic = 4,
  108151. /**
  108152. * Texture content is generated by rendering to it
  108153. */
  108154. RenderTarget = 5,
  108155. /**
  108156. * Texture content is part of a multi render target process
  108157. */
  108158. MultiRenderTarget = 6,
  108159. /**
  108160. * Texture data comes from a cube data file
  108161. */
  108162. Cube = 7,
  108163. /**
  108164. * Texture data comes from a raw cube data
  108165. */
  108166. CubeRaw = 8,
  108167. /**
  108168. * Texture data come from a prefiltered cube data file
  108169. */
  108170. CubePrefiltered = 9,
  108171. /**
  108172. * Texture content is raw 3D data
  108173. */
  108174. Raw3D = 10,
  108175. /**
  108176. * Texture content is raw 2D array data
  108177. */
  108178. Raw2DArray = 11,
  108179. /**
  108180. * Texture content is a depth texture
  108181. */
  108182. Depth = 12,
  108183. /**
  108184. * Texture data comes from a raw cube data encoded with RGBD
  108185. */
  108186. CubeRawRGBD = 13
  108187. }
  108188. /**
  108189. * Class used to store data associated with WebGL texture data for the engine
  108190. * This class should not be used directly
  108191. */
  108192. export class InternalTexture {
  108193. /** @hidden */
  108194. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  108195. /**
  108196. * Defines if the texture is ready
  108197. */
  108198. isReady: boolean;
  108199. /**
  108200. * Defines if the texture is a cube texture
  108201. */
  108202. isCube: boolean;
  108203. /**
  108204. * Defines if the texture contains 3D data
  108205. */
  108206. is3D: boolean;
  108207. /**
  108208. * Defines if the texture contains 2D array data
  108209. */
  108210. is2DArray: boolean;
  108211. /**
  108212. * Defines if the texture contains multiview data
  108213. */
  108214. isMultiview: boolean;
  108215. /**
  108216. * Gets the URL used to load this texture
  108217. */
  108218. url: string;
  108219. /**
  108220. * Gets the sampling mode of the texture
  108221. */
  108222. samplingMode: number;
  108223. /**
  108224. * Gets a boolean indicating if the texture needs mipmaps generation
  108225. */
  108226. generateMipMaps: boolean;
  108227. /**
  108228. * Gets the number of samples used by the texture (WebGL2+ only)
  108229. */
  108230. samples: number;
  108231. /**
  108232. * Gets the type of the texture (int, float...)
  108233. */
  108234. type: number;
  108235. /**
  108236. * Gets the format of the texture (RGB, RGBA...)
  108237. */
  108238. format: number;
  108239. /**
  108240. * Observable called when the texture is loaded
  108241. */
  108242. onLoadedObservable: Observable<InternalTexture>;
  108243. /**
  108244. * Gets the width of the texture
  108245. */
  108246. width: number;
  108247. /**
  108248. * Gets the height of the texture
  108249. */
  108250. height: number;
  108251. /**
  108252. * Gets the depth of the texture
  108253. */
  108254. depth: number;
  108255. /**
  108256. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  108257. */
  108258. baseWidth: number;
  108259. /**
  108260. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  108261. */
  108262. baseHeight: number;
  108263. /**
  108264. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  108265. */
  108266. baseDepth: number;
  108267. /**
  108268. * Gets a boolean indicating if the texture is inverted on Y axis
  108269. */
  108270. invertY: boolean;
  108271. /** @hidden */
  108272. _invertVScale: boolean;
  108273. /** @hidden */
  108274. _associatedChannel: number;
  108275. /** @hidden */
  108276. _source: InternalTextureSource;
  108277. /** @hidden */
  108278. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  108279. /** @hidden */
  108280. _bufferView: Nullable<ArrayBufferView>;
  108281. /** @hidden */
  108282. _bufferViewArray: Nullable<ArrayBufferView[]>;
  108283. /** @hidden */
  108284. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  108285. /** @hidden */
  108286. _size: number;
  108287. /** @hidden */
  108288. _extension: string;
  108289. /** @hidden */
  108290. _files: Nullable<string[]>;
  108291. /** @hidden */
  108292. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  108293. /** @hidden */
  108294. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  108295. /** @hidden */
  108296. _framebuffer: Nullable<WebGLFramebuffer>;
  108297. /** @hidden */
  108298. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  108299. /** @hidden */
  108300. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  108301. /** @hidden */
  108302. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  108303. /** @hidden */
  108304. _attachments: Nullable<number[]>;
  108305. /** @hidden */
  108306. _cachedCoordinatesMode: Nullable<number>;
  108307. /** @hidden */
  108308. _cachedWrapU: Nullable<number>;
  108309. /** @hidden */
  108310. _cachedWrapV: Nullable<number>;
  108311. /** @hidden */
  108312. _cachedWrapR: Nullable<number>;
  108313. /** @hidden */
  108314. _cachedAnisotropicFilteringLevel: Nullable<number>;
  108315. /** @hidden */
  108316. _isDisabled: boolean;
  108317. /** @hidden */
  108318. _compression: Nullable<string>;
  108319. /** @hidden */
  108320. _generateStencilBuffer: boolean;
  108321. /** @hidden */
  108322. _generateDepthBuffer: boolean;
  108323. /** @hidden */
  108324. _comparisonFunction: number;
  108325. /** @hidden */
  108326. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  108327. /** @hidden */
  108328. _lodGenerationScale: number;
  108329. /** @hidden */
  108330. _lodGenerationOffset: number;
  108331. /** @hidden */
  108332. _depthStencilTexture: Nullable<InternalTexture>;
  108333. /** @hidden */
  108334. _colorTextureArray: Nullable<WebGLTexture>;
  108335. /** @hidden */
  108336. _depthStencilTextureArray: Nullable<WebGLTexture>;
  108337. /** @hidden */
  108338. _lodTextureHigh: Nullable<BaseTexture>;
  108339. /** @hidden */
  108340. _lodTextureMid: Nullable<BaseTexture>;
  108341. /** @hidden */
  108342. _lodTextureLow: Nullable<BaseTexture>;
  108343. /** @hidden */
  108344. _isRGBD: boolean;
  108345. /** @hidden */
  108346. _linearSpecularLOD: boolean;
  108347. /** @hidden */
  108348. _irradianceTexture: Nullable<BaseTexture>;
  108349. /** @hidden */
  108350. _webGLTexture: Nullable<WebGLTexture>;
  108351. /** @hidden */
  108352. _references: number;
  108353. private _engine;
  108354. /**
  108355. * Gets the Engine the texture belongs to.
  108356. * @returns The babylon engine
  108357. */
  108358. getEngine(): ThinEngine;
  108359. /**
  108360. * Gets the data source type of the texture
  108361. */
  108362. get source(): InternalTextureSource;
  108363. /**
  108364. * Creates a new InternalTexture
  108365. * @param engine defines the engine to use
  108366. * @param source defines the type of data that will be used
  108367. * @param delayAllocation if the texture allocation should be delayed (default: false)
  108368. */
  108369. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  108370. /**
  108371. * Increments the number of references (ie. the number of Texture that point to it)
  108372. */
  108373. incrementReferences(): void;
  108374. /**
  108375. * Change the size of the texture (not the size of the content)
  108376. * @param width defines the new width
  108377. * @param height defines the new height
  108378. * @param depth defines the new depth (1 by default)
  108379. */
  108380. updateSize(width: int, height: int, depth?: int): void;
  108381. /** @hidden */
  108382. _rebuild(): void;
  108383. /** @hidden */
  108384. _swapAndDie(target: InternalTexture): void;
  108385. /**
  108386. * Dispose the current allocated resources
  108387. */
  108388. dispose(): void;
  108389. }
  108390. }
  108391. declare module BABYLON {
  108392. /**
  108393. * Class used to work with sound analyzer using fast fourier transform (FFT)
  108394. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  108395. */
  108396. export class Analyser {
  108397. /**
  108398. * Gets or sets the smoothing
  108399. * @ignorenaming
  108400. */
  108401. SMOOTHING: number;
  108402. /**
  108403. * Gets or sets the FFT table size
  108404. * @ignorenaming
  108405. */
  108406. FFT_SIZE: number;
  108407. /**
  108408. * Gets or sets the bar graph amplitude
  108409. * @ignorenaming
  108410. */
  108411. BARGRAPHAMPLITUDE: number;
  108412. /**
  108413. * Gets or sets the position of the debug canvas
  108414. * @ignorenaming
  108415. */
  108416. DEBUGCANVASPOS: {
  108417. x: number;
  108418. y: number;
  108419. };
  108420. /**
  108421. * Gets or sets the debug canvas size
  108422. * @ignorenaming
  108423. */
  108424. DEBUGCANVASSIZE: {
  108425. width: number;
  108426. height: number;
  108427. };
  108428. private _byteFreqs;
  108429. private _byteTime;
  108430. private _floatFreqs;
  108431. private _webAudioAnalyser;
  108432. private _debugCanvas;
  108433. private _debugCanvasContext;
  108434. private _scene;
  108435. private _registerFunc;
  108436. private _audioEngine;
  108437. /**
  108438. * Creates a new analyser
  108439. * @param scene defines hosting scene
  108440. */
  108441. constructor(scene: Scene);
  108442. /**
  108443. * Get the number of data values you will have to play with for the visualization
  108444. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  108445. * @returns a number
  108446. */
  108447. getFrequencyBinCount(): number;
  108448. /**
  108449. * Gets the current frequency data as a byte array
  108450. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  108451. * @returns a Uint8Array
  108452. */
  108453. getByteFrequencyData(): Uint8Array;
  108454. /**
  108455. * Gets the current waveform as a byte array
  108456. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  108457. * @returns a Uint8Array
  108458. */
  108459. getByteTimeDomainData(): Uint8Array;
  108460. /**
  108461. * Gets the current frequency data as a float array
  108462. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  108463. * @returns a Float32Array
  108464. */
  108465. getFloatFrequencyData(): Float32Array;
  108466. /**
  108467. * Renders the debug canvas
  108468. */
  108469. drawDebugCanvas(): void;
  108470. /**
  108471. * Stops rendering the debug canvas and removes it
  108472. */
  108473. stopDebugCanvas(): void;
  108474. /**
  108475. * Connects two audio nodes
  108476. * @param inputAudioNode defines first node to connect
  108477. * @param outputAudioNode defines second node to connect
  108478. */
  108479. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  108480. /**
  108481. * Releases all associated resources
  108482. */
  108483. dispose(): void;
  108484. }
  108485. }
  108486. declare module BABYLON {
  108487. /**
  108488. * This represents an audio engine and it is responsible
  108489. * to play, synchronize and analyse sounds throughout the application.
  108490. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  108491. */
  108492. export interface IAudioEngine extends IDisposable {
  108493. /**
  108494. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  108495. */
  108496. readonly canUseWebAudio: boolean;
  108497. /**
  108498. * Gets the current AudioContext if available.
  108499. */
  108500. readonly audioContext: Nullable<AudioContext>;
  108501. /**
  108502. * The master gain node defines the global audio volume of your audio engine.
  108503. */
  108504. readonly masterGain: GainNode;
  108505. /**
  108506. * Gets whether or not mp3 are supported by your browser.
  108507. */
  108508. readonly isMP3supported: boolean;
  108509. /**
  108510. * Gets whether or not ogg are supported by your browser.
  108511. */
  108512. readonly isOGGsupported: boolean;
  108513. /**
  108514. * Defines if Babylon should emit a warning if WebAudio is not supported.
  108515. * @ignoreNaming
  108516. */
  108517. WarnedWebAudioUnsupported: boolean;
  108518. /**
  108519. * Defines if the audio engine relies on a custom unlocked button.
  108520. * In this case, the embedded button will not be displayed.
  108521. */
  108522. useCustomUnlockedButton: boolean;
  108523. /**
  108524. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  108525. */
  108526. readonly unlocked: boolean;
  108527. /**
  108528. * Event raised when audio has been unlocked on the browser.
  108529. */
  108530. onAudioUnlockedObservable: Observable<AudioEngine>;
  108531. /**
  108532. * Event raised when audio has been locked on the browser.
  108533. */
  108534. onAudioLockedObservable: Observable<AudioEngine>;
  108535. /**
  108536. * Flags the audio engine in Locked state.
  108537. * This happens due to new browser policies preventing audio to autoplay.
  108538. */
  108539. lock(): void;
  108540. /**
  108541. * Unlocks the audio engine once a user action has been done on the dom.
  108542. * This is helpful to resume play once browser policies have been satisfied.
  108543. */
  108544. unlock(): void;
  108545. /**
  108546. * Gets the global volume sets on the master gain.
  108547. * @returns the global volume if set or -1 otherwise
  108548. */
  108549. getGlobalVolume(): number;
  108550. /**
  108551. * Sets the global volume of your experience (sets on the master gain).
  108552. * @param newVolume Defines the new global volume of the application
  108553. */
  108554. setGlobalVolume(newVolume: number): void;
  108555. /**
  108556. * Connect the audio engine to an audio analyser allowing some amazing
  108557. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  108558. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  108559. * @param analyser The analyser to connect to the engine
  108560. */
  108561. connectToAnalyser(analyser: Analyser): void;
  108562. }
  108563. /**
  108564. * This represents the default audio engine used in babylon.
  108565. * It is responsible to play, synchronize and analyse sounds throughout the application.
  108566. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  108567. */
  108568. export class AudioEngine implements IAudioEngine {
  108569. private _audioContext;
  108570. private _audioContextInitialized;
  108571. private _muteButton;
  108572. private _hostElement;
  108573. /**
  108574. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  108575. */
  108576. canUseWebAudio: boolean;
  108577. /**
  108578. * The master gain node defines the global audio volume of your audio engine.
  108579. */
  108580. masterGain: GainNode;
  108581. /**
  108582. * Defines if Babylon should emit a warning if WebAudio is not supported.
  108583. * @ignoreNaming
  108584. */
  108585. WarnedWebAudioUnsupported: boolean;
  108586. /**
  108587. * Gets whether or not mp3 are supported by your browser.
  108588. */
  108589. isMP3supported: boolean;
  108590. /**
  108591. * Gets whether or not ogg are supported by your browser.
  108592. */
  108593. isOGGsupported: boolean;
  108594. /**
  108595. * Gets whether audio has been unlocked on the device.
  108596. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  108597. * a user interaction has happened.
  108598. */
  108599. unlocked: boolean;
  108600. /**
  108601. * Defines if the audio engine relies on a custom unlocked button.
  108602. * In this case, the embedded button will not be displayed.
  108603. */
  108604. useCustomUnlockedButton: boolean;
  108605. /**
  108606. * Event raised when audio has been unlocked on the browser.
  108607. */
  108608. onAudioUnlockedObservable: Observable<AudioEngine>;
  108609. /**
  108610. * Event raised when audio has been locked on the browser.
  108611. */
  108612. onAudioLockedObservable: Observable<AudioEngine>;
  108613. /**
  108614. * Gets the current AudioContext if available.
  108615. */
  108616. get audioContext(): Nullable<AudioContext>;
  108617. private _connectedAnalyser;
  108618. /**
  108619. * Instantiates a new audio engine.
  108620. *
  108621. * There should be only one per page as some browsers restrict the number
  108622. * of audio contexts you can create.
  108623. * @param hostElement defines the host element where to display the mute icon if necessary
  108624. */
  108625. constructor(hostElement?: Nullable<HTMLElement>);
  108626. /**
  108627. * Flags the audio engine in Locked state.
  108628. * This happens due to new browser policies preventing audio to autoplay.
  108629. */
  108630. lock(): void;
  108631. /**
  108632. * Unlocks the audio engine once a user action has been done on the dom.
  108633. * This is helpful to resume play once browser policies have been satisfied.
  108634. */
  108635. unlock(): void;
  108636. private _resumeAudioContext;
  108637. private _initializeAudioContext;
  108638. private _tryToRun;
  108639. private _triggerRunningState;
  108640. private _triggerSuspendedState;
  108641. private _displayMuteButton;
  108642. private _moveButtonToTopLeft;
  108643. private _onResize;
  108644. private _hideMuteButton;
  108645. /**
  108646. * Destroy and release the resources associated with the audio ccontext.
  108647. */
  108648. dispose(): void;
  108649. /**
  108650. * Gets the global volume sets on the master gain.
  108651. * @returns the global volume if set or -1 otherwise
  108652. */
  108653. getGlobalVolume(): number;
  108654. /**
  108655. * Sets the global volume of your experience (sets on the master gain).
  108656. * @param newVolume Defines the new global volume of the application
  108657. */
  108658. setGlobalVolume(newVolume: number): void;
  108659. /**
  108660. * Connect the audio engine to an audio analyser allowing some amazing
  108661. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  108662. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  108663. * @param analyser The analyser to connect to the engine
  108664. */
  108665. connectToAnalyser(analyser: Analyser): void;
  108666. }
  108667. }
  108668. declare module BABYLON {
  108669. /**
  108670. * Interface used to present a loading screen while loading a scene
  108671. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  108672. */
  108673. export interface ILoadingScreen {
  108674. /**
  108675. * Function called to display the loading screen
  108676. */
  108677. displayLoadingUI: () => void;
  108678. /**
  108679. * Function called to hide the loading screen
  108680. */
  108681. hideLoadingUI: () => void;
  108682. /**
  108683. * Gets or sets the color to use for the background
  108684. */
  108685. loadingUIBackgroundColor: string;
  108686. /**
  108687. * Gets or sets the text to display while loading
  108688. */
  108689. loadingUIText: string;
  108690. }
  108691. /**
  108692. * Class used for the default loading screen
  108693. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  108694. */
  108695. export class DefaultLoadingScreen implements ILoadingScreen {
  108696. private _renderingCanvas;
  108697. private _loadingText;
  108698. private _loadingDivBackgroundColor;
  108699. private _loadingDiv;
  108700. private _loadingTextDiv;
  108701. /** Gets or sets the logo url to use for the default loading screen */
  108702. static DefaultLogoUrl: string;
  108703. /** Gets or sets the spinner url to use for the default loading screen */
  108704. static DefaultSpinnerUrl: string;
  108705. /**
  108706. * Creates a new default loading screen
  108707. * @param _renderingCanvas defines the canvas used to render the scene
  108708. * @param _loadingText defines the default text to display
  108709. * @param _loadingDivBackgroundColor defines the default background color
  108710. */
  108711. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  108712. /**
  108713. * Function called to display the loading screen
  108714. */
  108715. displayLoadingUI(): void;
  108716. /**
  108717. * Function called to hide the loading screen
  108718. */
  108719. hideLoadingUI(): void;
  108720. /**
  108721. * Gets or sets the text to display while loading
  108722. */
  108723. set loadingUIText(text: string);
  108724. get loadingUIText(): string;
  108725. /**
  108726. * Gets or sets the color to use for the background
  108727. */
  108728. get loadingUIBackgroundColor(): string;
  108729. set loadingUIBackgroundColor(color: string);
  108730. private _resizeLoadingUI;
  108731. }
  108732. }
  108733. declare module BABYLON {
  108734. /**
  108735. * Interface for any object that can request an animation frame
  108736. */
  108737. export interface ICustomAnimationFrameRequester {
  108738. /**
  108739. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  108740. */
  108741. renderFunction?: Function;
  108742. /**
  108743. * Called to request the next frame to render to
  108744. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  108745. */
  108746. requestAnimationFrame: Function;
  108747. /**
  108748. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  108749. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  108750. */
  108751. requestID?: number;
  108752. }
  108753. }
  108754. declare module BABYLON {
  108755. /**
  108756. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  108757. */
  108758. export class PerformanceMonitor {
  108759. private _enabled;
  108760. private _rollingFrameTime;
  108761. private _lastFrameTimeMs;
  108762. /**
  108763. * constructor
  108764. * @param frameSampleSize The number of samples required to saturate the sliding window
  108765. */
  108766. constructor(frameSampleSize?: number);
  108767. /**
  108768. * Samples current frame
  108769. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  108770. */
  108771. sampleFrame(timeMs?: number): void;
  108772. /**
  108773. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  108774. */
  108775. get averageFrameTime(): number;
  108776. /**
  108777. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  108778. */
  108779. get averageFrameTimeVariance(): number;
  108780. /**
  108781. * Returns the frame time of the most recent frame
  108782. */
  108783. get instantaneousFrameTime(): number;
  108784. /**
  108785. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  108786. */
  108787. get averageFPS(): number;
  108788. /**
  108789. * Returns the average framerate in frames per second using the most recent frame time
  108790. */
  108791. get instantaneousFPS(): number;
  108792. /**
  108793. * Returns true if enough samples have been taken to completely fill the sliding window
  108794. */
  108795. get isSaturated(): boolean;
  108796. /**
  108797. * Enables contributions to the sliding window sample set
  108798. */
  108799. enable(): void;
  108800. /**
  108801. * Disables contributions to the sliding window sample set
  108802. * Samples will not be interpolated over the disabled period
  108803. */
  108804. disable(): void;
  108805. /**
  108806. * Returns true if sampling is enabled
  108807. */
  108808. get isEnabled(): boolean;
  108809. /**
  108810. * Resets performance monitor
  108811. */
  108812. reset(): void;
  108813. }
  108814. /**
  108815. * RollingAverage
  108816. *
  108817. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  108818. */
  108819. export class RollingAverage {
  108820. /**
  108821. * Current average
  108822. */
  108823. average: number;
  108824. /**
  108825. * Current variance
  108826. */
  108827. variance: number;
  108828. protected _samples: Array<number>;
  108829. protected _sampleCount: number;
  108830. protected _pos: number;
  108831. protected _m2: number;
  108832. /**
  108833. * constructor
  108834. * @param length The number of samples required to saturate the sliding window
  108835. */
  108836. constructor(length: number);
  108837. /**
  108838. * Adds a sample to the sample set
  108839. * @param v The sample value
  108840. */
  108841. add(v: number): void;
  108842. /**
  108843. * Returns previously added values or null if outside of history or outside the sliding window domain
  108844. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  108845. * @return Value previously recorded with add() or null if outside of range
  108846. */
  108847. history(i: number): number;
  108848. /**
  108849. * Returns true if enough samples have been taken to completely fill the sliding window
  108850. * @return true if sample-set saturated
  108851. */
  108852. isSaturated(): boolean;
  108853. /**
  108854. * Resets the rolling average (equivalent to 0 samples taken so far)
  108855. */
  108856. reset(): void;
  108857. /**
  108858. * Wraps a value around the sample range boundaries
  108859. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  108860. * @return Wrapped position in sample range
  108861. */
  108862. protected _wrapPosition(i: number): number;
  108863. }
  108864. }
  108865. declare module BABYLON {
  108866. /**
  108867. * This class is used to track a performance counter which is number based.
  108868. * The user has access to many properties which give statistics of different nature.
  108869. *
  108870. * The implementer can track two kinds of Performance Counter: time and count.
  108871. * 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.
  108872. * 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.
  108873. */
  108874. export class PerfCounter {
  108875. /**
  108876. * Gets or sets a global boolean to turn on and off all the counters
  108877. */
  108878. static Enabled: boolean;
  108879. /**
  108880. * Returns the smallest value ever
  108881. */
  108882. get min(): number;
  108883. /**
  108884. * Returns the biggest value ever
  108885. */
  108886. get max(): number;
  108887. /**
  108888. * Returns the average value since the performance counter is running
  108889. */
  108890. get average(): number;
  108891. /**
  108892. * Returns the average value of the last second the counter was monitored
  108893. */
  108894. get lastSecAverage(): number;
  108895. /**
  108896. * Returns the current value
  108897. */
  108898. get current(): number;
  108899. /**
  108900. * Gets the accumulated total
  108901. */
  108902. get total(): number;
  108903. /**
  108904. * Gets the total value count
  108905. */
  108906. get count(): number;
  108907. /**
  108908. * Creates a new counter
  108909. */
  108910. constructor();
  108911. /**
  108912. * Call this method to start monitoring a new frame.
  108913. * 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.
  108914. */
  108915. fetchNewFrame(): void;
  108916. /**
  108917. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  108918. * @param newCount the count value to add to the monitored count
  108919. * @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.
  108920. */
  108921. addCount(newCount: number, fetchResult: boolean): void;
  108922. /**
  108923. * Start monitoring this performance counter
  108924. */
  108925. beginMonitoring(): void;
  108926. /**
  108927. * Compute the time lapsed since the previous beginMonitoring() call.
  108928. * @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
  108929. */
  108930. endMonitoring(newFrame?: boolean): void;
  108931. private _fetchResult;
  108932. private _startMonitoringTime;
  108933. private _min;
  108934. private _max;
  108935. private _average;
  108936. private _current;
  108937. private _totalValueCount;
  108938. private _totalAccumulated;
  108939. private _lastSecAverage;
  108940. private _lastSecAccumulated;
  108941. private _lastSecTime;
  108942. private _lastSecValueCount;
  108943. }
  108944. }
  108945. declare module BABYLON {
  108946. interface ThinEngine {
  108947. /**
  108948. * Sets alpha constants used by some alpha blending modes
  108949. * @param r defines the red component
  108950. * @param g defines the green component
  108951. * @param b defines the blue component
  108952. * @param a defines the alpha component
  108953. */
  108954. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  108955. /**
  108956. * Sets the current alpha mode
  108957. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  108958. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  108959. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  108960. */
  108961. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  108962. /**
  108963. * Gets the current alpha mode
  108964. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  108965. * @returns the current alpha mode
  108966. */
  108967. getAlphaMode(): number;
  108968. /**
  108969. * Sets the current alpha equation
  108970. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  108971. */
  108972. setAlphaEquation(equation: number): void;
  108973. /**
  108974. * Gets the current alpha equation.
  108975. * @returns the current alpha equation
  108976. */
  108977. getAlphaEquation(): number;
  108978. }
  108979. }
  108980. declare module BABYLON {
  108981. /**
  108982. * Defines the interface used by display changed events
  108983. */
  108984. export interface IDisplayChangedEventArgs {
  108985. /** Gets the vrDisplay object (if any) */
  108986. vrDisplay: Nullable<any>;
  108987. /** Gets a boolean indicating if webVR is supported */
  108988. vrSupported: boolean;
  108989. }
  108990. /**
  108991. * Defines the interface used by objects containing a viewport (like a camera)
  108992. */
  108993. interface IViewportOwnerLike {
  108994. /**
  108995. * Gets or sets the viewport
  108996. */
  108997. viewport: IViewportLike;
  108998. }
  108999. /**
  109000. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  109001. */
  109002. export class Engine extends ThinEngine {
  109003. /** Defines that alpha blending is disabled */
  109004. static readonly ALPHA_DISABLE: number;
  109005. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  109006. static readonly ALPHA_ADD: number;
  109007. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  109008. static readonly ALPHA_COMBINE: number;
  109009. /** Defines that alpha blending to DEST - SRC * DEST */
  109010. static readonly ALPHA_SUBTRACT: number;
  109011. /** Defines that alpha blending to SRC * DEST */
  109012. static readonly ALPHA_MULTIPLY: number;
  109013. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  109014. static readonly ALPHA_MAXIMIZED: number;
  109015. /** Defines that alpha blending to SRC + DEST */
  109016. static readonly ALPHA_ONEONE: number;
  109017. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  109018. static readonly ALPHA_PREMULTIPLIED: number;
  109019. /**
  109020. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  109021. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  109022. */
  109023. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  109024. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  109025. static readonly ALPHA_INTERPOLATE: number;
  109026. /**
  109027. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  109028. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  109029. */
  109030. static readonly ALPHA_SCREENMODE: number;
  109031. /** Defines that the ressource is not delayed*/
  109032. static readonly DELAYLOADSTATE_NONE: number;
  109033. /** Defines that the ressource was successfully delay loaded */
  109034. static readonly DELAYLOADSTATE_LOADED: number;
  109035. /** Defines that the ressource is currently delay loading */
  109036. static readonly DELAYLOADSTATE_LOADING: number;
  109037. /** Defines that the ressource is delayed and has not started loading */
  109038. static readonly DELAYLOADSTATE_NOTLOADED: number;
  109039. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  109040. static readonly NEVER: number;
  109041. /** 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 */
  109042. static readonly ALWAYS: number;
  109043. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  109044. static readonly LESS: number;
  109045. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  109046. static readonly EQUAL: number;
  109047. /** 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 */
  109048. static readonly LEQUAL: number;
  109049. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  109050. static readonly GREATER: number;
  109051. /** 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 */
  109052. static readonly GEQUAL: number;
  109053. /** 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 */
  109054. static readonly NOTEQUAL: number;
  109055. /** Passed to stencilOperation to specify that stencil value must be kept */
  109056. static readonly KEEP: number;
  109057. /** Passed to stencilOperation to specify that stencil value must be replaced */
  109058. static readonly REPLACE: number;
  109059. /** Passed to stencilOperation to specify that stencil value must be incremented */
  109060. static readonly INCR: number;
  109061. /** Passed to stencilOperation to specify that stencil value must be decremented */
  109062. static readonly DECR: number;
  109063. /** Passed to stencilOperation to specify that stencil value must be inverted */
  109064. static readonly INVERT: number;
  109065. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  109066. static readonly INCR_WRAP: number;
  109067. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  109068. static readonly DECR_WRAP: number;
  109069. /** Texture is not repeating outside of 0..1 UVs */
  109070. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  109071. /** Texture is repeating outside of 0..1 UVs */
  109072. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  109073. /** Texture is repeating and mirrored */
  109074. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  109075. /** ALPHA */
  109076. static readonly TEXTUREFORMAT_ALPHA: number;
  109077. /** LUMINANCE */
  109078. static readonly TEXTUREFORMAT_LUMINANCE: number;
  109079. /** LUMINANCE_ALPHA */
  109080. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  109081. /** RGB */
  109082. static readonly TEXTUREFORMAT_RGB: number;
  109083. /** RGBA */
  109084. static readonly TEXTUREFORMAT_RGBA: number;
  109085. /** RED */
  109086. static readonly TEXTUREFORMAT_RED: number;
  109087. /** RED (2nd reference) */
  109088. static readonly TEXTUREFORMAT_R: number;
  109089. /** RG */
  109090. static readonly TEXTUREFORMAT_RG: number;
  109091. /** RED_INTEGER */
  109092. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  109093. /** RED_INTEGER (2nd reference) */
  109094. static readonly TEXTUREFORMAT_R_INTEGER: number;
  109095. /** RG_INTEGER */
  109096. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  109097. /** RGB_INTEGER */
  109098. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  109099. /** RGBA_INTEGER */
  109100. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  109101. /** UNSIGNED_BYTE */
  109102. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  109103. /** UNSIGNED_BYTE (2nd reference) */
  109104. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  109105. /** FLOAT */
  109106. static readonly TEXTURETYPE_FLOAT: number;
  109107. /** HALF_FLOAT */
  109108. static readonly TEXTURETYPE_HALF_FLOAT: number;
  109109. /** BYTE */
  109110. static readonly TEXTURETYPE_BYTE: number;
  109111. /** SHORT */
  109112. static readonly TEXTURETYPE_SHORT: number;
  109113. /** UNSIGNED_SHORT */
  109114. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  109115. /** INT */
  109116. static readonly TEXTURETYPE_INT: number;
  109117. /** UNSIGNED_INT */
  109118. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  109119. /** UNSIGNED_SHORT_4_4_4_4 */
  109120. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  109121. /** UNSIGNED_SHORT_5_5_5_1 */
  109122. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  109123. /** UNSIGNED_SHORT_5_6_5 */
  109124. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  109125. /** UNSIGNED_INT_2_10_10_10_REV */
  109126. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  109127. /** UNSIGNED_INT_24_8 */
  109128. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  109129. /** UNSIGNED_INT_10F_11F_11F_REV */
  109130. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  109131. /** UNSIGNED_INT_5_9_9_9_REV */
  109132. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  109133. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  109134. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  109135. /** nearest is mag = nearest and min = nearest and mip = linear */
  109136. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  109137. /** Bilinear is mag = linear and min = linear and mip = nearest */
  109138. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  109139. /** Trilinear is mag = linear and min = linear and mip = linear */
  109140. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  109141. /** nearest is mag = nearest and min = nearest and mip = linear */
  109142. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  109143. /** Bilinear is mag = linear and min = linear and mip = nearest */
  109144. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  109145. /** Trilinear is mag = linear and min = linear and mip = linear */
  109146. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  109147. /** mag = nearest and min = nearest and mip = nearest */
  109148. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  109149. /** mag = nearest and min = linear and mip = nearest */
  109150. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  109151. /** mag = nearest and min = linear and mip = linear */
  109152. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  109153. /** mag = nearest and min = linear and mip = none */
  109154. static readonly TEXTURE_NEAREST_LINEAR: number;
  109155. /** mag = nearest and min = nearest and mip = none */
  109156. static readonly TEXTURE_NEAREST_NEAREST: number;
  109157. /** mag = linear and min = nearest and mip = nearest */
  109158. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  109159. /** mag = linear and min = nearest and mip = linear */
  109160. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  109161. /** mag = linear and min = linear and mip = none */
  109162. static readonly TEXTURE_LINEAR_LINEAR: number;
  109163. /** mag = linear and min = nearest and mip = none */
  109164. static readonly TEXTURE_LINEAR_NEAREST: number;
  109165. /** Explicit coordinates mode */
  109166. static readonly TEXTURE_EXPLICIT_MODE: number;
  109167. /** Spherical coordinates mode */
  109168. static readonly TEXTURE_SPHERICAL_MODE: number;
  109169. /** Planar coordinates mode */
  109170. static readonly TEXTURE_PLANAR_MODE: number;
  109171. /** Cubic coordinates mode */
  109172. static readonly TEXTURE_CUBIC_MODE: number;
  109173. /** Projection coordinates mode */
  109174. static readonly TEXTURE_PROJECTION_MODE: number;
  109175. /** Skybox coordinates mode */
  109176. static readonly TEXTURE_SKYBOX_MODE: number;
  109177. /** Inverse Cubic coordinates mode */
  109178. static readonly TEXTURE_INVCUBIC_MODE: number;
  109179. /** Equirectangular coordinates mode */
  109180. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  109181. /** Equirectangular Fixed coordinates mode */
  109182. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  109183. /** Equirectangular Fixed Mirrored coordinates mode */
  109184. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  109185. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  109186. static readonly SCALEMODE_FLOOR: number;
  109187. /** Defines that texture rescaling will look for the nearest power of 2 size */
  109188. static readonly SCALEMODE_NEAREST: number;
  109189. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  109190. static readonly SCALEMODE_CEILING: number;
  109191. /**
  109192. * Returns the current npm package of the sdk
  109193. */
  109194. static get NpmPackage(): string;
  109195. /**
  109196. * Returns the current version of the framework
  109197. */
  109198. static get Version(): string;
  109199. /** Gets the list of created engines */
  109200. static get Instances(): Engine[];
  109201. /**
  109202. * Gets the latest created engine
  109203. */
  109204. static get LastCreatedEngine(): Nullable<Engine>;
  109205. /**
  109206. * Gets the latest created scene
  109207. */
  109208. static get LastCreatedScene(): Nullable<Scene>;
  109209. /**
  109210. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  109211. * @param flag defines which part of the materials must be marked as dirty
  109212. * @param predicate defines a predicate used to filter which materials should be affected
  109213. */
  109214. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  109215. /**
  109216. * Method called to create the default loading screen.
  109217. * This can be overriden in your own app.
  109218. * @param canvas The rendering canvas element
  109219. * @returns The loading screen
  109220. */
  109221. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  109222. /**
  109223. * Method called to create the default rescale post process on each engine.
  109224. */
  109225. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  109226. /**
  109227. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  109228. **/
  109229. enableOfflineSupport: boolean;
  109230. /**
  109231. * 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)
  109232. **/
  109233. disableManifestCheck: boolean;
  109234. /**
  109235. * Gets the list of created scenes
  109236. */
  109237. scenes: Scene[];
  109238. /**
  109239. * Event raised when a new scene is created
  109240. */
  109241. onNewSceneAddedObservable: Observable<Scene>;
  109242. /**
  109243. * Gets the list of created postprocesses
  109244. */
  109245. postProcesses: PostProcess[];
  109246. /**
  109247. * Gets a boolean indicating if the pointer is currently locked
  109248. */
  109249. isPointerLock: boolean;
  109250. /**
  109251. * Observable event triggered each time the rendering canvas is resized
  109252. */
  109253. onResizeObservable: Observable<Engine>;
  109254. /**
  109255. * Observable event triggered each time the canvas loses focus
  109256. */
  109257. onCanvasBlurObservable: Observable<Engine>;
  109258. /**
  109259. * Observable event triggered each time the canvas gains focus
  109260. */
  109261. onCanvasFocusObservable: Observable<Engine>;
  109262. /**
  109263. * Observable event triggered each time the canvas receives pointerout event
  109264. */
  109265. onCanvasPointerOutObservable: Observable<PointerEvent>;
  109266. /**
  109267. * Observable raised when the engine begins a new frame
  109268. */
  109269. onBeginFrameObservable: Observable<Engine>;
  109270. /**
  109271. * If set, will be used to request the next animation frame for the render loop
  109272. */
  109273. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  109274. /**
  109275. * Observable raised when the engine ends the current frame
  109276. */
  109277. onEndFrameObservable: Observable<Engine>;
  109278. /**
  109279. * Observable raised when the engine is about to compile a shader
  109280. */
  109281. onBeforeShaderCompilationObservable: Observable<Engine>;
  109282. /**
  109283. * Observable raised when the engine has jsut compiled a shader
  109284. */
  109285. onAfterShaderCompilationObservable: Observable<Engine>;
  109286. /**
  109287. * Gets the audio engine
  109288. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  109289. * @ignorenaming
  109290. */
  109291. static audioEngine: IAudioEngine;
  109292. /**
  109293. * Default AudioEngine factory responsible of creating the Audio Engine.
  109294. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  109295. */
  109296. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  109297. /**
  109298. * Default offline support factory responsible of creating a tool used to store data locally.
  109299. * By default, this will create a Database object if the workload has been embedded.
  109300. */
  109301. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  109302. private _loadingScreen;
  109303. private _pointerLockRequested;
  109304. private _dummyFramebuffer;
  109305. private _rescalePostProcess;
  109306. private _deterministicLockstep;
  109307. private _lockstepMaxSteps;
  109308. private _timeStep;
  109309. protected get _supportsHardwareTextureRescaling(): boolean;
  109310. private _fps;
  109311. private _deltaTime;
  109312. /** @hidden */
  109313. _drawCalls: PerfCounter;
  109314. /** 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 */
  109315. canvasTabIndex: number;
  109316. /**
  109317. * Turn this value on if you want to pause FPS computation when in background
  109318. */
  109319. disablePerformanceMonitorInBackground: boolean;
  109320. private _performanceMonitor;
  109321. /**
  109322. * Gets the performance monitor attached to this engine
  109323. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  109324. */
  109325. get performanceMonitor(): PerformanceMonitor;
  109326. private _onFocus;
  109327. private _onBlur;
  109328. private _onCanvasPointerOut;
  109329. private _onCanvasBlur;
  109330. private _onCanvasFocus;
  109331. private _onFullscreenChange;
  109332. private _onPointerLockChange;
  109333. /**
  109334. * Gets the HTML element used to attach event listeners
  109335. * @returns a HTML element
  109336. */
  109337. getInputElement(): Nullable<HTMLElement>;
  109338. /**
  109339. * Creates a new engine
  109340. * @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
  109341. * @param antialias defines enable antialiasing (default: false)
  109342. * @param options defines further options to be sent to the getContext() function
  109343. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  109344. */
  109345. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  109346. /**
  109347. * Gets current aspect ratio
  109348. * @param viewportOwner defines the camera to use to get the aspect ratio
  109349. * @param useScreen defines if screen size must be used (or the current render target if any)
  109350. * @returns a number defining the aspect ratio
  109351. */
  109352. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  109353. /**
  109354. * Gets current screen aspect ratio
  109355. * @returns a number defining the aspect ratio
  109356. */
  109357. getScreenAspectRatio(): number;
  109358. /**
  109359. * Gets the client rect of the HTML canvas attached with the current webGL context
  109360. * @returns a client rectanglee
  109361. */
  109362. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  109363. /**
  109364. * Gets the client rect of the HTML element used for events
  109365. * @returns a client rectanglee
  109366. */
  109367. getInputElementClientRect(): Nullable<ClientRect>;
  109368. /**
  109369. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  109370. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  109371. * @returns true if engine is in deterministic lock step mode
  109372. */
  109373. isDeterministicLockStep(): boolean;
  109374. /**
  109375. * Gets the max steps when engine is running in deterministic lock step
  109376. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  109377. * @returns the max steps
  109378. */
  109379. getLockstepMaxSteps(): number;
  109380. /**
  109381. * Returns the time in ms between steps when using deterministic lock step.
  109382. * @returns time step in (ms)
  109383. */
  109384. getTimeStep(): number;
  109385. /**
  109386. * Force the mipmap generation for the given render target texture
  109387. * @param texture defines the render target texture to use
  109388. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  109389. */
  109390. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  109391. /** States */
  109392. /**
  109393. * Set various states to the webGL context
  109394. * @param culling defines backface culling state
  109395. * @param zOffset defines the value to apply to zOffset (0 by default)
  109396. * @param force defines if states must be applied even if cache is up to date
  109397. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  109398. */
  109399. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  109400. /**
  109401. * Set the z offset to apply to current rendering
  109402. * @param value defines the offset to apply
  109403. */
  109404. setZOffset(value: number): void;
  109405. /**
  109406. * Gets the current value of the zOffset
  109407. * @returns the current zOffset state
  109408. */
  109409. getZOffset(): number;
  109410. /**
  109411. * Enable or disable depth buffering
  109412. * @param enable defines the state to set
  109413. */
  109414. setDepthBuffer(enable: boolean): void;
  109415. /**
  109416. * Gets a boolean indicating if depth writing is enabled
  109417. * @returns the current depth writing state
  109418. */
  109419. getDepthWrite(): boolean;
  109420. /**
  109421. * Enable or disable depth writing
  109422. * @param enable defines the state to set
  109423. */
  109424. setDepthWrite(enable: boolean): void;
  109425. /**
  109426. * Gets a boolean indicating if stencil buffer is enabled
  109427. * @returns the current stencil buffer state
  109428. */
  109429. getStencilBuffer(): boolean;
  109430. /**
  109431. * Enable or disable the stencil buffer
  109432. * @param enable defines if the stencil buffer must be enabled or disabled
  109433. */
  109434. setStencilBuffer(enable: boolean): void;
  109435. /**
  109436. * Gets the current stencil mask
  109437. * @returns a number defining the new stencil mask to use
  109438. */
  109439. getStencilMask(): number;
  109440. /**
  109441. * Sets the current stencil mask
  109442. * @param mask defines the new stencil mask to use
  109443. */
  109444. setStencilMask(mask: number): void;
  109445. /**
  109446. * Gets the current stencil function
  109447. * @returns a number defining the stencil function to use
  109448. */
  109449. getStencilFunction(): number;
  109450. /**
  109451. * Gets the current stencil reference value
  109452. * @returns a number defining the stencil reference value to use
  109453. */
  109454. getStencilFunctionReference(): number;
  109455. /**
  109456. * Gets the current stencil mask
  109457. * @returns a number defining the stencil mask to use
  109458. */
  109459. getStencilFunctionMask(): number;
  109460. /**
  109461. * Sets the current stencil function
  109462. * @param stencilFunc defines the new stencil function to use
  109463. */
  109464. setStencilFunction(stencilFunc: number): void;
  109465. /**
  109466. * Sets the current stencil reference
  109467. * @param reference defines the new stencil reference to use
  109468. */
  109469. setStencilFunctionReference(reference: number): void;
  109470. /**
  109471. * Sets the current stencil mask
  109472. * @param mask defines the new stencil mask to use
  109473. */
  109474. setStencilFunctionMask(mask: number): void;
  109475. /**
  109476. * Gets the current stencil operation when stencil fails
  109477. * @returns a number defining stencil operation to use when stencil fails
  109478. */
  109479. getStencilOperationFail(): number;
  109480. /**
  109481. * Gets the current stencil operation when depth fails
  109482. * @returns a number defining stencil operation to use when depth fails
  109483. */
  109484. getStencilOperationDepthFail(): number;
  109485. /**
  109486. * Gets the current stencil operation when stencil passes
  109487. * @returns a number defining stencil operation to use when stencil passes
  109488. */
  109489. getStencilOperationPass(): number;
  109490. /**
  109491. * Sets the stencil operation to use when stencil fails
  109492. * @param operation defines the stencil operation to use when stencil fails
  109493. */
  109494. setStencilOperationFail(operation: number): void;
  109495. /**
  109496. * Sets the stencil operation to use when depth fails
  109497. * @param operation defines the stencil operation to use when depth fails
  109498. */
  109499. setStencilOperationDepthFail(operation: number): void;
  109500. /**
  109501. * Sets the stencil operation to use when stencil passes
  109502. * @param operation defines the stencil operation to use when stencil passes
  109503. */
  109504. setStencilOperationPass(operation: number): void;
  109505. /**
  109506. * Sets a boolean indicating if the dithering state is enabled or disabled
  109507. * @param value defines the dithering state
  109508. */
  109509. setDitheringState(value: boolean): void;
  109510. /**
  109511. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  109512. * @param value defines the rasterizer state
  109513. */
  109514. setRasterizerState(value: boolean): void;
  109515. /**
  109516. * Gets the current depth function
  109517. * @returns a number defining the depth function
  109518. */
  109519. getDepthFunction(): Nullable<number>;
  109520. /**
  109521. * Sets the current depth function
  109522. * @param depthFunc defines the function to use
  109523. */
  109524. setDepthFunction(depthFunc: number): void;
  109525. /**
  109526. * Sets the current depth function to GREATER
  109527. */
  109528. setDepthFunctionToGreater(): void;
  109529. /**
  109530. * Sets the current depth function to GEQUAL
  109531. */
  109532. setDepthFunctionToGreaterOrEqual(): void;
  109533. /**
  109534. * Sets the current depth function to LESS
  109535. */
  109536. setDepthFunctionToLess(): void;
  109537. /**
  109538. * Sets the current depth function to LEQUAL
  109539. */
  109540. setDepthFunctionToLessOrEqual(): void;
  109541. private _cachedStencilBuffer;
  109542. private _cachedStencilFunction;
  109543. private _cachedStencilMask;
  109544. private _cachedStencilOperationPass;
  109545. private _cachedStencilOperationFail;
  109546. private _cachedStencilOperationDepthFail;
  109547. private _cachedStencilReference;
  109548. /**
  109549. * Caches the the state of the stencil buffer
  109550. */
  109551. cacheStencilState(): void;
  109552. /**
  109553. * Restores the state of the stencil buffer
  109554. */
  109555. restoreStencilState(): void;
  109556. /**
  109557. * Directly set the WebGL Viewport
  109558. * @param x defines the x coordinate of the viewport (in screen space)
  109559. * @param y defines the y coordinate of the viewport (in screen space)
  109560. * @param width defines the width of the viewport (in screen space)
  109561. * @param height defines the height of the viewport (in screen space)
  109562. * @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
  109563. */
  109564. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  109565. /**
  109566. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  109567. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  109568. * @param y defines the y-coordinate of the corner of the clear rectangle
  109569. * @param width defines the width of the clear rectangle
  109570. * @param height defines the height of the clear rectangle
  109571. * @param clearColor defines the clear color
  109572. */
  109573. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  109574. /**
  109575. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  109576. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  109577. * @param y defines the y-coordinate of the corner of the clear rectangle
  109578. * @param width defines the width of the clear rectangle
  109579. * @param height defines the height of the clear rectangle
  109580. */
  109581. enableScissor(x: number, y: number, width: number, height: number): void;
  109582. /**
  109583. * Disable previously set scissor test rectangle
  109584. */
  109585. disableScissor(): void;
  109586. protected _reportDrawCall(): void;
  109587. /**
  109588. * Initializes a webVR display and starts listening to display change events
  109589. * The onVRDisplayChangedObservable will be notified upon these changes
  109590. * @returns The onVRDisplayChangedObservable
  109591. */
  109592. initWebVR(): Observable<IDisplayChangedEventArgs>;
  109593. /** @hidden */
  109594. _prepareVRComponent(): void;
  109595. /** @hidden */
  109596. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  109597. /** @hidden */
  109598. _submitVRFrame(): void;
  109599. /**
  109600. * Call this function to leave webVR mode
  109601. * Will do nothing if webVR is not supported or if there is no webVR device
  109602. * @see http://doc.babylonjs.com/how_to/webvr_camera
  109603. */
  109604. disableVR(): void;
  109605. /**
  109606. * Gets a boolean indicating that the system is in VR mode and is presenting
  109607. * @returns true if VR mode is engaged
  109608. */
  109609. isVRPresenting(): boolean;
  109610. /** @hidden */
  109611. _requestVRFrame(): void;
  109612. /** @hidden */
  109613. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  109614. /**
  109615. * Gets the source code of the vertex shader associated with a specific webGL program
  109616. * @param program defines the program to use
  109617. * @returns a string containing the source code of the vertex shader associated with the program
  109618. */
  109619. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  109620. /**
  109621. * Gets the source code of the fragment shader associated with a specific webGL program
  109622. * @param program defines the program to use
  109623. * @returns a string containing the source code of the fragment shader associated with the program
  109624. */
  109625. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  109626. /**
  109627. * Sets a depth stencil texture from a render target to the according uniform.
  109628. * @param channel The texture channel
  109629. * @param uniform The uniform to set
  109630. * @param texture The render target texture containing the depth stencil texture to apply
  109631. */
  109632. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  109633. /**
  109634. * Sets a texture to the webGL context from a postprocess
  109635. * @param channel defines the channel to use
  109636. * @param postProcess defines the source postprocess
  109637. */
  109638. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  109639. /**
  109640. * Binds the output of the passed in post process to the texture channel specified
  109641. * @param channel The channel the texture should be bound to
  109642. * @param postProcess The post process which's output should be bound
  109643. */
  109644. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  109645. protected _rebuildBuffers(): void;
  109646. /** @hidden */
  109647. _renderFrame(): void;
  109648. _renderLoop(): void;
  109649. /** @hidden */
  109650. _renderViews(): boolean;
  109651. /**
  109652. * Toggle full screen mode
  109653. * @param requestPointerLock defines if a pointer lock should be requested from the user
  109654. */
  109655. switchFullscreen(requestPointerLock: boolean): void;
  109656. /**
  109657. * Enters full screen mode
  109658. * @param requestPointerLock defines if a pointer lock should be requested from the user
  109659. */
  109660. enterFullscreen(requestPointerLock: boolean): void;
  109661. /**
  109662. * Exits full screen mode
  109663. */
  109664. exitFullscreen(): void;
  109665. /**
  109666. * Enters Pointerlock mode
  109667. */
  109668. enterPointerlock(): void;
  109669. /**
  109670. * Exits Pointerlock mode
  109671. */
  109672. exitPointerlock(): void;
  109673. /**
  109674. * Begin a new frame
  109675. */
  109676. beginFrame(): void;
  109677. /**
  109678. * Enf the current frame
  109679. */
  109680. endFrame(): void;
  109681. resize(): void;
  109682. /**
  109683. * Force a specific size of the canvas
  109684. * @param width defines the new canvas' width
  109685. * @param height defines the new canvas' height
  109686. */
  109687. setSize(width: number, height: number): void;
  109688. /**
  109689. * Updates a dynamic vertex buffer.
  109690. * @param vertexBuffer the vertex buffer to update
  109691. * @param data the data used to update the vertex buffer
  109692. * @param byteOffset the byte offset of the data
  109693. * @param byteLength the byte length of the data
  109694. */
  109695. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  109696. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  109697. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  109698. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  109699. _releaseTexture(texture: InternalTexture): void;
  109700. /**
  109701. * @hidden
  109702. * Rescales a texture
  109703. * @param source input texutre
  109704. * @param destination destination texture
  109705. * @param scene scene to use to render the resize
  109706. * @param internalFormat format to use when resizing
  109707. * @param onComplete callback to be called when resize has completed
  109708. */
  109709. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  109710. /**
  109711. * Gets the current framerate
  109712. * @returns a number representing the framerate
  109713. */
  109714. getFps(): number;
  109715. /**
  109716. * Gets the time spent between current and previous frame
  109717. * @returns a number representing the delta time in ms
  109718. */
  109719. getDeltaTime(): number;
  109720. private _measureFps;
  109721. /** @hidden */
  109722. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  109723. /**
  109724. * Update a dynamic index buffer
  109725. * @param indexBuffer defines the target index buffer
  109726. * @param indices defines the data to update
  109727. * @param offset defines the offset in the target index buffer where update should start
  109728. */
  109729. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  109730. /**
  109731. * Updates the sample count of a render target texture
  109732. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  109733. * @param texture defines the texture to update
  109734. * @param samples defines the sample count to set
  109735. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  109736. */
  109737. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  109738. /**
  109739. * Updates a depth texture Comparison Mode and Function.
  109740. * If the comparison Function is equal to 0, the mode will be set to none.
  109741. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  109742. * @param texture The texture to set the comparison function for
  109743. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  109744. */
  109745. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  109746. /**
  109747. * Creates a webGL buffer to use with instanciation
  109748. * @param capacity defines the size of the buffer
  109749. * @returns the webGL buffer
  109750. */
  109751. createInstancesBuffer(capacity: number): DataBuffer;
  109752. /**
  109753. * Delete a webGL buffer used with instanciation
  109754. * @param buffer defines the webGL buffer to delete
  109755. */
  109756. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  109757. private _clientWaitAsync;
  109758. /** @hidden */
  109759. _readPixelsAsync(x: number, y: number, w: number, h: number, format: number, type: number, outputBuffer: ArrayBufferView): Promise<ArrayBufferView> | null;
  109760. /** @hidden */
  109761. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  109762. dispose(): void;
  109763. private _disableTouchAction;
  109764. /**
  109765. * Display the loading screen
  109766. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  109767. */
  109768. displayLoadingUI(): void;
  109769. /**
  109770. * Hide the loading screen
  109771. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  109772. */
  109773. hideLoadingUI(): void;
  109774. /**
  109775. * Gets the current loading screen object
  109776. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  109777. */
  109778. get loadingScreen(): ILoadingScreen;
  109779. /**
  109780. * Sets the current loading screen object
  109781. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  109782. */
  109783. set loadingScreen(loadingScreen: ILoadingScreen);
  109784. /**
  109785. * Sets the current loading screen text
  109786. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  109787. */
  109788. set loadingUIText(text: string);
  109789. /**
  109790. * Sets the current loading screen background color
  109791. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  109792. */
  109793. set loadingUIBackgroundColor(color: string);
  109794. /** Pointerlock and fullscreen */
  109795. /**
  109796. * Ask the browser to promote the current element to pointerlock mode
  109797. * @param element defines the DOM element to promote
  109798. */
  109799. static _RequestPointerlock(element: HTMLElement): void;
  109800. /**
  109801. * Asks the browser to exit pointerlock mode
  109802. */
  109803. static _ExitPointerlock(): void;
  109804. /**
  109805. * Ask the browser to promote the current element to fullscreen rendering mode
  109806. * @param element defines the DOM element to promote
  109807. */
  109808. static _RequestFullscreen(element: HTMLElement): void;
  109809. /**
  109810. * Asks the browser to exit fullscreen mode
  109811. */
  109812. static _ExitFullscreen(): void;
  109813. }
  109814. }
  109815. declare module BABYLON {
  109816. /**
  109817. * The engine store class is responsible to hold all the instances of Engine and Scene created
  109818. * during the life time of the application.
  109819. */
  109820. export class EngineStore {
  109821. /** Gets the list of created engines */
  109822. static Instances: Engine[];
  109823. /** @hidden */
  109824. static _LastCreatedScene: Nullable<Scene>;
  109825. /**
  109826. * Gets the latest created engine
  109827. */
  109828. static get LastCreatedEngine(): Nullable<Engine>;
  109829. /**
  109830. * Gets the latest created scene
  109831. */
  109832. static get LastCreatedScene(): Nullable<Scene>;
  109833. /**
  109834. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  109835. * @ignorenaming
  109836. */
  109837. static UseFallbackTexture: boolean;
  109838. /**
  109839. * Texture content used if a texture cannot loaded
  109840. * @ignorenaming
  109841. */
  109842. static FallbackTexture: string;
  109843. }
  109844. }
  109845. declare module BABYLON {
  109846. /**
  109847. * Helper class that provides a small promise polyfill
  109848. */
  109849. export class PromisePolyfill {
  109850. /**
  109851. * Static function used to check if the polyfill is required
  109852. * If this is the case then the function will inject the polyfill to window.Promise
  109853. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  109854. */
  109855. static Apply(force?: boolean): void;
  109856. }
  109857. }
  109858. declare module BABYLON {
  109859. /**
  109860. * Interface for screenshot methods with describe argument called `size` as object with options
  109861. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  109862. */
  109863. export interface IScreenshotSize {
  109864. /**
  109865. * number in pixels for canvas height
  109866. */
  109867. height?: number;
  109868. /**
  109869. * multiplier allowing render at a higher or lower resolution
  109870. * If value is defined then height and width will be ignored and taken from camera
  109871. */
  109872. precision?: number;
  109873. /**
  109874. * number in pixels for canvas width
  109875. */
  109876. width?: number;
  109877. }
  109878. }
  109879. declare module BABYLON {
  109880. interface IColor4Like {
  109881. r: float;
  109882. g: float;
  109883. b: float;
  109884. a: float;
  109885. }
  109886. /**
  109887. * Class containing a set of static utilities functions
  109888. */
  109889. export class Tools {
  109890. /**
  109891. * Gets or sets the base URL to use to load assets
  109892. */
  109893. static get BaseUrl(): string;
  109894. static set BaseUrl(value: string);
  109895. /**
  109896. * Enable/Disable Custom HTTP Request Headers globally.
  109897. * default = false
  109898. * @see CustomRequestHeaders
  109899. */
  109900. static UseCustomRequestHeaders: boolean;
  109901. /**
  109902. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  109903. * i.e. when loading files, where the server/service expects an Authorization header
  109904. */
  109905. static CustomRequestHeaders: {
  109906. [key: string]: string;
  109907. };
  109908. /**
  109909. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  109910. */
  109911. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  109912. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  109913. /**
  109914. * Default behaviour for cors in the application.
  109915. * It can be a string if the expected behavior is identical in the entire app.
  109916. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  109917. */
  109918. static get CorsBehavior(): string | ((url: string | string[]) => string);
  109919. static set CorsBehavior(value: string | ((url: string | string[]) => string));
  109920. /**
  109921. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  109922. * @ignorenaming
  109923. */
  109924. static get UseFallbackTexture(): boolean;
  109925. static set UseFallbackTexture(value: boolean);
  109926. /**
  109927. * Use this object to register external classes like custom textures or material
  109928. * to allow the laoders to instantiate them
  109929. */
  109930. static get RegisteredExternalClasses(): {
  109931. [key: string]: Object;
  109932. };
  109933. static set RegisteredExternalClasses(classes: {
  109934. [key: string]: Object;
  109935. });
  109936. /**
  109937. * Texture content used if a texture cannot loaded
  109938. * @ignorenaming
  109939. */
  109940. static get fallbackTexture(): string;
  109941. static set fallbackTexture(value: string);
  109942. /**
  109943. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  109944. * @param u defines the coordinate on X axis
  109945. * @param v defines the coordinate on Y axis
  109946. * @param width defines the width of the source data
  109947. * @param height defines the height of the source data
  109948. * @param pixels defines the source byte array
  109949. * @param color defines the output color
  109950. */
  109951. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  109952. /**
  109953. * Interpolates between a and b via alpha
  109954. * @param a The lower value (returned when alpha = 0)
  109955. * @param b The upper value (returned when alpha = 1)
  109956. * @param alpha The interpolation-factor
  109957. * @return The mixed value
  109958. */
  109959. static Mix(a: number, b: number, alpha: number): number;
  109960. /**
  109961. * Tries to instantiate a new object from a given class name
  109962. * @param className defines the class name to instantiate
  109963. * @returns the new object or null if the system was not able to do the instantiation
  109964. */
  109965. static Instantiate(className: string): any;
  109966. /**
  109967. * Provides a slice function that will work even on IE
  109968. * @param data defines the array to slice
  109969. * @param start defines the start of the data (optional)
  109970. * @param end defines the end of the data (optional)
  109971. * @returns the new sliced array
  109972. */
  109973. static Slice<T>(data: T, start?: number, end?: number): T;
  109974. /**
  109975. * Polyfill for setImmediate
  109976. * @param action defines the action to execute after the current execution block
  109977. */
  109978. static SetImmediate(action: () => void): void;
  109979. /**
  109980. * Function indicating if a number is an exponent of 2
  109981. * @param value defines the value to test
  109982. * @returns true if the value is an exponent of 2
  109983. */
  109984. static IsExponentOfTwo(value: number): boolean;
  109985. private static _tmpFloatArray;
  109986. /**
  109987. * Returns the nearest 32-bit single precision float representation of a Number
  109988. * @param value A Number. If the parameter is of a different type, it will get converted
  109989. * to a number or to NaN if it cannot be converted
  109990. * @returns number
  109991. */
  109992. static FloatRound(value: number): number;
  109993. /**
  109994. * Extracts the filename from a path
  109995. * @param path defines the path to use
  109996. * @returns the filename
  109997. */
  109998. static GetFilename(path: string): string;
  109999. /**
  110000. * Extracts the "folder" part of a path (everything before the filename).
  110001. * @param uri The URI to extract the info from
  110002. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  110003. * @returns The "folder" part of the path
  110004. */
  110005. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  110006. /**
  110007. * Extracts text content from a DOM element hierarchy
  110008. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  110009. */
  110010. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  110011. /**
  110012. * Convert an angle in radians to degrees
  110013. * @param angle defines the angle to convert
  110014. * @returns the angle in degrees
  110015. */
  110016. static ToDegrees(angle: number): number;
  110017. /**
  110018. * Convert an angle in degrees to radians
  110019. * @param angle defines the angle to convert
  110020. * @returns the angle in radians
  110021. */
  110022. static ToRadians(angle: number): number;
  110023. /**
  110024. * Returns an array if obj is not an array
  110025. * @param obj defines the object to evaluate as an array
  110026. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  110027. * @returns either obj directly if obj is an array or a new array containing obj
  110028. */
  110029. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  110030. /**
  110031. * Gets the pointer prefix to use
  110032. * @returns "pointer" if touch is enabled. Else returns "mouse"
  110033. */
  110034. static GetPointerPrefix(): string;
  110035. /**
  110036. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  110037. * @param url define the url we are trying
  110038. * @param element define the dom element where to configure the cors policy
  110039. */
  110040. static SetCorsBehavior(url: string | string[], element: {
  110041. crossOrigin: string | null;
  110042. }): void;
  110043. /**
  110044. * Removes unwanted characters from an url
  110045. * @param url defines the url to clean
  110046. * @returns the cleaned url
  110047. */
  110048. static CleanUrl(url: string): string;
  110049. /**
  110050. * Gets or sets a function used to pre-process url before using them to load assets
  110051. */
  110052. static get PreprocessUrl(): (url: string) => string;
  110053. static set PreprocessUrl(processor: (url: string) => string);
  110054. /**
  110055. * Loads an image as an HTMLImageElement.
  110056. * @param input url string, ArrayBuffer, or Blob to load
  110057. * @param onLoad callback called when the image successfully loads
  110058. * @param onError callback called when the image fails to load
  110059. * @param offlineProvider offline provider for caching
  110060. * @param mimeType optional mime type
  110061. * @returns the HTMLImageElement of the loaded image
  110062. */
  110063. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  110064. /**
  110065. * Loads a file from a url
  110066. * @param url url string, ArrayBuffer, or Blob to load
  110067. * @param onSuccess callback called when the file successfully loads
  110068. * @param onProgress callback called while file is loading (if the server supports this mode)
  110069. * @param offlineProvider defines the offline provider for caching
  110070. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  110071. * @param onError callback called when the file fails to load
  110072. * @returns a file request object
  110073. */
  110074. 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;
  110075. /**
  110076. * Loads a file from a url
  110077. * @param url the file url to load
  110078. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  110079. * @returns a promise containing an ArrayBuffer corresponding to the loaded file
  110080. */
  110081. static LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>;
  110082. /**
  110083. * Load a script (identified by an url). When the url returns, the
  110084. * content of this file is added into a new script element, attached to the DOM (body element)
  110085. * @param scriptUrl defines the url of the script to laod
  110086. * @param onSuccess defines the callback called when the script is loaded
  110087. * @param onError defines the callback to call if an error occurs
  110088. * @param scriptId defines the id of the script element
  110089. */
  110090. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  110091. /**
  110092. * Load an asynchronous script (identified by an url). When the url returns, the
  110093. * content of this file is added into a new script element, attached to the DOM (body element)
  110094. * @param scriptUrl defines the url of the script to laod
  110095. * @param scriptId defines the id of the script element
  110096. * @returns a promise request object
  110097. */
  110098. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  110099. /**
  110100. * Loads a file from a blob
  110101. * @param fileToLoad defines the blob to use
  110102. * @param callback defines the callback to call when data is loaded
  110103. * @param progressCallback defines the callback to call during loading process
  110104. * @returns a file request object
  110105. */
  110106. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  110107. /**
  110108. * Reads a file from a File object
  110109. * @param file defines the file to load
  110110. * @param onSuccess defines the callback to call when data is loaded
  110111. * @param onProgress defines the callback to call during loading process
  110112. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  110113. * @param onError defines the callback to call when an error occurs
  110114. * @returns a file request object
  110115. */
  110116. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  110117. /**
  110118. * Creates a data url from a given string content
  110119. * @param content defines the content to convert
  110120. * @returns the new data url link
  110121. */
  110122. static FileAsURL(content: string): string;
  110123. /**
  110124. * Format the given number to a specific decimal format
  110125. * @param value defines the number to format
  110126. * @param decimals defines the number of decimals to use
  110127. * @returns the formatted string
  110128. */
  110129. static Format(value: number, decimals?: number): string;
  110130. /**
  110131. * Tries to copy an object by duplicating every property
  110132. * @param source defines the source object
  110133. * @param destination defines the target object
  110134. * @param doNotCopyList defines a list of properties to avoid
  110135. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  110136. */
  110137. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  110138. /**
  110139. * Gets a boolean indicating if the given object has no own property
  110140. * @param obj defines the object to test
  110141. * @returns true if object has no own property
  110142. */
  110143. static IsEmpty(obj: any): boolean;
  110144. /**
  110145. * Function used to register events at window level
  110146. * @param windowElement defines the Window object to use
  110147. * @param events defines the events to register
  110148. */
  110149. static RegisterTopRootEvents(windowElement: Window, events: {
  110150. name: string;
  110151. handler: Nullable<(e: FocusEvent) => any>;
  110152. }[]): void;
  110153. /**
  110154. * Function used to unregister events from window level
  110155. * @param windowElement defines the Window object to use
  110156. * @param events defines the events to unregister
  110157. */
  110158. static UnregisterTopRootEvents(windowElement: Window, events: {
  110159. name: string;
  110160. handler: Nullable<(e: FocusEvent) => any>;
  110161. }[]): void;
  110162. /**
  110163. * @ignore
  110164. */
  110165. static _ScreenshotCanvas: HTMLCanvasElement;
  110166. /**
  110167. * Dumps the current bound framebuffer
  110168. * @param width defines the rendering width
  110169. * @param height defines the rendering height
  110170. * @param engine defines the hosting engine
  110171. * @param successCallback defines the callback triggered once the data are available
  110172. * @param mimeType defines the mime type of the result
  110173. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  110174. */
  110175. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  110176. /**
  110177. * Converts the canvas data to blob.
  110178. * This acts as a polyfill for browsers not supporting the to blob function.
  110179. * @param canvas Defines the canvas to extract the data from
  110180. * @param successCallback Defines the callback triggered once the data are available
  110181. * @param mimeType Defines the mime type of the result
  110182. */
  110183. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  110184. /**
  110185. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  110186. * @param successCallback defines the callback triggered once the data are available
  110187. * @param mimeType defines the mime type of the result
  110188. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  110189. */
  110190. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  110191. /**
  110192. * Downloads a blob in the browser
  110193. * @param blob defines the blob to download
  110194. * @param fileName defines the name of the downloaded file
  110195. */
  110196. static Download(blob: Blob, fileName: string): void;
  110197. /**
  110198. * Captures a screenshot of the current rendering
  110199. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  110200. * @param engine defines the rendering engine
  110201. * @param camera defines the source camera
  110202. * @param size This parameter can be set to a single number or to an object with the
  110203. * following (optional) properties: precision, width, height. If a single number is passed,
  110204. * it will be used for both width and height. If an object is passed, the screenshot size
  110205. * will be derived from the parameters. The precision property is a multiplier allowing
  110206. * rendering at a higher or lower resolution
  110207. * @param successCallback defines the callback receives a single parameter which contains the
  110208. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  110209. * src parameter of an <img> to display it
  110210. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  110211. * Check your browser for supported MIME types
  110212. */
  110213. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  110214. /**
  110215. * Captures a screenshot of the current rendering
  110216. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  110217. * @param engine defines the rendering engine
  110218. * @param camera defines the source camera
  110219. * @param size This parameter can be set to a single number or to an object with the
  110220. * following (optional) properties: precision, width, height. If a single number is passed,
  110221. * it will be used for both width and height. If an object is passed, the screenshot size
  110222. * will be derived from the parameters. The precision property is a multiplier allowing
  110223. * rendering at a higher or lower resolution
  110224. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  110225. * Check your browser for supported MIME types
  110226. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  110227. * to the src parameter of an <img> to display it
  110228. */
  110229. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  110230. /**
  110231. * Generates an image screenshot from the specified camera.
  110232. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  110233. * @param engine The engine to use for rendering
  110234. * @param camera The camera to use for rendering
  110235. * @param size This parameter can be set to a single number or to an object with the
  110236. * following (optional) properties: precision, width, height. If a single number is passed,
  110237. * it will be used for both width and height. If an object is passed, the screenshot size
  110238. * will be derived from the parameters. The precision property is a multiplier allowing
  110239. * rendering at a higher or lower resolution
  110240. * @param successCallback The callback receives a single parameter which contains the
  110241. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  110242. * src parameter of an <img> to display it
  110243. * @param mimeType The MIME type of the screenshot image (default: image/png).
  110244. * Check your browser for supported MIME types
  110245. * @param samples Texture samples (default: 1)
  110246. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  110247. * @param fileName A name for for the downloaded file.
  110248. */
  110249. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  110250. /**
  110251. * Generates an image screenshot from the specified camera.
  110252. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  110253. * @param engine The engine to use for rendering
  110254. * @param camera The camera to use for rendering
  110255. * @param size This parameter can be set to a single number or to an object with the
  110256. * following (optional) properties: precision, width, height. If a single number is passed,
  110257. * it will be used for both width and height. If an object is passed, the screenshot size
  110258. * will be derived from the parameters. The precision property is a multiplier allowing
  110259. * rendering at a higher or lower resolution
  110260. * @param mimeType The MIME type of the screenshot image (default: image/png).
  110261. * Check your browser for supported MIME types
  110262. * @param samples Texture samples (default: 1)
  110263. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  110264. * @param fileName A name for for the downloaded file.
  110265. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  110266. * to the src parameter of an <img> to display it
  110267. */
  110268. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  110269. /**
  110270. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  110271. * Be aware Math.random() could cause collisions, but:
  110272. * "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"
  110273. * @returns a pseudo random id
  110274. */
  110275. static RandomId(): string;
  110276. /**
  110277. * Test if the given uri is a base64 string
  110278. * @param uri The uri to test
  110279. * @return True if the uri is a base64 string or false otherwise
  110280. */
  110281. static IsBase64(uri: string): boolean;
  110282. /**
  110283. * Decode the given base64 uri.
  110284. * @param uri The uri to decode
  110285. * @return The decoded base64 data.
  110286. */
  110287. static DecodeBase64(uri: string): ArrayBuffer;
  110288. /**
  110289. * Gets the absolute url.
  110290. * @param url the input url
  110291. * @return the absolute url
  110292. */
  110293. static GetAbsoluteUrl(url: string): string;
  110294. /**
  110295. * No log
  110296. */
  110297. static readonly NoneLogLevel: number;
  110298. /**
  110299. * Only message logs
  110300. */
  110301. static readonly MessageLogLevel: number;
  110302. /**
  110303. * Only warning logs
  110304. */
  110305. static readonly WarningLogLevel: number;
  110306. /**
  110307. * Only error logs
  110308. */
  110309. static readonly ErrorLogLevel: number;
  110310. /**
  110311. * All logs
  110312. */
  110313. static readonly AllLogLevel: number;
  110314. /**
  110315. * Gets a value indicating the number of loading errors
  110316. * @ignorenaming
  110317. */
  110318. static get errorsCount(): number;
  110319. /**
  110320. * Callback called when a new log is added
  110321. */
  110322. static OnNewCacheEntry: (entry: string) => void;
  110323. /**
  110324. * Log a message to the console
  110325. * @param message defines the message to log
  110326. */
  110327. static Log(message: string): void;
  110328. /**
  110329. * Write a warning message to the console
  110330. * @param message defines the message to log
  110331. */
  110332. static Warn(message: string): void;
  110333. /**
  110334. * Write an error message to the console
  110335. * @param message defines the message to log
  110336. */
  110337. static Error(message: string): void;
  110338. /**
  110339. * Gets current log cache (list of logs)
  110340. */
  110341. static get LogCache(): string;
  110342. /**
  110343. * Clears the log cache
  110344. */
  110345. static ClearLogCache(): void;
  110346. /**
  110347. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  110348. */
  110349. static set LogLevels(level: number);
  110350. /**
  110351. * Checks if the window object exists
  110352. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  110353. */
  110354. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  110355. /**
  110356. * No performance log
  110357. */
  110358. static readonly PerformanceNoneLogLevel: number;
  110359. /**
  110360. * Use user marks to log performance
  110361. */
  110362. static readonly PerformanceUserMarkLogLevel: number;
  110363. /**
  110364. * Log performance to the console
  110365. */
  110366. static readonly PerformanceConsoleLogLevel: number;
  110367. private static _performance;
  110368. /**
  110369. * Sets the current performance log level
  110370. */
  110371. static set PerformanceLogLevel(level: number);
  110372. private static _StartPerformanceCounterDisabled;
  110373. private static _EndPerformanceCounterDisabled;
  110374. private static _StartUserMark;
  110375. private static _EndUserMark;
  110376. private static _StartPerformanceConsole;
  110377. private static _EndPerformanceConsole;
  110378. /**
  110379. * Starts a performance counter
  110380. */
  110381. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  110382. /**
  110383. * Ends a specific performance coutner
  110384. */
  110385. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  110386. /**
  110387. * Gets either window.performance.now() if supported or Date.now() else
  110388. */
  110389. static get Now(): number;
  110390. /**
  110391. * This method will return the name of the class used to create the instance of the given object.
  110392. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  110393. * @param object the object to get the class name from
  110394. * @param isType defines if the object is actually a type
  110395. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  110396. */
  110397. static GetClassName(object: any, isType?: boolean): string;
  110398. /**
  110399. * Gets the first element of an array satisfying a given predicate
  110400. * @param array defines the array to browse
  110401. * @param predicate defines the predicate to use
  110402. * @returns null if not found or the element
  110403. */
  110404. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  110405. /**
  110406. * This method will return the name of the full name of the class, including its owning module (if any).
  110407. * 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).
  110408. * @param object the object to get the class name from
  110409. * @param isType defines if the object is actually a type
  110410. * @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.
  110411. * @ignorenaming
  110412. */
  110413. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  110414. /**
  110415. * Returns a promise that resolves after the given amount of time.
  110416. * @param delay Number of milliseconds to delay
  110417. * @returns Promise that resolves after the given amount of time
  110418. */
  110419. static DelayAsync(delay: number): Promise<void>;
  110420. /**
  110421. * Utility function to detect if the current user agent is Safari
  110422. * @returns whether or not the current user agent is safari
  110423. */
  110424. static IsSafari(): boolean;
  110425. }
  110426. /**
  110427. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  110428. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  110429. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  110430. * @param name The name of the class, case should be preserved
  110431. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  110432. */
  110433. export function className(name: string, module?: string): (target: Object) => void;
  110434. /**
  110435. * An implementation of a loop for asynchronous functions.
  110436. */
  110437. export class AsyncLoop {
  110438. /**
  110439. * Defines the number of iterations for the loop
  110440. */
  110441. iterations: number;
  110442. /**
  110443. * Defines the current index of the loop.
  110444. */
  110445. index: number;
  110446. private _done;
  110447. private _fn;
  110448. private _successCallback;
  110449. /**
  110450. * Constructor.
  110451. * @param iterations the number of iterations.
  110452. * @param func the function to run each iteration
  110453. * @param successCallback the callback that will be called upon succesful execution
  110454. * @param offset starting offset.
  110455. */
  110456. constructor(
  110457. /**
  110458. * Defines the number of iterations for the loop
  110459. */
  110460. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  110461. /**
  110462. * Execute the next iteration. Must be called after the last iteration was finished.
  110463. */
  110464. executeNext(): void;
  110465. /**
  110466. * Break the loop and run the success callback.
  110467. */
  110468. breakLoop(): void;
  110469. /**
  110470. * Create and run an async loop.
  110471. * @param iterations the number of iterations.
  110472. * @param fn the function to run each iteration
  110473. * @param successCallback the callback that will be called upon succesful execution
  110474. * @param offset starting offset.
  110475. * @returns the created async loop object
  110476. */
  110477. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  110478. /**
  110479. * A for-loop that will run a given number of iterations synchronous and the rest async.
  110480. * @param iterations total number of iterations
  110481. * @param syncedIterations number of synchronous iterations in each async iteration.
  110482. * @param fn the function to call each iteration.
  110483. * @param callback a success call back that will be called when iterating stops.
  110484. * @param breakFunction a break condition (optional)
  110485. * @param timeout timeout settings for the setTimeout function. default - 0.
  110486. * @returns the created async loop object
  110487. */
  110488. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  110489. }
  110490. }
  110491. declare module BABYLON {
  110492. /**
  110493. * This class implement a typical dictionary using a string as key and the generic type T as value.
  110494. * The underlying implementation relies on an associative array to ensure the best performances.
  110495. * The value can be anything including 'null' but except 'undefined'
  110496. */
  110497. export class StringDictionary<T> {
  110498. /**
  110499. * This will clear this dictionary and copy the content from the 'source' one.
  110500. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  110501. * @param source the dictionary to take the content from and copy to this dictionary
  110502. */
  110503. copyFrom(source: StringDictionary<T>): void;
  110504. /**
  110505. * Get a value based from its key
  110506. * @param key the given key to get the matching value from
  110507. * @return the value if found, otherwise undefined is returned
  110508. */
  110509. get(key: string): T | undefined;
  110510. /**
  110511. * Get a value from its key or add it if it doesn't exist.
  110512. * This method will ensure you that a given key/data will be present in the dictionary.
  110513. * @param key the given key to get the matching value from
  110514. * @param factory the factory that will create the value if the key is not present in the dictionary.
  110515. * The factory will only be invoked if there's no data for the given key.
  110516. * @return the value corresponding to the key.
  110517. */
  110518. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  110519. /**
  110520. * Get a value from its key if present in the dictionary otherwise add it
  110521. * @param key the key to get the value from
  110522. * @param val if there's no such key/value pair in the dictionary add it with this value
  110523. * @return the value corresponding to the key
  110524. */
  110525. getOrAdd(key: string, val: T): T;
  110526. /**
  110527. * Check if there's a given key in the dictionary
  110528. * @param key the key to check for
  110529. * @return true if the key is present, false otherwise
  110530. */
  110531. contains(key: string): boolean;
  110532. /**
  110533. * Add a new key and its corresponding value
  110534. * @param key the key to add
  110535. * @param value the value corresponding to the key
  110536. * @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
  110537. */
  110538. add(key: string, value: T): boolean;
  110539. /**
  110540. * Update a specific value associated to a key
  110541. * @param key defines the key to use
  110542. * @param value defines the value to store
  110543. * @returns true if the value was updated (or false if the key was not found)
  110544. */
  110545. set(key: string, value: T): boolean;
  110546. /**
  110547. * Get the element of the given key and remove it from the dictionary
  110548. * @param key defines the key to search
  110549. * @returns the value associated with the key or null if not found
  110550. */
  110551. getAndRemove(key: string): Nullable<T>;
  110552. /**
  110553. * Remove a key/value from the dictionary.
  110554. * @param key the key to remove
  110555. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  110556. */
  110557. remove(key: string): boolean;
  110558. /**
  110559. * Clear the whole content of the dictionary
  110560. */
  110561. clear(): void;
  110562. /**
  110563. * Gets the current count
  110564. */
  110565. get count(): number;
  110566. /**
  110567. * Execute a callback on each key/val of the dictionary.
  110568. * Note that you can remove any element in this dictionary in the callback implementation
  110569. * @param callback the callback to execute on a given key/value pair
  110570. */
  110571. forEach(callback: (key: string, val: T) => void): void;
  110572. /**
  110573. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  110574. * If the callback returns null or undefined the method will iterate to the next key/value pair
  110575. * Note that you can remove any element in this dictionary in the callback implementation
  110576. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  110577. * @returns the first item
  110578. */
  110579. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  110580. private _count;
  110581. private _data;
  110582. }
  110583. }
  110584. declare module BABYLON {
  110585. /** @hidden */
  110586. export interface ICollisionCoordinator {
  110587. createCollider(): Collider;
  110588. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  110589. init(scene: Scene): void;
  110590. }
  110591. /** @hidden */
  110592. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  110593. private _scene;
  110594. private _scaledPosition;
  110595. private _scaledVelocity;
  110596. private _finalPosition;
  110597. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  110598. createCollider(): Collider;
  110599. init(scene: Scene): void;
  110600. private _collideWithWorld;
  110601. }
  110602. }
  110603. declare module BABYLON {
  110604. /**
  110605. * Class used to manage all inputs for the scene.
  110606. */
  110607. export class InputManager {
  110608. /** The distance in pixel that you have to move to prevent some events */
  110609. static DragMovementThreshold: number;
  110610. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  110611. static LongPressDelay: number;
  110612. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  110613. static DoubleClickDelay: number;
  110614. /** If you need to check double click without raising a single click at first click, enable this flag */
  110615. static ExclusiveDoubleClickMode: boolean;
  110616. private _wheelEventName;
  110617. private _onPointerMove;
  110618. private _onPointerDown;
  110619. private _onPointerUp;
  110620. private _initClickEvent;
  110621. private _initActionManager;
  110622. private _delayedSimpleClick;
  110623. private _delayedSimpleClickTimeout;
  110624. private _previousDelayedSimpleClickTimeout;
  110625. private _meshPickProceed;
  110626. private _previousButtonPressed;
  110627. private _currentPickResult;
  110628. private _previousPickResult;
  110629. private _totalPointersPressed;
  110630. private _doubleClickOccured;
  110631. private _pointerOverMesh;
  110632. private _pickedDownMesh;
  110633. private _pickedUpMesh;
  110634. private _pointerX;
  110635. private _pointerY;
  110636. private _unTranslatedPointerX;
  110637. private _unTranslatedPointerY;
  110638. private _startingPointerPosition;
  110639. private _previousStartingPointerPosition;
  110640. private _startingPointerTime;
  110641. private _previousStartingPointerTime;
  110642. private _pointerCaptures;
  110643. private _onKeyDown;
  110644. private _onKeyUp;
  110645. private _onCanvasFocusObserver;
  110646. private _onCanvasBlurObserver;
  110647. private _scene;
  110648. /**
  110649. * Creates a new InputManager
  110650. * @param scene defines the hosting scene
  110651. */
  110652. constructor(scene: Scene);
  110653. /**
  110654. * Gets the mesh that is currently under the pointer
  110655. */
  110656. get meshUnderPointer(): Nullable<AbstractMesh>;
  110657. /**
  110658. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  110659. */
  110660. get unTranslatedPointer(): Vector2;
  110661. /**
  110662. * Gets or sets the current on-screen X position of the pointer
  110663. */
  110664. get pointerX(): number;
  110665. set pointerX(value: number);
  110666. /**
  110667. * Gets or sets the current on-screen Y position of the pointer
  110668. */
  110669. get pointerY(): number;
  110670. set pointerY(value: number);
  110671. private _updatePointerPosition;
  110672. private _processPointerMove;
  110673. private _setRayOnPointerInfo;
  110674. private _checkPrePointerObservable;
  110675. /**
  110676. * Use this method to simulate a pointer move on a mesh
  110677. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  110678. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  110679. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  110680. */
  110681. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  110682. /**
  110683. * Use this method to simulate a pointer down on a mesh
  110684. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  110685. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  110686. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  110687. */
  110688. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  110689. private _processPointerDown;
  110690. /** @hidden */
  110691. _isPointerSwiping(): boolean;
  110692. /**
  110693. * Use this method to simulate a pointer up on a mesh
  110694. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  110695. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  110696. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  110697. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  110698. */
  110699. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  110700. private _processPointerUp;
  110701. /**
  110702. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  110703. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  110704. * @returns true if the pointer was captured
  110705. */
  110706. isPointerCaptured(pointerId?: number): boolean;
  110707. /**
  110708. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  110709. * @param attachUp defines if you want to attach events to pointerup
  110710. * @param attachDown defines if you want to attach events to pointerdown
  110711. * @param attachMove defines if you want to attach events to pointermove
  110712. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  110713. */
  110714. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  110715. /**
  110716. * Detaches all event handlers
  110717. */
  110718. detachControl(): void;
  110719. /**
  110720. * Force the value of meshUnderPointer
  110721. * @param mesh defines the mesh to use
  110722. */
  110723. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  110724. /**
  110725. * Gets the mesh under the pointer
  110726. * @returns a Mesh or null if no mesh is under the pointer
  110727. */
  110728. getPointerOverMesh(): Nullable<AbstractMesh>;
  110729. }
  110730. }
  110731. declare module BABYLON {
  110732. /**
  110733. * Helper class used to generate session unique ID
  110734. */
  110735. export class UniqueIdGenerator {
  110736. private static _UniqueIdCounter;
  110737. /**
  110738. * Gets an unique (relatively to the current scene) Id
  110739. */
  110740. static get UniqueId(): number;
  110741. }
  110742. }
  110743. declare module BABYLON {
  110744. /**
  110745. * This class defines the direct association between an animation and a target
  110746. */
  110747. export class TargetedAnimation {
  110748. /**
  110749. * Animation to perform
  110750. */
  110751. animation: Animation;
  110752. /**
  110753. * Target to animate
  110754. */
  110755. target: any;
  110756. /**
  110757. * Serialize the object
  110758. * @returns the JSON object representing the current entity
  110759. */
  110760. serialize(): any;
  110761. }
  110762. /**
  110763. * Use this class to create coordinated animations on multiple targets
  110764. */
  110765. export class AnimationGroup implements IDisposable {
  110766. /** The name of the animation group */
  110767. name: string;
  110768. private _scene;
  110769. private _targetedAnimations;
  110770. private _animatables;
  110771. private _from;
  110772. private _to;
  110773. private _isStarted;
  110774. private _isPaused;
  110775. private _speedRatio;
  110776. private _loopAnimation;
  110777. private _isAdditive;
  110778. /**
  110779. * Gets or sets the unique id of the node
  110780. */
  110781. uniqueId: number;
  110782. /**
  110783. * This observable will notify when one animation have ended
  110784. */
  110785. onAnimationEndObservable: Observable<TargetedAnimation>;
  110786. /**
  110787. * Observer raised when one animation loops
  110788. */
  110789. onAnimationLoopObservable: Observable<TargetedAnimation>;
  110790. /**
  110791. * Observer raised when all animations have looped
  110792. */
  110793. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  110794. /**
  110795. * This observable will notify when all animations have ended.
  110796. */
  110797. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  110798. /**
  110799. * This observable will notify when all animations have paused.
  110800. */
  110801. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  110802. /**
  110803. * This observable will notify when all animations are playing.
  110804. */
  110805. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  110806. /**
  110807. * Gets the first frame
  110808. */
  110809. get from(): number;
  110810. /**
  110811. * Gets the last frame
  110812. */
  110813. get to(): number;
  110814. /**
  110815. * Define if the animations are started
  110816. */
  110817. get isStarted(): boolean;
  110818. /**
  110819. * Gets a value indicating that the current group is playing
  110820. */
  110821. get isPlaying(): boolean;
  110822. /**
  110823. * Gets or sets the speed ratio to use for all animations
  110824. */
  110825. get speedRatio(): number;
  110826. /**
  110827. * Gets or sets the speed ratio to use for all animations
  110828. */
  110829. set speedRatio(value: number);
  110830. /**
  110831. * Gets or sets if all animations should loop or not
  110832. */
  110833. get loopAnimation(): boolean;
  110834. set loopAnimation(value: boolean);
  110835. /**
  110836. * Gets or sets if all animations should be evaluated additively
  110837. */
  110838. get isAdditive(): boolean;
  110839. set isAdditive(value: boolean);
  110840. /**
  110841. * Gets the targeted animations for this animation group
  110842. */
  110843. get targetedAnimations(): Array<TargetedAnimation>;
  110844. /**
  110845. * returning the list of animatables controlled by this animation group.
  110846. */
  110847. get animatables(): Array<Animatable>;
  110848. /**
  110849. * Instantiates a new Animation Group.
  110850. * This helps managing several animations at once.
  110851. * @see http://doc.babylonjs.com/how_to/group
  110852. * @param name Defines the name of the group
  110853. * @param scene Defines the scene the group belongs to
  110854. */
  110855. constructor(
  110856. /** The name of the animation group */
  110857. name: string, scene?: Nullable<Scene>);
  110858. /**
  110859. * Add an animation (with its target) in the group
  110860. * @param animation defines the animation we want to add
  110861. * @param target defines the target of the animation
  110862. * @returns the TargetedAnimation object
  110863. */
  110864. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  110865. /**
  110866. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  110867. * It can add constant keys at begin or end
  110868. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  110869. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  110870. * @returns the animation group
  110871. */
  110872. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  110873. private _animationLoopCount;
  110874. private _animationLoopFlags;
  110875. private _processLoop;
  110876. /**
  110877. * Start all animations on given targets
  110878. * @param loop defines if animations must loop
  110879. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  110880. * @param from defines the from key (optional)
  110881. * @param to defines the to key (optional)
  110882. * @param isAdditive defines the additive state for the resulting animatables (optional)
  110883. * @returns the current animation group
  110884. */
  110885. start(loop?: boolean, speedRatio?: number, from?: number, to?: number, isAdditive?: boolean): AnimationGroup;
  110886. /**
  110887. * Pause all animations
  110888. * @returns the animation group
  110889. */
  110890. pause(): AnimationGroup;
  110891. /**
  110892. * Play all animations to initial state
  110893. * This function will start() the animations if they were not started or will restart() them if they were paused
  110894. * @param loop defines if animations must loop
  110895. * @returns the animation group
  110896. */
  110897. play(loop?: boolean): AnimationGroup;
  110898. /**
  110899. * Reset all animations to initial state
  110900. * @returns the animation group
  110901. */
  110902. reset(): AnimationGroup;
  110903. /**
  110904. * Restart animations from key 0
  110905. * @returns the animation group
  110906. */
  110907. restart(): AnimationGroup;
  110908. /**
  110909. * Stop all animations
  110910. * @returns the animation group
  110911. */
  110912. stop(): AnimationGroup;
  110913. /**
  110914. * Set animation weight for all animatables
  110915. * @param weight defines the weight to use
  110916. * @return the animationGroup
  110917. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  110918. */
  110919. setWeightForAllAnimatables(weight: number): AnimationGroup;
  110920. /**
  110921. * Synchronize and normalize all animatables with a source animatable
  110922. * @param root defines the root animatable to synchronize with
  110923. * @return the animationGroup
  110924. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  110925. */
  110926. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  110927. /**
  110928. * Goes to a specific frame in this animation group
  110929. * @param frame the frame number to go to
  110930. * @return the animationGroup
  110931. */
  110932. goToFrame(frame: number): AnimationGroup;
  110933. /**
  110934. * Dispose all associated resources
  110935. */
  110936. dispose(): void;
  110937. private _checkAnimationGroupEnded;
  110938. /**
  110939. * Clone the current animation group and returns a copy
  110940. * @param newName defines the name of the new group
  110941. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  110942. * @returns the new aniamtion group
  110943. */
  110944. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  110945. /**
  110946. * Serializes the animationGroup to an object
  110947. * @returns Serialized object
  110948. */
  110949. serialize(): any;
  110950. /**
  110951. * Returns a new AnimationGroup object parsed from the source provided.
  110952. * @param parsedAnimationGroup defines the source
  110953. * @param scene defines the scene that will receive the animationGroup
  110954. * @returns a new AnimationGroup
  110955. */
  110956. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  110957. /**
  110958. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  110959. * @param sourceAnimationGroup defines the AnimationGroup containing animations to convert
  110960. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  110961. * @param range defines the name of the AnimationRange belonging to the animations in the group to convert
  110962. * @param cloneOriginal defines whether or not to clone the group and convert the clone or convert the original group (default is false)
  110963. * @param clonedName defines the name of the resulting cloned AnimationGroup if cloneOriginal is true
  110964. * @returns a new AnimationGroup if cloneOriginal is true or the original AnimationGroup if cloneOriginal is false
  110965. */
  110966. static MakeAnimationAdditive(sourceAnimationGroup: AnimationGroup, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): AnimationGroup;
  110967. /**
  110968. * Returns the string "AnimationGroup"
  110969. * @returns "AnimationGroup"
  110970. */
  110971. getClassName(): string;
  110972. /**
  110973. * Creates a detailled string about the object
  110974. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  110975. * @returns a string representing the object
  110976. */
  110977. toString(fullDetails?: boolean): string;
  110978. }
  110979. }
  110980. declare module BABYLON {
  110981. /**
  110982. * Define an interface for all classes that will hold resources
  110983. */
  110984. export interface IDisposable {
  110985. /**
  110986. * Releases all held resources
  110987. */
  110988. dispose(): void;
  110989. }
  110990. /** Interface defining initialization parameters for Scene class */
  110991. export interface SceneOptions {
  110992. /**
  110993. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  110994. * It will improve performance when the number of geometries becomes important.
  110995. */
  110996. useGeometryUniqueIdsMap?: boolean;
  110997. /**
  110998. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  110999. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  111000. */
  111001. useMaterialMeshMap?: boolean;
  111002. /**
  111003. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  111004. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  111005. */
  111006. useClonedMeshMap?: boolean;
  111007. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  111008. virtual?: boolean;
  111009. }
  111010. /**
  111011. * Represents a scene to be rendered by the engine.
  111012. * @see http://doc.babylonjs.com/features/scene
  111013. */
  111014. export class Scene extends AbstractScene implements IAnimatable {
  111015. /** The fog is deactivated */
  111016. static readonly FOGMODE_NONE: number;
  111017. /** The fog density is following an exponential function */
  111018. static readonly FOGMODE_EXP: number;
  111019. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  111020. static readonly FOGMODE_EXP2: number;
  111021. /** The fog density is following a linear function. */
  111022. static readonly FOGMODE_LINEAR: number;
  111023. /**
  111024. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  111025. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  111026. */
  111027. static MinDeltaTime: number;
  111028. /**
  111029. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  111030. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  111031. */
  111032. static MaxDeltaTime: number;
  111033. /**
  111034. * Factory used to create the default material.
  111035. * @param name The name of the material to create
  111036. * @param scene The scene to create the material for
  111037. * @returns The default material
  111038. */
  111039. static DefaultMaterialFactory(scene: Scene): Material;
  111040. /**
  111041. * Factory used to create the a collision coordinator.
  111042. * @returns The collision coordinator
  111043. */
  111044. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  111045. /** @hidden */
  111046. _inputManager: InputManager;
  111047. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  111048. cameraToUseForPointers: Nullable<Camera>;
  111049. /** @hidden */
  111050. readonly _isScene: boolean;
  111051. /** @hidden */
  111052. _blockEntityCollection: boolean;
  111053. /**
  111054. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  111055. */
  111056. autoClear: boolean;
  111057. /**
  111058. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  111059. */
  111060. autoClearDepthAndStencil: boolean;
  111061. /**
  111062. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  111063. */
  111064. clearColor: Color4;
  111065. /**
  111066. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  111067. */
  111068. ambientColor: Color3;
  111069. /**
  111070. * This is use to store the default BRDF lookup for PBR materials in your scene.
  111071. * It should only be one of the following (if not the default embedded one):
  111072. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  111073. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  111074. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  111075. * The material properties need to be setup according to the type of texture in use.
  111076. */
  111077. environmentBRDFTexture: BaseTexture;
  111078. /** @hidden */
  111079. protected _environmentTexture: Nullable<BaseTexture>;
  111080. /**
  111081. * Texture used in all pbr material as the reflection texture.
  111082. * As in the majority of the scene they are the same (exception for multi room and so on),
  111083. * this is easier to reference from here than from all the materials.
  111084. */
  111085. get environmentTexture(): Nullable<BaseTexture>;
  111086. /**
  111087. * Texture used in all pbr material as the reflection texture.
  111088. * As in the majority of the scene they are the same (exception for multi room and so on),
  111089. * this is easier to set here than in all the materials.
  111090. */
  111091. set environmentTexture(value: Nullable<BaseTexture>);
  111092. /** @hidden */
  111093. protected _environmentIntensity: number;
  111094. /**
  111095. * Intensity of the environment in all pbr material.
  111096. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  111097. * As in the majority of the scene they are the same (exception for multi room and so on),
  111098. * this is easier to reference from here than from all the materials.
  111099. */
  111100. get environmentIntensity(): number;
  111101. /**
  111102. * Intensity of the environment in all pbr material.
  111103. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  111104. * As in the majority of the scene they are the same (exception for multi room and so on),
  111105. * this is easier to set here than in all the materials.
  111106. */
  111107. set environmentIntensity(value: number);
  111108. /** @hidden */
  111109. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  111110. /**
  111111. * Default image processing configuration used either in the rendering
  111112. * Forward main pass or through the imageProcessingPostProcess if present.
  111113. * As in the majority of the scene they are the same (exception for multi camera),
  111114. * this is easier to reference from here than from all the materials and post process.
  111115. *
  111116. * No setter as we it is a shared configuration, you can set the values instead.
  111117. */
  111118. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  111119. private _forceWireframe;
  111120. /**
  111121. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  111122. */
  111123. set forceWireframe(value: boolean);
  111124. get forceWireframe(): boolean;
  111125. private _skipFrustumClipping;
  111126. /**
  111127. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  111128. */
  111129. set skipFrustumClipping(value: boolean);
  111130. get skipFrustumClipping(): boolean;
  111131. private _forcePointsCloud;
  111132. /**
  111133. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  111134. */
  111135. set forcePointsCloud(value: boolean);
  111136. get forcePointsCloud(): boolean;
  111137. /**
  111138. * Gets or sets the active clipplane 1
  111139. */
  111140. clipPlane: Nullable<Plane>;
  111141. /**
  111142. * Gets or sets the active clipplane 2
  111143. */
  111144. clipPlane2: Nullable<Plane>;
  111145. /**
  111146. * Gets or sets the active clipplane 3
  111147. */
  111148. clipPlane3: Nullable<Plane>;
  111149. /**
  111150. * Gets or sets the active clipplane 4
  111151. */
  111152. clipPlane4: Nullable<Plane>;
  111153. /**
  111154. * Gets or sets the active clipplane 5
  111155. */
  111156. clipPlane5: Nullable<Plane>;
  111157. /**
  111158. * Gets or sets the active clipplane 6
  111159. */
  111160. clipPlane6: Nullable<Plane>;
  111161. /**
  111162. * Gets or sets a boolean indicating if animations are enabled
  111163. */
  111164. animationsEnabled: boolean;
  111165. private _animationPropertiesOverride;
  111166. /**
  111167. * Gets or sets the animation properties override
  111168. */
  111169. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  111170. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  111171. /**
  111172. * Gets or sets a boolean indicating if a constant deltatime has to be used
  111173. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  111174. */
  111175. useConstantAnimationDeltaTime: boolean;
  111176. /**
  111177. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  111178. * Please note that it requires to run a ray cast through the scene on every frame
  111179. */
  111180. constantlyUpdateMeshUnderPointer: boolean;
  111181. /**
  111182. * Defines the HTML cursor to use when hovering over interactive elements
  111183. */
  111184. hoverCursor: string;
  111185. /**
  111186. * Defines the HTML default cursor to use (empty by default)
  111187. */
  111188. defaultCursor: string;
  111189. /**
  111190. * Defines whether cursors are handled by the scene.
  111191. */
  111192. doNotHandleCursors: boolean;
  111193. /**
  111194. * This is used to call preventDefault() on pointer down
  111195. * in order to block unwanted artifacts like system double clicks
  111196. */
  111197. preventDefaultOnPointerDown: boolean;
  111198. /**
  111199. * This is used to call preventDefault() on pointer up
  111200. * in order to block unwanted artifacts like system double clicks
  111201. */
  111202. preventDefaultOnPointerUp: boolean;
  111203. /**
  111204. * Gets or sets user defined metadata
  111205. */
  111206. metadata: any;
  111207. /**
  111208. * For internal use only. Please do not use.
  111209. */
  111210. reservedDataStore: any;
  111211. /**
  111212. * Gets the name of the plugin used to load this scene (null by default)
  111213. */
  111214. loadingPluginName: string;
  111215. /**
  111216. * Use this array to add regular expressions used to disable offline support for specific urls
  111217. */
  111218. disableOfflineSupportExceptionRules: RegExp[];
  111219. /**
  111220. * An event triggered when the scene is disposed.
  111221. */
  111222. onDisposeObservable: Observable<Scene>;
  111223. private _onDisposeObserver;
  111224. /** Sets a function to be executed when this scene is disposed. */
  111225. set onDispose(callback: () => void);
  111226. /**
  111227. * An event triggered before rendering the scene (right after animations and physics)
  111228. */
  111229. onBeforeRenderObservable: Observable<Scene>;
  111230. private _onBeforeRenderObserver;
  111231. /** Sets a function to be executed before rendering this scene */
  111232. set beforeRender(callback: Nullable<() => void>);
  111233. /**
  111234. * An event triggered after rendering the scene
  111235. */
  111236. onAfterRenderObservable: Observable<Scene>;
  111237. /**
  111238. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  111239. */
  111240. onAfterRenderCameraObservable: Observable<Camera>;
  111241. private _onAfterRenderObserver;
  111242. /** Sets a function to be executed after rendering this scene */
  111243. set afterRender(callback: Nullable<() => void>);
  111244. /**
  111245. * An event triggered before animating the scene
  111246. */
  111247. onBeforeAnimationsObservable: Observable<Scene>;
  111248. /**
  111249. * An event triggered after animations processing
  111250. */
  111251. onAfterAnimationsObservable: Observable<Scene>;
  111252. /**
  111253. * An event triggered before draw calls are ready to be sent
  111254. */
  111255. onBeforeDrawPhaseObservable: Observable<Scene>;
  111256. /**
  111257. * An event triggered after draw calls have been sent
  111258. */
  111259. onAfterDrawPhaseObservable: Observable<Scene>;
  111260. /**
  111261. * An event triggered when the scene is ready
  111262. */
  111263. onReadyObservable: Observable<Scene>;
  111264. /**
  111265. * An event triggered before rendering a camera
  111266. */
  111267. onBeforeCameraRenderObservable: Observable<Camera>;
  111268. private _onBeforeCameraRenderObserver;
  111269. /** Sets a function to be executed before rendering a camera*/
  111270. set beforeCameraRender(callback: () => void);
  111271. /**
  111272. * An event triggered after rendering a camera
  111273. */
  111274. onAfterCameraRenderObservable: Observable<Camera>;
  111275. private _onAfterCameraRenderObserver;
  111276. /** Sets a function to be executed after rendering a camera*/
  111277. set afterCameraRender(callback: () => void);
  111278. /**
  111279. * An event triggered when active meshes evaluation is about to start
  111280. */
  111281. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  111282. /**
  111283. * An event triggered when active meshes evaluation is done
  111284. */
  111285. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  111286. /**
  111287. * An event triggered when particles rendering is about to start
  111288. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  111289. */
  111290. onBeforeParticlesRenderingObservable: Observable<Scene>;
  111291. /**
  111292. * An event triggered when particles rendering is done
  111293. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  111294. */
  111295. onAfterParticlesRenderingObservable: Observable<Scene>;
  111296. /**
  111297. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  111298. */
  111299. onDataLoadedObservable: Observable<Scene>;
  111300. /**
  111301. * An event triggered when a camera is created
  111302. */
  111303. onNewCameraAddedObservable: Observable<Camera>;
  111304. /**
  111305. * An event triggered when a camera is removed
  111306. */
  111307. onCameraRemovedObservable: Observable<Camera>;
  111308. /**
  111309. * An event triggered when a light is created
  111310. */
  111311. onNewLightAddedObservable: Observable<Light>;
  111312. /**
  111313. * An event triggered when a light is removed
  111314. */
  111315. onLightRemovedObservable: Observable<Light>;
  111316. /**
  111317. * An event triggered when a geometry is created
  111318. */
  111319. onNewGeometryAddedObservable: Observable<Geometry>;
  111320. /**
  111321. * An event triggered when a geometry is removed
  111322. */
  111323. onGeometryRemovedObservable: Observable<Geometry>;
  111324. /**
  111325. * An event triggered when a transform node is created
  111326. */
  111327. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  111328. /**
  111329. * An event triggered when a transform node is removed
  111330. */
  111331. onTransformNodeRemovedObservable: Observable<TransformNode>;
  111332. /**
  111333. * An event triggered when a mesh is created
  111334. */
  111335. onNewMeshAddedObservable: Observable<AbstractMesh>;
  111336. /**
  111337. * An event triggered when a mesh is removed
  111338. */
  111339. onMeshRemovedObservable: Observable<AbstractMesh>;
  111340. /**
  111341. * An event triggered when a skeleton is created
  111342. */
  111343. onNewSkeletonAddedObservable: Observable<Skeleton>;
  111344. /**
  111345. * An event triggered when a skeleton is removed
  111346. */
  111347. onSkeletonRemovedObservable: Observable<Skeleton>;
  111348. /**
  111349. * An event triggered when a material is created
  111350. */
  111351. onNewMaterialAddedObservable: Observable<Material>;
  111352. /**
  111353. * An event triggered when a material is removed
  111354. */
  111355. onMaterialRemovedObservable: Observable<Material>;
  111356. /**
  111357. * An event triggered when a texture is created
  111358. */
  111359. onNewTextureAddedObservable: Observable<BaseTexture>;
  111360. /**
  111361. * An event triggered when a texture is removed
  111362. */
  111363. onTextureRemovedObservable: Observable<BaseTexture>;
  111364. /**
  111365. * An event triggered when render targets are about to be rendered
  111366. * Can happen multiple times per frame.
  111367. */
  111368. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  111369. /**
  111370. * An event triggered when render targets were rendered.
  111371. * Can happen multiple times per frame.
  111372. */
  111373. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  111374. /**
  111375. * An event triggered before calculating deterministic simulation step
  111376. */
  111377. onBeforeStepObservable: Observable<Scene>;
  111378. /**
  111379. * An event triggered after calculating deterministic simulation step
  111380. */
  111381. onAfterStepObservable: Observable<Scene>;
  111382. /**
  111383. * An event triggered when the activeCamera property is updated
  111384. */
  111385. onActiveCameraChanged: Observable<Scene>;
  111386. /**
  111387. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  111388. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  111389. * 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)
  111390. */
  111391. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  111392. /**
  111393. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  111394. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  111395. * 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)
  111396. */
  111397. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  111398. /**
  111399. * This Observable will when a mesh has been imported into the scene.
  111400. */
  111401. onMeshImportedObservable: Observable<AbstractMesh>;
  111402. /**
  111403. * This Observable will when an animation file has been imported into the scene.
  111404. */
  111405. onAnimationFileImportedObservable: Observable<Scene>;
  111406. /**
  111407. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  111408. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  111409. */
  111410. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  111411. /** @hidden */
  111412. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  111413. /**
  111414. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  111415. */
  111416. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  111417. /**
  111418. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  111419. */
  111420. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  111421. /**
  111422. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  111423. */
  111424. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  111425. /** Callback called when a pointer move is detected */
  111426. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  111427. /** Callback called when a pointer down is detected */
  111428. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  111429. /** Callback called when a pointer up is detected */
  111430. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  111431. /** Callback called when a pointer pick is detected */
  111432. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  111433. /**
  111434. * 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).
  111435. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  111436. */
  111437. onPrePointerObservable: Observable<PointerInfoPre>;
  111438. /**
  111439. * Observable event triggered each time an input event is received from the rendering canvas
  111440. */
  111441. onPointerObservable: Observable<PointerInfo>;
  111442. /**
  111443. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  111444. */
  111445. get unTranslatedPointer(): Vector2;
  111446. /**
  111447. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  111448. */
  111449. static get DragMovementThreshold(): number;
  111450. static set DragMovementThreshold(value: number);
  111451. /**
  111452. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  111453. */
  111454. static get LongPressDelay(): number;
  111455. static set LongPressDelay(value: number);
  111456. /**
  111457. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  111458. */
  111459. static get DoubleClickDelay(): number;
  111460. static set DoubleClickDelay(value: number);
  111461. /** If you need to check double click without raising a single click at first click, enable this flag */
  111462. static get ExclusiveDoubleClickMode(): boolean;
  111463. static set ExclusiveDoubleClickMode(value: boolean);
  111464. /** @hidden */
  111465. _mirroredCameraPosition: Nullable<Vector3>;
  111466. /**
  111467. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  111468. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  111469. */
  111470. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  111471. /**
  111472. * Observable event triggered each time an keyboard event is received from the hosting window
  111473. */
  111474. onKeyboardObservable: Observable<KeyboardInfo>;
  111475. private _useRightHandedSystem;
  111476. /**
  111477. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  111478. */
  111479. set useRightHandedSystem(value: boolean);
  111480. get useRightHandedSystem(): boolean;
  111481. private _timeAccumulator;
  111482. private _currentStepId;
  111483. private _currentInternalStep;
  111484. /**
  111485. * Sets the step Id used by deterministic lock step
  111486. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  111487. * @param newStepId defines the step Id
  111488. */
  111489. setStepId(newStepId: number): void;
  111490. /**
  111491. * Gets the step Id used by deterministic lock step
  111492. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  111493. * @returns the step Id
  111494. */
  111495. getStepId(): number;
  111496. /**
  111497. * Gets the internal step used by deterministic lock step
  111498. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  111499. * @returns the internal step
  111500. */
  111501. getInternalStep(): number;
  111502. private _fogEnabled;
  111503. /**
  111504. * Gets or sets a boolean indicating if fog is enabled on this scene
  111505. * @see http://doc.babylonjs.com/babylon101/environment#fog
  111506. * (Default is true)
  111507. */
  111508. set fogEnabled(value: boolean);
  111509. get fogEnabled(): boolean;
  111510. private _fogMode;
  111511. /**
  111512. * Gets or sets the fog mode to use
  111513. * @see http://doc.babylonjs.com/babylon101/environment#fog
  111514. * | mode | value |
  111515. * | --- | --- |
  111516. * | FOGMODE_NONE | 0 |
  111517. * | FOGMODE_EXP | 1 |
  111518. * | FOGMODE_EXP2 | 2 |
  111519. * | FOGMODE_LINEAR | 3 |
  111520. */
  111521. set fogMode(value: number);
  111522. get fogMode(): number;
  111523. /**
  111524. * Gets or sets the fog color to use
  111525. * @see http://doc.babylonjs.com/babylon101/environment#fog
  111526. * (Default is Color3(0.2, 0.2, 0.3))
  111527. */
  111528. fogColor: Color3;
  111529. /**
  111530. * Gets or sets the fog density to use
  111531. * @see http://doc.babylonjs.com/babylon101/environment#fog
  111532. * (Default is 0.1)
  111533. */
  111534. fogDensity: number;
  111535. /**
  111536. * Gets or sets the fog start distance to use
  111537. * @see http://doc.babylonjs.com/babylon101/environment#fog
  111538. * (Default is 0)
  111539. */
  111540. fogStart: number;
  111541. /**
  111542. * Gets or sets the fog end distance to use
  111543. * @see http://doc.babylonjs.com/babylon101/environment#fog
  111544. * (Default is 1000)
  111545. */
  111546. fogEnd: number;
  111547. private _shadowsEnabled;
  111548. /**
  111549. * Gets or sets a boolean indicating if shadows are enabled on this scene
  111550. */
  111551. set shadowsEnabled(value: boolean);
  111552. get shadowsEnabled(): boolean;
  111553. private _lightsEnabled;
  111554. /**
  111555. * Gets or sets a boolean indicating if lights are enabled on this scene
  111556. */
  111557. set lightsEnabled(value: boolean);
  111558. get lightsEnabled(): boolean;
  111559. /** All of the active cameras added to this scene. */
  111560. activeCameras: Camera[];
  111561. /** @hidden */
  111562. _activeCamera: Nullable<Camera>;
  111563. /** Gets or sets the current active camera */
  111564. get activeCamera(): Nullable<Camera>;
  111565. set activeCamera(value: Nullable<Camera>);
  111566. private _defaultMaterial;
  111567. /** The default material used on meshes when no material is affected */
  111568. get defaultMaterial(): Material;
  111569. /** The default material used on meshes when no material is affected */
  111570. set defaultMaterial(value: Material);
  111571. private _texturesEnabled;
  111572. /**
  111573. * Gets or sets a boolean indicating if textures are enabled on this scene
  111574. */
  111575. set texturesEnabled(value: boolean);
  111576. get texturesEnabled(): boolean;
  111577. /**
  111578. * Gets or sets a boolean indicating if physic engines are enabled on this scene
  111579. */
  111580. physicsEnabled: boolean;
  111581. /**
  111582. * Gets or sets a boolean indicating if particles are enabled on this scene
  111583. */
  111584. particlesEnabled: boolean;
  111585. /**
  111586. * Gets or sets a boolean indicating if sprites are enabled on this scene
  111587. */
  111588. spritesEnabled: boolean;
  111589. private _skeletonsEnabled;
  111590. /**
  111591. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  111592. */
  111593. set skeletonsEnabled(value: boolean);
  111594. get skeletonsEnabled(): boolean;
  111595. /**
  111596. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  111597. */
  111598. lensFlaresEnabled: boolean;
  111599. /**
  111600. * Gets or sets a boolean indicating if collisions are enabled on this scene
  111601. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  111602. */
  111603. collisionsEnabled: boolean;
  111604. private _collisionCoordinator;
  111605. /** @hidden */
  111606. get collisionCoordinator(): ICollisionCoordinator;
  111607. /**
  111608. * Defines the gravity applied to this scene (used only for collisions)
  111609. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  111610. */
  111611. gravity: Vector3;
  111612. /**
  111613. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  111614. */
  111615. postProcessesEnabled: boolean;
  111616. /**
  111617. * The list of postprocesses added to the scene
  111618. */
  111619. postProcesses: PostProcess[];
  111620. /**
  111621. * Gets the current postprocess manager
  111622. */
  111623. postProcessManager: PostProcessManager;
  111624. /**
  111625. * Gets or sets a boolean indicating if render targets are enabled on this scene
  111626. */
  111627. renderTargetsEnabled: boolean;
  111628. /**
  111629. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  111630. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  111631. */
  111632. dumpNextRenderTargets: boolean;
  111633. /**
  111634. * The list of user defined render targets added to the scene
  111635. */
  111636. customRenderTargets: RenderTargetTexture[];
  111637. /**
  111638. * Defines if texture loading must be delayed
  111639. * If true, textures will only be loaded when they need to be rendered
  111640. */
  111641. useDelayedTextureLoading: boolean;
  111642. /**
  111643. * Gets the list of meshes imported to the scene through SceneLoader
  111644. */
  111645. importedMeshesFiles: String[];
  111646. /**
  111647. * Gets or sets a boolean indicating if probes are enabled on this scene
  111648. */
  111649. probesEnabled: boolean;
  111650. /**
  111651. * Gets or sets the current offline provider to use to store scene data
  111652. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  111653. */
  111654. offlineProvider: IOfflineProvider;
  111655. /**
  111656. * Gets or sets the action manager associated with the scene
  111657. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  111658. */
  111659. actionManager: AbstractActionManager;
  111660. private _meshesForIntersections;
  111661. /**
  111662. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  111663. */
  111664. proceduralTexturesEnabled: boolean;
  111665. private _engine;
  111666. private _totalVertices;
  111667. /** @hidden */
  111668. _activeIndices: PerfCounter;
  111669. /** @hidden */
  111670. _activeParticles: PerfCounter;
  111671. /** @hidden */
  111672. _activeBones: PerfCounter;
  111673. private _animationRatio;
  111674. /** @hidden */
  111675. _animationTimeLast: number;
  111676. /** @hidden */
  111677. _animationTime: number;
  111678. /**
  111679. * Gets or sets a general scale for animation speed
  111680. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  111681. */
  111682. animationTimeScale: number;
  111683. /** @hidden */
  111684. _cachedMaterial: Nullable<Material>;
  111685. /** @hidden */
  111686. _cachedEffect: Nullable<Effect>;
  111687. /** @hidden */
  111688. _cachedVisibility: Nullable<number>;
  111689. private _renderId;
  111690. private _frameId;
  111691. private _executeWhenReadyTimeoutId;
  111692. private _intermediateRendering;
  111693. private _viewUpdateFlag;
  111694. private _projectionUpdateFlag;
  111695. /** @hidden */
  111696. _toBeDisposed: Nullable<IDisposable>[];
  111697. private _activeRequests;
  111698. /** @hidden */
  111699. _pendingData: any[];
  111700. private _isDisposed;
  111701. /**
  111702. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  111703. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  111704. */
  111705. dispatchAllSubMeshesOfActiveMeshes: boolean;
  111706. private _activeMeshes;
  111707. private _processedMaterials;
  111708. private _renderTargets;
  111709. /** @hidden */
  111710. _activeParticleSystems: SmartArray<IParticleSystem>;
  111711. private _activeSkeletons;
  111712. private _softwareSkinnedMeshes;
  111713. private _renderingManager;
  111714. /** @hidden */
  111715. _activeAnimatables: Animatable[];
  111716. private _transformMatrix;
  111717. private _sceneUbo;
  111718. /** @hidden */
  111719. _viewMatrix: Matrix;
  111720. private _projectionMatrix;
  111721. /** @hidden */
  111722. _forcedViewPosition: Nullable<Vector3>;
  111723. /** @hidden */
  111724. _frustumPlanes: Plane[];
  111725. /**
  111726. * Gets the list of frustum planes (built from the active camera)
  111727. */
  111728. get frustumPlanes(): Plane[];
  111729. /**
  111730. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  111731. * This is useful if there are more lights that the maximum simulteanous authorized
  111732. */
  111733. requireLightSorting: boolean;
  111734. /** @hidden */
  111735. readonly useMaterialMeshMap: boolean;
  111736. /** @hidden */
  111737. readonly useClonedMeshMap: boolean;
  111738. private _externalData;
  111739. private _uid;
  111740. /**
  111741. * @hidden
  111742. * Backing store of defined scene components.
  111743. */
  111744. _components: ISceneComponent[];
  111745. /**
  111746. * @hidden
  111747. * Backing store of defined scene components.
  111748. */
  111749. _serializableComponents: ISceneSerializableComponent[];
  111750. /**
  111751. * List of components to register on the next registration step.
  111752. */
  111753. private _transientComponents;
  111754. /**
  111755. * Registers the transient components if needed.
  111756. */
  111757. private _registerTransientComponents;
  111758. /**
  111759. * @hidden
  111760. * Add a component to the scene.
  111761. * Note that the ccomponent could be registered on th next frame if this is called after
  111762. * the register component stage.
  111763. * @param component Defines the component to add to the scene
  111764. */
  111765. _addComponent(component: ISceneComponent): void;
  111766. /**
  111767. * @hidden
  111768. * Gets a component from the scene.
  111769. * @param name defines the name of the component to retrieve
  111770. * @returns the component or null if not present
  111771. */
  111772. _getComponent(name: string): Nullable<ISceneComponent>;
  111773. /**
  111774. * @hidden
  111775. * Defines the actions happening before camera updates.
  111776. */
  111777. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  111778. /**
  111779. * @hidden
  111780. * Defines the actions happening before clear the canvas.
  111781. */
  111782. _beforeClearStage: Stage<SimpleStageAction>;
  111783. /**
  111784. * @hidden
  111785. * Defines the actions when collecting render targets for the frame.
  111786. */
  111787. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  111788. /**
  111789. * @hidden
  111790. * Defines the actions happening for one camera in the frame.
  111791. */
  111792. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  111793. /**
  111794. * @hidden
  111795. * Defines the actions happening during the per mesh ready checks.
  111796. */
  111797. _isReadyForMeshStage: Stage<MeshStageAction>;
  111798. /**
  111799. * @hidden
  111800. * Defines the actions happening before evaluate active mesh checks.
  111801. */
  111802. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  111803. /**
  111804. * @hidden
  111805. * Defines the actions happening during the evaluate sub mesh checks.
  111806. */
  111807. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  111808. /**
  111809. * @hidden
  111810. * Defines the actions happening during the active mesh stage.
  111811. */
  111812. _activeMeshStage: Stage<ActiveMeshStageAction>;
  111813. /**
  111814. * @hidden
  111815. * Defines the actions happening during the per camera render target step.
  111816. */
  111817. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  111818. /**
  111819. * @hidden
  111820. * Defines the actions happening just before the active camera is drawing.
  111821. */
  111822. _beforeCameraDrawStage: Stage<CameraStageAction>;
  111823. /**
  111824. * @hidden
  111825. * Defines the actions happening just before a render target is drawing.
  111826. */
  111827. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  111828. /**
  111829. * @hidden
  111830. * Defines the actions happening just before a rendering group is drawing.
  111831. */
  111832. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  111833. /**
  111834. * @hidden
  111835. * Defines the actions happening just before a mesh is drawing.
  111836. */
  111837. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  111838. /**
  111839. * @hidden
  111840. * Defines the actions happening just after a mesh has been drawn.
  111841. */
  111842. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  111843. /**
  111844. * @hidden
  111845. * Defines the actions happening just after a rendering group has been drawn.
  111846. */
  111847. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  111848. /**
  111849. * @hidden
  111850. * Defines the actions happening just after the active camera has been drawn.
  111851. */
  111852. _afterCameraDrawStage: Stage<CameraStageAction>;
  111853. /**
  111854. * @hidden
  111855. * Defines the actions happening just after a render target has been drawn.
  111856. */
  111857. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  111858. /**
  111859. * @hidden
  111860. * Defines the actions happening just after rendering all cameras and computing intersections.
  111861. */
  111862. _afterRenderStage: Stage<SimpleStageAction>;
  111863. /**
  111864. * @hidden
  111865. * Defines the actions happening when a pointer move event happens.
  111866. */
  111867. _pointerMoveStage: Stage<PointerMoveStageAction>;
  111868. /**
  111869. * @hidden
  111870. * Defines the actions happening when a pointer down event happens.
  111871. */
  111872. _pointerDownStage: Stage<PointerUpDownStageAction>;
  111873. /**
  111874. * @hidden
  111875. * Defines the actions happening when a pointer up event happens.
  111876. */
  111877. _pointerUpStage: Stage<PointerUpDownStageAction>;
  111878. /**
  111879. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  111880. */
  111881. private geometriesByUniqueId;
  111882. /**
  111883. * Creates a new Scene
  111884. * @param engine defines the engine to use to render this scene
  111885. * @param options defines the scene options
  111886. */
  111887. constructor(engine: Engine, options?: SceneOptions);
  111888. /**
  111889. * Gets a string idenfifying the name of the class
  111890. * @returns "Scene" string
  111891. */
  111892. getClassName(): string;
  111893. private _defaultMeshCandidates;
  111894. /**
  111895. * @hidden
  111896. */
  111897. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  111898. private _defaultSubMeshCandidates;
  111899. /**
  111900. * @hidden
  111901. */
  111902. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  111903. /**
  111904. * Sets the default candidate providers for the scene.
  111905. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  111906. * and getCollidingSubMeshCandidates to their default function
  111907. */
  111908. setDefaultCandidateProviders(): void;
  111909. /**
  111910. * Gets the mesh that is currently under the pointer
  111911. */
  111912. get meshUnderPointer(): Nullable<AbstractMesh>;
  111913. /**
  111914. * Gets or sets the current on-screen X position of the pointer
  111915. */
  111916. get pointerX(): number;
  111917. set pointerX(value: number);
  111918. /**
  111919. * Gets or sets the current on-screen Y position of the pointer
  111920. */
  111921. get pointerY(): number;
  111922. set pointerY(value: number);
  111923. /**
  111924. * Gets the cached material (ie. the latest rendered one)
  111925. * @returns the cached material
  111926. */
  111927. getCachedMaterial(): Nullable<Material>;
  111928. /**
  111929. * Gets the cached effect (ie. the latest rendered one)
  111930. * @returns the cached effect
  111931. */
  111932. getCachedEffect(): Nullable<Effect>;
  111933. /**
  111934. * Gets the cached visibility state (ie. the latest rendered one)
  111935. * @returns the cached visibility state
  111936. */
  111937. getCachedVisibility(): Nullable<number>;
  111938. /**
  111939. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  111940. * @param material defines the current material
  111941. * @param effect defines the current effect
  111942. * @param visibility defines the current visibility state
  111943. * @returns true if one parameter is not cached
  111944. */
  111945. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  111946. /**
  111947. * Gets the engine associated with the scene
  111948. * @returns an Engine
  111949. */
  111950. getEngine(): Engine;
  111951. /**
  111952. * Gets the total number of vertices rendered per frame
  111953. * @returns the total number of vertices rendered per frame
  111954. */
  111955. getTotalVertices(): number;
  111956. /**
  111957. * Gets the performance counter for total vertices
  111958. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  111959. */
  111960. get totalVerticesPerfCounter(): PerfCounter;
  111961. /**
  111962. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  111963. * @returns the total number of active indices rendered per frame
  111964. */
  111965. getActiveIndices(): number;
  111966. /**
  111967. * Gets the performance counter for active indices
  111968. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  111969. */
  111970. get totalActiveIndicesPerfCounter(): PerfCounter;
  111971. /**
  111972. * Gets the total number of active particles rendered per frame
  111973. * @returns the total number of active particles rendered per frame
  111974. */
  111975. getActiveParticles(): number;
  111976. /**
  111977. * Gets the performance counter for active particles
  111978. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  111979. */
  111980. get activeParticlesPerfCounter(): PerfCounter;
  111981. /**
  111982. * Gets the total number of active bones rendered per frame
  111983. * @returns the total number of active bones rendered per frame
  111984. */
  111985. getActiveBones(): number;
  111986. /**
  111987. * Gets the performance counter for active bones
  111988. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  111989. */
  111990. get activeBonesPerfCounter(): PerfCounter;
  111991. /**
  111992. * Gets the array of active meshes
  111993. * @returns an array of AbstractMesh
  111994. */
  111995. getActiveMeshes(): SmartArray<AbstractMesh>;
  111996. /**
  111997. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  111998. * @returns a number
  111999. */
  112000. getAnimationRatio(): number;
  112001. /**
  112002. * Gets an unique Id for the current render phase
  112003. * @returns a number
  112004. */
  112005. getRenderId(): number;
  112006. /**
  112007. * Gets an unique Id for the current frame
  112008. * @returns a number
  112009. */
  112010. getFrameId(): number;
  112011. /** Call this function if you want to manually increment the render Id*/
  112012. incrementRenderId(): void;
  112013. private _createUbo;
  112014. /**
  112015. * Use this method to simulate a pointer move on a mesh
  112016. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  112017. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  112018. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  112019. * @returns the current scene
  112020. */
  112021. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  112022. /**
  112023. * Use this method to simulate a pointer down on a mesh
  112024. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  112025. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  112026. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  112027. * @returns the current scene
  112028. */
  112029. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  112030. /**
  112031. * Use this method to simulate a pointer up on a mesh
  112032. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  112033. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  112034. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  112035. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  112036. * @returns the current scene
  112037. */
  112038. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  112039. /**
  112040. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  112041. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  112042. * @returns true if the pointer was captured
  112043. */
  112044. isPointerCaptured(pointerId?: number): boolean;
  112045. /**
  112046. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  112047. * @param attachUp defines if you want to attach events to pointerup
  112048. * @param attachDown defines if you want to attach events to pointerdown
  112049. * @param attachMove defines if you want to attach events to pointermove
  112050. */
  112051. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  112052. /** Detaches all event handlers*/
  112053. detachControl(): void;
  112054. /**
  112055. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  112056. * Delay loaded resources are not taking in account
  112057. * @return true if all required resources are ready
  112058. */
  112059. isReady(): boolean;
  112060. /** Resets all cached information relative to material (including effect and visibility) */
  112061. resetCachedMaterial(): void;
  112062. /**
  112063. * Registers a function to be called before every frame render
  112064. * @param func defines the function to register
  112065. */
  112066. registerBeforeRender(func: () => void): void;
  112067. /**
  112068. * Unregisters a function called before every frame render
  112069. * @param func defines the function to unregister
  112070. */
  112071. unregisterBeforeRender(func: () => void): void;
  112072. /**
  112073. * Registers a function to be called after every frame render
  112074. * @param func defines the function to register
  112075. */
  112076. registerAfterRender(func: () => void): void;
  112077. /**
  112078. * Unregisters a function called after every frame render
  112079. * @param func defines the function to unregister
  112080. */
  112081. unregisterAfterRender(func: () => void): void;
  112082. private _executeOnceBeforeRender;
  112083. /**
  112084. * The provided function will run before render once and will be disposed afterwards.
  112085. * A timeout delay can be provided so that the function will be executed in N ms.
  112086. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  112087. * @param func The function to be executed.
  112088. * @param timeout optional delay in ms
  112089. */
  112090. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  112091. /** @hidden */
  112092. _addPendingData(data: any): void;
  112093. /** @hidden */
  112094. _removePendingData(data: any): void;
  112095. /**
  112096. * Returns the number of items waiting to be loaded
  112097. * @returns the number of items waiting to be loaded
  112098. */
  112099. getWaitingItemsCount(): number;
  112100. /**
  112101. * Returns a boolean indicating if the scene is still loading data
  112102. */
  112103. get isLoading(): boolean;
  112104. /**
  112105. * Registers a function to be executed when the scene is ready
  112106. * @param {Function} func - the function to be executed
  112107. */
  112108. executeWhenReady(func: () => void): void;
  112109. /**
  112110. * Returns a promise that resolves when the scene is ready
  112111. * @returns A promise that resolves when the scene is ready
  112112. */
  112113. whenReadyAsync(): Promise<void>;
  112114. /** @hidden */
  112115. _checkIsReady(): void;
  112116. /**
  112117. * Gets all animatable attached to the scene
  112118. */
  112119. get animatables(): Animatable[];
  112120. /**
  112121. * Resets the last animation time frame.
  112122. * Useful to override when animations start running when loading a scene for the first time.
  112123. */
  112124. resetLastAnimationTimeFrame(): void;
  112125. /**
  112126. * Gets the current view matrix
  112127. * @returns a Matrix
  112128. */
  112129. getViewMatrix(): Matrix;
  112130. /**
  112131. * Gets the current projection matrix
  112132. * @returns a Matrix
  112133. */
  112134. getProjectionMatrix(): Matrix;
  112135. /**
  112136. * Gets the current transform matrix
  112137. * @returns a Matrix made of View * Projection
  112138. */
  112139. getTransformMatrix(): Matrix;
  112140. /**
  112141. * Sets the current transform matrix
  112142. * @param viewL defines the View matrix to use
  112143. * @param projectionL defines the Projection matrix to use
  112144. * @param viewR defines the right View matrix to use (if provided)
  112145. * @param projectionR defines the right Projection matrix to use (if provided)
  112146. */
  112147. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  112148. /**
  112149. * Gets the uniform buffer used to store scene data
  112150. * @returns a UniformBuffer
  112151. */
  112152. getSceneUniformBuffer(): UniformBuffer;
  112153. /**
  112154. * Gets an unique (relatively to the current scene) Id
  112155. * @returns an unique number for the scene
  112156. */
  112157. getUniqueId(): number;
  112158. /**
  112159. * Add a mesh to the list of scene's meshes
  112160. * @param newMesh defines the mesh to add
  112161. * @param recursive if all child meshes should also be added to the scene
  112162. */
  112163. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  112164. /**
  112165. * Remove a mesh for the list of scene's meshes
  112166. * @param toRemove defines the mesh to remove
  112167. * @param recursive if all child meshes should also be removed from the scene
  112168. * @returns the index where the mesh was in the mesh list
  112169. */
  112170. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  112171. /**
  112172. * Add a transform node to the list of scene's transform nodes
  112173. * @param newTransformNode defines the transform node to add
  112174. */
  112175. addTransformNode(newTransformNode: TransformNode): void;
  112176. /**
  112177. * Remove a transform node for the list of scene's transform nodes
  112178. * @param toRemove defines the transform node to remove
  112179. * @returns the index where the transform node was in the transform node list
  112180. */
  112181. removeTransformNode(toRemove: TransformNode): number;
  112182. /**
  112183. * Remove a skeleton for the list of scene's skeletons
  112184. * @param toRemove defines the skeleton to remove
  112185. * @returns the index where the skeleton was in the skeleton list
  112186. */
  112187. removeSkeleton(toRemove: Skeleton): number;
  112188. /**
  112189. * Remove a morph target for the list of scene's morph targets
  112190. * @param toRemove defines the morph target to remove
  112191. * @returns the index where the morph target was in the morph target list
  112192. */
  112193. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  112194. /**
  112195. * Remove a light for the list of scene's lights
  112196. * @param toRemove defines the light to remove
  112197. * @returns the index where the light was in the light list
  112198. */
  112199. removeLight(toRemove: Light): number;
  112200. /**
  112201. * Remove a camera for the list of scene's cameras
  112202. * @param toRemove defines the camera to remove
  112203. * @returns the index where the camera was in the camera list
  112204. */
  112205. removeCamera(toRemove: Camera): number;
  112206. /**
  112207. * Remove a particle system for the list of scene's particle systems
  112208. * @param toRemove defines the particle system to remove
  112209. * @returns the index where the particle system was in the particle system list
  112210. */
  112211. removeParticleSystem(toRemove: IParticleSystem): number;
  112212. /**
  112213. * Remove a animation for the list of scene's animations
  112214. * @param toRemove defines the animation to remove
  112215. * @returns the index where the animation was in the animation list
  112216. */
  112217. removeAnimation(toRemove: Animation): number;
  112218. /**
  112219. * Will stop the animation of the given target
  112220. * @param target - the target
  112221. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  112222. * @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)
  112223. */
  112224. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  112225. /**
  112226. * Removes the given animation group from this scene.
  112227. * @param toRemove The animation group to remove
  112228. * @returns The index of the removed animation group
  112229. */
  112230. removeAnimationGroup(toRemove: AnimationGroup): number;
  112231. /**
  112232. * Removes the given multi-material from this scene.
  112233. * @param toRemove The multi-material to remove
  112234. * @returns The index of the removed multi-material
  112235. */
  112236. removeMultiMaterial(toRemove: MultiMaterial): number;
  112237. /**
  112238. * Removes the given material from this scene.
  112239. * @param toRemove The material to remove
  112240. * @returns The index of the removed material
  112241. */
  112242. removeMaterial(toRemove: Material): number;
  112243. /**
  112244. * Removes the given action manager from this scene.
  112245. * @param toRemove The action manager to remove
  112246. * @returns The index of the removed action manager
  112247. */
  112248. removeActionManager(toRemove: AbstractActionManager): number;
  112249. /**
  112250. * Removes the given texture from this scene.
  112251. * @param toRemove The texture to remove
  112252. * @returns The index of the removed texture
  112253. */
  112254. removeTexture(toRemove: BaseTexture): number;
  112255. /**
  112256. * Adds the given light to this scene
  112257. * @param newLight The light to add
  112258. */
  112259. addLight(newLight: Light): void;
  112260. /**
  112261. * Sorts the list list based on light priorities
  112262. */
  112263. sortLightsByPriority(): void;
  112264. /**
  112265. * Adds the given camera to this scene
  112266. * @param newCamera The camera to add
  112267. */
  112268. addCamera(newCamera: Camera): void;
  112269. /**
  112270. * Adds the given skeleton to this scene
  112271. * @param newSkeleton The skeleton to add
  112272. */
  112273. addSkeleton(newSkeleton: Skeleton): void;
  112274. /**
  112275. * Adds the given particle system to this scene
  112276. * @param newParticleSystem The particle system to add
  112277. */
  112278. addParticleSystem(newParticleSystem: IParticleSystem): void;
  112279. /**
  112280. * Adds the given animation to this scene
  112281. * @param newAnimation The animation to add
  112282. */
  112283. addAnimation(newAnimation: Animation): void;
  112284. /**
  112285. * Adds the given animation group to this scene.
  112286. * @param newAnimationGroup The animation group to add
  112287. */
  112288. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  112289. /**
  112290. * Adds the given multi-material to this scene
  112291. * @param newMultiMaterial The multi-material to add
  112292. */
  112293. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  112294. /**
  112295. * Adds the given material to this scene
  112296. * @param newMaterial The material to add
  112297. */
  112298. addMaterial(newMaterial: Material): void;
  112299. /**
  112300. * Adds the given morph target to this scene
  112301. * @param newMorphTargetManager The morph target to add
  112302. */
  112303. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  112304. /**
  112305. * Adds the given geometry to this scene
  112306. * @param newGeometry The geometry to add
  112307. */
  112308. addGeometry(newGeometry: Geometry): void;
  112309. /**
  112310. * Adds the given action manager to this scene
  112311. * @param newActionManager The action manager to add
  112312. */
  112313. addActionManager(newActionManager: AbstractActionManager): void;
  112314. /**
  112315. * Adds the given texture to this scene.
  112316. * @param newTexture The texture to add
  112317. */
  112318. addTexture(newTexture: BaseTexture): void;
  112319. /**
  112320. * Switch active camera
  112321. * @param newCamera defines the new active camera
  112322. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  112323. */
  112324. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  112325. /**
  112326. * sets the active camera of the scene using its ID
  112327. * @param id defines the camera's ID
  112328. * @return the new active camera or null if none found.
  112329. */
  112330. setActiveCameraByID(id: string): Nullable<Camera>;
  112331. /**
  112332. * sets the active camera of the scene using its name
  112333. * @param name defines the camera's name
  112334. * @returns the new active camera or null if none found.
  112335. */
  112336. setActiveCameraByName(name: string): Nullable<Camera>;
  112337. /**
  112338. * get an animation group using its name
  112339. * @param name defines the material's name
  112340. * @return the animation group or null if none found.
  112341. */
  112342. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  112343. /**
  112344. * Get a material using its unique id
  112345. * @param uniqueId defines the material's unique id
  112346. * @return the material or null if none found.
  112347. */
  112348. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  112349. /**
  112350. * get a material using its id
  112351. * @param id defines the material's ID
  112352. * @return the material or null if none found.
  112353. */
  112354. getMaterialByID(id: string): Nullable<Material>;
  112355. /**
  112356. * Gets a the last added material using a given id
  112357. * @param id defines the material's ID
  112358. * @return the last material with the given id or null if none found.
  112359. */
  112360. getLastMaterialByID(id: string): Nullable<Material>;
  112361. /**
  112362. * Gets a material using its name
  112363. * @param name defines the material's name
  112364. * @return the material or null if none found.
  112365. */
  112366. getMaterialByName(name: string): Nullable<Material>;
  112367. /**
  112368. * Get a texture using its unique id
  112369. * @param uniqueId defines the texture's unique id
  112370. * @return the texture or null if none found.
  112371. */
  112372. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  112373. /**
  112374. * Gets a camera using its id
  112375. * @param id defines the id to look for
  112376. * @returns the camera or null if not found
  112377. */
  112378. getCameraByID(id: string): Nullable<Camera>;
  112379. /**
  112380. * Gets a camera using its unique id
  112381. * @param uniqueId defines the unique id to look for
  112382. * @returns the camera or null if not found
  112383. */
  112384. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  112385. /**
  112386. * Gets a camera using its name
  112387. * @param name defines the camera's name
  112388. * @return the camera or null if none found.
  112389. */
  112390. getCameraByName(name: string): Nullable<Camera>;
  112391. /**
  112392. * Gets a bone using its id
  112393. * @param id defines the bone's id
  112394. * @return the bone or null if not found
  112395. */
  112396. getBoneByID(id: string): Nullable<Bone>;
  112397. /**
  112398. * Gets a bone using its id
  112399. * @param name defines the bone's name
  112400. * @return the bone or null if not found
  112401. */
  112402. getBoneByName(name: string): Nullable<Bone>;
  112403. /**
  112404. * Gets a light node using its name
  112405. * @param name defines the the light's name
  112406. * @return the light or null if none found.
  112407. */
  112408. getLightByName(name: string): Nullable<Light>;
  112409. /**
  112410. * Gets a light node using its id
  112411. * @param id defines the light's id
  112412. * @return the light or null if none found.
  112413. */
  112414. getLightByID(id: string): Nullable<Light>;
  112415. /**
  112416. * Gets a light node using its scene-generated unique ID
  112417. * @param uniqueId defines the light's unique id
  112418. * @return the light or null if none found.
  112419. */
  112420. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  112421. /**
  112422. * Gets a particle system by id
  112423. * @param id defines the particle system id
  112424. * @return the corresponding system or null if none found
  112425. */
  112426. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  112427. /**
  112428. * Gets a geometry using its ID
  112429. * @param id defines the geometry's id
  112430. * @return the geometry or null if none found.
  112431. */
  112432. getGeometryByID(id: string): Nullable<Geometry>;
  112433. private _getGeometryByUniqueID;
  112434. /**
  112435. * Add a new geometry to this scene
  112436. * @param geometry defines the geometry to be added to the scene.
  112437. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  112438. * @return a boolean defining if the geometry was added or not
  112439. */
  112440. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  112441. /**
  112442. * Removes an existing geometry
  112443. * @param geometry defines the geometry to be removed from the scene
  112444. * @return a boolean defining if the geometry was removed or not
  112445. */
  112446. removeGeometry(geometry: Geometry): boolean;
  112447. /**
  112448. * Gets the list of geometries attached to the scene
  112449. * @returns an array of Geometry
  112450. */
  112451. getGeometries(): Geometry[];
  112452. /**
  112453. * Gets the first added mesh found of a given ID
  112454. * @param id defines the id to search for
  112455. * @return the mesh found or null if not found at all
  112456. */
  112457. getMeshByID(id: string): Nullable<AbstractMesh>;
  112458. /**
  112459. * Gets a list of meshes using their id
  112460. * @param id defines the id to search for
  112461. * @returns a list of meshes
  112462. */
  112463. getMeshesByID(id: string): Array<AbstractMesh>;
  112464. /**
  112465. * Gets the first added transform node found of a given ID
  112466. * @param id defines the id to search for
  112467. * @return the found transform node or null if not found at all.
  112468. */
  112469. getTransformNodeByID(id: string): Nullable<TransformNode>;
  112470. /**
  112471. * Gets a transform node with its auto-generated unique id
  112472. * @param uniqueId efines the unique id to search for
  112473. * @return the found transform node or null if not found at all.
  112474. */
  112475. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  112476. /**
  112477. * Gets a list of transform nodes using their id
  112478. * @param id defines the id to search for
  112479. * @returns a list of transform nodes
  112480. */
  112481. getTransformNodesByID(id: string): Array<TransformNode>;
  112482. /**
  112483. * Gets a mesh with its auto-generated unique id
  112484. * @param uniqueId defines the unique id to search for
  112485. * @return the found mesh or null if not found at all.
  112486. */
  112487. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  112488. /**
  112489. * Gets a the last added mesh using a given id
  112490. * @param id defines the id to search for
  112491. * @return the found mesh or null if not found at all.
  112492. */
  112493. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  112494. /**
  112495. * Gets a the last added node (Mesh, Camera, Light) using a given id
  112496. * @param id defines the id to search for
  112497. * @return the found node or null if not found at all
  112498. */
  112499. getLastEntryByID(id: string): Nullable<Node>;
  112500. /**
  112501. * Gets a node (Mesh, Camera, Light) using a given id
  112502. * @param id defines the id to search for
  112503. * @return the found node or null if not found at all
  112504. */
  112505. getNodeByID(id: string): Nullable<Node>;
  112506. /**
  112507. * Gets a node (Mesh, Camera, Light) using a given name
  112508. * @param name defines the name to search for
  112509. * @return the found node or null if not found at all.
  112510. */
  112511. getNodeByName(name: string): Nullable<Node>;
  112512. /**
  112513. * Gets a mesh using a given name
  112514. * @param name defines the name to search for
  112515. * @return the found mesh or null if not found at all.
  112516. */
  112517. getMeshByName(name: string): Nullable<AbstractMesh>;
  112518. /**
  112519. * Gets a transform node using a given name
  112520. * @param name defines the name to search for
  112521. * @return the found transform node or null if not found at all.
  112522. */
  112523. getTransformNodeByName(name: string): Nullable<TransformNode>;
  112524. /**
  112525. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  112526. * @param id defines the id to search for
  112527. * @return the found skeleton or null if not found at all.
  112528. */
  112529. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  112530. /**
  112531. * Gets a skeleton using a given auto generated unique id
  112532. * @param uniqueId defines the unique id to search for
  112533. * @return the found skeleton or null if not found at all.
  112534. */
  112535. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  112536. /**
  112537. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  112538. * @param id defines the id to search for
  112539. * @return the found skeleton or null if not found at all.
  112540. */
  112541. getSkeletonById(id: string): Nullable<Skeleton>;
  112542. /**
  112543. * Gets a skeleton using a given name
  112544. * @param name defines the name to search for
  112545. * @return the found skeleton or null if not found at all.
  112546. */
  112547. getSkeletonByName(name: string): Nullable<Skeleton>;
  112548. /**
  112549. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  112550. * @param id defines the id to search for
  112551. * @return the found morph target manager or null if not found at all.
  112552. */
  112553. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  112554. /**
  112555. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  112556. * @param id defines the id to search for
  112557. * @return the found morph target or null if not found at all.
  112558. */
  112559. getMorphTargetById(id: string): Nullable<MorphTarget>;
  112560. /**
  112561. * Gets a morph target using a given name (if many are found, this function will pick the first one)
  112562. * @param name defines the name to search for
  112563. * @return the found morph target or null if not found at all.
  112564. */
  112565. getMorphTargetByName(name: string): Nullable<MorphTarget>;
  112566. /**
  112567. * Gets a boolean indicating if the given mesh is active
  112568. * @param mesh defines the mesh to look for
  112569. * @returns true if the mesh is in the active list
  112570. */
  112571. isActiveMesh(mesh: AbstractMesh): boolean;
  112572. /**
  112573. * Return a unique id as a string which can serve as an identifier for the scene
  112574. */
  112575. get uid(): string;
  112576. /**
  112577. * Add an externaly attached data from its key.
  112578. * This method call will fail and return false, if such key already exists.
  112579. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  112580. * @param key the unique key that identifies the data
  112581. * @param data the data object to associate to the key for this Engine instance
  112582. * @return true if no such key were already present and the data was added successfully, false otherwise
  112583. */
  112584. addExternalData<T>(key: string, data: T): boolean;
  112585. /**
  112586. * Get an externaly attached data from its key
  112587. * @param key the unique key that identifies the data
  112588. * @return the associated data, if present (can be null), or undefined if not present
  112589. */
  112590. getExternalData<T>(key: string): Nullable<T>;
  112591. /**
  112592. * Get an externaly attached data from its key, create it using a factory if it's not already present
  112593. * @param key the unique key that identifies the data
  112594. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  112595. * @return the associated data, can be null if the factory returned null.
  112596. */
  112597. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  112598. /**
  112599. * Remove an externaly attached data from the Engine instance
  112600. * @param key the unique key that identifies the data
  112601. * @return true if the data was successfully removed, false if it doesn't exist
  112602. */
  112603. removeExternalData(key: string): boolean;
  112604. private _evaluateSubMesh;
  112605. /**
  112606. * Clear the processed materials smart array preventing retention point in material dispose.
  112607. */
  112608. freeProcessedMaterials(): void;
  112609. private _preventFreeActiveMeshesAndRenderingGroups;
  112610. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  112611. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  112612. * when disposing several meshes in a row or a hierarchy of meshes.
  112613. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  112614. */
  112615. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  112616. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  112617. /**
  112618. * Clear the active meshes smart array preventing retention point in mesh dispose.
  112619. */
  112620. freeActiveMeshes(): void;
  112621. /**
  112622. * Clear the info related to rendering groups preventing retention points during dispose.
  112623. */
  112624. freeRenderingGroups(): void;
  112625. /** @hidden */
  112626. _isInIntermediateRendering(): boolean;
  112627. /**
  112628. * Lambda returning the list of potentially active meshes.
  112629. */
  112630. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  112631. /**
  112632. * Lambda returning the list of potentially active sub meshes.
  112633. */
  112634. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  112635. /**
  112636. * Lambda returning the list of potentially intersecting sub meshes.
  112637. */
  112638. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  112639. /**
  112640. * Lambda returning the list of potentially colliding sub meshes.
  112641. */
  112642. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  112643. private _activeMeshesFrozen;
  112644. private _skipEvaluateActiveMeshesCompletely;
  112645. /**
  112646. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  112647. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  112648. * @returns the current scene
  112649. */
  112650. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean): Scene;
  112651. /**
  112652. * Use this function to restart evaluating active meshes on every frame
  112653. * @returns the current scene
  112654. */
  112655. unfreezeActiveMeshes(): Scene;
  112656. private _evaluateActiveMeshes;
  112657. private _activeMesh;
  112658. /**
  112659. * Update the transform matrix to update from the current active camera
  112660. * @param force defines a boolean used to force the update even if cache is up to date
  112661. */
  112662. updateTransformMatrix(force?: boolean): void;
  112663. private _bindFrameBuffer;
  112664. /** @hidden */
  112665. _allowPostProcessClearColor: boolean;
  112666. /** @hidden */
  112667. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  112668. private _processSubCameras;
  112669. private _checkIntersections;
  112670. /** @hidden */
  112671. _advancePhysicsEngineStep(step: number): void;
  112672. /**
  112673. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  112674. */
  112675. getDeterministicFrameTime: () => number;
  112676. /** @hidden */
  112677. _animate(): void;
  112678. /** Execute all animations (for a frame) */
  112679. animate(): void;
  112680. /**
  112681. * Render the scene
  112682. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  112683. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  112684. */
  112685. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  112686. /**
  112687. * Freeze all materials
  112688. * A frozen material will not be updatable but should be faster to render
  112689. */
  112690. freezeMaterials(): void;
  112691. /**
  112692. * Unfreeze all materials
  112693. * A frozen material will not be updatable but should be faster to render
  112694. */
  112695. unfreezeMaterials(): void;
  112696. /**
  112697. * Releases all held ressources
  112698. */
  112699. dispose(): void;
  112700. /**
  112701. * Gets if the scene is already disposed
  112702. */
  112703. get isDisposed(): boolean;
  112704. /**
  112705. * Call this function to reduce memory footprint of the scene.
  112706. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  112707. */
  112708. clearCachedVertexData(): void;
  112709. /**
  112710. * This function will remove the local cached buffer data from texture.
  112711. * It will save memory but will prevent the texture from being rebuilt
  112712. */
  112713. cleanCachedTextureBuffer(): void;
  112714. /**
  112715. * Get the world extend vectors with an optional filter
  112716. *
  112717. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  112718. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  112719. */
  112720. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  112721. min: Vector3;
  112722. max: Vector3;
  112723. };
  112724. /**
  112725. * Creates a ray that can be used to pick in the scene
  112726. * @param x defines the x coordinate of the origin (on-screen)
  112727. * @param y defines the y coordinate of the origin (on-screen)
  112728. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  112729. * @param camera defines the camera to use for the picking
  112730. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  112731. * @returns a Ray
  112732. */
  112733. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  112734. /**
  112735. * Creates a ray that can be used to pick in the scene
  112736. * @param x defines the x coordinate of the origin (on-screen)
  112737. * @param y defines the y coordinate of the origin (on-screen)
  112738. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  112739. * @param result defines the ray where to store the picking ray
  112740. * @param camera defines the camera to use for the picking
  112741. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  112742. * @returns the current scene
  112743. */
  112744. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  112745. /**
  112746. * Creates a ray that can be used to pick in the scene
  112747. * @param x defines the x coordinate of the origin (on-screen)
  112748. * @param y defines the y coordinate of the origin (on-screen)
  112749. * @param camera defines the camera to use for the picking
  112750. * @returns a Ray
  112751. */
  112752. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  112753. /**
  112754. * Creates a ray that can be used to pick in the scene
  112755. * @param x defines the x coordinate of the origin (on-screen)
  112756. * @param y defines the y coordinate of the origin (on-screen)
  112757. * @param result defines the ray where to store the picking ray
  112758. * @param camera defines the camera to use for the picking
  112759. * @returns the current scene
  112760. */
  112761. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  112762. /** Launch a ray to try to pick a mesh in the scene
  112763. * @param x position on screen
  112764. * @param y position on screen
  112765. * @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
  112766. * @param fastCheck defines if the first intersection will be used (and not the closest)
  112767. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  112768. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  112769. * @returns a PickingInfo
  112770. */
  112771. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  112772. /** Launch a ray to try to pick a mesh in the scene using only bounding information of the main mesh (not using submeshes)
  112773. * @param x position on screen
  112774. * @param y position on screen
  112775. * @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
  112776. * @param fastCheck defines if the first intersection will be used (and not the closest)
  112777. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  112778. * @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)
  112779. */
  112780. pickWithBoundingInfo(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  112781. /** Use the given ray to pick a mesh in the scene
  112782. * @param ray The ray to use to pick meshes
  112783. * @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
  112784. * @param fastCheck defines if the first intersection will be used (and not the closest)
  112785. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  112786. * @returns a PickingInfo
  112787. */
  112788. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  112789. /**
  112790. * Launch a ray to try to pick a mesh in the scene
  112791. * @param x X position on screen
  112792. * @param y Y position on screen
  112793. * @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
  112794. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  112795. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  112796. * @returns an array of PickingInfo
  112797. */
  112798. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  112799. /**
  112800. * Launch a ray to try to pick a mesh in the scene
  112801. * @param ray Ray to use
  112802. * @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
  112803. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  112804. * @returns an array of PickingInfo
  112805. */
  112806. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  112807. /**
  112808. * Force the value of meshUnderPointer
  112809. * @param mesh defines the mesh to use
  112810. */
  112811. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  112812. /**
  112813. * Gets the mesh under the pointer
  112814. * @returns a Mesh or null if no mesh is under the pointer
  112815. */
  112816. getPointerOverMesh(): Nullable<AbstractMesh>;
  112817. /** @hidden */
  112818. _rebuildGeometries(): void;
  112819. /** @hidden */
  112820. _rebuildTextures(): void;
  112821. private _getByTags;
  112822. /**
  112823. * Get a list of meshes by tags
  112824. * @param tagsQuery defines the tags query to use
  112825. * @param forEach defines a predicate used to filter results
  112826. * @returns an array of Mesh
  112827. */
  112828. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  112829. /**
  112830. * Get a list of cameras by tags
  112831. * @param tagsQuery defines the tags query to use
  112832. * @param forEach defines a predicate used to filter results
  112833. * @returns an array of Camera
  112834. */
  112835. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  112836. /**
  112837. * Get a list of lights by tags
  112838. * @param tagsQuery defines the tags query to use
  112839. * @param forEach defines a predicate used to filter results
  112840. * @returns an array of Light
  112841. */
  112842. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  112843. /**
  112844. * Get a list of materials by tags
  112845. * @param tagsQuery defines the tags query to use
  112846. * @param forEach defines a predicate used to filter results
  112847. * @returns an array of Material
  112848. */
  112849. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  112850. /**
  112851. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  112852. * This allowed control for front to back rendering or reversly depending of the special needs.
  112853. *
  112854. * @param renderingGroupId The rendering group id corresponding to its index
  112855. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  112856. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  112857. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  112858. */
  112859. 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;
  112860. /**
  112861. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  112862. *
  112863. * @param renderingGroupId The rendering group id corresponding to its index
  112864. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  112865. * @param depth Automatically clears depth between groups if true and autoClear is true.
  112866. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  112867. */
  112868. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  112869. /**
  112870. * Gets the current auto clear configuration for one rendering group of the rendering
  112871. * manager.
  112872. * @param index the rendering group index to get the information for
  112873. * @returns The auto clear setup for the requested rendering group
  112874. */
  112875. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  112876. private _blockMaterialDirtyMechanism;
  112877. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  112878. get blockMaterialDirtyMechanism(): boolean;
  112879. set blockMaterialDirtyMechanism(value: boolean);
  112880. /**
  112881. * Will flag all materials as dirty to trigger new shader compilation
  112882. * @param flag defines the flag used to specify which material part must be marked as dirty
  112883. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  112884. */
  112885. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  112886. /** @hidden */
  112887. _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;
  112888. /** @hidden */
  112889. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  112890. /** @hidden */
  112891. _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;
  112892. /** @hidden */
  112893. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  112894. /** @hidden */
  112895. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  112896. /** @hidden */
  112897. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  112898. }
  112899. }
  112900. declare module BABYLON {
  112901. /**
  112902. * Set of assets to keep when moving a scene into an asset container.
  112903. */
  112904. export class KeepAssets extends AbstractScene {
  112905. }
  112906. /**
  112907. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  112908. */
  112909. export class InstantiatedEntries {
  112910. /**
  112911. * List of new root nodes (eg. nodes with no parent)
  112912. */
  112913. rootNodes: TransformNode[];
  112914. /**
  112915. * List of new skeletons
  112916. */
  112917. skeletons: Skeleton[];
  112918. /**
  112919. * List of new animation groups
  112920. */
  112921. animationGroups: AnimationGroup[];
  112922. }
  112923. /**
  112924. * Container with a set of assets that can be added or removed from a scene.
  112925. */
  112926. export class AssetContainer extends AbstractScene {
  112927. private _wasAddedToScene;
  112928. /**
  112929. * The scene the AssetContainer belongs to.
  112930. */
  112931. scene: Scene;
  112932. /**
  112933. * Instantiates an AssetContainer.
  112934. * @param scene The scene the AssetContainer belongs to.
  112935. */
  112936. constructor(scene: Scene);
  112937. /**
  112938. * Instantiate or clone all meshes and add the new ones to the scene.
  112939. * Skeletons and animation groups will all be cloned
  112940. * @param nameFunction defines an optional function used to get new names for clones
  112941. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  112942. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  112943. */
  112944. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  112945. /**
  112946. * Adds all the assets from the container to the scene.
  112947. */
  112948. addAllToScene(): void;
  112949. /**
  112950. * Removes all the assets in the container from the scene
  112951. */
  112952. removeAllFromScene(): void;
  112953. /**
  112954. * Disposes all the assets in the container
  112955. */
  112956. dispose(): void;
  112957. private _moveAssets;
  112958. /**
  112959. * Removes all the assets contained in the scene and adds them to the container.
  112960. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  112961. */
  112962. moveAllFromScene(keepAssets?: KeepAssets): void;
  112963. /**
  112964. * 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.
  112965. * @returns the root mesh
  112966. */
  112967. createRootMesh(): Mesh;
  112968. /**
  112969. * Merge animations (direct and animation groups) from this asset container into a scene
  112970. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  112971. * @param animatables set of animatables to retarget to a node from the scene
  112972. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  112973. * @returns an array of the new AnimationGroup added to the scene (empty array if none)
  112974. */
  112975. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): AnimationGroup[];
  112976. }
  112977. }
  112978. declare module BABYLON {
  112979. /**
  112980. * Defines how the parser contract is defined.
  112981. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  112982. */
  112983. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  112984. /**
  112985. * Defines how the individual parser contract is defined.
  112986. * These parser can parse an individual asset
  112987. */
  112988. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  112989. /**
  112990. * Base class of the scene acting as a container for the different elements composing a scene.
  112991. * This class is dynamically extended by the different components of the scene increasing
  112992. * flexibility and reducing coupling
  112993. */
  112994. export abstract class AbstractScene {
  112995. /**
  112996. * Stores the list of available parsers in the application.
  112997. */
  112998. private static _BabylonFileParsers;
  112999. /**
  113000. * Stores the list of available individual parsers in the application.
  113001. */
  113002. private static _IndividualBabylonFileParsers;
  113003. /**
  113004. * Adds a parser in the list of available ones
  113005. * @param name Defines the name of the parser
  113006. * @param parser Defines the parser to add
  113007. */
  113008. static AddParser(name: string, parser: BabylonFileParser): void;
  113009. /**
  113010. * Gets a general parser from the list of avaialble ones
  113011. * @param name Defines the name of the parser
  113012. * @returns the requested parser or null
  113013. */
  113014. static GetParser(name: string): Nullable<BabylonFileParser>;
  113015. /**
  113016. * Adds n individual parser in the list of available ones
  113017. * @param name Defines the name of the parser
  113018. * @param parser Defines the parser to add
  113019. */
  113020. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  113021. /**
  113022. * Gets an individual parser from the list of avaialble ones
  113023. * @param name Defines the name of the parser
  113024. * @returns the requested parser or null
  113025. */
  113026. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  113027. /**
  113028. * Parser json data and populate both a scene and its associated container object
  113029. * @param jsonData Defines the data to parse
  113030. * @param scene Defines the scene to parse the data for
  113031. * @param container Defines the container attached to the parsing sequence
  113032. * @param rootUrl Defines the root url of the data
  113033. */
  113034. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  113035. /**
  113036. * Gets the list of root nodes (ie. nodes with no parent)
  113037. */
  113038. rootNodes: Node[];
  113039. /** All of the cameras added to this scene
  113040. * @see http://doc.babylonjs.com/babylon101/cameras
  113041. */
  113042. cameras: Camera[];
  113043. /**
  113044. * All of the lights added to this scene
  113045. * @see http://doc.babylonjs.com/babylon101/lights
  113046. */
  113047. lights: Light[];
  113048. /**
  113049. * All of the (abstract) meshes added to this scene
  113050. */
  113051. meshes: AbstractMesh[];
  113052. /**
  113053. * The list of skeletons added to the scene
  113054. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  113055. */
  113056. skeletons: Skeleton[];
  113057. /**
  113058. * All of the particle systems added to this scene
  113059. * @see http://doc.babylonjs.com/babylon101/particles
  113060. */
  113061. particleSystems: IParticleSystem[];
  113062. /**
  113063. * Gets a list of Animations associated with the scene
  113064. */
  113065. animations: Animation[];
  113066. /**
  113067. * All of the animation groups added to this scene
  113068. * @see http://doc.babylonjs.com/how_to/group
  113069. */
  113070. animationGroups: AnimationGroup[];
  113071. /**
  113072. * All of the multi-materials added to this scene
  113073. * @see http://doc.babylonjs.com/how_to/multi_materials
  113074. */
  113075. multiMaterials: MultiMaterial[];
  113076. /**
  113077. * All of the materials added to this scene
  113078. * In the context of a Scene, it is not supposed to be modified manually.
  113079. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  113080. * Note also that the order of the Material within the array is not significant and might change.
  113081. * @see http://doc.babylonjs.com/babylon101/materials
  113082. */
  113083. materials: Material[];
  113084. /**
  113085. * The list of morph target managers added to the scene
  113086. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  113087. */
  113088. morphTargetManagers: MorphTargetManager[];
  113089. /**
  113090. * The list of geometries used in the scene.
  113091. */
  113092. geometries: Geometry[];
  113093. /**
  113094. * All of the tranform nodes added to this scene
  113095. * In the context of a Scene, it is not supposed to be modified manually.
  113096. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  113097. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  113098. * @see http://doc.babylonjs.com/how_to/transformnode
  113099. */
  113100. transformNodes: TransformNode[];
  113101. /**
  113102. * ActionManagers available on the scene.
  113103. */
  113104. actionManagers: AbstractActionManager[];
  113105. /**
  113106. * Textures to keep.
  113107. */
  113108. textures: BaseTexture[];
  113109. /**
  113110. * Environment texture for the scene
  113111. */
  113112. environmentTexture: Nullable<BaseTexture>;
  113113. /**
  113114. * @returns all meshes, lights, cameras, transformNodes and bones
  113115. */
  113116. getNodes(): Array<Node>;
  113117. }
  113118. }
  113119. declare module BABYLON {
  113120. /**
  113121. * Interface used to define options for Sound class
  113122. */
  113123. export interface ISoundOptions {
  113124. /**
  113125. * Does the sound autoplay once loaded.
  113126. */
  113127. autoplay?: boolean;
  113128. /**
  113129. * Does the sound loop after it finishes playing once.
  113130. */
  113131. loop?: boolean;
  113132. /**
  113133. * Sound's volume
  113134. */
  113135. volume?: number;
  113136. /**
  113137. * Is it a spatial sound?
  113138. */
  113139. spatialSound?: boolean;
  113140. /**
  113141. * Maximum distance to hear that sound
  113142. */
  113143. maxDistance?: number;
  113144. /**
  113145. * Uses user defined attenuation function
  113146. */
  113147. useCustomAttenuation?: boolean;
  113148. /**
  113149. * Define the roll off factor of spatial sounds.
  113150. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  113151. */
  113152. rolloffFactor?: number;
  113153. /**
  113154. * Define the reference distance the sound should be heard perfectly.
  113155. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  113156. */
  113157. refDistance?: number;
  113158. /**
  113159. * Define the distance attenuation model the sound will follow.
  113160. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  113161. */
  113162. distanceModel?: string;
  113163. /**
  113164. * Defines the playback speed (1 by default)
  113165. */
  113166. playbackRate?: number;
  113167. /**
  113168. * Defines if the sound is from a streaming source
  113169. */
  113170. streaming?: boolean;
  113171. /**
  113172. * Defines an optional length (in seconds) inside the sound file
  113173. */
  113174. length?: number;
  113175. /**
  113176. * Defines an optional offset (in seconds) inside the sound file
  113177. */
  113178. offset?: number;
  113179. /**
  113180. * If true, URLs will not be required to state the audio file codec to use.
  113181. */
  113182. skipCodecCheck?: boolean;
  113183. }
  113184. /**
  113185. * Defines a sound that can be played in the application.
  113186. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  113187. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  113188. */
  113189. export class Sound {
  113190. /**
  113191. * The name of the sound in the scene.
  113192. */
  113193. name: string;
  113194. /**
  113195. * Does the sound autoplay once loaded.
  113196. */
  113197. autoplay: boolean;
  113198. /**
  113199. * Does the sound loop after it finishes playing once.
  113200. */
  113201. loop: boolean;
  113202. /**
  113203. * Does the sound use a custom attenuation curve to simulate the falloff
  113204. * happening when the source gets further away from the camera.
  113205. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  113206. */
  113207. useCustomAttenuation: boolean;
  113208. /**
  113209. * The sound track id this sound belongs to.
  113210. */
  113211. soundTrackId: number;
  113212. /**
  113213. * Is this sound currently played.
  113214. */
  113215. isPlaying: boolean;
  113216. /**
  113217. * Is this sound currently paused.
  113218. */
  113219. isPaused: boolean;
  113220. /**
  113221. * Does this sound enables spatial sound.
  113222. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  113223. */
  113224. spatialSound: boolean;
  113225. /**
  113226. * Define the reference distance the sound should be heard perfectly.
  113227. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  113228. */
  113229. refDistance: number;
  113230. /**
  113231. * Define the roll off factor of spatial sounds.
  113232. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  113233. */
  113234. rolloffFactor: number;
  113235. /**
  113236. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  113237. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  113238. */
  113239. maxDistance: number;
  113240. /**
  113241. * Define the distance attenuation model the sound will follow.
  113242. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  113243. */
  113244. distanceModel: string;
  113245. /**
  113246. * @hidden
  113247. * Back Compat
  113248. **/
  113249. onended: () => any;
  113250. /**
  113251. * Observable event when the current playing sound finishes.
  113252. */
  113253. onEndedObservable: Observable<Sound>;
  113254. private _panningModel;
  113255. private _playbackRate;
  113256. private _streaming;
  113257. private _startTime;
  113258. private _startOffset;
  113259. private _position;
  113260. /** @hidden */
  113261. _positionInEmitterSpace: boolean;
  113262. private _localDirection;
  113263. private _volume;
  113264. private _isReadyToPlay;
  113265. private _isDirectional;
  113266. private _readyToPlayCallback;
  113267. private _audioBuffer;
  113268. private _soundSource;
  113269. private _streamingSource;
  113270. private _soundPanner;
  113271. private _soundGain;
  113272. private _inputAudioNode;
  113273. private _outputAudioNode;
  113274. private _coneInnerAngle;
  113275. private _coneOuterAngle;
  113276. private _coneOuterGain;
  113277. private _scene;
  113278. private _connectedTransformNode;
  113279. private _customAttenuationFunction;
  113280. private _registerFunc;
  113281. private _isOutputConnected;
  113282. private _htmlAudioElement;
  113283. private _urlType;
  113284. private _length?;
  113285. private _offset?;
  113286. /** @hidden */
  113287. static _SceneComponentInitialization: (scene: Scene) => void;
  113288. /**
  113289. * Create a sound and attach it to a scene
  113290. * @param name Name of your sound
  113291. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  113292. * @param scene defines the scene the sound belongs to
  113293. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  113294. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  113295. */
  113296. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  113297. /**
  113298. * Release the sound and its associated resources
  113299. */
  113300. dispose(): void;
  113301. /**
  113302. * Gets if the sounds is ready to be played or not.
  113303. * @returns true if ready, otherwise false
  113304. */
  113305. isReady(): boolean;
  113306. private _soundLoaded;
  113307. /**
  113308. * Sets the data of the sound from an audiobuffer
  113309. * @param audioBuffer The audioBuffer containing the data
  113310. */
  113311. setAudioBuffer(audioBuffer: AudioBuffer): void;
  113312. /**
  113313. * Updates the current sounds options such as maxdistance, loop...
  113314. * @param options A JSON object containing values named as the object properties
  113315. */
  113316. updateOptions(options: ISoundOptions): void;
  113317. private _createSpatialParameters;
  113318. private _updateSpatialParameters;
  113319. /**
  113320. * Switch the panning model to HRTF:
  113321. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  113322. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  113323. */
  113324. switchPanningModelToHRTF(): void;
  113325. /**
  113326. * Switch the panning model to Equal Power:
  113327. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  113328. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  113329. */
  113330. switchPanningModelToEqualPower(): void;
  113331. private _switchPanningModel;
  113332. /**
  113333. * Connect this sound to a sound track audio node like gain...
  113334. * @param soundTrackAudioNode the sound track audio node to connect to
  113335. */
  113336. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  113337. /**
  113338. * Transform this sound into a directional source
  113339. * @param coneInnerAngle Size of the inner cone in degree
  113340. * @param coneOuterAngle Size of the outer cone in degree
  113341. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  113342. */
  113343. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  113344. /**
  113345. * Gets or sets the inner angle for the directional cone.
  113346. */
  113347. get directionalConeInnerAngle(): number;
  113348. /**
  113349. * Gets or sets the inner angle for the directional cone.
  113350. */
  113351. set directionalConeInnerAngle(value: number);
  113352. /**
  113353. * Gets or sets the outer angle for the directional cone.
  113354. */
  113355. get directionalConeOuterAngle(): number;
  113356. /**
  113357. * Gets or sets the outer angle for the directional cone.
  113358. */
  113359. set directionalConeOuterAngle(value: number);
  113360. /**
  113361. * Sets the position of the emitter if spatial sound is enabled
  113362. * @param newPosition Defines the new posisiton
  113363. */
  113364. setPosition(newPosition: Vector3): void;
  113365. /**
  113366. * Sets the local direction of the emitter if spatial sound is enabled
  113367. * @param newLocalDirection Defines the new local direction
  113368. */
  113369. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  113370. private _updateDirection;
  113371. /** @hidden */
  113372. updateDistanceFromListener(): void;
  113373. /**
  113374. * Sets a new custom attenuation function for the sound.
  113375. * @param callback Defines the function used for the attenuation
  113376. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  113377. */
  113378. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  113379. /**
  113380. * Play the sound
  113381. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  113382. * @param offset (optional) Start the sound at a specific time in seconds
  113383. * @param length (optional) Sound duration (in seconds)
  113384. */
  113385. play(time?: number, offset?: number, length?: number): void;
  113386. private _onended;
  113387. /**
  113388. * Stop the sound
  113389. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  113390. */
  113391. stop(time?: number): void;
  113392. /**
  113393. * Put the sound in pause
  113394. */
  113395. pause(): void;
  113396. /**
  113397. * Sets a dedicated volume for this sounds
  113398. * @param newVolume Define the new volume of the sound
  113399. * @param time Define time for gradual change to new volume
  113400. */
  113401. setVolume(newVolume: number, time?: number): void;
  113402. /**
  113403. * Set the sound play back rate
  113404. * @param newPlaybackRate Define the playback rate the sound should be played at
  113405. */
  113406. setPlaybackRate(newPlaybackRate: number): void;
  113407. /**
  113408. * Gets the volume of the sound.
  113409. * @returns the volume of the sound
  113410. */
  113411. getVolume(): number;
  113412. /**
  113413. * Attach the sound to a dedicated mesh
  113414. * @param transformNode The transform node to connect the sound with
  113415. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  113416. */
  113417. attachToMesh(transformNode: TransformNode): void;
  113418. /**
  113419. * Detach the sound from the previously attached mesh
  113420. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  113421. */
  113422. detachFromMesh(): void;
  113423. private _onRegisterAfterWorldMatrixUpdate;
  113424. /**
  113425. * Clone the current sound in the scene.
  113426. * @returns the new sound clone
  113427. */
  113428. clone(): Nullable<Sound>;
  113429. /**
  113430. * Gets the current underlying audio buffer containing the data
  113431. * @returns the audio buffer
  113432. */
  113433. getAudioBuffer(): Nullable<AudioBuffer>;
  113434. /**
  113435. * Gets the WebAudio AudioBufferSourceNode, lets you keep track of and stop instances of this Sound.
  113436. * @returns the source node
  113437. */
  113438. getSoundSource(): Nullable<AudioBufferSourceNode>;
  113439. /**
  113440. * Gets the WebAudio GainNode, gives you precise control over the gain of instances of this Sound.
  113441. * @returns the gain node
  113442. */
  113443. getSoundGain(): Nullable<GainNode>;
  113444. /**
  113445. * Serializes the Sound in a JSON representation
  113446. * @returns the JSON representation of the sound
  113447. */
  113448. serialize(): any;
  113449. /**
  113450. * Parse a JSON representation of a sound to innstantiate in a given scene
  113451. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  113452. * @param scene Define the scene the new parsed sound should be created in
  113453. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  113454. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  113455. * @returns the newly parsed sound
  113456. */
  113457. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  113458. }
  113459. }
  113460. declare module BABYLON {
  113461. /**
  113462. * This defines an action helpful to play a defined sound on a triggered action.
  113463. */
  113464. export class PlaySoundAction extends Action {
  113465. private _sound;
  113466. /**
  113467. * Instantiate the action
  113468. * @param triggerOptions defines the trigger options
  113469. * @param sound defines the sound to play
  113470. * @param condition defines the trigger related conditions
  113471. */
  113472. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  113473. /** @hidden */
  113474. _prepare(): void;
  113475. /**
  113476. * Execute the action and play the sound.
  113477. */
  113478. execute(): void;
  113479. /**
  113480. * Serializes the actions and its related information.
  113481. * @param parent defines the object to serialize in
  113482. * @returns the serialized object
  113483. */
  113484. serialize(parent: any): any;
  113485. }
  113486. /**
  113487. * This defines an action helpful to stop a defined sound on a triggered action.
  113488. */
  113489. export class StopSoundAction extends Action {
  113490. private _sound;
  113491. /**
  113492. * Instantiate the action
  113493. * @param triggerOptions defines the trigger options
  113494. * @param sound defines the sound to stop
  113495. * @param condition defines the trigger related conditions
  113496. */
  113497. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  113498. /** @hidden */
  113499. _prepare(): void;
  113500. /**
  113501. * Execute the action and stop the sound.
  113502. */
  113503. execute(): void;
  113504. /**
  113505. * Serializes the actions and its related information.
  113506. * @param parent defines the object to serialize in
  113507. * @returns the serialized object
  113508. */
  113509. serialize(parent: any): any;
  113510. }
  113511. }
  113512. declare module BABYLON {
  113513. /**
  113514. * This defines an action responsible to change the value of a property
  113515. * by interpolating between its current value and the newly set one once triggered.
  113516. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  113517. */
  113518. export class InterpolateValueAction extends Action {
  113519. /**
  113520. * Defines the path of the property where the value should be interpolated
  113521. */
  113522. propertyPath: string;
  113523. /**
  113524. * Defines the target value at the end of the interpolation.
  113525. */
  113526. value: any;
  113527. /**
  113528. * Defines the time it will take for the property to interpolate to the value.
  113529. */
  113530. duration: number;
  113531. /**
  113532. * Defines if the other scene animations should be stopped when the action has been triggered
  113533. */
  113534. stopOtherAnimations?: boolean;
  113535. /**
  113536. * Defines a callback raised once the interpolation animation has been done.
  113537. */
  113538. onInterpolationDone?: () => void;
  113539. /**
  113540. * Observable triggered once the interpolation animation has been done.
  113541. */
  113542. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  113543. private _target;
  113544. private _effectiveTarget;
  113545. private _property;
  113546. /**
  113547. * Instantiate the action
  113548. * @param triggerOptions defines the trigger options
  113549. * @param target defines the object containing the value to interpolate
  113550. * @param propertyPath defines the path to the property in the target object
  113551. * @param value defines the target value at the end of the interpolation
  113552. * @param duration deines the time it will take for the property to interpolate to the value.
  113553. * @param condition defines the trigger related conditions
  113554. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  113555. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  113556. */
  113557. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  113558. /** @hidden */
  113559. _prepare(): void;
  113560. /**
  113561. * Execute the action starts the value interpolation.
  113562. */
  113563. execute(): void;
  113564. /**
  113565. * Serializes the actions and its related information.
  113566. * @param parent defines the object to serialize in
  113567. * @returns the serialized object
  113568. */
  113569. serialize(parent: any): any;
  113570. }
  113571. }
  113572. declare module BABYLON {
  113573. /**
  113574. * Options allowed during the creation of a sound track.
  113575. */
  113576. export interface ISoundTrackOptions {
  113577. /**
  113578. * The volume the sound track should take during creation
  113579. */
  113580. volume?: number;
  113581. /**
  113582. * Define if the sound track is the main sound track of the scene
  113583. */
  113584. mainTrack?: boolean;
  113585. }
  113586. /**
  113587. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  113588. * It will be also used in a future release to apply effects on a specific track.
  113589. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  113590. */
  113591. export class SoundTrack {
  113592. /**
  113593. * The unique identifier of the sound track in the scene.
  113594. */
  113595. id: number;
  113596. /**
  113597. * The list of sounds included in the sound track.
  113598. */
  113599. soundCollection: Array<Sound>;
  113600. private _outputAudioNode;
  113601. private _scene;
  113602. private _connectedAnalyser;
  113603. private _options;
  113604. private _isInitialized;
  113605. /**
  113606. * Creates a new sound track.
  113607. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  113608. * @param scene Define the scene the sound track belongs to
  113609. * @param options
  113610. */
  113611. constructor(scene: Scene, options?: ISoundTrackOptions);
  113612. private _initializeSoundTrackAudioGraph;
  113613. /**
  113614. * Release the sound track and its associated resources
  113615. */
  113616. dispose(): void;
  113617. /**
  113618. * Adds a sound to this sound track
  113619. * @param sound define the cound to add
  113620. * @ignoreNaming
  113621. */
  113622. AddSound(sound: Sound): void;
  113623. /**
  113624. * Removes a sound to this sound track
  113625. * @param sound define the cound to remove
  113626. * @ignoreNaming
  113627. */
  113628. RemoveSound(sound: Sound): void;
  113629. /**
  113630. * Set a global volume for the full sound track.
  113631. * @param newVolume Define the new volume of the sound track
  113632. */
  113633. setVolume(newVolume: number): void;
  113634. /**
  113635. * Switch the panning model to HRTF:
  113636. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  113637. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  113638. */
  113639. switchPanningModelToHRTF(): void;
  113640. /**
  113641. * Switch the panning model to Equal Power:
  113642. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  113643. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  113644. */
  113645. switchPanningModelToEqualPower(): void;
  113646. /**
  113647. * Connect the sound track to an audio analyser allowing some amazing
  113648. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  113649. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  113650. * @param analyser The analyser to connect to the engine
  113651. */
  113652. connectToAnalyser(analyser: Analyser): void;
  113653. }
  113654. }
  113655. declare module BABYLON {
  113656. interface AbstractScene {
  113657. /**
  113658. * The list of sounds used in the scene.
  113659. */
  113660. sounds: Nullable<Array<Sound>>;
  113661. }
  113662. interface Scene {
  113663. /**
  113664. * @hidden
  113665. * Backing field
  113666. */
  113667. _mainSoundTrack: SoundTrack;
  113668. /**
  113669. * The main sound track played by the scene.
  113670. * It cotains your primary collection of sounds.
  113671. */
  113672. mainSoundTrack: SoundTrack;
  113673. /**
  113674. * The list of sound tracks added to the scene
  113675. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  113676. */
  113677. soundTracks: Nullable<Array<SoundTrack>>;
  113678. /**
  113679. * Gets a sound using a given name
  113680. * @param name defines the name to search for
  113681. * @return the found sound or null if not found at all.
  113682. */
  113683. getSoundByName(name: string): Nullable<Sound>;
  113684. /**
  113685. * Gets or sets if audio support is enabled
  113686. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  113687. */
  113688. audioEnabled: boolean;
  113689. /**
  113690. * Gets or sets if audio will be output to headphones
  113691. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  113692. */
  113693. headphone: boolean;
  113694. /**
  113695. * Gets or sets custom audio listener position provider
  113696. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  113697. */
  113698. audioListenerPositionProvider: Nullable<() => Vector3>;
  113699. /**
  113700. * Gets or sets a refresh rate when using 3D audio positioning
  113701. */
  113702. audioPositioningRefreshRate: number;
  113703. }
  113704. /**
  113705. * Defines the sound scene component responsible to manage any sounds
  113706. * in a given scene.
  113707. */
  113708. export class AudioSceneComponent implements ISceneSerializableComponent {
  113709. /**
  113710. * The component name helpfull to identify the component in the list of scene components.
  113711. */
  113712. readonly name: string;
  113713. /**
  113714. * The scene the component belongs to.
  113715. */
  113716. scene: Scene;
  113717. private _audioEnabled;
  113718. /**
  113719. * Gets whether audio is enabled or not.
  113720. * Please use related enable/disable method to switch state.
  113721. */
  113722. get audioEnabled(): boolean;
  113723. private _headphone;
  113724. /**
  113725. * Gets whether audio is outputing to headphone or not.
  113726. * Please use the according Switch methods to change output.
  113727. */
  113728. get headphone(): boolean;
  113729. /**
  113730. * Gets or sets a refresh rate when using 3D audio positioning
  113731. */
  113732. audioPositioningRefreshRate: number;
  113733. private _audioListenerPositionProvider;
  113734. /**
  113735. * Gets the current audio listener position provider
  113736. */
  113737. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  113738. /**
  113739. * Sets a custom listener position for all sounds in the scene
  113740. * By default, this is the position of the first active camera
  113741. */
  113742. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  113743. /**
  113744. * Creates a new instance of the component for the given scene
  113745. * @param scene Defines the scene to register the component in
  113746. */
  113747. constructor(scene: Scene);
  113748. /**
  113749. * Registers the component in a given scene
  113750. */
  113751. register(): void;
  113752. /**
  113753. * Rebuilds the elements related to this component in case of
  113754. * context lost for instance.
  113755. */
  113756. rebuild(): void;
  113757. /**
  113758. * Serializes the component data to the specified json object
  113759. * @param serializationObject The object to serialize to
  113760. */
  113761. serialize(serializationObject: any): void;
  113762. /**
  113763. * Adds all the elements from the container to the scene
  113764. * @param container the container holding the elements
  113765. */
  113766. addFromContainer(container: AbstractScene): void;
  113767. /**
  113768. * Removes all the elements in the container from the scene
  113769. * @param container contains the elements to remove
  113770. * @param dispose if the removed element should be disposed (default: false)
  113771. */
  113772. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  113773. /**
  113774. * Disposes the component and the associated ressources.
  113775. */
  113776. dispose(): void;
  113777. /**
  113778. * Disables audio in the associated scene.
  113779. */
  113780. disableAudio(): void;
  113781. /**
  113782. * Enables audio in the associated scene.
  113783. */
  113784. enableAudio(): void;
  113785. /**
  113786. * Switch audio to headphone output.
  113787. */
  113788. switchAudioModeForHeadphones(): void;
  113789. /**
  113790. * Switch audio to normal speakers.
  113791. */
  113792. switchAudioModeForNormalSpeakers(): void;
  113793. private _cachedCameraDirection;
  113794. private _cachedCameraPosition;
  113795. private _lastCheck;
  113796. private _afterRender;
  113797. }
  113798. }
  113799. declare module BABYLON {
  113800. /**
  113801. * Wraps one or more Sound objects and selects one with random weight for playback.
  113802. */
  113803. export class WeightedSound {
  113804. /** When true a Sound will be selected and played when the current playing Sound completes. */
  113805. loop: boolean;
  113806. private _coneInnerAngle;
  113807. private _coneOuterAngle;
  113808. private _volume;
  113809. /** A Sound is currently playing. */
  113810. isPlaying: boolean;
  113811. /** A Sound is currently paused. */
  113812. isPaused: boolean;
  113813. private _sounds;
  113814. private _weights;
  113815. private _currentIndex?;
  113816. /**
  113817. * Creates a new WeightedSound from the list of sounds given.
  113818. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  113819. * @param sounds Array of Sounds that will be selected from.
  113820. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  113821. */
  113822. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  113823. /**
  113824. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  113825. */
  113826. get directionalConeInnerAngle(): number;
  113827. /**
  113828. * The size of cone in degress for a directional sound in which there will be no attenuation.
  113829. */
  113830. set directionalConeInnerAngle(value: number);
  113831. /**
  113832. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  113833. * Listener angles between innerAngle and outerAngle will falloff linearly.
  113834. */
  113835. get directionalConeOuterAngle(): number;
  113836. /**
  113837. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  113838. * Listener angles between innerAngle and outerAngle will falloff linearly.
  113839. */
  113840. set directionalConeOuterAngle(value: number);
  113841. /**
  113842. * Playback volume.
  113843. */
  113844. get volume(): number;
  113845. /**
  113846. * Playback volume.
  113847. */
  113848. set volume(value: number);
  113849. private _onended;
  113850. /**
  113851. * Suspend playback
  113852. */
  113853. pause(): void;
  113854. /**
  113855. * Stop playback
  113856. */
  113857. stop(): void;
  113858. /**
  113859. * Start playback.
  113860. * @param startOffset Position the clip head at a specific time in seconds.
  113861. */
  113862. play(startOffset?: number): void;
  113863. }
  113864. }
  113865. declare module BABYLON {
  113866. /**
  113867. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  113868. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  113869. */
  113870. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  113871. /**
  113872. * Gets the name of the behavior.
  113873. */
  113874. get name(): string;
  113875. /**
  113876. * The easing function used by animations
  113877. */
  113878. static EasingFunction: BackEase;
  113879. /**
  113880. * The easing mode used by animations
  113881. */
  113882. static EasingMode: number;
  113883. /**
  113884. * The duration of the animation, in milliseconds
  113885. */
  113886. transitionDuration: number;
  113887. /**
  113888. * Length of the distance animated by the transition when lower radius is reached
  113889. */
  113890. lowerRadiusTransitionRange: number;
  113891. /**
  113892. * Length of the distance animated by the transition when upper radius is reached
  113893. */
  113894. upperRadiusTransitionRange: number;
  113895. private _autoTransitionRange;
  113896. /**
  113897. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  113898. */
  113899. get autoTransitionRange(): boolean;
  113900. /**
  113901. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  113902. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  113903. */
  113904. set autoTransitionRange(value: boolean);
  113905. private _attachedCamera;
  113906. private _onAfterCheckInputsObserver;
  113907. private _onMeshTargetChangedObserver;
  113908. /**
  113909. * Initializes the behavior.
  113910. */
  113911. init(): void;
  113912. /**
  113913. * Attaches the behavior to its arc rotate camera.
  113914. * @param camera Defines the camera to attach the behavior to
  113915. */
  113916. attach(camera: ArcRotateCamera): void;
  113917. /**
  113918. * Detaches the behavior from its current arc rotate camera.
  113919. */
  113920. detach(): void;
  113921. private _radiusIsAnimating;
  113922. private _radiusBounceTransition;
  113923. private _animatables;
  113924. private _cachedWheelPrecision;
  113925. /**
  113926. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  113927. * @param radiusLimit The limit to check against.
  113928. * @return Bool to indicate if at limit.
  113929. */
  113930. private _isRadiusAtLimit;
  113931. /**
  113932. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  113933. * @param radiusDelta The delta by which to animate to. Can be negative.
  113934. */
  113935. private _applyBoundRadiusAnimation;
  113936. /**
  113937. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  113938. */
  113939. protected _clearAnimationLocks(): void;
  113940. /**
  113941. * Stops and removes all animations that have been applied to the camera
  113942. */
  113943. stopAllAnimations(): void;
  113944. }
  113945. }
  113946. declare module BABYLON {
  113947. /**
  113948. * 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.
  113949. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  113950. */
  113951. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  113952. /**
  113953. * Gets the name of the behavior.
  113954. */
  113955. get name(): string;
  113956. private _mode;
  113957. private _radiusScale;
  113958. private _positionScale;
  113959. private _defaultElevation;
  113960. private _elevationReturnTime;
  113961. private _elevationReturnWaitTime;
  113962. private _zoomStopsAnimation;
  113963. private _framingTime;
  113964. /**
  113965. * The easing function used by animations
  113966. */
  113967. static EasingFunction: ExponentialEase;
  113968. /**
  113969. * The easing mode used by animations
  113970. */
  113971. static EasingMode: number;
  113972. /**
  113973. * Sets the current mode used by the behavior
  113974. */
  113975. set mode(mode: number);
  113976. /**
  113977. * Gets current mode used by the behavior.
  113978. */
  113979. get mode(): number;
  113980. /**
  113981. * Sets the scale applied to the radius (1 by default)
  113982. */
  113983. set radiusScale(radius: number);
  113984. /**
  113985. * Gets the scale applied to the radius
  113986. */
  113987. get radiusScale(): number;
  113988. /**
  113989. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  113990. */
  113991. set positionScale(scale: number);
  113992. /**
  113993. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  113994. */
  113995. get positionScale(): number;
  113996. /**
  113997. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  113998. * behaviour is triggered, in radians.
  113999. */
  114000. set defaultElevation(elevation: number);
  114001. /**
  114002. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  114003. * behaviour is triggered, in radians.
  114004. */
  114005. get defaultElevation(): number;
  114006. /**
  114007. * Sets the time (in milliseconds) taken to return to the default beta position.
  114008. * Negative value indicates camera should not return to default.
  114009. */
  114010. set elevationReturnTime(speed: number);
  114011. /**
  114012. * Gets the time (in milliseconds) taken to return to the default beta position.
  114013. * Negative value indicates camera should not return to default.
  114014. */
  114015. get elevationReturnTime(): number;
  114016. /**
  114017. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  114018. */
  114019. set elevationReturnWaitTime(time: number);
  114020. /**
  114021. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  114022. */
  114023. get elevationReturnWaitTime(): number;
  114024. /**
  114025. * Sets the flag that indicates if user zooming should stop animation.
  114026. */
  114027. set zoomStopsAnimation(flag: boolean);
  114028. /**
  114029. * Gets the flag that indicates if user zooming should stop animation.
  114030. */
  114031. get zoomStopsAnimation(): boolean;
  114032. /**
  114033. * Sets the transition time when framing the mesh, in milliseconds
  114034. */
  114035. set framingTime(time: number);
  114036. /**
  114037. * Gets the transition time when framing the mesh, in milliseconds
  114038. */
  114039. get framingTime(): number;
  114040. /**
  114041. * Define if the behavior should automatically change the configured
  114042. * camera limits and sensibilities.
  114043. */
  114044. autoCorrectCameraLimitsAndSensibility: boolean;
  114045. private _onPrePointerObservableObserver;
  114046. private _onAfterCheckInputsObserver;
  114047. private _onMeshTargetChangedObserver;
  114048. private _attachedCamera;
  114049. private _isPointerDown;
  114050. private _lastInteractionTime;
  114051. /**
  114052. * Initializes the behavior.
  114053. */
  114054. init(): void;
  114055. /**
  114056. * Attaches the behavior to its arc rotate camera.
  114057. * @param camera Defines the camera to attach the behavior to
  114058. */
  114059. attach(camera: ArcRotateCamera): void;
  114060. /**
  114061. * Detaches the behavior from its current arc rotate camera.
  114062. */
  114063. detach(): void;
  114064. private _animatables;
  114065. private _betaIsAnimating;
  114066. private _betaTransition;
  114067. private _radiusTransition;
  114068. private _vectorTransition;
  114069. /**
  114070. * Targets the given mesh and updates zoom level accordingly.
  114071. * @param mesh The mesh to target.
  114072. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  114073. * @param onAnimationEnd Callback triggered at the end of the framing animation
  114074. */
  114075. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  114076. /**
  114077. * Targets the given mesh with its children and updates zoom level accordingly.
  114078. * @param mesh The mesh to target.
  114079. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  114080. * @param onAnimationEnd Callback triggered at the end of the framing animation
  114081. */
  114082. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  114083. /**
  114084. * Targets the given meshes with their children and updates zoom level accordingly.
  114085. * @param meshes The mesh to target.
  114086. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  114087. * @param onAnimationEnd Callback triggered at the end of the framing animation
  114088. */
  114089. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  114090. /**
  114091. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  114092. * @param minimumWorld Determines the smaller position of the bounding box extend
  114093. * @param maximumWorld Determines the bigger position of the bounding box extend
  114094. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  114095. * @param onAnimationEnd Callback triggered at the end of the framing animation
  114096. */
  114097. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  114098. /**
  114099. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  114100. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  114101. * frustum width.
  114102. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  114103. * to fully enclose the mesh in the viewing frustum.
  114104. */
  114105. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  114106. /**
  114107. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  114108. * is automatically returned to its default position (expected to be above ground plane).
  114109. */
  114110. private _maintainCameraAboveGround;
  114111. /**
  114112. * Returns the frustum slope based on the canvas ratio and camera FOV
  114113. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  114114. */
  114115. private _getFrustumSlope;
  114116. /**
  114117. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  114118. */
  114119. private _clearAnimationLocks;
  114120. /**
  114121. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  114122. */
  114123. private _applyUserInteraction;
  114124. /**
  114125. * Stops and removes all animations that have been applied to the camera
  114126. */
  114127. stopAllAnimations(): void;
  114128. /**
  114129. * Gets a value indicating if the user is moving the camera
  114130. */
  114131. get isUserIsMoving(): boolean;
  114132. /**
  114133. * The camera can move all the way towards the mesh.
  114134. */
  114135. static IgnoreBoundsSizeMode: number;
  114136. /**
  114137. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  114138. */
  114139. static FitFrustumSidesMode: number;
  114140. }
  114141. }
  114142. declare module BABYLON {
  114143. /**
  114144. * Base class for Camera Pointer Inputs.
  114145. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  114146. * for example usage.
  114147. */
  114148. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  114149. /**
  114150. * Defines the camera the input is attached to.
  114151. */
  114152. abstract camera: Camera;
  114153. /**
  114154. * Whether keyboard modifier keys are pressed at time of last mouse event.
  114155. */
  114156. protected _altKey: boolean;
  114157. protected _ctrlKey: boolean;
  114158. protected _metaKey: boolean;
  114159. protected _shiftKey: boolean;
  114160. /**
  114161. * Which mouse buttons were pressed at time of last mouse event.
  114162. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  114163. */
  114164. protected _buttonsPressed: number;
  114165. /**
  114166. * Defines the buttons associated with the input to handle camera move.
  114167. */
  114168. buttons: number[];
  114169. /**
  114170. * Attach the input controls to a specific dom element to get the input from.
  114171. * @param element Defines the element the controls should be listened from
  114172. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  114173. */
  114174. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  114175. /**
  114176. * Detach the current controls from the specified dom element.
  114177. * @param element Defines the element to stop listening the inputs from
  114178. */
  114179. detachControl(element: Nullable<HTMLElement>): void;
  114180. /**
  114181. * Gets the class name of the current input.
  114182. * @returns the class name
  114183. */
  114184. getClassName(): string;
  114185. /**
  114186. * Get the friendly name associated with the input class.
  114187. * @returns the input friendly name
  114188. */
  114189. getSimpleName(): string;
  114190. /**
  114191. * Called on pointer POINTERDOUBLETAP event.
  114192. * Override this method to provide functionality on POINTERDOUBLETAP event.
  114193. */
  114194. protected onDoubleTap(type: string): void;
  114195. /**
  114196. * Called on pointer POINTERMOVE event if only a single touch is active.
  114197. * Override this method to provide functionality.
  114198. */
  114199. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  114200. /**
  114201. * Called on pointer POINTERMOVE event if multiple touches are active.
  114202. * Override this method to provide functionality.
  114203. */
  114204. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  114205. /**
  114206. * Called on JS contextmenu event.
  114207. * Override this method to provide functionality.
  114208. */
  114209. protected onContextMenu(evt: PointerEvent): void;
  114210. /**
  114211. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  114212. * press.
  114213. * Override this method to provide functionality.
  114214. */
  114215. protected onButtonDown(evt: PointerEvent): void;
  114216. /**
  114217. * Called each time a new POINTERUP event occurs. Ie, for each button
  114218. * release.
  114219. * Override this method to provide functionality.
  114220. */
  114221. protected onButtonUp(evt: PointerEvent): void;
  114222. /**
  114223. * Called when window becomes inactive.
  114224. * Override this method to provide functionality.
  114225. */
  114226. protected onLostFocus(): void;
  114227. private _pointerInput;
  114228. private _observer;
  114229. private _onLostFocus;
  114230. private pointA;
  114231. private pointB;
  114232. }
  114233. }
  114234. declare module BABYLON {
  114235. /**
  114236. * Manage the pointers inputs to control an arc rotate camera.
  114237. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  114238. */
  114239. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  114240. /**
  114241. * Defines the camera the input is attached to.
  114242. */
  114243. camera: ArcRotateCamera;
  114244. /**
  114245. * Gets the class name of the current input.
  114246. * @returns the class name
  114247. */
  114248. getClassName(): string;
  114249. /**
  114250. * Defines the buttons associated with the input to handle camera move.
  114251. */
  114252. buttons: number[];
  114253. /**
  114254. * Defines the pointer angular sensibility along the X axis or how fast is
  114255. * the camera rotating.
  114256. */
  114257. angularSensibilityX: number;
  114258. /**
  114259. * Defines the pointer angular sensibility along the Y axis or how fast is
  114260. * the camera rotating.
  114261. */
  114262. angularSensibilityY: number;
  114263. /**
  114264. * Defines the pointer pinch precision or how fast is the camera zooming.
  114265. */
  114266. pinchPrecision: number;
  114267. /**
  114268. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  114269. * from 0.
  114270. * It defines the percentage of current camera.radius to use as delta when
  114271. * pinch zoom is used.
  114272. */
  114273. pinchDeltaPercentage: number;
  114274. /**
  114275. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  114276. * that any object in the plane at the camera's target point will scale
  114277. * perfectly with finger motion.
  114278. * Overrides pinchDeltaPercentage and pinchPrecision.
  114279. */
  114280. useNaturalPinchZoom: boolean;
  114281. /**
  114282. * Defines the pointer panning sensibility or how fast is the camera moving.
  114283. */
  114284. panningSensibility: number;
  114285. /**
  114286. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  114287. */
  114288. multiTouchPanning: boolean;
  114289. /**
  114290. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  114291. * zoom (pinch) through multitouch.
  114292. */
  114293. multiTouchPanAndZoom: boolean;
  114294. /**
  114295. * Revers pinch action direction.
  114296. */
  114297. pinchInwards: boolean;
  114298. private _isPanClick;
  114299. private _twoFingerActivityCount;
  114300. private _isPinching;
  114301. /**
  114302. * Called on pointer POINTERMOVE event if only a single touch is active.
  114303. */
  114304. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  114305. /**
  114306. * Called on pointer POINTERDOUBLETAP event.
  114307. */
  114308. protected onDoubleTap(type: string): void;
  114309. /**
  114310. * Called on pointer POINTERMOVE event if multiple touches are active.
  114311. */
  114312. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  114313. /**
  114314. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  114315. * press.
  114316. */
  114317. protected onButtonDown(evt: PointerEvent): void;
  114318. /**
  114319. * Called each time a new POINTERUP event occurs. Ie, for each button
  114320. * release.
  114321. */
  114322. protected onButtonUp(evt: PointerEvent): void;
  114323. /**
  114324. * Called when window becomes inactive.
  114325. */
  114326. protected onLostFocus(): void;
  114327. }
  114328. }
  114329. declare module BABYLON {
  114330. /**
  114331. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  114332. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  114333. */
  114334. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  114335. /**
  114336. * Defines the camera the input is attached to.
  114337. */
  114338. camera: ArcRotateCamera;
  114339. /**
  114340. * Defines the list of key codes associated with the up action (increase alpha)
  114341. */
  114342. keysUp: number[];
  114343. /**
  114344. * Defines the list of key codes associated with the down action (decrease alpha)
  114345. */
  114346. keysDown: number[];
  114347. /**
  114348. * Defines the list of key codes associated with the left action (increase beta)
  114349. */
  114350. keysLeft: number[];
  114351. /**
  114352. * Defines the list of key codes associated with the right action (decrease beta)
  114353. */
  114354. keysRight: number[];
  114355. /**
  114356. * Defines the list of key codes associated with the reset action.
  114357. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  114358. */
  114359. keysReset: number[];
  114360. /**
  114361. * Defines the panning sensibility of the inputs.
  114362. * (How fast is the camera panning)
  114363. */
  114364. panningSensibility: number;
  114365. /**
  114366. * Defines the zooming sensibility of the inputs.
  114367. * (How fast is the camera zooming)
  114368. */
  114369. zoomingSensibility: number;
  114370. /**
  114371. * Defines whether maintaining the alt key down switch the movement mode from
  114372. * orientation to zoom.
  114373. */
  114374. useAltToZoom: boolean;
  114375. /**
  114376. * Rotation speed of the camera
  114377. */
  114378. angularSpeed: number;
  114379. private _keys;
  114380. private _ctrlPressed;
  114381. private _altPressed;
  114382. private _onCanvasBlurObserver;
  114383. private _onKeyboardObserver;
  114384. private _engine;
  114385. private _scene;
  114386. /**
  114387. * Attach the input controls to a specific dom element to get the input from.
  114388. * @param element Defines the element the controls should be listened from
  114389. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  114390. */
  114391. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  114392. /**
  114393. * Detach the current controls from the specified dom element.
  114394. * @param element Defines the element to stop listening the inputs from
  114395. */
  114396. detachControl(element: Nullable<HTMLElement>): void;
  114397. /**
  114398. * Update the current camera state depending on the inputs that have been used this frame.
  114399. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  114400. */
  114401. checkInputs(): void;
  114402. /**
  114403. * Gets the class name of the current intput.
  114404. * @returns the class name
  114405. */
  114406. getClassName(): string;
  114407. /**
  114408. * Get the friendly name associated with the input class.
  114409. * @returns the input friendly name
  114410. */
  114411. getSimpleName(): string;
  114412. }
  114413. }
  114414. declare module BABYLON {
  114415. /**
  114416. * Manage the mouse wheel inputs to control an arc rotate camera.
  114417. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  114418. */
  114419. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  114420. /**
  114421. * Defines the camera the input is attached to.
  114422. */
  114423. camera: ArcRotateCamera;
  114424. /**
  114425. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  114426. */
  114427. wheelPrecision: number;
  114428. /**
  114429. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  114430. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  114431. */
  114432. wheelDeltaPercentage: number;
  114433. private _wheel;
  114434. private _observer;
  114435. private computeDeltaFromMouseWheelLegacyEvent;
  114436. /**
  114437. * Attach the input controls to a specific dom element to get the input from.
  114438. * @param element Defines the element the controls should be listened from
  114439. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  114440. */
  114441. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  114442. /**
  114443. * Detach the current controls from the specified dom element.
  114444. * @param element Defines the element to stop listening the inputs from
  114445. */
  114446. detachControl(element: Nullable<HTMLElement>): void;
  114447. /**
  114448. * Gets the class name of the current intput.
  114449. * @returns the class name
  114450. */
  114451. getClassName(): string;
  114452. /**
  114453. * Get the friendly name associated with the input class.
  114454. * @returns the input friendly name
  114455. */
  114456. getSimpleName(): string;
  114457. }
  114458. }
  114459. declare module BABYLON {
  114460. /**
  114461. * Default Inputs manager for the ArcRotateCamera.
  114462. * It groups all the default supported inputs for ease of use.
  114463. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  114464. */
  114465. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  114466. /**
  114467. * Instantiates a new ArcRotateCameraInputsManager.
  114468. * @param camera Defines the camera the inputs belong to
  114469. */
  114470. constructor(camera: ArcRotateCamera);
  114471. /**
  114472. * Add mouse wheel input support to the input manager.
  114473. * @returns the current input manager
  114474. */
  114475. addMouseWheel(): ArcRotateCameraInputsManager;
  114476. /**
  114477. * Add pointers input support to the input manager.
  114478. * @returns the current input manager
  114479. */
  114480. addPointers(): ArcRotateCameraInputsManager;
  114481. /**
  114482. * Add keyboard input support to the input manager.
  114483. * @returns the current input manager
  114484. */
  114485. addKeyboard(): ArcRotateCameraInputsManager;
  114486. }
  114487. }
  114488. declare module BABYLON {
  114489. /**
  114490. * This represents an orbital type of camera.
  114491. *
  114492. * 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.
  114493. * 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.
  114494. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  114495. */
  114496. export class ArcRotateCamera extends TargetCamera {
  114497. /**
  114498. * Defines the rotation angle of the camera along the longitudinal axis.
  114499. */
  114500. alpha: number;
  114501. /**
  114502. * Defines the rotation angle of the camera along the latitudinal axis.
  114503. */
  114504. beta: number;
  114505. /**
  114506. * Defines the radius of the camera from it s target point.
  114507. */
  114508. radius: number;
  114509. protected _target: Vector3;
  114510. protected _targetHost: Nullable<AbstractMesh>;
  114511. /**
  114512. * Defines the target point of the camera.
  114513. * The camera looks towards it form the radius distance.
  114514. */
  114515. get target(): Vector3;
  114516. set target(value: Vector3);
  114517. /**
  114518. * Define the current local position of the camera in the scene
  114519. */
  114520. get position(): Vector3;
  114521. set position(newPosition: Vector3);
  114522. protected _upVector: Vector3;
  114523. protected _upToYMatrix: Matrix;
  114524. protected _YToUpMatrix: Matrix;
  114525. /**
  114526. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  114527. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  114528. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  114529. */
  114530. set upVector(vec: Vector3);
  114531. get upVector(): Vector3;
  114532. /**
  114533. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  114534. */
  114535. setMatUp(): void;
  114536. /**
  114537. * Current inertia value on the longitudinal axis.
  114538. * The bigger this number the longer it will take for the camera to stop.
  114539. */
  114540. inertialAlphaOffset: number;
  114541. /**
  114542. * Current inertia value on the latitudinal axis.
  114543. * The bigger this number the longer it will take for the camera to stop.
  114544. */
  114545. inertialBetaOffset: number;
  114546. /**
  114547. * Current inertia value on the radius axis.
  114548. * The bigger this number the longer it will take for the camera to stop.
  114549. */
  114550. inertialRadiusOffset: number;
  114551. /**
  114552. * Minimum allowed angle on the longitudinal axis.
  114553. * This can help limiting how the Camera is able to move in the scene.
  114554. */
  114555. lowerAlphaLimit: Nullable<number>;
  114556. /**
  114557. * Maximum allowed angle on the longitudinal axis.
  114558. * This can help limiting how the Camera is able to move in the scene.
  114559. */
  114560. upperAlphaLimit: Nullable<number>;
  114561. /**
  114562. * Minimum allowed angle on the latitudinal axis.
  114563. * This can help limiting how the Camera is able to move in the scene.
  114564. */
  114565. lowerBetaLimit: number;
  114566. /**
  114567. * Maximum allowed angle on the latitudinal axis.
  114568. * This can help limiting how the Camera is able to move in the scene.
  114569. */
  114570. upperBetaLimit: number;
  114571. /**
  114572. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  114573. * This can help limiting how the Camera is able to move in the scene.
  114574. */
  114575. lowerRadiusLimit: Nullable<number>;
  114576. /**
  114577. * Maximum allowed distance of the camera to the target (The camera can not get further).
  114578. * This can help limiting how the Camera is able to move in the scene.
  114579. */
  114580. upperRadiusLimit: Nullable<number>;
  114581. /**
  114582. * Defines the current inertia value used during panning of the camera along the X axis.
  114583. */
  114584. inertialPanningX: number;
  114585. /**
  114586. * Defines the current inertia value used during panning of the camera along the Y axis.
  114587. */
  114588. inertialPanningY: number;
  114589. /**
  114590. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  114591. * Basically if your fingers moves away from more than this distance you will be considered
  114592. * in pinch mode.
  114593. */
  114594. pinchToPanMaxDistance: number;
  114595. /**
  114596. * Defines the maximum distance the camera can pan.
  114597. * This could help keeping the cammera always in your scene.
  114598. */
  114599. panningDistanceLimit: Nullable<number>;
  114600. /**
  114601. * Defines the target of the camera before paning.
  114602. */
  114603. panningOriginTarget: Vector3;
  114604. /**
  114605. * Defines the value of the inertia used during panning.
  114606. * 0 would mean stop inertia and one would mean no decelleration at all.
  114607. */
  114608. panningInertia: number;
  114609. /**
  114610. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  114611. */
  114612. get angularSensibilityX(): number;
  114613. set angularSensibilityX(value: number);
  114614. /**
  114615. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  114616. */
  114617. get angularSensibilityY(): number;
  114618. set angularSensibilityY(value: number);
  114619. /**
  114620. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  114621. */
  114622. get pinchPrecision(): number;
  114623. set pinchPrecision(value: number);
  114624. /**
  114625. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  114626. * It will be used instead of pinchDeltaPrecision if different from 0.
  114627. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  114628. */
  114629. get pinchDeltaPercentage(): number;
  114630. set pinchDeltaPercentage(value: number);
  114631. /**
  114632. * Gets or Set the pointer use natural pinch zoom to override the pinch precision
  114633. * and pinch delta percentage.
  114634. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  114635. * that any object in the plane at the camera's target point will scale
  114636. * perfectly with finger motion.
  114637. */
  114638. get useNaturalPinchZoom(): boolean;
  114639. set useNaturalPinchZoom(value: boolean);
  114640. /**
  114641. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  114642. */
  114643. get panningSensibility(): number;
  114644. set panningSensibility(value: number);
  114645. /**
  114646. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  114647. */
  114648. get keysUp(): number[];
  114649. set keysUp(value: number[]);
  114650. /**
  114651. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  114652. */
  114653. get keysDown(): number[];
  114654. set keysDown(value: number[]);
  114655. /**
  114656. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  114657. */
  114658. get keysLeft(): number[];
  114659. set keysLeft(value: number[]);
  114660. /**
  114661. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  114662. */
  114663. get keysRight(): number[];
  114664. set keysRight(value: number[]);
  114665. /**
  114666. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  114667. */
  114668. get wheelPrecision(): number;
  114669. set wheelPrecision(value: number);
  114670. /**
  114671. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  114672. * It will be used instead of pinchDeltaPrecision if different from 0.
  114673. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  114674. */
  114675. get wheelDeltaPercentage(): number;
  114676. set wheelDeltaPercentage(value: number);
  114677. /**
  114678. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  114679. */
  114680. zoomOnFactor: number;
  114681. /**
  114682. * Defines a screen offset for the camera position.
  114683. */
  114684. targetScreenOffset: Vector2;
  114685. /**
  114686. * Allows the camera to be completely reversed.
  114687. * If false the camera can not arrive upside down.
  114688. */
  114689. allowUpsideDown: boolean;
  114690. /**
  114691. * Define if double tap/click is used to restore the previously saved state of the camera.
  114692. */
  114693. useInputToRestoreState: boolean;
  114694. /** @hidden */
  114695. _viewMatrix: Matrix;
  114696. /** @hidden */
  114697. _useCtrlForPanning: boolean;
  114698. /** @hidden */
  114699. _panningMouseButton: number;
  114700. /**
  114701. * Defines the input associated to the camera.
  114702. */
  114703. inputs: ArcRotateCameraInputsManager;
  114704. /** @hidden */
  114705. _reset: () => void;
  114706. /**
  114707. * Defines the allowed panning axis.
  114708. */
  114709. panningAxis: Vector3;
  114710. protected _localDirection: Vector3;
  114711. protected _transformedDirection: Vector3;
  114712. private _bouncingBehavior;
  114713. /**
  114714. * Gets the bouncing behavior of the camera if it has been enabled.
  114715. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  114716. */
  114717. get bouncingBehavior(): Nullable<BouncingBehavior>;
  114718. /**
  114719. * Defines if the bouncing behavior of the camera is enabled on the camera.
  114720. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  114721. */
  114722. get useBouncingBehavior(): boolean;
  114723. set useBouncingBehavior(value: boolean);
  114724. private _framingBehavior;
  114725. /**
  114726. * Gets the framing behavior of the camera if it has been enabled.
  114727. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  114728. */
  114729. get framingBehavior(): Nullable<FramingBehavior>;
  114730. /**
  114731. * Defines if the framing behavior of the camera is enabled on the camera.
  114732. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  114733. */
  114734. get useFramingBehavior(): boolean;
  114735. set useFramingBehavior(value: boolean);
  114736. private _autoRotationBehavior;
  114737. /**
  114738. * Gets the auto rotation behavior of the camera if it has been enabled.
  114739. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  114740. */
  114741. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  114742. /**
  114743. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  114744. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  114745. */
  114746. get useAutoRotationBehavior(): boolean;
  114747. set useAutoRotationBehavior(value: boolean);
  114748. /**
  114749. * Observable triggered when the mesh target has been changed on the camera.
  114750. */
  114751. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  114752. /**
  114753. * Event raised when the camera is colliding with a mesh.
  114754. */
  114755. onCollide: (collidedMesh: AbstractMesh) => void;
  114756. /**
  114757. * Defines whether the camera should check collision with the objects oh the scene.
  114758. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  114759. */
  114760. checkCollisions: boolean;
  114761. /**
  114762. * Defines the collision radius of the camera.
  114763. * This simulates a sphere around the camera.
  114764. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  114765. */
  114766. collisionRadius: Vector3;
  114767. protected _collider: Collider;
  114768. protected _previousPosition: Vector3;
  114769. protected _collisionVelocity: Vector3;
  114770. protected _newPosition: Vector3;
  114771. protected _previousAlpha: number;
  114772. protected _previousBeta: number;
  114773. protected _previousRadius: number;
  114774. protected _collisionTriggered: boolean;
  114775. protected _targetBoundingCenter: Nullable<Vector3>;
  114776. private _computationVector;
  114777. /**
  114778. * Instantiates a new ArcRotateCamera in a given scene
  114779. * @param name Defines the name of the camera
  114780. * @param alpha Defines the camera rotation along the logitudinal axis
  114781. * @param beta Defines the camera rotation along the latitudinal axis
  114782. * @param radius Defines the camera distance from its target
  114783. * @param target Defines the camera target
  114784. * @param scene Defines the scene the camera belongs to
  114785. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  114786. */
  114787. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  114788. /** @hidden */
  114789. _initCache(): void;
  114790. /** @hidden */
  114791. _updateCache(ignoreParentClass?: boolean): void;
  114792. protected _getTargetPosition(): Vector3;
  114793. private _storedAlpha;
  114794. private _storedBeta;
  114795. private _storedRadius;
  114796. private _storedTarget;
  114797. private _storedTargetScreenOffset;
  114798. /**
  114799. * Stores the current state of the camera (alpha, beta, radius and target)
  114800. * @returns the camera itself
  114801. */
  114802. storeState(): Camera;
  114803. /**
  114804. * @hidden
  114805. * Restored camera state. You must call storeState() first
  114806. */
  114807. _restoreStateValues(): boolean;
  114808. /** @hidden */
  114809. _isSynchronizedViewMatrix(): boolean;
  114810. /**
  114811. * Attached controls to the current camera.
  114812. * @param element Defines the element the controls should be listened from
  114813. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  114814. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  114815. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  114816. */
  114817. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  114818. /**
  114819. * Detach the current controls from the camera.
  114820. * The camera will stop reacting to inputs.
  114821. * @param element Defines the element to stop listening the inputs from
  114822. */
  114823. detachControl(element: HTMLElement): void;
  114824. /** @hidden */
  114825. _checkInputs(): void;
  114826. protected _checkLimits(): void;
  114827. /**
  114828. * Rebuilds angles (alpha, beta) and radius from the give position and target
  114829. */
  114830. rebuildAnglesAndRadius(): void;
  114831. /**
  114832. * Use a position to define the current camera related information like alpha, beta and radius
  114833. * @param position Defines the position to set the camera at
  114834. */
  114835. setPosition(position: Vector3): void;
  114836. /**
  114837. * Defines the target the camera should look at.
  114838. * This will automatically adapt alpha beta and radius to fit within the new target.
  114839. * @param target Defines the new target as a Vector or a mesh
  114840. * @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
  114841. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  114842. */
  114843. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  114844. /** @hidden */
  114845. _getViewMatrix(): Matrix;
  114846. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  114847. /**
  114848. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  114849. * @param meshes Defines the mesh to zoom on
  114850. * @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)
  114851. */
  114852. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  114853. /**
  114854. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  114855. * The target will be changed but the radius
  114856. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  114857. * @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)
  114858. */
  114859. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  114860. min: Vector3;
  114861. max: Vector3;
  114862. distance: number;
  114863. }, doNotUpdateMaxZ?: boolean): void;
  114864. /**
  114865. * @override
  114866. * Override Camera.createRigCamera
  114867. */
  114868. createRigCamera(name: string, cameraIndex: number): Camera;
  114869. /**
  114870. * @hidden
  114871. * @override
  114872. * Override Camera._updateRigCameras
  114873. */
  114874. _updateRigCameras(): void;
  114875. /**
  114876. * Destroy the camera and release the current resources hold by it.
  114877. */
  114878. dispose(): void;
  114879. /**
  114880. * Gets the current object class name.
  114881. * @return the class name
  114882. */
  114883. getClassName(): string;
  114884. }
  114885. }
  114886. declare module BABYLON {
  114887. /**
  114888. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  114889. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  114890. */
  114891. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  114892. /**
  114893. * Gets the name of the behavior.
  114894. */
  114895. get name(): string;
  114896. private _zoomStopsAnimation;
  114897. private _idleRotationSpeed;
  114898. private _idleRotationWaitTime;
  114899. private _idleRotationSpinupTime;
  114900. /**
  114901. * Sets the flag that indicates if user zooming should stop animation.
  114902. */
  114903. set zoomStopsAnimation(flag: boolean);
  114904. /**
  114905. * Gets the flag that indicates if user zooming should stop animation.
  114906. */
  114907. get zoomStopsAnimation(): boolean;
  114908. /**
  114909. * Sets the default speed at which the camera rotates around the model.
  114910. */
  114911. set idleRotationSpeed(speed: number);
  114912. /**
  114913. * Gets the default speed at which the camera rotates around the model.
  114914. */
  114915. get idleRotationSpeed(): number;
  114916. /**
  114917. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  114918. */
  114919. set idleRotationWaitTime(time: number);
  114920. /**
  114921. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  114922. */
  114923. get idleRotationWaitTime(): number;
  114924. /**
  114925. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  114926. */
  114927. set idleRotationSpinupTime(time: number);
  114928. /**
  114929. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  114930. */
  114931. get idleRotationSpinupTime(): number;
  114932. /**
  114933. * Gets a value indicating if the camera is currently rotating because of this behavior
  114934. */
  114935. get rotationInProgress(): boolean;
  114936. private _onPrePointerObservableObserver;
  114937. private _onAfterCheckInputsObserver;
  114938. private _attachedCamera;
  114939. private _isPointerDown;
  114940. private _lastFrameTime;
  114941. private _lastInteractionTime;
  114942. private _cameraRotationSpeed;
  114943. /**
  114944. * Initializes the behavior.
  114945. */
  114946. init(): void;
  114947. /**
  114948. * Attaches the behavior to its arc rotate camera.
  114949. * @param camera Defines the camera to attach the behavior to
  114950. */
  114951. attach(camera: ArcRotateCamera): void;
  114952. /**
  114953. * Detaches the behavior from its current arc rotate camera.
  114954. */
  114955. detach(): void;
  114956. /**
  114957. * Returns true if user is scrolling.
  114958. * @return true if user is scrolling.
  114959. */
  114960. private _userIsZooming;
  114961. private _lastFrameRadius;
  114962. private _shouldAnimationStopForInteraction;
  114963. /**
  114964. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  114965. */
  114966. private _applyUserInteraction;
  114967. private _userIsMoving;
  114968. }
  114969. }
  114970. declare module BABYLON {
  114971. /**
  114972. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  114973. */
  114974. export class AttachToBoxBehavior implements Behavior<Mesh> {
  114975. private ui;
  114976. /**
  114977. * The name of the behavior
  114978. */
  114979. name: string;
  114980. /**
  114981. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  114982. */
  114983. distanceAwayFromFace: number;
  114984. /**
  114985. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  114986. */
  114987. distanceAwayFromBottomOfFace: number;
  114988. private _faceVectors;
  114989. private _target;
  114990. private _scene;
  114991. private _onRenderObserver;
  114992. private _tmpMatrix;
  114993. private _tmpVector;
  114994. /**
  114995. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  114996. * @param ui The transform node that should be attched to the mesh
  114997. */
  114998. constructor(ui: TransformNode);
  114999. /**
  115000. * Initializes the behavior
  115001. */
  115002. init(): void;
  115003. private _closestFace;
  115004. private _zeroVector;
  115005. private _lookAtTmpMatrix;
  115006. private _lookAtToRef;
  115007. /**
  115008. * Attaches the AttachToBoxBehavior to the passed in mesh
  115009. * @param target The mesh that the specified node will be attached to
  115010. */
  115011. attach(target: Mesh): void;
  115012. /**
  115013. * Detaches the behavior from the mesh
  115014. */
  115015. detach(): void;
  115016. }
  115017. }
  115018. declare module BABYLON {
  115019. /**
  115020. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  115021. */
  115022. export class FadeInOutBehavior implements Behavior<Mesh> {
  115023. /**
  115024. * Time in milliseconds to delay before fading in (Default: 0)
  115025. */
  115026. delay: number;
  115027. /**
  115028. * Time in milliseconds for the mesh to fade in (Default: 300)
  115029. */
  115030. fadeInTime: number;
  115031. private _millisecondsPerFrame;
  115032. private _hovered;
  115033. private _hoverValue;
  115034. private _ownerNode;
  115035. /**
  115036. * Instatiates the FadeInOutBehavior
  115037. */
  115038. constructor();
  115039. /**
  115040. * The name of the behavior
  115041. */
  115042. get name(): string;
  115043. /**
  115044. * Initializes the behavior
  115045. */
  115046. init(): void;
  115047. /**
  115048. * Attaches the fade behavior on the passed in mesh
  115049. * @param ownerNode The mesh that will be faded in/out once attached
  115050. */
  115051. attach(ownerNode: Mesh): void;
  115052. /**
  115053. * Detaches the behavior from the mesh
  115054. */
  115055. detach(): void;
  115056. /**
  115057. * Triggers the mesh to begin fading in or out
  115058. * @param value if the object should fade in or out (true to fade in)
  115059. */
  115060. fadeIn(value: boolean): void;
  115061. private _update;
  115062. private _setAllVisibility;
  115063. }
  115064. }
  115065. declare module BABYLON {
  115066. /**
  115067. * Class containing a set of static utilities functions for managing Pivots
  115068. * @hidden
  115069. */
  115070. export class PivotTools {
  115071. private static _PivotCached;
  115072. private static _OldPivotPoint;
  115073. private static _PivotTranslation;
  115074. private static _PivotTmpVector;
  115075. /** @hidden */
  115076. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  115077. /** @hidden */
  115078. static _RestorePivotPoint(mesh: AbstractMesh): void;
  115079. }
  115080. }
  115081. declare module BABYLON {
  115082. /**
  115083. * Class containing static functions to help procedurally build meshes
  115084. */
  115085. export class PlaneBuilder {
  115086. /**
  115087. * Creates a plane mesh
  115088. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  115089. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  115090. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  115091. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  115092. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  115093. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  115094. * @param name defines the name of the mesh
  115095. * @param options defines the options used to create the mesh
  115096. * @param scene defines the hosting scene
  115097. * @returns the plane mesh
  115098. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  115099. */
  115100. static CreatePlane(name: string, options: {
  115101. size?: number;
  115102. width?: number;
  115103. height?: number;
  115104. sideOrientation?: number;
  115105. frontUVs?: Vector4;
  115106. backUVs?: Vector4;
  115107. updatable?: boolean;
  115108. sourcePlane?: Plane;
  115109. }, scene?: Nullable<Scene>): Mesh;
  115110. }
  115111. }
  115112. declare module BABYLON {
  115113. /**
  115114. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  115115. */
  115116. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  115117. private static _AnyMouseID;
  115118. /**
  115119. * Abstract mesh the behavior is set on
  115120. */
  115121. attachedNode: AbstractMesh;
  115122. private _dragPlane;
  115123. private _scene;
  115124. private _pointerObserver;
  115125. private _beforeRenderObserver;
  115126. private static _planeScene;
  115127. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  115128. /**
  115129. * 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)
  115130. */
  115131. maxDragAngle: number;
  115132. /**
  115133. * @hidden
  115134. */
  115135. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  115136. /**
  115137. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  115138. */
  115139. currentDraggingPointerID: number;
  115140. /**
  115141. * The last position where the pointer hit the drag plane in world space
  115142. */
  115143. lastDragPosition: Vector3;
  115144. /**
  115145. * If the behavior is currently in a dragging state
  115146. */
  115147. dragging: boolean;
  115148. /**
  115149. * 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)
  115150. */
  115151. dragDeltaRatio: number;
  115152. /**
  115153. * If the drag plane orientation should be updated during the dragging (Default: true)
  115154. */
  115155. updateDragPlane: boolean;
  115156. private _debugMode;
  115157. private _moving;
  115158. /**
  115159. * Fires each time the attached mesh is dragged with the pointer
  115160. * * delta between last drag position and current drag position in world space
  115161. * * dragDistance along the drag axis
  115162. * * dragPlaneNormal normal of the current drag plane used during the drag
  115163. * * dragPlanePoint in world space where the drag intersects the drag plane
  115164. */
  115165. onDragObservable: Observable<{
  115166. delta: Vector3;
  115167. dragPlanePoint: Vector3;
  115168. dragPlaneNormal: Vector3;
  115169. dragDistance: number;
  115170. pointerId: number;
  115171. }>;
  115172. /**
  115173. * Fires each time a drag begins (eg. mouse down on mesh)
  115174. */
  115175. onDragStartObservable: Observable<{
  115176. dragPlanePoint: Vector3;
  115177. pointerId: number;
  115178. }>;
  115179. /**
  115180. * Fires each time a drag ends (eg. mouse release after drag)
  115181. */
  115182. onDragEndObservable: Observable<{
  115183. dragPlanePoint: Vector3;
  115184. pointerId: number;
  115185. }>;
  115186. /**
  115187. * If the attached mesh should be moved when dragged
  115188. */
  115189. moveAttached: boolean;
  115190. /**
  115191. * If the drag behavior will react to drag events (Default: true)
  115192. */
  115193. enabled: boolean;
  115194. /**
  115195. * If pointer events should start and release the drag (Default: true)
  115196. */
  115197. startAndReleaseDragOnPointerEvents: boolean;
  115198. /**
  115199. * If camera controls should be detached during the drag
  115200. */
  115201. detachCameraControls: boolean;
  115202. /**
  115203. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  115204. */
  115205. useObjectOrientationForDragging: boolean;
  115206. private _options;
  115207. /**
  115208. * Gets the options used by the behavior
  115209. */
  115210. get options(): {
  115211. dragAxis?: Vector3;
  115212. dragPlaneNormal?: Vector3;
  115213. };
  115214. /**
  115215. * Sets the options used by the behavior
  115216. */
  115217. set options(options: {
  115218. dragAxis?: Vector3;
  115219. dragPlaneNormal?: Vector3;
  115220. });
  115221. /**
  115222. * Creates a pointer drag behavior that can be attached to a mesh
  115223. * @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)
  115224. */
  115225. constructor(options?: {
  115226. dragAxis?: Vector3;
  115227. dragPlaneNormal?: Vector3;
  115228. });
  115229. /**
  115230. * Predicate to determine if it is valid to move the object to a new position when it is moved
  115231. */
  115232. validateDrag: (targetPosition: Vector3) => boolean;
  115233. /**
  115234. * The name of the behavior
  115235. */
  115236. get name(): string;
  115237. /**
  115238. * Initializes the behavior
  115239. */
  115240. init(): void;
  115241. private _tmpVector;
  115242. private _alternatePickedPoint;
  115243. private _worldDragAxis;
  115244. private _targetPosition;
  115245. private _attachedElement;
  115246. /**
  115247. * Attaches the drag behavior the passed in mesh
  115248. * @param ownerNode The mesh that will be dragged around once attached
  115249. * @param predicate Predicate to use for pick filtering
  115250. */
  115251. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  115252. /**
  115253. * Force relase the drag action by code.
  115254. */
  115255. releaseDrag(): void;
  115256. private _startDragRay;
  115257. private _lastPointerRay;
  115258. /**
  115259. * Simulates the start of a pointer drag event on the behavior
  115260. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  115261. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  115262. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  115263. */
  115264. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  115265. private _startDrag;
  115266. private _dragDelta;
  115267. private _moveDrag;
  115268. private _pickWithRayOnDragPlane;
  115269. private _pointA;
  115270. private _pointB;
  115271. private _pointC;
  115272. private _lineA;
  115273. private _lineB;
  115274. private _localAxis;
  115275. private _lookAt;
  115276. private _updateDragPlanePosition;
  115277. /**
  115278. * Detaches the behavior from the mesh
  115279. */
  115280. detach(): void;
  115281. }
  115282. }
  115283. declare module BABYLON {
  115284. /**
  115285. * A behavior that when attached to a mesh will allow the mesh to be scaled
  115286. */
  115287. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  115288. private _dragBehaviorA;
  115289. private _dragBehaviorB;
  115290. private _startDistance;
  115291. private _initialScale;
  115292. private _targetScale;
  115293. private _ownerNode;
  115294. private _sceneRenderObserver;
  115295. /**
  115296. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  115297. */
  115298. constructor();
  115299. /**
  115300. * The name of the behavior
  115301. */
  115302. get name(): string;
  115303. /**
  115304. * Initializes the behavior
  115305. */
  115306. init(): void;
  115307. private _getCurrentDistance;
  115308. /**
  115309. * Attaches the scale behavior the passed in mesh
  115310. * @param ownerNode The mesh that will be scaled around once attached
  115311. */
  115312. attach(ownerNode: Mesh): void;
  115313. /**
  115314. * Detaches the behavior from the mesh
  115315. */
  115316. detach(): void;
  115317. }
  115318. }
  115319. declare module BABYLON {
  115320. /**
  115321. * 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
  115322. */
  115323. export class SixDofDragBehavior implements Behavior<Mesh> {
  115324. private static _virtualScene;
  115325. private _ownerNode;
  115326. private _sceneRenderObserver;
  115327. private _scene;
  115328. private _targetPosition;
  115329. private _virtualOriginMesh;
  115330. private _virtualDragMesh;
  115331. private _pointerObserver;
  115332. private _moving;
  115333. private _startingOrientation;
  115334. private _attachedElement;
  115335. /**
  115336. * 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)
  115337. */
  115338. private zDragFactor;
  115339. /**
  115340. * If the object should rotate to face the drag origin
  115341. */
  115342. rotateDraggedObject: boolean;
  115343. /**
  115344. * If the behavior is currently in a dragging state
  115345. */
  115346. dragging: boolean;
  115347. /**
  115348. * 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)
  115349. */
  115350. dragDeltaRatio: number;
  115351. /**
  115352. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  115353. */
  115354. currentDraggingPointerID: number;
  115355. /**
  115356. * If camera controls should be detached during the drag
  115357. */
  115358. detachCameraControls: boolean;
  115359. /**
  115360. * Fires each time a drag starts
  115361. */
  115362. onDragStartObservable: Observable<{}>;
  115363. /**
  115364. * Fires each time a drag ends (eg. mouse release after drag)
  115365. */
  115366. onDragEndObservable: Observable<{}>;
  115367. /**
  115368. * 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
  115369. */
  115370. constructor();
  115371. /**
  115372. * The name of the behavior
  115373. */
  115374. get name(): string;
  115375. /**
  115376. * Initializes the behavior
  115377. */
  115378. init(): void;
  115379. /**
  115380. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  115381. */
  115382. private get _pointerCamera();
  115383. /**
  115384. * Attaches the scale behavior the passed in mesh
  115385. * @param ownerNode The mesh that will be scaled around once attached
  115386. */
  115387. attach(ownerNode: Mesh): void;
  115388. /**
  115389. * Detaches the behavior from the mesh
  115390. */
  115391. detach(): void;
  115392. }
  115393. }
  115394. declare module BABYLON {
  115395. /**
  115396. * Class used to apply inverse kinematics to bones
  115397. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  115398. */
  115399. export class BoneIKController {
  115400. private static _tmpVecs;
  115401. private static _tmpQuat;
  115402. private static _tmpMats;
  115403. /**
  115404. * Gets or sets the target mesh
  115405. */
  115406. targetMesh: AbstractMesh;
  115407. /** Gets or sets the mesh used as pole */
  115408. poleTargetMesh: AbstractMesh;
  115409. /**
  115410. * Gets or sets the bone used as pole
  115411. */
  115412. poleTargetBone: Nullable<Bone>;
  115413. /**
  115414. * Gets or sets the target position
  115415. */
  115416. targetPosition: Vector3;
  115417. /**
  115418. * Gets or sets the pole target position
  115419. */
  115420. poleTargetPosition: Vector3;
  115421. /**
  115422. * Gets or sets the pole target local offset
  115423. */
  115424. poleTargetLocalOffset: Vector3;
  115425. /**
  115426. * Gets or sets the pole angle
  115427. */
  115428. poleAngle: number;
  115429. /**
  115430. * Gets or sets the mesh associated with the controller
  115431. */
  115432. mesh: AbstractMesh;
  115433. /**
  115434. * 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)
  115435. */
  115436. slerpAmount: number;
  115437. private _bone1Quat;
  115438. private _bone1Mat;
  115439. private _bone2Ang;
  115440. private _bone1;
  115441. private _bone2;
  115442. private _bone1Length;
  115443. private _bone2Length;
  115444. private _maxAngle;
  115445. private _maxReach;
  115446. private _rightHandedSystem;
  115447. private _bendAxis;
  115448. private _slerping;
  115449. private _adjustRoll;
  115450. /**
  115451. * Gets or sets maximum allowed angle
  115452. */
  115453. get maxAngle(): number;
  115454. set maxAngle(value: number);
  115455. /**
  115456. * Creates a new BoneIKController
  115457. * @param mesh defines the mesh to control
  115458. * @param bone defines the bone to control
  115459. * @param options defines options to set up the controller
  115460. */
  115461. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  115462. targetMesh?: AbstractMesh;
  115463. poleTargetMesh?: AbstractMesh;
  115464. poleTargetBone?: Bone;
  115465. poleTargetLocalOffset?: Vector3;
  115466. poleAngle?: number;
  115467. bendAxis?: Vector3;
  115468. maxAngle?: number;
  115469. slerpAmount?: number;
  115470. });
  115471. private _setMaxAngle;
  115472. /**
  115473. * Force the controller to update the bones
  115474. */
  115475. update(): void;
  115476. }
  115477. }
  115478. declare module BABYLON {
  115479. /**
  115480. * Class used to make a bone look toward a point in space
  115481. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  115482. */
  115483. export class BoneLookController {
  115484. private static _tmpVecs;
  115485. private static _tmpQuat;
  115486. private static _tmpMats;
  115487. /**
  115488. * The target Vector3 that the bone will look at
  115489. */
  115490. target: Vector3;
  115491. /**
  115492. * The mesh that the bone is attached to
  115493. */
  115494. mesh: AbstractMesh;
  115495. /**
  115496. * The bone that will be looking to the target
  115497. */
  115498. bone: Bone;
  115499. /**
  115500. * The up axis of the coordinate system that is used when the bone is rotated
  115501. */
  115502. upAxis: Vector3;
  115503. /**
  115504. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  115505. */
  115506. upAxisSpace: Space;
  115507. /**
  115508. * Used to make an adjustment to the yaw of the bone
  115509. */
  115510. adjustYaw: number;
  115511. /**
  115512. * Used to make an adjustment to the pitch of the bone
  115513. */
  115514. adjustPitch: number;
  115515. /**
  115516. * Used to make an adjustment to the roll of the bone
  115517. */
  115518. adjustRoll: number;
  115519. /**
  115520. * 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)
  115521. */
  115522. slerpAmount: number;
  115523. private _minYaw;
  115524. private _maxYaw;
  115525. private _minPitch;
  115526. private _maxPitch;
  115527. private _minYawSin;
  115528. private _minYawCos;
  115529. private _maxYawSin;
  115530. private _maxYawCos;
  115531. private _midYawConstraint;
  115532. private _minPitchTan;
  115533. private _maxPitchTan;
  115534. private _boneQuat;
  115535. private _slerping;
  115536. private _transformYawPitch;
  115537. private _transformYawPitchInv;
  115538. private _firstFrameSkipped;
  115539. private _yawRange;
  115540. private _fowardAxis;
  115541. /**
  115542. * Gets or sets the minimum yaw angle that the bone can look to
  115543. */
  115544. get minYaw(): number;
  115545. set minYaw(value: number);
  115546. /**
  115547. * Gets or sets the maximum yaw angle that the bone can look to
  115548. */
  115549. get maxYaw(): number;
  115550. set maxYaw(value: number);
  115551. /**
  115552. * Gets or sets the minimum pitch angle that the bone can look to
  115553. */
  115554. get minPitch(): number;
  115555. set minPitch(value: number);
  115556. /**
  115557. * Gets or sets the maximum pitch angle that the bone can look to
  115558. */
  115559. get maxPitch(): number;
  115560. set maxPitch(value: number);
  115561. /**
  115562. * Create a BoneLookController
  115563. * @param mesh the mesh that the bone belongs to
  115564. * @param bone the bone that will be looking to the target
  115565. * @param target the target Vector3 to look at
  115566. * @param options optional settings:
  115567. * * maxYaw: the maximum angle the bone will yaw to
  115568. * * minYaw: the minimum angle the bone will yaw to
  115569. * * maxPitch: the maximum angle the bone will pitch to
  115570. * * minPitch: the minimum angle the bone will yaw to
  115571. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  115572. * * upAxis: the up axis of the coordinate system
  115573. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  115574. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  115575. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  115576. * * adjustYaw: used to make an adjustment to the yaw of the bone
  115577. * * adjustPitch: used to make an adjustment to the pitch of the bone
  115578. * * adjustRoll: used to make an adjustment to the roll of the bone
  115579. **/
  115580. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  115581. maxYaw?: number;
  115582. minYaw?: number;
  115583. maxPitch?: number;
  115584. minPitch?: number;
  115585. slerpAmount?: number;
  115586. upAxis?: Vector3;
  115587. upAxisSpace?: Space;
  115588. yawAxis?: Vector3;
  115589. pitchAxis?: Vector3;
  115590. adjustYaw?: number;
  115591. adjustPitch?: number;
  115592. adjustRoll?: number;
  115593. });
  115594. /**
  115595. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  115596. */
  115597. update(): void;
  115598. private _getAngleDiff;
  115599. private _getAngleBetween;
  115600. private _isAngleBetween;
  115601. }
  115602. }
  115603. declare module BABYLON {
  115604. /**
  115605. * Manage the gamepad inputs to control an arc rotate camera.
  115606. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  115607. */
  115608. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  115609. /**
  115610. * Defines the camera the input is attached to.
  115611. */
  115612. camera: ArcRotateCamera;
  115613. /**
  115614. * Defines the gamepad the input is gathering event from.
  115615. */
  115616. gamepad: Nullable<Gamepad>;
  115617. /**
  115618. * Defines the gamepad rotation sensiblity.
  115619. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  115620. */
  115621. gamepadRotationSensibility: number;
  115622. /**
  115623. * Defines the gamepad move sensiblity.
  115624. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  115625. */
  115626. gamepadMoveSensibility: number;
  115627. private _yAxisScale;
  115628. /**
  115629. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  115630. */
  115631. get invertYAxis(): boolean;
  115632. set invertYAxis(value: boolean);
  115633. private _onGamepadConnectedObserver;
  115634. private _onGamepadDisconnectedObserver;
  115635. /**
  115636. * Attach the input controls to a specific dom element to get the input from.
  115637. * @param element Defines the element the controls should be listened from
  115638. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  115639. */
  115640. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  115641. /**
  115642. * Detach the current controls from the specified dom element.
  115643. * @param element Defines the element to stop listening the inputs from
  115644. */
  115645. detachControl(element: Nullable<HTMLElement>): void;
  115646. /**
  115647. * Update the current camera state depending on the inputs that have been used this frame.
  115648. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  115649. */
  115650. checkInputs(): void;
  115651. /**
  115652. * Gets the class name of the current intput.
  115653. * @returns the class name
  115654. */
  115655. getClassName(): string;
  115656. /**
  115657. * Get the friendly name associated with the input class.
  115658. * @returns the input friendly name
  115659. */
  115660. getSimpleName(): string;
  115661. }
  115662. }
  115663. declare module BABYLON {
  115664. interface ArcRotateCameraInputsManager {
  115665. /**
  115666. * Add orientation input support to the input manager.
  115667. * @returns the current input manager
  115668. */
  115669. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  115670. }
  115671. /**
  115672. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  115673. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  115674. */
  115675. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  115676. /**
  115677. * Defines the camera the input is attached to.
  115678. */
  115679. camera: ArcRotateCamera;
  115680. /**
  115681. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  115682. */
  115683. alphaCorrection: number;
  115684. /**
  115685. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  115686. */
  115687. gammaCorrection: number;
  115688. private _alpha;
  115689. private _gamma;
  115690. private _dirty;
  115691. private _deviceOrientationHandler;
  115692. /**
  115693. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  115694. */
  115695. constructor();
  115696. /**
  115697. * Attach the input controls to a specific dom element to get the input from.
  115698. * @param element Defines the element the controls should be listened from
  115699. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  115700. */
  115701. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  115702. /** @hidden */
  115703. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  115704. /**
  115705. * Update the current camera state depending on the inputs that have been used this frame.
  115706. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  115707. */
  115708. checkInputs(): void;
  115709. /**
  115710. * Detach the current controls from the specified dom element.
  115711. * @param element Defines the element to stop listening the inputs from
  115712. */
  115713. detachControl(element: Nullable<HTMLElement>): void;
  115714. /**
  115715. * Gets the class name of the current intput.
  115716. * @returns the class name
  115717. */
  115718. getClassName(): string;
  115719. /**
  115720. * Get the friendly name associated with the input class.
  115721. * @returns the input friendly name
  115722. */
  115723. getSimpleName(): string;
  115724. }
  115725. }
  115726. declare module BABYLON {
  115727. /**
  115728. * Listen to mouse events to control the camera.
  115729. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  115730. */
  115731. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  115732. /**
  115733. * Defines the camera the input is attached to.
  115734. */
  115735. camera: FlyCamera;
  115736. /**
  115737. * Defines if touch is enabled. (Default is true.)
  115738. */
  115739. touchEnabled: boolean;
  115740. /**
  115741. * Defines the buttons associated with the input to handle camera rotation.
  115742. */
  115743. buttons: number[];
  115744. /**
  115745. * Assign buttons for Yaw control.
  115746. */
  115747. buttonsYaw: number[];
  115748. /**
  115749. * Assign buttons for Pitch control.
  115750. */
  115751. buttonsPitch: number[];
  115752. /**
  115753. * Assign buttons for Roll control.
  115754. */
  115755. buttonsRoll: number[];
  115756. /**
  115757. * Detect if any button is being pressed while mouse is moved.
  115758. * -1 = Mouse locked.
  115759. * 0 = Left button.
  115760. * 1 = Middle Button.
  115761. * 2 = Right Button.
  115762. */
  115763. activeButton: number;
  115764. /**
  115765. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  115766. * Higher values reduce its sensitivity.
  115767. */
  115768. angularSensibility: number;
  115769. private _mousemoveCallback;
  115770. private _observer;
  115771. private _rollObserver;
  115772. private previousPosition;
  115773. private noPreventDefault;
  115774. private element;
  115775. /**
  115776. * Listen to mouse events to control the camera.
  115777. * @param touchEnabled Define if touch is enabled. (Default is true.)
  115778. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  115779. */
  115780. constructor(touchEnabled?: boolean);
  115781. /**
  115782. * Attach the mouse control to the HTML DOM element.
  115783. * @param element Defines the element that listens to the input events.
  115784. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  115785. */
  115786. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  115787. /**
  115788. * Detach the current controls from the specified dom element.
  115789. * @param element Defines the element to stop listening the inputs from
  115790. */
  115791. detachControl(element: Nullable<HTMLElement>): void;
  115792. /**
  115793. * Gets the class name of the current input.
  115794. * @returns the class name.
  115795. */
  115796. getClassName(): string;
  115797. /**
  115798. * Get the friendly name associated with the input class.
  115799. * @returns the input's friendly name.
  115800. */
  115801. getSimpleName(): string;
  115802. private _pointerInput;
  115803. private _onMouseMove;
  115804. /**
  115805. * Rotate camera by mouse offset.
  115806. */
  115807. private rotateCamera;
  115808. }
  115809. }
  115810. declare module BABYLON {
  115811. /**
  115812. * Default Inputs manager for the FlyCamera.
  115813. * It groups all the default supported inputs for ease of use.
  115814. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  115815. */
  115816. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  115817. /**
  115818. * Instantiates a new FlyCameraInputsManager.
  115819. * @param camera Defines the camera the inputs belong to.
  115820. */
  115821. constructor(camera: FlyCamera);
  115822. /**
  115823. * Add keyboard input support to the input manager.
  115824. * @returns the new FlyCameraKeyboardMoveInput().
  115825. */
  115826. addKeyboard(): FlyCameraInputsManager;
  115827. /**
  115828. * Add mouse input support to the input manager.
  115829. * @param touchEnabled Enable touch screen support.
  115830. * @returns the new FlyCameraMouseInput().
  115831. */
  115832. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  115833. }
  115834. }
  115835. declare module BABYLON {
  115836. /**
  115837. * This is a flying camera, designed for 3D movement and rotation in all directions,
  115838. * such as in a 3D Space Shooter or a Flight Simulator.
  115839. */
  115840. export class FlyCamera extends TargetCamera {
  115841. /**
  115842. * Define the collision ellipsoid of the camera.
  115843. * This is helpful for simulating a camera body, like a player's body.
  115844. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  115845. */
  115846. ellipsoid: Vector3;
  115847. /**
  115848. * Define an offset for the position of the ellipsoid around the camera.
  115849. * This can be helpful if the camera is attached away from the player's body center,
  115850. * such as at its head.
  115851. */
  115852. ellipsoidOffset: Vector3;
  115853. /**
  115854. * Enable or disable collisions of the camera with the rest of the scene objects.
  115855. */
  115856. checkCollisions: boolean;
  115857. /**
  115858. * Enable or disable gravity on the camera.
  115859. */
  115860. applyGravity: boolean;
  115861. /**
  115862. * Define the current direction the camera is moving to.
  115863. */
  115864. cameraDirection: Vector3;
  115865. /**
  115866. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  115867. * This overrides and empties cameraRotation.
  115868. */
  115869. rotationQuaternion: Quaternion;
  115870. /**
  115871. * Track Roll to maintain the wanted Rolling when looking around.
  115872. */
  115873. _trackRoll: number;
  115874. /**
  115875. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  115876. */
  115877. rollCorrect: number;
  115878. /**
  115879. * Mimic a banked turn, Rolling the camera when Yawing.
  115880. * It's recommended to use rollCorrect = 10 for faster banking correction.
  115881. */
  115882. bankedTurn: boolean;
  115883. /**
  115884. * Limit in radians for how much Roll banking will add. (Default: 90°)
  115885. */
  115886. bankedTurnLimit: number;
  115887. /**
  115888. * Value of 0 disables the banked Roll.
  115889. * Value of 1 is equal to the Yaw angle in radians.
  115890. */
  115891. bankedTurnMultiplier: number;
  115892. /**
  115893. * The inputs manager loads all the input sources, such as keyboard and mouse.
  115894. */
  115895. inputs: FlyCameraInputsManager;
  115896. /**
  115897. * Gets the input sensibility for mouse input.
  115898. * Higher values reduce sensitivity.
  115899. */
  115900. get angularSensibility(): number;
  115901. /**
  115902. * Sets the input sensibility for a mouse input.
  115903. * Higher values reduce sensitivity.
  115904. */
  115905. set angularSensibility(value: number);
  115906. /**
  115907. * Get the keys for camera movement forward.
  115908. */
  115909. get keysForward(): number[];
  115910. /**
  115911. * Set the keys for camera movement forward.
  115912. */
  115913. set keysForward(value: number[]);
  115914. /**
  115915. * Get the keys for camera movement backward.
  115916. */
  115917. get keysBackward(): number[];
  115918. set keysBackward(value: number[]);
  115919. /**
  115920. * Get the keys for camera movement up.
  115921. */
  115922. get keysUp(): number[];
  115923. /**
  115924. * Set the keys for camera movement up.
  115925. */
  115926. set keysUp(value: number[]);
  115927. /**
  115928. * Get the keys for camera movement down.
  115929. */
  115930. get keysDown(): number[];
  115931. /**
  115932. * Set the keys for camera movement down.
  115933. */
  115934. set keysDown(value: number[]);
  115935. /**
  115936. * Get the keys for camera movement left.
  115937. */
  115938. get keysLeft(): number[];
  115939. /**
  115940. * Set the keys for camera movement left.
  115941. */
  115942. set keysLeft(value: number[]);
  115943. /**
  115944. * Set the keys for camera movement right.
  115945. */
  115946. get keysRight(): number[];
  115947. /**
  115948. * Set the keys for camera movement right.
  115949. */
  115950. set keysRight(value: number[]);
  115951. /**
  115952. * Event raised when the camera collides with a mesh in the scene.
  115953. */
  115954. onCollide: (collidedMesh: AbstractMesh) => void;
  115955. private _collider;
  115956. private _needMoveForGravity;
  115957. private _oldPosition;
  115958. private _diffPosition;
  115959. private _newPosition;
  115960. /** @hidden */
  115961. _localDirection: Vector3;
  115962. /** @hidden */
  115963. _transformedDirection: Vector3;
  115964. /**
  115965. * Instantiates a FlyCamera.
  115966. * This is a flying camera, designed for 3D movement and rotation in all directions,
  115967. * such as in a 3D Space Shooter or a Flight Simulator.
  115968. * @param name Define the name of the camera in the scene.
  115969. * @param position Define the starting position of the camera in the scene.
  115970. * @param scene Define the scene the camera belongs to.
  115971. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  115972. */
  115973. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  115974. /**
  115975. * Attach a control to the HTML DOM element.
  115976. * @param element Defines the element that listens to the input events.
  115977. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  115978. */
  115979. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  115980. /**
  115981. * Detach a control from the HTML DOM element.
  115982. * The camera will stop reacting to that input.
  115983. * @param element Defines the element that listens to the input events.
  115984. */
  115985. detachControl(element: HTMLElement): void;
  115986. private _collisionMask;
  115987. /**
  115988. * Get the mask that the camera ignores in collision events.
  115989. */
  115990. get collisionMask(): number;
  115991. /**
  115992. * Set the mask that the camera ignores in collision events.
  115993. */
  115994. set collisionMask(mask: number);
  115995. /** @hidden */
  115996. _collideWithWorld(displacement: Vector3): void;
  115997. /** @hidden */
  115998. private _onCollisionPositionChange;
  115999. /** @hidden */
  116000. _checkInputs(): void;
  116001. /** @hidden */
  116002. _decideIfNeedsToMove(): boolean;
  116003. /** @hidden */
  116004. _updatePosition(): void;
  116005. /**
  116006. * Restore the Roll to its target value at the rate specified.
  116007. * @param rate - Higher means slower restoring.
  116008. * @hidden
  116009. */
  116010. restoreRoll(rate: number): void;
  116011. /**
  116012. * Destroy the camera and release the current resources held by it.
  116013. */
  116014. dispose(): void;
  116015. /**
  116016. * Get the current object class name.
  116017. * @returns the class name.
  116018. */
  116019. getClassName(): string;
  116020. }
  116021. }
  116022. declare module BABYLON {
  116023. /**
  116024. * Listen to keyboard events to control the camera.
  116025. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  116026. */
  116027. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  116028. /**
  116029. * Defines the camera the input is attached to.
  116030. */
  116031. camera: FlyCamera;
  116032. /**
  116033. * The list of keyboard keys used to control the forward move of the camera.
  116034. */
  116035. keysForward: number[];
  116036. /**
  116037. * The list of keyboard keys used to control the backward move of the camera.
  116038. */
  116039. keysBackward: number[];
  116040. /**
  116041. * The list of keyboard keys used to control the forward move of the camera.
  116042. */
  116043. keysUp: number[];
  116044. /**
  116045. * The list of keyboard keys used to control the backward move of the camera.
  116046. */
  116047. keysDown: number[];
  116048. /**
  116049. * The list of keyboard keys used to control the right strafe move of the camera.
  116050. */
  116051. keysRight: number[];
  116052. /**
  116053. * The list of keyboard keys used to control the left strafe move of the camera.
  116054. */
  116055. keysLeft: number[];
  116056. private _keys;
  116057. private _onCanvasBlurObserver;
  116058. private _onKeyboardObserver;
  116059. private _engine;
  116060. private _scene;
  116061. /**
  116062. * Attach the input controls to a specific dom element to get the input from.
  116063. * @param element Defines the element the controls should be listened from
  116064. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  116065. */
  116066. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  116067. /**
  116068. * Detach the current controls from the specified dom element.
  116069. * @param element Defines the element to stop listening the inputs from
  116070. */
  116071. detachControl(element: Nullable<HTMLElement>): void;
  116072. /**
  116073. * Gets the class name of the current intput.
  116074. * @returns the class name
  116075. */
  116076. getClassName(): string;
  116077. /** @hidden */
  116078. _onLostFocus(e: FocusEvent): void;
  116079. /**
  116080. * Get the friendly name associated with the input class.
  116081. * @returns the input friendly name
  116082. */
  116083. getSimpleName(): string;
  116084. /**
  116085. * Update the current camera state depending on the inputs that have been used this frame.
  116086. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  116087. */
  116088. checkInputs(): void;
  116089. }
  116090. }
  116091. declare module BABYLON {
  116092. /**
  116093. * Manage the mouse wheel inputs to control a follow camera.
  116094. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  116095. */
  116096. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  116097. /**
  116098. * Defines the camera the input is attached to.
  116099. */
  116100. camera: FollowCamera;
  116101. /**
  116102. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  116103. */
  116104. axisControlRadius: boolean;
  116105. /**
  116106. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  116107. */
  116108. axisControlHeight: boolean;
  116109. /**
  116110. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  116111. */
  116112. axisControlRotation: boolean;
  116113. /**
  116114. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  116115. * relation to mouseWheel events.
  116116. */
  116117. wheelPrecision: number;
  116118. /**
  116119. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  116120. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  116121. */
  116122. wheelDeltaPercentage: number;
  116123. private _wheel;
  116124. private _observer;
  116125. /**
  116126. * Attach the input controls to a specific dom element to get the input from.
  116127. * @param element Defines the element the controls should be listened from
  116128. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  116129. */
  116130. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  116131. /**
  116132. * Detach the current controls from the specified dom element.
  116133. * @param element Defines the element to stop listening the inputs from
  116134. */
  116135. detachControl(element: Nullable<HTMLElement>): void;
  116136. /**
  116137. * Gets the class name of the current intput.
  116138. * @returns the class name
  116139. */
  116140. getClassName(): string;
  116141. /**
  116142. * Get the friendly name associated with the input class.
  116143. * @returns the input friendly name
  116144. */
  116145. getSimpleName(): string;
  116146. }
  116147. }
  116148. declare module BABYLON {
  116149. /**
  116150. * Manage the pointers inputs to control an follow camera.
  116151. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  116152. */
  116153. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  116154. /**
  116155. * Defines the camera the input is attached to.
  116156. */
  116157. camera: FollowCamera;
  116158. /**
  116159. * Gets the class name of the current input.
  116160. * @returns the class name
  116161. */
  116162. getClassName(): string;
  116163. /**
  116164. * Defines the pointer angular sensibility along the X axis or how fast is
  116165. * the camera rotating.
  116166. * A negative number will reverse the axis direction.
  116167. */
  116168. angularSensibilityX: number;
  116169. /**
  116170. * Defines the pointer angular sensibility along the Y axis or how fast is
  116171. * the camera rotating.
  116172. * A negative number will reverse the axis direction.
  116173. */
  116174. angularSensibilityY: number;
  116175. /**
  116176. * Defines the pointer pinch precision or how fast is the camera zooming.
  116177. * A negative number will reverse the axis direction.
  116178. */
  116179. pinchPrecision: number;
  116180. /**
  116181. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  116182. * from 0.
  116183. * It defines the percentage of current camera.radius to use as delta when
  116184. * pinch zoom is used.
  116185. */
  116186. pinchDeltaPercentage: number;
  116187. /**
  116188. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  116189. */
  116190. axisXControlRadius: boolean;
  116191. /**
  116192. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  116193. */
  116194. axisXControlHeight: boolean;
  116195. /**
  116196. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  116197. */
  116198. axisXControlRotation: boolean;
  116199. /**
  116200. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  116201. */
  116202. axisYControlRadius: boolean;
  116203. /**
  116204. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  116205. */
  116206. axisYControlHeight: boolean;
  116207. /**
  116208. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  116209. */
  116210. axisYControlRotation: boolean;
  116211. /**
  116212. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  116213. */
  116214. axisPinchControlRadius: boolean;
  116215. /**
  116216. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  116217. */
  116218. axisPinchControlHeight: boolean;
  116219. /**
  116220. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  116221. */
  116222. axisPinchControlRotation: boolean;
  116223. /**
  116224. * Log error messages if basic misconfiguration has occurred.
  116225. */
  116226. warningEnable: boolean;
  116227. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  116228. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  116229. private _warningCounter;
  116230. private _warning;
  116231. }
  116232. }
  116233. declare module BABYLON {
  116234. /**
  116235. * Default Inputs manager for the FollowCamera.
  116236. * It groups all the default supported inputs for ease of use.
  116237. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  116238. */
  116239. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  116240. /**
  116241. * Instantiates a new FollowCameraInputsManager.
  116242. * @param camera Defines the camera the inputs belong to
  116243. */
  116244. constructor(camera: FollowCamera);
  116245. /**
  116246. * Add keyboard input support to the input manager.
  116247. * @returns the current input manager
  116248. */
  116249. addKeyboard(): FollowCameraInputsManager;
  116250. /**
  116251. * Add mouse wheel input support to the input manager.
  116252. * @returns the current input manager
  116253. */
  116254. addMouseWheel(): FollowCameraInputsManager;
  116255. /**
  116256. * Add pointers input support to the input manager.
  116257. * @returns the current input manager
  116258. */
  116259. addPointers(): FollowCameraInputsManager;
  116260. /**
  116261. * Add orientation input support to the input manager.
  116262. * @returns the current input manager
  116263. */
  116264. addVRDeviceOrientation(): FollowCameraInputsManager;
  116265. }
  116266. }
  116267. declare module BABYLON {
  116268. /**
  116269. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  116270. * an arc rotate version arcFollowCamera are available.
  116271. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  116272. */
  116273. export class FollowCamera extends TargetCamera {
  116274. /**
  116275. * Distance the follow camera should follow an object at
  116276. */
  116277. radius: number;
  116278. /**
  116279. * Minimum allowed distance of the camera to the axis of rotation
  116280. * (The camera can not get closer).
  116281. * This can help limiting how the Camera is able to move in the scene.
  116282. */
  116283. lowerRadiusLimit: Nullable<number>;
  116284. /**
  116285. * Maximum allowed distance of the camera to the axis of rotation
  116286. * (The camera can not get further).
  116287. * This can help limiting how the Camera is able to move in the scene.
  116288. */
  116289. upperRadiusLimit: Nullable<number>;
  116290. /**
  116291. * Define a rotation offset between the camera and the object it follows
  116292. */
  116293. rotationOffset: number;
  116294. /**
  116295. * Minimum allowed angle to camera position relative to target object.
  116296. * This can help limiting how the Camera is able to move in the scene.
  116297. */
  116298. lowerRotationOffsetLimit: Nullable<number>;
  116299. /**
  116300. * Maximum allowed angle to camera position relative to target object.
  116301. * This can help limiting how the Camera is able to move in the scene.
  116302. */
  116303. upperRotationOffsetLimit: Nullable<number>;
  116304. /**
  116305. * Define a height offset between the camera and the object it follows.
  116306. * It can help following an object from the top (like a car chaing a plane)
  116307. */
  116308. heightOffset: number;
  116309. /**
  116310. * Minimum allowed height of camera position relative to target object.
  116311. * This can help limiting how the Camera is able to move in the scene.
  116312. */
  116313. lowerHeightOffsetLimit: Nullable<number>;
  116314. /**
  116315. * Maximum allowed height of camera position relative to target object.
  116316. * This can help limiting how the Camera is able to move in the scene.
  116317. */
  116318. upperHeightOffsetLimit: Nullable<number>;
  116319. /**
  116320. * Define how fast the camera can accelerate to follow it s target.
  116321. */
  116322. cameraAcceleration: number;
  116323. /**
  116324. * Define the speed limit of the camera following an object.
  116325. */
  116326. maxCameraSpeed: number;
  116327. /**
  116328. * Define the target of the camera.
  116329. */
  116330. lockedTarget: Nullable<AbstractMesh>;
  116331. /**
  116332. * Defines the input associated with the camera.
  116333. */
  116334. inputs: FollowCameraInputsManager;
  116335. /**
  116336. * Instantiates the follow camera.
  116337. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  116338. * @param name Define the name of the camera in the scene
  116339. * @param position Define the position of the camera
  116340. * @param scene Define the scene the camera belong to
  116341. * @param lockedTarget Define the target of the camera
  116342. */
  116343. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  116344. private _follow;
  116345. /**
  116346. * Attached controls to the current camera.
  116347. * @param element Defines the element the controls should be listened from
  116348. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  116349. */
  116350. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  116351. /**
  116352. * Detach the current controls from the camera.
  116353. * The camera will stop reacting to inputs.
  116354. * @param element Defines the element to stop listening the inputs from
  116355. */
  116356. detachControl(element: HTMLElement): void;
  116357. /** @hidden */
  116358. _checkInputs(): void;
  116359. private _checkLimits;
  116360. /**
  116361. * Gets the camera class name.
  116362. * @returns the class name
  116363. */
  116364. getClassName(): string;
  116365. }
  116366. /**
  116367. * Arc Rotate version of the follow camera.
  116368. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  116369. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  116370. */
  116371. export class ArcFollowCamera extends TargetCamera {
  116372. /** The longitudinal angle of the camera */
  116373. alpha: number;
  116374. /** The latitudinal angle of the camera */
  116375. beta: number;
  116376. /** The radius of the camera from its target */
  116377. radius: number;
  116378. /** Define the camera target (the messh it should follow) */
  116379. target: Nullable<AbstractMesh>;
  116380. private _cartesianCoordinates;
  116381. /**
  116382. * Instantiates a new ArcFollowCamera
  116383. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  116384. * @param name Define the name of the camera
  116385. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  116386. * @param beta Define the rotation angle of the camera around the elevation axis
  116387. * @param radius Define the radius of the camera from its target point
  116388. * @param target Define the target of the camera
  116389. * @param scene Define the scene the camera belongs to
  116390. */
  116391. constructor(name: string,
  116392. /** The longitudinal angle of the camera */
  116393. alpha: number,
  116394. /** The latitudinal angle of the camera */
  116395. beta: number,
  116396. /** The radius of the camera from its target */
  116397. radius: number,
  116398. /** Define the camera target (the messh it should follow) */
  116399. target: Nullable<AbstractMesh>, scene: Scene);
  116400. private _follow;
  116401. /** @hidden */
  116402. _checkInputs(): void;
  116403. /**
  116404. * Returns the class name of the object.
  116405. * It is mostly used internally for serialization purposes.
  116406. */
  116407. getClassName(): string;
  116408. }
  116409. }
  116410. declare module BABYLON {
  116411. /**
  116412. * Manage the keyboard inputs to control the movement of a follow camera.
  116413. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  116414. */
  116415. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  116416. /**
  116417. * Defines the camera the input is attached to.
  116418. */
  116419. camera: FollowCamera;
  116420. /**
  116421. * Defines the list of key codes associated with the up action (increase heightOffset)
  116422. */
  116423. keysHeightOffsetIncr: number[];
  116424. /**
  116425. * Defines the list of key codes associated with the down action (decrease heightOffset)
  116426. */
  116427. keysHeightOffsetDecr: number[];
  116428. /**
  116429. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  116430. */
  116431. keysHeightOffsetModifierAlt: boolean;
  116432. /**
  116433. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  116434. */
  116435. keysHeightOffsetModifierCtrl: boolean;
  116436. /**
  116437. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  116438. */
  116439. keysHeightOffsetModifierShift: boolean;
  116440. /**
  116441. * Defines the list of key codes associated with the left action (increase rotationOffset)
  116442. */
  116443. keysRotationOffsetIncr: number[];
  116444. /**
  116445. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  116446. */
  116447. keysRotationOffsetDecr: number[];
  116448. /**
  116449. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  116450. */
  116451. keysRotationOffsetModifierAlt: boolean;
  116452. /**
  116453. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  116454. */
  116455. keysRotationOffsetModifierCtrl: boolean;
  116456. /**
  116457. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  116458. */
  116459. keysRotationOffsetModifierShift: boolean;
  116460. /**
  116461. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  116462. */
  116463. keysRadiusIncr: number[];
  116464. /**
  116465. * Defines the list of key codes associated with the zoom-out action (increase radius)
  116466. */
  116467. keysRadiusDecr: number[];
  116468. /**
  116469. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  116470. */
  116471. keysRadiusModifierAlt: boolean;
  116472. /**
  116473. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  116474. */
  116475. keysRadiusModifierCtrl: boolean;
  116476. /**
  116477. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  116478. */
  116479. keysRadiusModifierShift: boolean;
  116480. /**
  116481. * Defines the rate of change of heightOffset.
  116482. */
  116483. heightSensibility: number;
  116484. /**
  116485. * Defines the rate of change of rotationOffset.
  116486. */
  116487. rotationSensibility: number;
  116488. /**
  116489. * Defines the rate of change of radius.
  116490. */
  116491. radiusSensibility: number;
  116492. private _keys;
  116493. private _ctrlPressed;
  116494. private _altPressed;
  116495. private _shiftPressed;
  116496. private _onCanvasBlurObserver;
  116497. private _onKeyboardObserver;
  116498. private _engine;
  116499. private _scene;
  116500. /**
  116501. * Attach the input controls to a specific dom element to get the input from.
  116502. * @param element Defines the element the controls should be listened from
  116503. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  116504. */
  116505. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  116506. /**
  116507. * Detach the current controls from the specified dom element.
  116508. * @param element Defines the element to stop listening the inputs from
  116509. */
  116510. detachControl(element: Nullable<HTMLElement>): void;
  116511. /**
  116512. * Update the current camera state depending on the inputs that have been used this frame.
  116513. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  116514. */
  116515. checkInputs(): void;
  116516. /**
  116517. * Gets the class name of the current input.
  116518. * @returns the class name
  116519. */
  116520. getClassName(): string;
  116521. /**
  116522. * Get the friendly name associated with the input class.
  116523. * @returns the input friendly name
  116524. */
  116525. getSimpleName(): string;
  116526. /**
  116527. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  116528. * allow modification of the heightOffset value.
  116529. */
  116530. private _modifierHeightOffset;
  116531. /**
  116532. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  116533. * allow modification of the rotationOffset value.
  116534. */
  116535. private _modifierRotationOffset;
  116536. /**
  116537. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  116538. * allow modification of the radius value.
  116539. */
  116540. private _modifierRadius;
  116541. }
  116542. }
  116543. declare module BABYLON {
  116544. interface FreeCameraInputsManager {
  116545. /**
  116546. * @hidden
  116547. */
  116548. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  116549. /**
  116550. * Add orientation input support to the input manager.
  116551. * @returns the current input manager
  116552. */
  116553. addDeviceOrientation(): FreeCameraInputsManager;
  116554. }
  116555. /**
  116556. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  116557. * Screen rotation is taken into account.
  116558. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  116559. */
  116560. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  116561. private _camera;
  116562. private _screenOrientationAngle;
  116563. private _constantTranform;
  116564. private _screenQuaternion;
  116565. private _alpha;
  116566. private _beta;
  116567. private _gamma;
  116568. /**
  116569. * Can be used to detect if a device orientation sensor is available on a device
  116570. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  116571. * @returns a promise that will resolve on orientation change
  116572. */
  116573. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  116574. /**
  116575. * @hidden
  116576. */
  116577. _onDeviceOrientationChangedObservable: Observable<void>;
  116578. /**
  116579. * Instantiates a new input
  116580. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  116581. */
  116582. constructor();
  116583. /**
  116584. * Define the camera controlled by the input.
  116585. */
  116586. get camera(): FreeCamera;
  116587. set camera(camera: FreeCamera);
  116588. /**
  116589. * Attach the input controls to a specific dom element to get the input from.
  116590. * @param element Defines the element the controls should be listened from
  116591. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  116592. */
  116593. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  116594. private _orientationChanged;
  116595. private _deviceOrientation;
  116596. /**
  116597. * Detach the current controls from the specified dom element.
  116598. * @param element Defines the element to stop listening the inputs from
  116599. */
  116600. detachControl(element: Nullable<HTMLElement>): void;
  116601. /**
  116602. * Update the current camera state depending on the inputs that have been used this frame.
  116603. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  116604. */
  116605. checkInputs(): void;
  116606. /**
  116607. * Gets the class name of the current intput.
  116608. * @returns the class name
  116609. */
  116610. getClassName(): string;
  116611. /**
  116612. * Get the friendly name associated with the input class.
  116613. * @returns the input friendly name
  116614. */
  116615. getSimpleName(): string;
  116616. }
  116617. }
  116618. declare module BABYLON {
  116619. /**
  116620. * Manage the gamepad inputs to control a free camera.
  116621. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  116622. */
  116623. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  116624. /**
  116625. * Define the camera the input is attached to.
  116626. */
  116627. camera: FreeCamera;
  116628. /**
  116629. * Define the Gamepad controlling the input
  116630. */
  116631. gamepad: Nullable<Gamepad>;
  116632. /**
  116633. * Defines the gamepad rotation sensiblity.
  116634. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  116635. */
  116636. gamepadAngularSensibility: number;
  116637. /**
  116638. * Defines the gamepad move sensiblity.
  116639. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  116640. */
  116641. gamepadMoveSensibility: number;
  116642. private _yAxisScale;
  116643. /**
  116644. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  116645. */
  116646. get invertYAxis(): boolean;
  116647. set invertYAxis(value: boolean);
  116648. private _onGamepadConnectedObserver;
  116649. private _onGamepadDisconnectedObserver;
  116650. private _cameraTransform;
  116651. private _deltaTransform;
  116652. private _vector3;
  116653. private _vector2;
  116654. /**
  116655. * Attach the input controls to a specific dom element to get the input from.
  116656. * @param element Defines the element the controls should be listened from
  116657. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  116658. */
  116659. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  116660. /**
  116661. * Detach the current controls from the specified dom element.
  116662. * @param element Defines the element to stop listening the inputs from
  116663. */
  116664. detachControl(element: Nullable<HTMLElement>): void;
  116665. /**
  116666. * Update the current camera state depending on the inputs that have been used this frame.
  116667. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  116668. */
  116669. checkInputs(): void;
  116670. /**
  116671. * Gets the class name of the current intput.
  116672. * @returns the class name
  116673. */
  116674. getClassName(): string;
  116675. /**
  116676. * Get the friendly name associated with the input class.
  116677. * @returns the input friendly name
  116678. */
  116679. getSimpleName(): string;
  116680. }
  116681. }
  116682. declare module BABYLON {
  116683. /**
  116684. * Defines the potential axis of a Joystick
  116685. */
  116686. export enum JoystickAxis {
  116687. /** X axis */
  116688. X = 0,
  116689. /** Y axis */
  116690. Y = 1,
  116691. /** Z axis */
  116692. Z = 2
  116693. }
  116694. /**
  116695. * Class used to define virtual joystick (used in touch mode)
  116696. */
  116697. export class VirtualJoystick {
  116698. /**
  116699. * Gets or sets a boolean indicating that left and right values must be inverted
  116700. */
  116701. reverseLeftRight: boolean;
  116702. /**
  116703. * Gets or sets a boolean indicating that up and down values must be inverted
  116704. */
  116705. reverseUpDown: boolean;
  116706. /**
  116707. * Gets the offset value for the position (ie. the change of the position value)
  116708. */
  116709. deltaPosition: Vector3;
  116710. /**
  116711. * Gets a boolean indicating if the virtual joystick was pressed
  116712. */
  116713. pressed: boolean;
  116714. /**
  116715. * Canvas the virtual joystick will render onto, default z-index of this is 5
  116716. */
  116717. static Canvas: Nullable<HTMLCanvasElement>;
  116718. private static _globalJoystickIndex;
  116719. private static vjCanvasContext;
  116720. private static vjCanvasWidth;
  116721. private static vjCanvasHeight;
  116722. private static halfWidth;
  116723. private _action;
  116724. private _axisTargetedByLeftAndRight;
  116725. private _axisTargetedByUpAndDown;
  116726. private _joystickSensibility;
  116727. private _inversedSensibility;
  116728. private _joystickPointerID;
  116729. private _joystickColor;
  116730. private _joystickPointerPos;
  116731. private _joystickPreviousPointerPos;
  116732. private _joystickPointerStartPos;
  116733. private _deltaJoystickVector;
  116734. private _leftJoystick;
  116735. private _touches;
  116736. private _onPointerDownHandlerRef;
  116737. private _onPointerMoveHandlerRef;
  116738. private _onPointerUpHandlerRef;
  116739. private _onResize;
  116740. /**
  116741. * Creates a new virtual joystick
  116742. * @param leftJoystick defines that the joystick is for left hand (false by default)
  116743. */
  116744. constructor(leftJoystick?: boolean);
  116745. /**
  116746. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  116747. * @param newJoystickSensibility defines the new sensibility
  116748. */
  116749. setJoystickSensibility(newJoystickSensibility: number): void;
  116750. private _onPointerDown;
  116751. private _onPointerMove;
  116752. private _onPointerUp;
  116753. /**
  116754. * Change the color of the virtual joystick
  116755. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  116756. */
  116757. setJoystickColor(newColor: string): void;
  116758. /**
  116759. * Defines a callback to call when the joystick is touched
  116760. * @param action defines the callback
  116761. */
  116762. setActionOnTouch(action: () => any): void;
  116763. /**
  116764. * Defines which axis you'd like to control for left & right
  116765. * @param axis defines the axis to use
  116766. */
  116767. setAxisForLeftRight(axis: JoystickAxis): void;
  116768. /**
  116769. * Defines which axis you'd like to control for up & down
  116770. * @param axis defines the axis to use
  116771. */
  116772. setAxisForUpDown(axis: JoystickAxis): void;
  116773. private _drawVirtualJoystick;
  116774. /**
  116775. * Release internal HTML canvas
  116776. */
  116777. releaseCanvas(): void;
  116778. }
  116779. }
  116780. declare module BABYLON {
  116781. interface FreeCameraInputsManager {
  116782. /**
  116783. * Add virtual joystick input support to the input manager.
  116784. * @returns the current input manager
  116785. */
  116786. addVirtualJoystick(): FreeCameraInputsManager;
  116787. }
  116788. /**
  116789. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  116790. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  116791. */
  116792. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  116793. /**
  116794. * Defines the camera the input is attached to.
  116795. */
  116796. camera: FreeCamera;
  116797. private _leftjoystick;
  116798. private _rightjoystick;
  116799. /**
  116800. * Gets the left stick of the virtual joystick.
  116801. * @returns The virtual Joystick
  116802. */
  116803. getLeftJoystick(): VirtualJoystick;
  116804. /**
  116805. * Gets the right stick of the virtual joystick.
  116806. * @returns The virtual Joystick
  116807. */
  116808. getRightJoystick(): VirtualJoystick;
  116809. /**
  116810. * Update the current camera state depending on the inputs that have been used this frame.
  116811. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  116812. */
  116813. checkInputs(): void;
  116814. /**
  116815. * Attach the input controls to a specific dom element to get the input from.
  116816. * @param element Defines the element the controls should be listened from
  116817. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  116818. */
  116819. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  116820. /**
  116821. * Detach the current controls from the specified dom element.
  116822. * @param element Defines the element to stop listening the inputs from
  116823. */
  116824. detachControl(element: Nullable<HTMLElement>): void;
  116825. /**
  116826. * Gets the class name of the current intput.
  116827. * @returns the class name
  116828. */
  116829. getClassName(): string;
  116830. /**
  116831. * Get the friendly name associated with the input class.
  116832. * @returns the input friendly name
  116833. */
  116834. getSimpleName(): string;
  116835. }
  116836. }
  116837. declare module BABYLON {
  116838. /**
  116839. * This represents a FPS type of camera controlled by touch.
  116840. * This is like a universal camera minus the Gamepad controls.
  116841. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  116842. */
  116843. export class TouchCamera extends FreeCamera {
  116844. /**
  116845. * Defines the touch sensibility for rotation.
  116846. * The higher the faster.
  116847. */
  116848. get touchAngularSensibility(): number;
  116849. set touchAngularSensibility(value: number);
  116850. /**
  116851. * Defines the touch sensibility for move.
  116852. * The higher the faster.
  116853. */
  116854. get touchMoveSensibility(): number;
  116855. set touchMoveSensibility(value: number);
  116856. /**
  116857. * Instantiates a new touch camera.
  116858. * This represents a FPS type of camera controlled by touch.
  116859. * This is like a universal camera minus the Gamepad controls.
  116860. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  116861. * @param name Define the name of the camera in the scene
  116862. * @param position Define the start position of the camera in the scene
  116863. * @param scene Define the scene the camera belongs to
  116864. */
  116865. constructor(name: string, position: Vector3, scene: Scene);
  116866. /**
  116867. * Gets the current object class name.
  116868. * @return the class name
  116869. */
  116870. getClassName(): string;
  116871. /** @hidden */
  116872. _setupInputs(): void;
  116873. }
  116874. }
  116875. declare module BABYLON {
  116876. /**
  116877. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  116878. * being tilted forward or back and left or right.
  116879. */
  116880. export class DeviceOrientationCamera extends FreeCamera {
  116881. private _initialQuaternion;
  116882. private _quaternionCache;
  116883. private _tmpDragQuaternion;
  116884. private _disablePointerInputWhenUsingDeviceOrientation;
  116885. /**
  116886. * Creates a new device orientation camera
  116887. * @param name The name of the camera
  116888. * @param position The start position camera
  116889. * @param scene The scene the camera belongs to
  116890. */
  116891. constructor(name: string, position: Vector3, scene: Scene);
  116892. /**
  116893. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  116894. */
  116895. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  116896. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  116897. private _dragFactor;
  116898. /**
  116899. * Enabled turning on the y axis when the orientation sensor is active
  116900. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  116901. */
  116902. enableHorizontalDragging(dragFactor?: number): void;
  116903. /**
  116904. * Gets the current instance class name ("DeviceOrientationCamera").
  116905. * This helps avoiding instanceof at run time.
  116906. * @returns the class name
  116907. */
  116908. getClassName(): string;
  116909. /**
  116910. * @hidden
  116911. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  116912. */
  116913. _checkInputs(): void;
  116914. /**
  116915. * Reset the camera to its default orientation on the specified axis only.
  116916. * @param axis The axis to reset
  116917. */
  116918. resetToCurrentRotation(axis?: Axis): void;
  116919. }
  116920. }
  116921. declare module BABYLON {
  116922. /**
  116923. * Defines supported buttons for XBox360 compatible gamepads
  116924. */
  116925. export enum Xbox360Button {
  116926. /** A */
  116927. A = 0,
  116928. /** B */
  116929. B = 1,
  116930. /** X */
  116931. X = 2,
  116932. /** Y */
  116933. Y = 3,
  116934. /** Left button */
  116935. LB = 4,
  116936. /** Right button */
  116937. RB = 5,
  116938. /** Back */
  116939. Back = 8,
  116940. /** Start */
  116941. Start = 9,
  116942. /** Left stick */
  116943. LeftStick = 10,
  116944. /** Right stick */
  116945. RightStick = 11
  116946. }
  116947. /** Defines values for XBox360 DPad */
  116948. export enum Xbox360Dpad {
  116949. /** Up */
  116950. Up = 12,
  116951. /** Down */
  116952. Down = 13,
  116953. /** Left */
  116954. Left = 14,
  116955. /** Right */
  116956. Right = 15
  116957. }
  116958. /**
  116959. * Defines a XBox360 gamepad
  116960. */
  116961. export class Xbox360Pad extends Gamepad {
  116962. private _leftTrigger;
  116963. private _rightTrigger;
  116964. private _onlefttriggerchanged;
  116965. private _onrighttriggerchanged;
  116966. private _onbuttondown;
  116967. private _onbuttonup;
  116968. private _ondpaddown;
  116969. private _ondpadup;
  116970. /** Observable raised when a button is pressed */
  116971. onButtonDownObservable: Observable<Xbox360Button>;
  116972. /** Observable raised when a button is released */
  116973. onButtonUpObservable: Observable<Xbox360Button>;
  116974. /** Observable raised when a pad is pressed */
  116975. onPadDownObservable: Observable<Xbox360Dpad>;
  116976. /** Observable raised when a pad is released */
  116977. onPadUpObservable: Observable<Xbox360Dpad>;
  116978. private _buttonA;
  116979. private _buttonB;
  116980. private _buttonX;
  116981. private _buttonY;
  116982. private _buttonBack;
  116983. private _buttonStart;
  116984. private _buttonLB;
  116985. private _buttonRB;
  116986. private _buttonLeftStick;
  116987. private _buttonRightStick;
  116988. private _dPadUp;
  116989. private _dPadDown;
  116990. private _dPadLeft;
  116991. private _dPadRight;
  116992. private _isXboxOnePad;
  116993. /**
  116994. * Creates a new XBox360 gamepad object
  116995. * @param id defines the id of this gamepad
  116996. * @param index defines its index
  116997. * @param gamepad defines the internal HTML gamepad object
  116998. * @param xboxOne defines if it is a XBox One gamepad
  116999. */
  117000. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  117001. /**
  117002. * Defines the callback to call when left trigger is pressed
  117003. * @param callback defines the callback to use
  117004. */
  117005. onlefttriggerchanged(callback: (value: number) => void): void;
  117006. /**
  117007. * Defines the callback to call when right trigger is pressed
  117008. * @param callback defines the callback to use
  117009. */
  117010. onrighttriggerchanged(callback: (value: number) => void): void;
  117011. /**
  117012. * Gets the left trigger value
  117013. */
  117014. get leftTrigger(): number;
  117015. /**
  117016. * Sets the left trigger value
  117017. */
  117018. set leftTrigger(newValue: number);
  117019. /**
  117020. * Gets the right trigger value
  117021. */
  117022. get rightTrigger(): number;
  117023. /**
  117024. * Sets the right trigger value
  117025. */
  117026. set rightTrigger(newValue: number);
  117027. /**
  117028. * Defines the callback to call when a button is pressed
  117029. * @param callback defines the callback to use
  117030. */
  117031. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  117032. /**
  117033. * Defines the callback to call when a button is released
  117034. * @param callback defines the callback to use
  117035. */
  117036. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  117037. /**
  117038. * Defines the callback to call when a pad is pressed
  117039. * @param callback defines the callback to use
  117040. */
  117041. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  117042. /**
  117043. * Defines the callback to call when a pad is released
  117044. * @param callback defines the callback to use
  117045. */
  117046. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  117047. private _setButtonValue;
  117048. private _setDPadValue;
  117049. /**
  117050. * Gets the value of the `A` button
  117051. */
  117052. get buttonA(): number;
  117053. /**
  117054. * Sets the value of the `A` button
  117055. */
  117056. set buttonA(value: number);
  117057. /**
  117058. * Gets the value of the `B` button
  117059. */
  117060. get buttonB(): number;
  117061. /**
  117062. * Sets the value of the `B` button
  117063. */
  117064. set buttonB(value: number);
  117065. /**
  117066. * Gets the value of the `X` button
  117067. */
  117068. get buttonX(): number;
  117069. /**
  117070. * Sets the value of the `X` button
  117071. */
  117072. set buttonX(value: number);
  117073. /**
  117074. * Gets the value of the `Y` button
  117075. */
  117076. get buttonY(): number;
  117077. /**
  117078. * Sets the value of the `Y` button
  117079. */
  117080. set buttonY(value: number);
  117081. /**
  117082. * Gets the value of the `Start` button
  117083. */
  117084. get buttonStart(): number;
  117085. /**
  117086. * Sets the value of the `Start` button
  117087. */
  117088. set buttonStart(value: number);
  117089. /**
  117090. * Gets the value of the `Back` button
  117091. */
  117092. get buttonBack(): number;
  117093. /**
  117094. * Sets the value of the `Back` button
  117095. */
  117096. set buttonBack(value: number);
  117097. /**
  117098. * Gets the value of the `Left` button
  117099. */
  117100. get buttonLB(): number;
  117101. /**
  117102. * Sets the value of the `Left` button
  117103. */
  117104. set buttonLB(value: number);
  117105. /**
  117106. * Gets the value of the `Right` button
  117107. */
  117108. get buttonRB(): number;
  117109. /**
  117110. * Sets the value of the `Right` button
  117111. */
  117112. set buttonRB(value: number);
  117113. /**
  117114. * Gets the value of the Left joystick
  117115. */
  117116. get buttonLeftStick(): number;
  117117. /**
  117118. * Sets the value of the Left joystick
  117119. */
  117120. set buttonLeftStick(value: number);
  117121. /**
  117122. * Gets the value of the Right joystick
  117123. */
  117124. get buttonRightStick(): number;
  117125. /**
  117126. * Sets the value of the Right joystick
  117127. */
  117128. set buttonRightStick(value: number);
  117129. /**
  117130. * Gets the value of D-pad up
  117131. */
  117132. get dPadUp(): number;
  117133. /**
  117134. * Sets the value of D-pad up
  117135. */
  117136. set dPadUp(value: number);
  117137. /**
  117138. * Gets the value of D-pad down
  117139. */
  117140. get dPadDown(): number;
  117141. /**
  117142. * Sets the value of D-pad down
  117143. */
  117144. set dPadDown(value: number);
  117145. /**
  117146. * Gets the value of D-pad left
  117147. */
  117148. get dPadLeft(): number;
  117149. /**
  117150. * Sets the value of D-pad left
  117151. */
  117152. set dPadLeft(value: number);
  117153. /**
  117154. * Gets the value of D-pad right
  117155. */
  117156. get dPadRight(): number;
  117157. /**
  117158. * Sets the value of D-pad right
  117159. */
  117160. set dPadRight(value: number);
  117161. /**
  117162. * Force the gamepad to synchronize with device values
  117163. */
  117164. update(): void;
  117165. /**
  117166. * Disposes the gamepad
  117167. */
  117168. dispose(): void;
  117169. }
  117170. }
  117171. declare module BABYLON {
  117172. /**
  117173. * Defines supported buttons for DualShock compatible gamepads
  117174. */
  117175. export enum DualShockButton {
  117176. /** Cross */
  117177. Cross = 0,
  117178. /** Circle */
  117179. Circle = 1,
  117180. /** Square */
  117181. Square = 2,
  117182. /** Triangle */
  117183. Triangle = 3,
  117184. /** L1 */
  117185. L1 = 4,
  117186. /** R1 */
  117187. R1 = 5,
  117188. /** Share */
  117189. Share = 8,
  117190. /** Options */
  117191. Options = 9,
  117192. /** Left stick */
  117193. LeftStick = 10,
  117194. /** Right stick */
  117195. RightStick = 11
  117196. }
  117197. /** Defines values for DualShock DPad */
  117198. export enum DualShockDpad {
  117199. /** Up */
  117200. Up = 12,
  117201. /** Down */
  117202. Down = 13,
  117203. /** Left */
  117204. Left = 14,
  117205. /** Right */
  117206. Right = 15
  117207. }
  117208. /**
  117209. * Defines a DualShock gamepad
  117210. */
  117211. export class DualShockPad extends Gamepad {
  117212. private _leftTrigger;
  117213. private _rightTrigger;
  117214. private _onlefttriggerchanged;
  117215. private _onrighttriggerchanged;
  117216. private _onbuttondown;
  117217. private _onbuttonup;
  117218. private _ondpaddown;
  117219. private _ondpadup;
  117220. /** Observable raised when a button is pressed */
  117221. onButtonDownObservable: Observable<DualShockButton>;
  117222. /** Observable raised when a button is released */
  117223. onButtonUpObservable: Observable<DualShockButton>;
  117224. /** Observable raised when a pad is pressed */
  117225. onPadDownObservable: Observable<DualShockDpad>;
  117226. /** Observable raised when a pad is released */
  117227. onPadUpObservable: Observable<DualShockDpad>;
  117228. private _buttonCross;
  117229. private _buttonCircle;
  117230. private _buttonSquare;
  117231. private _buttonTriangle;
  117232. private _buttonShare;
  117233. private _buttonOptions;
  117234. private _buttonL1;
  117235. private _buttonR1;
  117236. private _buttonLeftStick;
  117237. private _buttonRightStick;
  117238. private _dPadUp;
  117239. private _dPadDown;
  117240. private _dPadLeft;
  117241. private _dPadRight;
  117242. /**
  117243. * Creates a new DualShock gamepad object
  117244. * @param id defines the id of this gamepad
  117245. * @param index defines its index
  117246. * @param gamepad defines the internal HTML gamepad object
  117247. */
  117248. constructor(id: string, index: number, gamepad: any);
  117249. /**
  117250. * Defines the callback to call when left trigger is pressed
  117251. * @param callback defines the callback to use
  117252. */
  117253. onlefttriggerchanged(callback: (value: number) => void): void;
  117254. /**
  117255. * Defines the callback to call when right trigger is pressed
  117256. * @param callback defines the callback to use
  117257. */
  117258. onrighttriggerchanged(callback: (value: number) => void): void;
  117259. /**
  117260. * Gets the left trigger value
  117261. */
  117262. get leftTrigger(): number;
  117263. /**
  117264. * Sets the left trigger value
  117265. */
  117266. set leftTrigger(newValue: number);
  117267. /**
  117268. * Gets the right trigger value
  117269. */
  117270. get rightTrigger(): number;
  117271. /**
  117272. * Sets the right trigger value
  117273. */
  117274. set rightTrigger(newValue: number);
  117275. /**
  117276. * Defines the callback to call when a button is pressed
  117277. * @param callback defines the callback to use
  117278. */
  117279. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  117280. /**
  117281. * Defines the callback to call when a button is released
  117282. * @param callback defines the callback to use
  117283. */
  117284. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  117285. /**
  117286. * Defines the callback to call when a pad is pressed
  117287. * @param callback defines the callback to use
  117288. */
  117289. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  117290. /**
  117291. * Defines the callback to call when a pad is released
  117292. * @param callback defines the callback to use
  117293. */
  117294. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  117295. private _setButtonValue;
  117296. private _setDPadValue;
  117297. /**
  117298. * Gets the value of the `Cross` button
  117299. */
  117300. get buttonCross(): number;
  117301. /**
  117302. * Sets the value of the `Cross` button
  117303. */
  117304. set buttonCross(value: number);
  117305. /**
  117306. * Gets the value of the `Circle` button
  117307. */
  117308. get buttonCircle(): number;
  117309. /**
  117310. * Sets the value of the `Circle` button
  117311. */
  117312. set buttonCircle(value: number);
  117313. /**
  117314. * Gets the value of the `Square` button
  117315. */
  117316. get buttonSquare(): number;
  117317. /**
  117318. * Sets the value of the `Square` button
  117319. */
  117320. set buttonSquare(value: number);
  117321. /**
  117322. * Gets the value of the `Triangle` button
  117323. */
  117324. get buttonTriangle(): number;
  117325. /**
  117326. * Sets the value of the `Triangle` button
  117327. */
  117328. set buttonTriangle(value: number);
  117329. /**
  117330. * Gets the value of the `Options` button
  117331. */
  117332. get buttonOptions(): number;
  117333. /**
  117334. * Sets the value of the `Options` button
  117335. */
  117336. set buttonOptions(value: number);
  117337. /**
  117338. * Gets the value of the `Share` button
  117339. */
  117340. get buttonShare(): number;
  117341. /**
  117342. * Sets the value of the `Share` button
  117343. */
  117344. set buttonShare(value: number);
  117345. /**
  117346. * Gets the value of the `L1` button
  117347. */
  117348. get buttonL1(): number;
  117349. /**
  117350. * Sets the value of the `L1` button
  117351. */
  117352. set buttonL1(value: number);
  117353. /**
  117354. * Gets the value of the `R1` button
  117355. */
  117356. get buttonR1(): number;
  117357. /**
  117358. * Sets the value of the `R1` button
  117359. */
  117360. set buttonR1(value: number);
  117361. /**
  117362. * Gets the value of the Left joystick
  117363. */
  117364. get buttonLeftStick(): number;
  117365. /**
  117366. * Sets the value of the Left joystick
  117367. */
  117368. set buttonLeftStick(value: number);
  117369. /**
  117370. * Gets the value of the Right joystick
  117371. */
  117372. get buttonRightStick(): number;
  117373. /**
  117374. * Sets the value of the Right joystick
  117375. */
  117376. set buttonRightStick(value: number);
  117377. /**
  117378. * Gets the value of D-pad up
  117379. */
  117380. get dPadUp(): number;
  117381. /**
  117382. * Sets the value of D-pad up
  117383. */
  117384. set dPadUp(value: number);
  117385. /**
  117386. * Gets the value of D-pad down
  117387. */
  117388. get dPadDown(): number;
  117389. /**
  117390. * Sets the value of D-pad down
  117391. */
  117392. set dPadDown(value: number);
  117393. /**
  117394. * Gets the value of D-pad left
  117395. */
  117396. get dPadLeft(): number;
  117397. /**
  117398. * Sets the value of D-pad left
  117399. */
  117400. set dPadLeft(value: number);
  117401. /**
  117402. * Gets the value of D-pad right
  117403. */
  117404. get dPadRight(): number;
  117405. /**
  117406. * Sets the value of D-pad right
  117407. */
  117408. set dPadRight(value: number);
  117409. /**
  117410. * Force the gamepad to synchronize with device values
  117411. */
  117412. update(): void;
  117413. /**
  117414. * Disposes the gamepad
  117415. */
  117416. dispose(): void;
  117417. }
  117418. }
  117419. declare module BABYLON {
  117420. /**
  117421. * Manager for handling gamepads
  117422. */
  117423. export class GamepadManager {
  117424. private _scene?;
  117425. private _babylonGamepads;
  117426. private _oneGamepadConnected;
  117427. /** @hidden */
  117428. _isMonitoring: boolean;
  117429. private _gamepadEventSupported;
  117430. private _gamepadSupport?;
  117431. /**
  117432. * observable to be triggered when the gamepad controller has been connected
  117433. */
  117434. onGamepadConnectedObservable: Observable<Gamepad>;
  117435. /**
  117436. * observable to be triggered when the gamepad controller has been disconnected
  117437. */
  117438. onGamepadDisconnectedObservable: Observable<Gamepad>;
  117439. private _onGamepadConnectedEvent;
  117440. private _onGamepadDisconnectedEvent;
  117441. /**
  117442. * Initializes the gamepad manager
  117443. * @param _scene BabylonJS scene
  117444. */
  117445. constructor(_scene?: Scene | undefined);
  117446. /**
  117447. * The gamepads in the game pad manager
  117448. */
  117449. get gamepads(): Gamepad[];
  117450. /**
  117451. * Get the gamepad controllers based on type
  117452. * @param type The type of gamepad controller
  117453. * @returns Nullable gamepad
  117454. */
  117455. getGamepadByType(type?: number): Nullable<Gamepad>;
  117456. /**
  117457. * Disposes the gamepad manager
  117458. */
  117459. dispose(): void;
  117460. private _addNewGamepad;
  117461. private _startMonitoringGamepads;
  117462. private _stopMonitoringGamepads;
  117463. /** @hidden */
  117464. _checkGamepadsStatus(): void;
  117465. private _updateGamepadObjects;
  117466. }
  117467. }
  117468. declare module BABYLON {
  117469. interface Scene {
  117470. /** @hidden */
  117471. _gamepadManager: Nullable<GamepadManager>;
  117472. /**
  117473. * Gets the gamepad manager associated with the scene
  117474. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  117475. */
  117476. gamepadManager: GamepadManager;
  117477. }
  117478. /**
  117479. * Interface representing a free camera inputs manager
  117480. */
  117481. interface FreeCameraInputsManager {
  117482. /**
  117483. * Adds gamepad input support to the FreeCameraInputsManager.
  117484. * @returns the FreeCameraInputsManager
  117485. */
  117486. addGamepad(): FreeCameraInputsManager;
  117487. }
  117488. /**
  117489. * Interface representing an arc rotate camera inputs manager
  117490. */
  117491. interface ArcRotateCameraInputsManager {
  117492. /**
  117493. * Adds gamepad input support to the ArcRotateCamera InputManager.
  117494. * @returns the camera inputs manager
  117495. */
  117496. addGamepad(): ArcRotateCameraInputsManager;
  117497. }
  117498. /**
  117499. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  117500. */
  117501. export class GamepadSystemSceneComponent implements ISceneComponent {
  117502. /**
  117503. * The component name helpfull to identify the component in the list of scene components.
  117504. */
  117505. readonly name: string;
  117506. /**
  117507. * The scene the component belongs to.
  117508. */
  117509. scene: Scene;
  117510. /**
  117511. * Creates a new instance of the component for the given scene
  117512. * @param scene Defines the scene to register the component in
  117513. */
  117514. constructor(scene: Scene);
  117515. /**
  117516. * Registers the component in a given scene
  117517. */
  117518. register(): void;
  117519. /**
  117520. * Rebuilds the elements related to this component in case of
  117521. * context lost for instance.
  117522. */
  117523. rebuild(): void;
  117524. /**
  117525. * Disposes the component and the associated ressources
  117526. */
  117527. dispose(): void;
  117528. private _beforeCameraUpdate;
  117529. }
  117530. }
  117531. declare module BABYLON {
  117532. /**
  117533. * 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,
  117534. * which still works and will still be found in many Playgrounds.
  117535. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  117536. */
  117537. export class UniversalCamera extends TouchCamera {
  117538. /**
  117539. * Defines the gamepad rotation sensiblity.
  117540. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  117541. */
  117542. get gamepadAngularSensibility(): number;
  117543. set gamepadAngularSensibility(value: number);
  117544. /**
  117545. * Defines the gamepad move sensiblity.
  117546. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  117547. */
  117548. get gamepadMoveSensibility(): number;
  117549. set gamepadMoveSensibility(value: number);
  117550. /**
  117551. * 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,
  117552. * which still works and will still be found in many Playgrounds.
  117553. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  117554. * @param name Define the name of the camera in the scene
  117555. * @param position Define the start position of the camera in the scene
  117556. * @param scene Define the scene the camera belongs to
  117557. */
  117558. constructor(name: string, position: Vector3, scene: Scene);
  117559. /**
  117560. * Gets the current object class name.
  117561. * @return the class name
  117562. */
  117563. getClassName(): string;
  117564. }
  117565. }
  117566. declare module BABYLON {
  117567. /**
  117568. * This represents a FPS type of camera. This is only here for back compat purpose.
  117569. * Please use the UniversalCamera instead as both are identical.
  117570. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  117571. */
  117572. export class GamepadCamera extends UniversalCamera {
  117573. /**
  117574. * Instantiates a new Gamepad Camera
  117575. * This represents a FPS type of camera. This is only here for back compat purpose.
  117576. * Please use the UniversalCamera instead as both are identical.
  117577. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  117578. * @param name Define the name of the camera in the scene
  117579. * @param position Define the start position of the camera in the scene
  117580. * @param scene Define the scene the camera belongs to
  117581. */
  117582. constructor(name: string, position: Vector3, scene: Scene);
  117583. /**
  117584. * Gets the current object class name.
  117585. * @return the class name
  117586. */
  117587. getClassName(): string;
  117588. }
  117589. }
  117590. declare module BABYLON {
  117591. /** @hidden */
  117592. export var passPixelShader: {
  117593. name: string;
  117594. shader: string;
  117595. };
  117596. }
  117597. declare module BABYLON {
  117598. /** @hidden */
  117599. export var passCubePixelShader: {
  117600. name: string;
  117601. shader: string;
  117602. };
  117603. }
  117604. declare module BABYLON {
  117605. /**
  117606. * PassPostProcess which produces an output the same as it's input
  117607. */
  117608. export class PassPostProcess extends PostProcess {
  117609. /**
  117610. * Creates the PassPostProcess
  117611. * @param name The name of the effect.
  117612. * @param options The required width/height ratio to downsize to before computing the render pass.
  117613. * @param camera The camera to apply the render pass to.
  117614. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  117615. * @param engine The engine which the post process will be applied. (default: current engine)
  117616. * @param reusable If the post process can be reused on the same frame. (default: false)
  117617. * @param textureType The type of texture to be used when performing the post processing.
  117618. * @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)
  117619. */
  117620. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  117621. }
  117622. /**
  117623. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  117624. */
  117625. export class PassCubePostProcess extends PostProcess {
  117626. private _face;
  117627. /**
  117628. * Gets or sets the cube face to display.
  117629. * * 0 is +X
  117630. * * 1 is -X
  117631. * * 2 is +Y
  117632. * * 3 is -Y
  117633. * * 4 is +Z
  117634. * * 5 is -Z
  117635. */
  117636. get face(): number;
  117637. set face(value: number);
  117638. /**
  117639. * Creates the PassCubePostProcess
  117640. * @param name The name of the effect.
  117641. * @param options The required width/height ratio to downsize to before computing the render pass.
  117642. * @param camera The camera to apply the render pass to.
  117643. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  117644. * @param engine The engine which the post process will be applied. (default: current engine)
  117645. * @param reusable If the post process can be reused on the same frame. (default: false)
  117646. * @param textureType The type of texture to be used when performing the post processing.
  117647. * @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)
  117648. */
  117649. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  117650. }
  117651. }
  117652. declare module BABYLON {
  117653. /** @hidden */
  117654. export var anaglyphPixelShader: {
  117655. name: string;
  117656. shader: string;
  117657. };
  117658. }
  117659. declare module BABYLON {
  117660. /**
  117661. * Postprocess used to generate anaglyphic rendering
  117662. */
  117663. export class AnaglyphPostProcess extends PostProcess {
  117664. private _passedProcess;
  117665. /**
  117666. * Creates a new AnaglyphPostProcess
  117667. * @param name defines postprocess name
  117668. * @param options defines creation options or target ratio scale
  117669. * @param rigCameras defines cameras using this postprocess
  117670. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  117671. * @param engine defines hosting engine
  117672. * @param reusable defines if the postprocess will be reused multiple times per frame
  117673. */
  117674. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  117675. }
  117676. }
  117677. declare module BABYLON {
  117678. /**
  117679. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  117680. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  117681. */
  117682. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  117683. /**
  117684. * Creates a new AnaglyphArcRotateCamera
  117685. * @param name defines camera name
  117686. * @param alpha defines alpha angle (in radians)
  117687. * @param beta defines beta angle (in radians)
  117688. * @param radius defines radius
  117689. * @param target defines camera target
  117690. * @param interaxialDistance defines distance between each color axis
  117691. * @param scene defines the hosting scene
  117692. */
  117693. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  117694. /**
  117695. * Gets camera class name
  117696. * @returns AnaglyphArcRotateCamera
  117697. */
  117698. getClassName(): string;
  117699. }
  117700. }
  117701. declare module BABYLON {
  117702. /**
  117703. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  117704. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  117705. */
  117706. export class AnaglyphFreeCamera extends FreeCamera {
  117707. /**
  117708. * Creates a new AnaglyphFreeCamera
  117709. * @param name defines camera name
  117710. * @param position defines initial position
  117711. * @param interaxialDistance defines distance between each color axis
  117712. * @param scene defines the hosting scene
  117713. */
  117714. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  117715. /**
  117716. * Gets camera class name
  117717. * @returns AnaglyphFreeCamera
  117718. */
  117719. getClassName(): string;
  117720. }
  117721. }
  117722. declare module BABYLON {
  117723. /**
  117724. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  117725. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  117726. */
  117727. export class AnaglyphGamepadCamera extends GamepadCamera {
  117728. /**
  117729. * Creates a new AnaglyphGamepadCamera
  117730. * @param name defines camera name
  117731. * @param position defines initial position
  117732. * @param interaxialDistance defines distance between each color axis
  117733. * @param scene defines the hosting scene
  117734. */
  117735. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  117736. /**
  117737. * Gets camera class name
  117738. * @returns AnaglyphGamepadCamera
  117739. */
  117740. getClassName(): string;
  117741. }
  117742. }
  117743. declare module BABYLON {
  117744. /**
  117745. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  117746. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  117747. */
  117748. export class AnaglyphUniversalCamera extends UniversalCamera {
  117749. /**
  117750. * Creates a new AnaglyphUniversalCamera
  117751. * @param name defines camera name
  117752. * @param position defines initial position
  117753. * @param interaxialDistance defines distance between each color axis
  117754. * @param scene defines the hosting scene
  117755. */
  117756. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  117757. /**
  117758. * Gets camera class name
  117759. * @returns AnaglyphUniversalCamera
  117760. */
  117761. getClassName(): string;
  117762. }
  117763. }
  117764. declare module BABYLON {
  117765. /**
  117766. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  117767. * @see http://doc.babylonjs.com/features/cameras
  117768. */
  117769. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  117770. /**
  117771. * Creates a new StereoscopicArcRotateCamera
  117772. * @param name defines camera name
  117773. * @param alpha defines alpha angle (in radians)
  117774. * @param beta defines beta angle (in radians)
  117775. * @param radius defines radius
  117776. * @param target defines camera target
  117777. * @param interaxialDistance defines distance between each color axis
  117778. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  117779. * @param scene defines the hosting scene
  117780. */
  117781. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  117782. /**
  117783. * Gets camera class name
  117784. * @returns StereoscopicArcRotateCamera
  117785. */
  117786. getClassName(): string;
  117787. }
  117788. }
  117789. declare module BABYLON {
  117790. /**
  117791. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  117792. * @see http://doc.babylonjs.com/features/cameras
  117793. */
  117794. export class StereoscopicFreeCamera extends FreeCamera {
  117795. /**
  117796. * Creates a new StereoscopicFreeCamera
  117797. * @param name defines camera name
  117798. * @param position defines initial position
  117799. * @param interaxialDistance defines distance between each color axis
  117800. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  117801. * @param scene defines the hosting scene
  117802. */
  117803. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  117804. /**
  117805. * Gets camera class name
  117806. * @returns StereoscopicFreeCamera
  117807. */
  117808. getClassName(): string;
  117809. }
  117810. }
  117811. declare module BABYLON {
  117812. /**
  117813. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  117814. * @see http://doc.babylonjs.com/features/cameras
  117815. */
  117816. export class StereoscopicGamepadCamera extends GamepadCamera {
  117817. /**
  117818. * Creates a new StereoscopicGamepadCamera
  117819. * @param name defines camera name
  117820. * @param position defines initial position
  117821. * @param interaxialDistance defines distance between each color axis
  117822. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  117823. * @param scene defines the hosting scene
  117824. */
  117825. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  117826. /**
  117827. * Gets camera class name
  117828. * @returns StereoscopicGamepadCamera
  117829. */
  117830. getClassName(): string;
  117831. }
  117832. }
  117833. declare module BABYLON {
  117834. /**
  117835. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  117836. * @see http://doc.babylonjs.com/features/cameras
  117837. */
  117838. export class StereoscopicUniversalCamera extends UniversalCamera {
  117839. /**
  117840. * Creates a new StereoscopicUniversalCamera
  117841. * @param name defines camera name
  117842. * @param position defines initial position
  117843. * @param interaxialDistance defines distance between each color axis
  117844. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  117845. * @param scene defines the hosting scene
  117846. */
  117847. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  117848. /**
  117849. * Gets camera class name
  117850. * @returns StereoscopicUniversalCamera
  117851. */
  117852. getClassName(): string;
  117853. }
  117854. }
  117855. declare module BABYLON {
  117856. /**
  117857. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  117858. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  117859. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  117860. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  117861. */
  117862. export class VirtualJoysticksCamera extends FreeCamera {
  117863. /**
  117864. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  117865. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  117866. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  117867. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  117868. * @param name Define the name of the camera in the scene
  117869. * @param position Define the start position of the camera in the scene
  117870. * @param scene Define the scene the camera belongs to
  117871. */
  117872. constructor(name: string, position: Vector3, scene: Scene);
  117873. /**
  117874. * Gets the current object class name.
  117875. * @return the class name
  117876. */
  117877. getClassName(): string;
  117878. }
  117879. }
  117880. declare module BABYLON {
  117881. /**
  117882. * This represents all the required metrics to create a VR camera.
  117883. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  117884. */
  117885. export class VRCameraMetrics {
  117886. /**
  117887. * Define the horizontal resolution off the screen.
  117888. */
  117889. hResolution: number;
  117890. /**
  117891. * Define the vertical resolution off the screen.
  117892. */
  117893. vResolution: number;
  117894. /**
  117895. * Define the horizontal screen size.
  117896. */
  117897. hScreenSize: number;
  117898. /**
  117899. * Define the vertical screen size.
  117900. */
  117901. vScreenSize: number;
  117902. /**
  117903. * Define the vertical screen center position.
  117904. */
  117905. vScreenCenter: number;
  117906. /**
  117907. * Define the distance of the eyes to the screen.
  117908. */
  117909. eyeToScreenDistance: number;
  117910. /**
  117911. * Define the distance between both lenses
  117912. */
  117913. lensSeparationDistance: number;
  117914. /**
  117915. * Define the distance between both viewer's eyes.
  117916. */
  117917. interpupillaryDistance: number;
  117918. /**
  117919. * Define the distortion factor of the VR postprocess.
  117920. * Please, touch with care.
  117921. */
  117922. distortionK: number[];
  117923. /**
  117924. * Define the chromatic aberration correction factors for the VR post process.
  117925. */
  117926. chromaAbCorrection: number[];
  117927. /**
  117928. * Define the scale factor of the post process.
  117929. * The smaller the better but the slower.
  117930. */
  117931. postProcessScaleFactor: number;
  117932. /**
  117933. * Define an offset for the lens center.
  117934. */
  117935. lensCenterOffset: number;
  117936. /**
  117937. * Define if the current vr camera should compensate the distortion of the lense or not.
  117938. */
  117939. compensateDistortion: boolean;
  117940. /**
  117941. * Defines if multiview should be enabled when rendering (Default: false)
  117942. */
  117943. multiviewEnabled: boolean;
  117944. /**
  117945. * Gets the rendering aspect ratio based on the provided resolutions.
  117946. */
  117947. get aspectRatio(): number;
  117948. /**
  117949. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  117950. */
  117951. get aspectRatioFov(): number;
  117952. /**
  117953. * @hidden
  117954. */
  117955. get leftHMatrix(): Matrix;
  117956. /**
  117957. * @hidden
  117958. */
  117959. get rightHMatrix(): Matrix;
  117960. /**
  117961. * @hidden
  117962. */
  117963. get leftPreViewMatrix(): Matrix;
  117964. /**
  117965. * @hidden
  117966. */
  117967. get rightPreViewMatrix(): Matrix;
  117968. /**
  117969. * Get the default VRMetrics based on the most generic setup.
  117970. * @returns the default vr metrics
  117971. */
  117972. static GetDefault(): VRCameraMetrics;
  117973. }
  117974. }
  117975. declare module BABYLON {
  117976. /** @hidden */
  117977. export var vrDistortionCorrectionPixelShader: {
  117978. name: string;
  117979. shader: string;
  117980. };
  117981. }
  117982. declare module BABYLON {
  117983. /**
  117984. * VRDistortionCorrectionPostProcess used for mobile VR
  117985. */
  117986. export class VRDistortionCorrectionPostProcess extends PostProcess {
  117987. private _isRightEye;
  117988. private _distortionFactors;
  117989. private _postProcessScaleFactor;
  117990. private _lensCenterOffset;
  117991. private _scaleIn;
  117992. private _scaleFactor;
  117993. private _lensCenter;
  117994. /**
  117995. * Initializes the VRDistortionCorrectionPostProcess
  117996. * @param name The name of the effect.
  117997. * @param camera The camera to apply the render pass to.
  117998. * @param isRightEye If this is for the right eye distortion
  117999. * @param vrMetrics All the required metrics for the VR camera
  118000. */
  118001. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  118002. }
  118003. }
  118004. declare module BABYLON {
  118005. /**
  118006. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  118007. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  118008. */
  118009. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  118010. /**
  118011. * Creates a new VRDeviceOrientationArcRotateCamera
  118012. * @param name defines camera name
  118013. * @param alpha defines the camera rotation along the logitudinal axis
  118014. * @param beta defines the camera rotation along the latitudinal axis
  118015. * @param radius defines the camera distance from its target
  118016. * @param target defines the camera target
  118017. * @param scene defines the scene the camera belongs to
  118018. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  118019. * @param vrCameraMetrics defines the vr metrics associated to the camera
  118020. */
  118021. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  118022. /**
  118023. * Gets camera class name
  118024. * @returns VRDeviceOrientationArcRotateCamera
  118025. */
  118026. getClassName(): string;
  118027. }
  118028. }
  118029. declare module BABYLON {
  118030. /**
  118031. * Camera used to simulate VR rendering (based on FreeCamera)
  118032. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  118033. */
  118034. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  118035. /**
  118036. * Creates a new VRDeviceOrientationFreeCamera
  118037. * @param name defines camera name
  118038. * @param position defines the start position of the camera
  118039. * @param scene defines the scene the camera belongs to
  118040. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  118041. * @param vrCameraMetrics defines the vr metrics associated to the camera
  118042. */
  118043. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  118044. /**
  118045. * Gets camera class name
  118046. * @returns VRDeviceOrientationFreeCamera
  118047. */
  118048. getClassName(): string;
  118049. }
  118050. }
  118051. declare module BABYLON {
  118052. /**
  118053. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  118054. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  118055. */
  118056. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  118057. /**
  118058. * Creates a new VRDeviceOrientationGamepadCamera
  118059. * @param name defines camera name
  118060. * @param position defines the start position of the camera
  118061. * @param scene defines the scene the camera belongs to
  118062. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  118063. * @param vrCameraMetrics defines the vr metrics associated to the camera
  118064. */
  118065. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  118066. /**
  118067. * Gets camera class name
  118068. * @returns VRDeviceOrientationGamepadCamera
  118069. */
  118070. getClassName(): string;
  118071. }
  118072. }
  118073. declare module BABYLON {
  118074. /** @hidden */
  118075. export var imageProcessingPixelShader: {
  118076. name: string;
  118077. shader: string;
  118078. };
  118079. }
  118080. declare module BABYLON {
  118081. /**
  118082. * ImageProcessingPostProcess
  118083. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  118084. */
  118085. export class ImageProcessingPostProcess extends PostProcess {
  118086. /**
  118087. * Default configuration related to image processing available in the PBR Material.
  118088. */
  118089. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  118090. /**
  118091. * Gets the image processing configuration used either in this material.
  118092. */
  118093. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  118094. /**
  118095. * Sets the Default image processing configuration used either in the this material.
  118096. *
  118097. * If sets to null, the scene one is in use.
  118098. */
  118099. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  118100. /**
  118101. * Keep track of the image processing observer to allow dispose and replace.
  118102. */
  118103. private _imageProcessingObserver;
  118104. /**
  118105. * Attaches a new image processing configuration to the PBR Material.
  118106. * @param configuration
  118107. */
  118108. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  118109. /**
  118110. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  118111. */
  118112. get colorCurves(): Nullable<ColorCurves>;
  118113. /**
  118114. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  118115. */
  118116. set colorCurves(value: Nullable<ColorCurves>);
  118117. /**
  118118. * Gets wether the color curves effect is enabled.
  118119. */
  118120. get colorCurvesEnabled(): boolean;
  118121. /**
  118122. * Sets wether the color curves effect is enabled.
  118123. */
  118124. set colorCurvesEnabled(value: boolean);
  118125. /**
  118126. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  118127. */
  118128. get colorGradingTexture(): Nullable<BaseTexture>;
  118129. /**
  118130. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  118131. */
  118132. set colorGradingTexture(value: Nullable<BaseTexture>);
  118133. /**
  118134. * Gets wether the color grading effect is enabled.
  118135. */
  118136. get colorGradingEnabled(): boolean;
  118137. /**
  118138. * Gets wether the color grading effect is enabled.
  118139. */
  118140. set colorGradingEnabled(value: boolean);
  118141. /**
  118142. * Gets exposure used in the effect.
  118143. */
  118144. get exposure(): number;
  118145. /**
  118146. * Sets exposure used in the effect.
  118147. */
  118148. set exposure(value: number);
  118149. /**
  118150. * Gets wether tonemapping is enabled or not.
  118151. */
  118152. get toneMappingEnabled(): boolean;
  118153. /**
  118154. * Sets wether tonemapping is enabled or not
  118155. */
  118156. set toneMappingEnabled(value: boolean);
  118157. /**
  118158. * Gets the type of tone mapping effect.
  118159. */
  118160. get toneMappingType(): number;
  118161. /**
  118162. * Sets the type of tone mapping effect.
  118163. */
  118164. set toneMappingType(value: number);
  118165. /**
  118166. * Gets contrast used in the effect.
  118167. */
  118168. get contrast(): number;
  118169. /**
  118170. * Sets contrast used in the effect.
  118171. */
  118172. set contrast(value: number);
  118173. /**
  118174. * Gets Vignette stretch size.
  118175. */
  118176. get vignetteStretch(): number;
  118177. /**
  118178. * Sets Vignette stretch size.
  118179. */
  118180. set vignetteStretch(value: number);
  118181. /**
  118182. * Gets Vignette centre X Offset.
  118183. */
  118184. get vignetteCentreX(): number;
  118185. /**
  118186. * Sets Vignette centre X Offset.
  118187. */
  118188. set vignetteCentreX(value: number);
  118189. /**
  118190. * Gets Vignette centre Y Offset.
  118191. */
  118192. get vignetteCentreY(): number;
  118193. /**
  118194. * Sets Vignette centre Y Offset.
  118195. */
  118196. set vignetteCentreY(value: number);
  118197. /**
  118198. * Gets Vignette weight or intensity of the vignette effect.
  118199. */
  118200. get vignetteWeight(): number;
  118201. /**
  118202. * Sets Vignette weight or intensity of the vignette effect.
  118203. */
  118204. set vignetteWeight(value: number);
  118205. /**
  118206. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  118207. * if vignetteEnabled is set to true.
  118208. */
  118209. get vignetteColor(): Color4;
  118210. /**
  118211. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  118212. * if vignetteEnabled is set to true.
  118213. */
  118214. set vignetteColor(value: Color4);
  118215. /**
  118216. * Gets Camera field of view used by the Vignette effect.
  118217. */
  118218. get vignetteCameraFov(): number;
  118219. /**
  118220. * Sets Camera field of view used by the Vignette effect.
  118221. */
  118222. set vignetteCameraFov(value: number);
  118223. /**
  118224. * Gets the vignette blend mode allowing different kind of effect.
  118225. */
  118226. get vignetteBlendMode(): number;
  118227. /**
  118228. * Sets the vignette blend mode allowing different kind of effect.
  118229. */
  118230. set vignetteBlendMode(value: number);
  118231. /**
  118232. * Gets wether the vignette effect is enabled.
  118233. */
  118234. get vignetteEnabled(): boolean;
  118235. /**
  118236. * Sets wether the vignette effect is enabled.
  118237. */
  118238. set vignetteEnabled(value: boolean);
  118239. private _fromLinearSpace;
  118240. /**
  118241. * Gets wether the input of the processing is in Gamma or Linear Space.
  118242. */
  118243. get fromLinearSpace(): boolean;
  118244. /**
  118245. * Sets wether the input of the processing is in Gamma or Linear Space.
  118246. */
  118247. set fromLinearSpace(value: boolean);
  118248. /**
  118249. * Defines cache preventing GC.
  118250. */
  118251. private _defines;
  118252. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  118253. /**
  118254. * "ImageProcessingPostProcess"
  118255. * @returns "ImageProcessingPostProcess"
  118256. */
  118257. getClassName(): string;
  118258. protected _updateParameters(): void;
  118259. dispose(camera?: Camera): void;
  118260. }
  118261. }
  118262. declare module BABYLON {
  118263. /**
  118264. * Class containing static functions to help procedurally build meshes
  118265. */
  118266. export class GroundBuilder {
  118267. /**
  118268. * Creates a ground mesh
  118269. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  118270. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  118271. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  118272. * @param name defines the name of the mesh
  118273. * @param options defines the options used to create the mesh
  118274. * @param scene defines the hosting scene
  118275. * @returns the ground mesh
  118276. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  118277. */
  118278. static CreateGround(name: string, options: {
  118279. width?: number;
  118280. height?: number;
  118281. subdivisions?: number;
  118282. subdivisionsX?: number;
  118283. subdivisionsY?: number;
  118284. updatable?: boolean;
  118285. }, scene: any): Mesh;
  118286. /**
  118287. * Creates a tiled ground mesh
  118288. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  118289. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  118290. * * 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
  118291. * * 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
  118292. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  118293. * @param name defines the name of the mesh
  118294. * @param options defines the options used to create the mesh
  118295. * @param scene defines the hosting scene
  118296. * @returns the tiled ground mesh
  118297. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  118298. */
  118299. static CreateTiledGround(name: string, options: {
  118300. xmin: number;
  118301. zmin: number;
  118302. xmax: number;
  118303. zmax: number;
  118304. subdivisions?: {
  118305. w: number;
  118306. h: number;
  118307. };
  118308. precision?: {
  118309. w: number;
  118310. h: number;
  118311. };
  118312. updatable?: boolean;
  118313. }, scene?: Nullable<Scene>): Mesh;
  118314. /**
  118315. * Creates a ground mesh from a height map
  118316. * * The parameter `url` sets the URL of the height map image resource.
  118317. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  118318. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  118319. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  118320. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  118321. * * 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.
  118322. * * 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).
  118323. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  118324. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  118325. * @param name defines the name of the mesh
  118326. * @param url defines the url to the height map
  118327. * @param options defines the options used to create the mesh
  118328. * @param scene defines the hosting scene
  118329. * @returns the ground mesh
  118330. * @see https://doc.babylonjs.com/babylon101/height_map
  118331. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  118332. */
  118333. static CreateGroundFromHeightMap(name: string, url: string, options: {
  118334. width?: number;
  118335. height?: number;
  118336. subdivisions?: number;
  118337. minHeight?: number;
  118338. maxHeight?: number;
  118339. colorFilter?: Color3;
  118340. alphaFilter?: number;
  118341. updatable?: boolean;
  118342. onReady?: (mesh: GroundMesh) => void;
  118343. }, scene?: Nullable<Scene>): GroundMesh;
  118344. }
  118345. }
  118346. declare module BABYLON {
  118347. /**
  118348. * Class containing static functions to help procedurally build meshes
  118349. */
  118350. export class TorusBuilder {
  118351. /**
  118352. * Creates a torus mesh
  118353. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  118354. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  118355. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  118356. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  118357. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  118358. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  118359. * @param name defines the name of the mesh
  118360. * @param options defines the options used to create the mesh
  118361. * @param scene defines the hosting scene
  118362. * @returns the torus mesh
  118363. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  118364. */
  118365. static CreateTorus(name: string, options: {
  118366. diameter?: number;
  118367. thickness?: number;
  118368. tessellation?: number;
  118369. updatable?: boolean;
  118370. sideOrientation?: number;
  118371. frontUVs?: Vector4;
  118372. backUVs?: Vector4;
  118373. }, scene: any): Mesh;
  118374. }
  118375. }
  118376. declare module BABYLON {
  118377. /**
  118378. * Class containing static functions to help procedurally build meshes
  118379. */
  118380. export class CylinderBuilder {
  118381. /**
  118382. * Creates a cylinder or a cone mesh
  118383. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  118384. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  118385. * * 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.
  118386. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  118387. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  118388. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  118389. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  118390. * * 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).
  118391. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  118392. * * 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).
  118393. * * 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
  118394. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  118395. * * 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
  118396. * * 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.
  118397. * * If `enclose` is false, a ring surface is one element.
  118398. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  118399. * * 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
  118400. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  118401. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  118402. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  118403. * @param name defines the name of the mesh
  118404. * @param options defines the options used to create the mesh
  118405. * @param scene defines the hosting scene
  118406. * @returns the cylinder mesh
  118407. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  118408. */
  118409. static CreateCylinder(name: string, options: {
  118410. height?: number;
  118411. diameterTop?: number;
  118412. diameterBottom?: number;
  118413. diameter?: number;
  118414. tessellation?: number;
  118415. subdivisions?: number;
  118416. arc?: number;
  118417. faceColors?: Color4[];
  118418. faceUV?: Vector4[];
  118419. updatable?: boolean;
  118420. hasRings?: boolean;
  118421. enclose?: boolean;
  118422. cap?: number;
  118423. sideOrientation?: number;
  118424. frontUVs?: Vector4;
  118425. backUVs?: Vector4;
  118426. }, scene: any): Mesh;
  118427. }
  118428. }
  118429. declare module BABYLON {
  118430. /**
  118431. * States of the webXR experience
  118432. */
  118433. export enum WebXRState {
  118434. /**
  118435. * Transitioning to being in XR mode
  118436. */
  118437. ENTERING_XR = 0,
  118438. /**
  118439. * Transitioning to non XR mode
  118440. */
  118441. EXITING_XR = 1,
  118442. /**
  118443. * In XR mode and presenting
  118444. */
  118445. IN_XR = 2,
  118446. /**
  118447. * Not entered XR mode
  118448. */
  118449. NOT_IN_XR = 3
  118450. }
  118451. /**
  118452. * Abstraction of the XR render target
  118453. */
  118454. export interface WebXRRenderTarget extends IDisposable {
  118455. /**
  118456. * xrpresent context of the canvas which can be used to display/mirror xr content
  118457. */
  118458. canvasContext: WebGLRenderingContext;
  118459. /**
  118460. * xr layer for the canvas
  118461. */
  118462. xrLayer: Nullable<XRWebGLLayer>;
  118463. /**
  118464. * Initializes the xr layer for the session
  118465. * @param xrSession xr session
  118466. * @returns a promise that will resolve once the XR Layer has been created
  118467. */
  118468. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  118469. }
  118470. }
  118471. declare module BABYLON {
  118472. /**
  118473. * COnfiguration object for WebXR output canvas
  118474. */
  118475. export class WebXRManagedOutputCanvasOptions {
  118476. /**
  118477. * An optional canvas in case you wish to create it yourself and provide it here.
  118478. * If not provided, a new canvas will be created
  118479. */
  118480. canvasElement?: HTMLCanvasElement;
  118481. /**
  118482. * Options for this XR Layer output
  118483. */
  118484. canvasOptions?: XRWebGLLayerOptions;
  118485. /**
  118486. * CSS styling for a newly created canvas (if not provided)
  118487. */
  118488. newCanvasCssStyle?: string;
  118489. /**
  118490. * Get the default values of the configuration object
  118491. * @returns default values of this configuration object
  118492. */
  118493. static GetDefaults(): WebXRManagedOutputCanvasOptions;
  118494. }
  118495. /**
  118496. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  118497. */
  118498. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  118499. private _options;
  118500. private _canvas;
  118501. private _engine;
  118502. /**
  118503. * Rendering context of the canvas which can be used to display/mirror xr content
  118504. */
  118505. canvasContext: WebGLRenderingContext;
  118506. /**
  118507. * xr layer for the canvas
  118508. */
  118509. xrLayer: Nullable<XRWebGLLayer>;
  118510. /**
  118511. * Initializes the canvas to be added/removed upon entering/exiting xr
  118512. * @param _xrSessionManager The XR Session manager
  118513. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  118514. */
  118515. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  118516. /**
  118517. * Disposes of the object
  118518. */
  118519. dispose(): void;
  118520. /**
  118521. * Initializes the xr layer for the session
  118522. * @param xrSession xr session
  118523. * @returns a promise that will resolve once the XR Layer has been created
  118524. */
  118525. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  118526. private _addCanvas;
  118527. private _removeCanvas;
  118528. private _setManagedOutputCanvas;
  118529. }
  118530. }
  118531. declare module BABYLON {
  118532. /**
  118533. * Manages an XRSession to work with Babylon's engine
  118534. * @see https://doc.babylonjs.com/how_to/webxr
  118535. */
  118536. export class WebXRSessionManager implements IDisposable {
  118537. /** The scene which the session should be created for */
  118538. scene: Scene;
  118539. private _referenceSpace;
  118540. private _rttProvider;
  118541. private _sessionEnded;
  118542. private _xrNavigator;
  118543. private baseLayer;
  118544. /**
  118545. * The base reference space from which the session started. good if you want to reset your
  118546. * reference space
  118547. */
  118548. baseReferenceSpace: XRReferenceSpace;
  118549. /**
  118550. * Current XR frame
  118551. */
  118552. currentFrame: Nullable<XRFrame>;
  118553. /** WebXR timestamp updated every frame */
  118554. currentTimestamp: number;
  118555. /**
  118556. * Used just in case of a failure to initialize an immersive session.
  118557. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  118558. */
  118559. defaultHeightCompensation: number;
  118560. /**
  118561. * Fires every time a new xrFrame arrives which can be used to update the camera
  118562. */
  118563. onXRFrameObservable: Observable<XRFrame>;
  118564. /**
  118565. * Fires when the reference space changed
  118566. */
  118567. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  118568. /**
  118569. * Fires when the xr session is ended either by the device or manually done
  118570. */
  118571. onXRSessionEnded: Observable<any>;
  118572. /**
  118573. * Fires when the xr session is ended either by the device or manually done
  118574. */
  118575. onXRSessionInit: Observable<XRSession>;
  118576. /**
  118577. * Underlying xr session
  118578. */
  118579. session: XRSession;
  118580. /**
  118581. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  118582. * or get the offset the player is currently at.
  118583. */
  118584. viewerReferenceSpace: XRReferenceSpace;
  118585. /**
  118586. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  118587. * @param scene The scene which the session should be created for
  118588. */
  118589. constructor(
  118590. /** The scene which the session should be created for */
  118591. scene: Scene);
  118592. /**
  118593. * The current reference space used in this session. This reference space can constantly change!
  118594. * It is mainly used to offset the camera's position.
  118595. */
  118596. get referenceSpace(): XRReferenceSpace;
  118597. /**
  118598. * Set a new reference space and triggers the observable
  118599. */
  118600. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  118601. /**
  118602. * Disposes of the session manager
  118603. */
  118604. dispose(): void;
  118605. /**
  118606. * Stops the xrSession and restores the render loop
  118607. * @returns Promise which resolves after it exits XR
  118608. */
  118609. exitXRAsync(): Promise<void>;
  118610. /**
  118611. * Gets the correct render target texture to be rendered this frame for this eye
  118612. * @param eye the eye for which to get the render target
  118613. * @returns the render target for the specified eye
  118614. */
  118615. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  118616. /**
  118617. * Creates a WebXRRenderTarget object for the XR session
  118618. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  118619. * @param options optional options to provide when creating a new render target
  118620. * @returns a WebXR render target to which the session can render
  118621. */
  118622. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  118623. /**
  118624. * Initializes the manager
  118625. * After initialization enterXR can be called to start an XR session
  118626. * @returns Promise which resolves after it is initialized
  118627. */
  118628. initializeAsync(): Promise<void>;
  118629. /**
  118630. * Initializes an xr session
  118631. * @param xrSessionMode mode to initialize
  118632. * @param xrSessionInit defines optional and required values to pass to the session builder
  118633. * @returns a promise which will resolve once the session has been initialized
  118634. */
  118635. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  118636. /**
  118637. * Checks if a session would be supported for the creation options specified
  118638. * @param sessionMode session mode to check if supported eg. immersive-vr
  118639. * @returns A Promise that resolves to true if supported and false if not
  118640. */
  118641. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  118642. /**
  118643. * Resets the reference space to the one started the session
  118644. */
  118645. resetReferenceSpace(): void;
  118646. /**
  118647. * Starts rendering to the xr layer
  118648. */
  118649. runXRRenderLoop(): void;
  118650. /**
  118651. * Sets the reference space on the xr session
  118652. * @param referenceSpaceType space to set
  118653. * @returns a promise that will resolve once the reference space has been set
  118654. */
  118655. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  118656. /**
  118657. * Updates the render state of the session
  118658. * @param state state to set
  118659. * @returns a promise that resolves once the render state has been updated
  118660. */
  118661. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  118662. /**
  118663. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  118664. * @param sessionMode defines the session to test
  118665. * @returns a promise with boolean as final value
  118666. */
  118667. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  118668. private _createRenderTargetTexture;
  118669. }
  118670. }
  118671. declare module BABYLON {
  118672. /**
  118673. * WebXR Camera which holds the views for the xrSession
  118674. * @see https://doc.babylonjs.com/how_to/webxr_camera
  118675. */
  118676. export class WebXRCamera extends FreeCamera {
  118677. private _xrSessionManager;
  118678. private _firstFrame;
  118679. private _referenceQuaternion;
  118680. private _referencedPosition;
  118681. private _xrInvPositionCache;
  118682. private _xrInvQuaternionCache;
  118683. /**
  118684. * Should position compensation execute on first frame.
  118685. * This is used when copying the position from a native (non XR) camera
  118686. */
  118687. compensateOnFirstFrame: boolean;
  118688. /**
  118689. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  118690. * @param name the name of the camera
  118691. * @param scene the scene to add the camera to
  118692. * @param _xrSessionManager a constructed xr session manager
  118693. */
  118694. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  118695. /**
  118696. * Return the user's height, unrelated to the current ground.
  118697. * This will be the y position of this camera, when ground level is 0.
  118698. */
  118699. get realWorldHeight(): number;
  118700. /** @hidden */
  118701. _updateForDualEyeDebugging(): void;
  118702. /**
  118703. * Sets this camera's transformation based on a non-vr camera
  118704. * @param otherCamera the non-vr camera to copy the transformation from
  118705. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  118706. */
  118707. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  118708. /**
  118709. * Gets the current instance class name ("WebXRCamera").
  118710. * @returns the class name
  118711. */
  118712. getClassName(): string;
  118713. private _updateFromXRSession;
  118714. private _updateNumberOfRigCameras;
  118715. private _updateReferenceSpace;
  118716. private _updateReferenceSpaceOffset;
  118717. }
  118718. }
  118719. declare module BABYLON {
  118720. /**
  118721. * Defining the interface required for a (webxr) feature
  118722. */
  118723. export interface IWebXRFeature extends IDisposable {
  118724. /**
  118725. * Is this feature attached
  118726. */
  118727. attached: boolean;
  118728. /**
  118729. * Should auto-attach be disabled?
  118730. */
  118731. disableAutoAttach: boolean;
  118732. /**
  118733. * Attach the feature to the session
  118734. * Will usually be called by the features manager
  118735. *
  118736. * @param force should attachment be forced (even when already attached)
  118737. * @returns true if successful.
  118738. */
  118739. attach(force?: boolean): boolean;
  118740. /**
  118741. * Detach the feature from the session
  118742. * Will usually be called by the features manager
  118743. *
  118744. * @returns true if successful.
  118745. */
  118746. detach(): boolean;
  118747. }
  118748. /**
  118749. * A list of the currently available features without referencing them
  118750. */
  118751. export class WebXRFeatureName {
  118752. /**
  118753. * The name of the anchor system feature
  118754. */
  118755. static ANCHOR_SYSTEM: string;
  118756. /**
  118757. * The name of the background remover feature
  118758. */
  118759. static BACKGROUND_REMOVER: string;
  118760. /**
  118761. * The name of the hit test feature
  118762. */
  118763. static HIT_TEST: string;
  118764. /**
  118765. * physics impostors for xr controllers feature
  118766. */
  118767. static PHYSICS_CONTROLLERS: string;
  118768. /**
  118769. * The name of the plane detection feature
  118770. */
  118771. static PLANE_DETECTION: string;
  118772. /**
  118773. * The name of the pointer selection feature
  118774. */
  118775. static POINTER_SELECTION: string;
  118776. /**
  118777. * The name of the teleportation feature
  118778. */
  118779. static TELEPORTATION: string;
  118780. }
  118781. /**
  118782. * Defining the constructor of a feature. Used to register the modules.
  118783. */
  118784. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => (() => IWebXRFeature);
  118785. /**
  118786. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  118787. * It is mainly used in AR sessions.
  118788. *
  118789. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  118790. */
  118791. export class WebXRFeaturesManager implements IDisposable {
  118792. private _xrSessionManager;
  118793. private static readonly _AvailableFeatures;
  118794. private _features;
  118795. /**
  118796. * constructs a new features manages.
  118797. *
  118798. * @param _xrSessionManager an instance of WebXRSessionManager
  118799. */
  118800. constructor(_xrSessionManager: WebXRSessionManager);
  118801. /**
  118802. * Used to register a module. After calling this function a developer can use this feature in the scene.
  118803. * Mainly used internally.
  118804. *
  118805. * @param featureName the name of the feature to register
  118806. * @param constructorFunction the function used to construct the module
  118807. * @param version the (babylon) version of the module
  118808. * @param stable is that a stable version of this module
  118809. */
  118810. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  118811. /**
  118812. * Returns a constructor of a specific feature.
  118813. *
  118814. * @param featureName the name of the feature to construct
  118815. * @param version the version of the feature to load
  118816. * @param xrSessionManager the xrSessionManager. Used to construct the module
  118817. * @param options optional options provided to the module.
  118818. * @returns a function that, when called, will return a new instance of this feature
  118819. */
  118820. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): (() => IWebXRFeature);
  118821. /**
  118822. * Can be used to return the list of features currently registered
  118823. *
  118824. * @returns an Array of available features
  118825. */
  118826. static GetAvailableFeatures(): string[];
  118827. /**
  118828. * Gets the versions available for a specific feature
  118829. * @param featureName the name of the feature
  118830. * @returns an array with the available versions
  118831. */
  118832. static GetAvailableVersions(featureName: string): string[];
  118833. /**
  118834. * Return the latest unstable version of this feature
  118835. * @param featureName the name of the feature to search
  118836. * @returns the version number. if not found will return -1
  118837. */
  118838. static GetLatestVersionOfFeature(featureName: string): number;
  118839. /**
  118840. * Return the latest stable version of this feature
  118841. * @param featureName the name of the feature to search
  118842. * @returns the version number. if not found will return -1
  118843. */
  118844. static GetStableVersionOfFeature(featureName: string): number;
  118845. /**
  118846. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  118847. * Can be used during a session to start a feature
  118848. * @param featureName the name of feature to attach
  118849. */
  118850. attachFeature(featureName: string): void;
  118851. /**
  118852. * Can be used inside a session or when the session ends to detach a specific feature
  118853. * @param featureName the name of the feature to detach
  118854. */
  118855. detachFeature(featureName: string): void;
  118856. /**
  118857. * Used to disable an already-enabled feature
  118858. * The feature will be disposed and will be recreated once enabled.
  118859. * @param featureName the feature to disable
  118860. * @returns true if disable was successful
  118861. */
  118862. disableFeature(featureName: string | {
  118863. Name: string;
  118864. }): boolean;
  118865. /**
  118866. * dispose this features manager
  118867. */
  118868. dispose(): void;
  118869. /**
  118870. * 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.
  118871. * 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.
  118872. *
  118873. * @param featureName the name of the feature to load or the class of the feature
  118874. * @param version optional version to load. if not provided the latest version will be enabled
  118875. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  118876. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  118877. * @returns a new constructed feature or throws an error if feature not found.
  118878. */
  118879. enableFeature(featureName: string | {
  118880. Name: string;
  118881. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean): IWebXRFeature;
  118882. /**
  118883. * get the implementation of an enabled feature.
  118884. * @param featureName the name of the feature to load
  118885. * @returns the feature class, if found
  118886. */
  118887. getEnabledFeature(featureName: string): IWebXRFeature;
  118888. /**
  118889. * Get the list of enabled features
  118890. * @returns an array of enabled features
  118891. */
  118892. getEnabledFeatures(): string[];
  118893. }
  118894. }
  118895. declare module BABYLON {
  118896. /**
  118897. * Base set of functionality needed to create an XR experience (WebXRSessionManager, Camera, StateManagement, etc.)
  118898. * @see https://doc.babylonjs.com/how_to/webxr
  118899. */
  118900. export class WebXRExperienceHelper implements IDisposable {
  118901. private scene;
  118902. private _nonVRCamera;
  118903. private _originalSceneAutoClear;
  118904. private _supported;
  118905. /**
  118906. * Camera used to render xr content
  118907. */
  118908. camera: WebXRCamera;
  118909. /** A features manager for this xr session */
  118910. featuresManager: WebXRFeaturesManager;
  118911. /**
  118912. * Observers registered here will be triggered after the camera's initial transformation is set
  118913. * This can be used to set a different ground level or an extra rotation.
  118914. *
  118915. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  118916. * to the position set after this observable is done executing.
  118917. */
  118918. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  118919. /**
  118920. * Fires when the state of the experience helper has changed
  118921. */
  118922. onStateChangedObservable: Observable<WebXRState>;
  118923. /** Session manager used to keep track of xr session */
  118924. sessionManager: WebXRSessionManager;
  118925. /**
  118926. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  118927. */
  118928. state: WebXRState;
  118929. /**
  118930. * Creates a WebXRExperienceHelper
  118931. * @param scene The scene the helper should be created in
  118932. */
  118933. private constructor();
  118934. /**
  118935. * Creates the experience helper
  118936. * @param scene the scene to attach the experience helper to
  118937. * @returns a promise for the experience helper
  118938. */
  118939. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  118940. /**
  118941. * Disposes of the experience helper
  118942. */
  118943. dispose(): void;
  118944. /**
  118945. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  118946. * @param sessionMode options for the XR session
  118947. * @param referenceSpaceType frame of reference of the XR session
  118948. * @param renderTarget the output canvas that will be used to enter XR mode
  118949. * @returns promise that resolves after xr mode has entered
  118950. */
  118951. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget): Promise<WebXRSessionManager>;
  118952. /**
  118953. * Exits XR mode and returns the scene to its original state
  118954. * @returns promise that resolves after xr mode has exited
  118955. */
  118956. exitXRAsync(): Promise<void>;
  118957. private _nonXRToXRCamera;
  118958. private _setState;
  118959. }
  118960. }
  118961. declare module BABYLON {
  118962. /**
  118963. * X-Y values for axes in WebXR
  118964. */
  118965. export interface IWebXRMotionControllerAxesValue {
  118966. /**
  118967. * The value of the x axis
  118968. */
  118969. x: number;
  118970. /**
  118971. * The value of the y-axis
  118972. */
  118973. y: number;
  118974. }
  118975. /**
  118976. * changed / previous values for the values of this component
  118977. */
  118978. export interface IWebXRMotionControllerComponentChangesValues<T> {
  118979. /**
  118980. * current (this frame) value
  118981. */
  118982. current: T;
  118983. /**
  118984. * previous (last change) value
  118985. */
  118986. previous: T;
  118987. }
  118988. /**
  118989. * Represents changes in the component between current frame and last values recorded
  118990. */
  118991. export interface IWebXRMotionControllerComponentChanges {
  118992. /**
  118993. * will be populated with previous and current values if axes changed
  118994. */
  118995. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  118996. /**
  118997. * will be populated with previous and current values if pressed changed
  118998. */
  118999. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  119000. /**
  119001. * will be populated with previous and current values if touched changed
  119002. */
  119003. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  119004. /**
  119005. * will be populated with previous and current values if value changed
  119006. */
  119007. value?: IWebXRMotionControllerComponentChangesValues<number>;
  119008. }
  119009. /**
  119010. * This class represents a single component (for example button or thumbstick) of a motion controller
  119011. */
  119012. export class WebXRControllerComponent implements IDisposable {
  119013. /**
  119014. * the id of this component
  119015. */
  119016. id: string;
  119017. /**
  119018. * the type of the component
  119019. */
  119020. type: MotionControllerComponentType;
  119021. private _buttonIndex;
  119022. private _axesIndices;
  119023. private _axes;
  119024. private _changes;
  119025. private _currentValue;
  119026. private _hasChanges;
  119027. private _pressed;
  119028. private _touched;
  119029. /**
  119030. * button component type
  119031. */
  119032. static BUTTON_TYPE: MotionControllerComponentType;
  119033. /**
  119034. * squeeze component type
  119035. */
  119036. static SQUEEZE_TYPE: MotionControllerComponentType;
  119037. /**
  119038. * Thumbstick component type
  119039. */
  119040. static THUMBSTICK_TYPE: MotionControllerComponentType;
  119041. /**
  119042. * Touchpad component type
  119043. */
  119044. static TOUCHPAD_TYPE: MotionControllerComponentType;
  119045. /**
  119046. * trigger component type
  119047. */
  119048. static TRIGGER_TYPE: MotionControllerComponentType;
  119049. /**
  119050. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  119051. * the axes data changes
  119052. */
  119053. onAxisValueChangedObservable: Observable<{
  119054. x: number;
  119055. y: number;
  119056. }>;
  119057. /**
  119058. * Observers registered here will be triggered when the state of a button changes
  119059. * State change is either pressed / touched / value
  119060. */
  119061. onButtonStateChangedObservable: Observable<WebXRControllerComponent>;
  119062. /**
  119063. * Creates a new component for a motion controller.
  119064. * It is created by the motion controller itself
  119065. *
  119066. * @param id the id of this component
  119067. * @param type the type of the component
  119068. * @param _buttonIndex index in the buttons array of the gamepad
  119069. * @param _axesIndices indices of the values in the axes array of the gamepad
  119070. */
  119071. constructor(
  119072. /**
  119073. * the id of this component
  119074. */
  119075. id: string,
  119076. /**
  119077. * the type of the component
  119078. */
  119079. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  119080. /**
  119081. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  119082. */
  119083. get axes(): IWebXRMotionControllerAxesValue;
  119084. /**
  119085. * Get the changes. Elements will be populated only if they changed with their previous and current value
  119086. */
  119087. get changes(): IWebXRMotionControllerComponentChanges;
  119088. /**
  119089. * Return whether or not the component changed the last frame
  119090. */
  119091. get hasChanges(): boolean;
  119092. /**
  119093. * is the button currently pressed
  119094. */
  119095. get pressed(): boolean;
  119096. /**
  119097. * is the button currently touched
  119098. */
  119099. get touched(): boolean;
  119100. /**
  119101. * Get the current value of this component
  119102. */
  119103. get value(): number;
  119104. /**
  119105. * Dispose this component
  119106. */
  119107. dispose(): void;
  119108. /**
  119109. * Are there axes correlating to this component
  119110. * @return true is axes data is available
  119111. */
  119112. isAxes(): boolean;
  119113. /**
  119114. * Is this component a button (hence - pressable)
  119115. * @returns true if can be pressed
  119116. */
  119117. isButton(): boolean;
  119118. /**
  119119. * update this component using the gamepad object it is in. Called on every frame
  119120. * @param nativeController the native gamepad controller object
  119121. */
  119122. update(nativeController: IMinimalMotionControllerObject): void;
  119123. }
  119124. }
  119125. declare module BABYLON {
  119126. /**
  119127. * Class used to represent data loading progression
  119128. */
  119129. export class SceneLoaderProgressEvent {
  119130. /** defines if data length to load can be evaluated */
  119131. readonly lengthComputable: boolean;
  119132. /** defines the loaded data length */
  119133. readonly loaded: number;
  119134. /** defines the data length to load */
  119135. readonly total: number;
  119136. /**
  119137. * Create a new progress event
  119138. * @param lengthComputable defines if data length to load can be evaluated
  119139. * @param loaded defines the loaded data length
  119140. * @param total defines the data length to load
  119141. */
  119142. constructor(
  119143. /** defines if data length to load can be evaluated */
  119144. lengthComputable: boolean,
  119145. /** defines the loaded data length */
  119146. loaded: number,
  119147. /** defines the data length to load */
  119148. total: number);
  119149. /**
  119150. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  119151. * @param event defines the source event
  119152. * @returns a new SceneLoaderProgressEvent
  119153. */
  119154. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  119155. }
  119156. /**
  119157. * Interface used by SceneLoader plugins to define supported file extensions
  119158. */
  119159. export interface ISceneLoaderPluginExtensions {
  119160. /**
  119161. * Defines the list of supported extensions
  119162. */
  119163. [extension: string]: {
  119164. isBinary: boolean;
  119165. };
  119166. }
  119167. /**
  119168. * Interface used by SceneLoader plugin factory
  119169. */
  119170. export interface ISceneLoaderPluginFactory {
  119171. /**
  119172. * Defines the name of the factory
  119173. */
  119174. name: string;
  119175. /**
  119176. * Function called to create a new plugin
  119177. * @return the new plugin
  119178. */
  119179. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  119180. /**
  119181. * The callback that returns true if the data can be directly loaded.
  119182. * @param data string containing the file data
  119183. * @returns if the data can be loaded directly
  119184. */
  119185. canDirectLoad?(data: string): boolean;
  119186. }
  119187. /**
  119188. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  119189. */
  119190. export interface ISceneLoaderPluginBase {
  119191. /**
  119192. * The friendly name of this plugin.
  119193. */
  119194. name: string;
  119195. /**
  119196. * The file extensions supported by this plugin.
  119197. */
  119198. extensions: string | ISceneLoaderPluginExtensions;
  119199. /**
  119200. * The callback called when loading from a url.
  119201. * @param scene scene loading this url
  119202. * @param url url to load
  119203. * @param onSuccess callback called when the file successfully loads
  119204. * @param onProgress callback called while file is loading (if the server supports this mode)
  119205. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  119206. * @param onError callback called when the file fails to load
  119207. * @returns a file request object
  119208. */
  119209. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  119210. /**
  119211. * The callback called when loading from a file object.
  119212. * @param scene scene loading this file
  119213. * @param file defines the file to load
  119214. * @param onSuccess defines the callback to call when data is loaded
  119215. * @param onProgress defines the callback to call during loading process
  119216. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  119217. * @param onError defines the callback to call when an error occurs
  119218. * @returns a file request object
  119219. */
  119220. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  119221. /**
  119222. * The callback that returns true if the data can be directly loaded.
  119223. * @param data string containing the file data
  119224. * @returns if the data can be loaded directly
  119225. */
  119226. canDirectLoad?(data: string): boolean;
  119227. /**
  119228. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  119229. * @param scene scene loading this data
  119230. * @param data string containing the data
  119231. * @returns data to pass to the plugin
  119232. */
  119233. directLoad?(scene: Scene, data: string): any;
  119234. /**
  119235. * The callback that allows custom handling of the root url based on the response url.
  119236. * @param rootUrl the original root url
  119237. * @param responseURL the response url if available
  119238. * @returns the new root url
  119239. */
  119240. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  119241. }
  119242. /**
  119243. * Interface used to define a SceneLoader plugin
  119244. */
  119245. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  119246. /**
  119247. * Import meshes into a scene.
  119248. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  119249. * @param scene The scene to import into
  119250. * @param data The data to import
  119251. * @param rootUrl The root url for scene and resources
  119252. * @param meshes The meshes array to import into
  119253. * @param particleSystems The particle systems array to import into
  119254. * @param skeletons The skeletons array to import into
  119255. * @param onError The callback when import fails
  119256. * @returns True if successful or false otherwise
  119257. */
  119258. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  119259. /**
  119260. * Load into a scene.
  119261. * @param scene The scene to load into
  119262. * @param data The data to import
  119263. * @param rootUrl The root url for scene and resources
  119264. * @param onError The callback when import fails
  119265. * @returns True if successful or false otherwise
  119266. */
  119267. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  119268. /**
  119269. * Load into an asset container.
  119270. * @param scene The scene to load into
  119271. * @param data The data to import
  119272. * @param rootUrl The root url for scene and resources
  119273. * @param onError The callback when import fails
  119274. * @returns The loaded asset container
  119275. */
  119276. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  119277. }
  119278. /**
  119279. * Interface used to define an async SceneLoader plugin
  119280. */
  119281. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  119282. /**
  119283. * Import meshes into a scene.
  119284. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  119285. * @param scene The scene to import into
  119286. * @param data The data to import
  119287. * @param rootUrl The root url for scene and resources
  119288. * @param onProgress The callback when the load progresses
  119289. * @param fileName Defines the name of the file to load
  119290. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  119291. */
  119292. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  119293. meshes: AbstractMesh[];
  119294. particleSystems: IParticleSystem[];
  119295. skeletons: Skeleton[];
  119296. animationGroups: AnimationGroup[];
  119297. }>;
  119298. /**
  119299. * Load into a scene.
  119300. * @param scene The scene to load into
  119301. * @param data The data to import
  119302. * @param rootUrl The root url for scene and resources
  119303. * @param onProgress The callback when the load progresses
  119304. * @param fileName Defines the name of the file to load
  119305. * @returns Nothing
  119306. */
  119307. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  119308. /**
  119309. * Load into an asset container.
  119310. * @param scene The scene to load into
  119311. * @param data The data to import
  119312. * @param rootUrl The root url for scene and resources
  119313. * @param onProgress The callback when the load progresses
  119314. * @param fileName Defines the name of the file to load
  119315. * @returns The loaded asset container
  119316. */
  119317. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  119318. }
  119319. /**
  119320. * Mode that determines how to handle old animation groups before loading new ones.
  119321. */
  119322. export enum SceneLoaderAnimationGroupLoadingMode {
  119323. /**
  119324. * Reset all old animations to initial state then dispose them.
  119325. */
  119326. Clean = 0,
  119327. /**
  119328. * Stop all old animations.
  119329. */
  119330. Stop = 1,
  119331. /**
  119332. * Restart old animations from first frame.
  119333. */
  119334. Sync = 2,
  119335. /**
  119336. * Old animations remains untouched.
  119337. */
  119338. NoSync = 3
  119339. }
  119340. /**
  119341. * Class used to load scene from various file formats using registered plugins
  119342. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  119343. */
  119344. export class SceneLoader {
  119345. /**
  119346. * No logging while loading
  119347. */
  119348. static readonly NO_LOGGING: number;
  119349. /**
  119350. * Minimal logging while loading
  119351. */
  119352. static readonly MINIMAL_LOGGING: number;
  119353. /**
  119354. * Summary logging while loading
  119355. */
  119356. static readonly SUMMARY_LOGGING: number;
  119357. /**
  119358. * Detailled logging while loading
  119359. */
  119360. static readonly DETAILED_LOGGING: number;
  119361. /**
  119362. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  119363. */
  119364. static get ForceFullSceneLoadingForIncremental(): boolean;
  119365. static set ForceFullSceneLoadingForIncremental(value: boolean);
  119366. /**
  119367. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  119368. */
  119369. static get ShowLoadingScreen(): boolean;
  119370. static set ShowLoadingScreen(value: boolean);
  119371. /**
  119372. * Defines the current logging level (while loading the scene)
  119373. * @ignorenaming
  119374. */
  119375. static get loggingLevel(): number;
  119376. static set loggingLevel(value: number);
  119377. /**
  119378. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  119379. */
  119380. static get CleanBoneMatrixWeights(): boolean;
  119381. static set CleanBoneMatrixWeights(value: boolean);
  119382. /**
  119383. * Event raised when a plugin is used to load a scene
  119384. */
  119385. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  119386. private static _registeredPlugins;
  119387. private static _getDefaultPlugin;
  119388. private static _getPluginForExtension;
  119389. private static _getPluginForDirectLoad;
  119390. private static _getPluginForFilename;
  119391. private static _getDirectLoad;
  119392. private static _loadData;
  119393. private static _getFileInfo;
  119394. /**
  119395. * Gets a plugin that can load the given extension
  119396. * @param extension defines the extension to load
  119397. * @returns a plugin or null if none works
  119398. */
  119399. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  119400. /**
  119401. * Gets a boolean indicating that the given extension can be loaded
  119402. * @param extension defines the extension to load
  119403. * @returns true if the extension is supported
  119404. */
  119405. static IsPluginForExtensionAvailable(extension: string): boolean;
  119406. /**
  119407. * Adds a new plugin to the list of registered plugins
  119408. * @param plugin defines the plugin to add
  119409. */
  119410. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  119411. /**
  119412. * Import meshes into a scene
  119413. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  119414. * @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)
  119415. * @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)
  119416. * @param scene the instance of BABYLON.Scene to append to
  119417. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  119418. * @param onProgress a callback with a progress event for each file being loaded
  119419. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  119420. * @param pluginExtension the extension used to determine the plugin
  119421. * @returns The loaded plugin
  119422. */
  119423. 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>;
  119424. /**
  119425. * Import meshes into a scene
  119426. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  119427. * @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)
  119428. * @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)
  119429. * @param scene the instance of BABYLON.Scene to append to
  119430. * @param onProgress a callback with a progress event for each file being loaded
  119431. * @param pluginExtension the extension used to determine the plugin
  119432. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  119433. */
  119434. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  119435. meshes: AbstractMesh[];
  119436. particleSystems: IParticleSystem[];
  119437. skeletons: Skeleton[];
  119438. animationGroups: AnimationGroup[];
  119439. }>;
  119440. /**
  119441. * Load a scene
  119442. * @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)
  119443. * @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)
  119444. * @param engine is the instance of BABYLON.Engine to use to create the scene
  119445. * @param onSuccess a callback with the scene when import succeeds
  119446. * @param onProgress a callback with a progress event for each file being loaded
  119447. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  119448. * @param pluginExtension the extension used to determine the plugin
  119449. * @returns The loaded plugin
  119450. */
  119451. 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>;
  119452. /**
  119453. * Load a scene
  119454. * @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)
  119455. * @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)
  119456. * @param engine is the instance of BABYLON.Engine to use to create the scene
  119457. * @param onProgress a callback with a progress event for each file being loaded
  119458. * @param pluginExtension the extension used to determine the plugin
  119459. * @returns The loaded scene
  119460. */
  119461. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  119462. /**
  119463. * Append a scene
  119464. * @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)
  119465. * @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)
  119466. * @param scene is the instance of BABYLON.Scene to append to
  119467. * @param onSuccess a callback with the scene when import succeeds
  119468. * @param onProgress a callback with a progress event for each file being loaded
  119469. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  119470. * @param pluginExtension the extension used to determine the plugin
  119471. * @returns The loaded plugin
  119472. */
  119473. 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>;
  119474. /**
  119475. * Append a scene
  119476. * @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)
  119477. * @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)
  119478. * @param scene is the instance of BABYLON.Scene to append to
  119479. * @param onProgress a callback with a progress event for each file being loaded
  119480. * @param pluginExtension the extension used to determine the plugin
  119481. * @returns The given scene
  119482. */
  119483. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  119484. /**
  119485. * Load a scene into an asset container
  119486. * @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)
  119487. * @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)
  119488. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  119489. * @param onSuccess a callback with the scene when import succeeds
  119490. * @param onProgress a callback with a progress event for each file being loaded
  119491. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  119492. * @param pluginExtension the extension used to determine the plugin
  119493. * @returns The loaded plugin
  119494. */
  119495. 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>;
  119496. /**
  119497. * Load a scene into an asset container
  119498. * @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)
  119499. * @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)
  119500. * @param scene is the instance of Scene to append to
  119501. * @param onProgress a callback with a progress event for each file being loaded
  119502. * @param pluginExtension the extension used to determine the plugin
  119503. * @returns The loaded asset container
  119504. */
  119505. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  119506. /**
  119507. * Import animations from a file into a scene
  119508. * @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)
  119509. * @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)
  119510. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  119511. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  119512. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  119513. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  119514. * @param onSuccess a callback with the scene when import succeeds
  119515. * @param onProgress a callback with a progress event for each file being loaded
  119516. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  119517. */
  119518. 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;
  119519. /**
  119520. * Import animations from a file into a scene
  119521. * @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)
  119522. * @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)
  119523. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  119524. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  119525. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  119526. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  119527. * @param onSuccess a callback with the scene when import succeeds
  119528. * @param onProgress a callback with a progress event for each file being loaded
  119529. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  119530. * @returns the updated scene with imported animations
  119531. */
  119532. 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>;
  119533. }
  119534. }
  119535. declare module BABYLON {
  119536. /**
  119537. * Handedness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  119538. */
  119539. export type MotionControllerHandedness = "none" | "left" | "right";
  119540. /**
  119541. * The type of components available in motion controllers.
  119542. * This is not the name of the component.
  119543. */
  119544. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  119545. /**
  119546. * The state of a controller component
  119547. */
  119548. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  119549. /**
  119550. * The schema of motion controller layout.
  119551. * No object will be initialized using this interface
  119552. * This is used just to define the profile.
  119553. */
  119554. export interface IMotionControllerLayout {
  119555. /**
  119556. * Path to load the assets. Usually relative to the base path
  119557. */
  119558. assetPath: string;
  119559. /**
  119560. * Available components (unsorted)
  119561. */
  119562. components: {
  119563. /**
  119564. * A map of component Ids
  119565. */
  119566. [componentId: string]: {
  119567. /**
  119568. * The type of input the component outputs
  119569. */
  119570. type: MotionControllerComponentType;
  119571. /**
  119572. * The indices of this component in the gamepad object
  119573. */
  119574. gamepadIndices: {
  119575. /**
  119576. * Index of button
  119577. */
  119578. button?: number;
  119579. /**
  119580. * If available, index of x-axis
  119581. */
  119582. xAxis?: number;
  119583. /**
  119584. * If available, index of y-axis
  119585. */
  119586. yAxis?: number;
  119587. };
  119588. /**
  119589. * The mesh's root node name
  119590. */
  119591. rootNodeName: string;
  119592. /**
  119593. * Animation definitions for this model
  119594. */
  119595. visualResponses: {
  119596. [stateKey: string]: {
  119597. /**
  119598. * What property will be animated
  119599. */
  119600. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  119601. /**
  119602. * What states influence this visual response
  119603. */
  119604. states: MotionControllerComponentStateType[];
  119605. /**
  119606. * Type of animation - movement or visibility
  119607. */
  119608. valueNodeProperty: "transform" | "visibility";
  119609. /**
  119610. * Base node name to move. Its position will be calculated according to the min and max nodes
  119611. */
  119612. valueNodeName?: string;
  119613. /**
  119614. * Minimum movement node
  119615. */
  119616. minNodeName?: string;
  119617. /**
  119618. * Max movement node
  119619. */
  119620. maxNodeName?: string;
  119621. };
  119622. };
  119623. /**
  119624. * If touch enabled, what is the name of node to display user feedback
  119625. */
  119626. touchPointNodeName?: string;
  119627. };
  119628. };
  119629. /**
  119630. * Is it xr standard mapping or not
  119631. */
  119632. gamepadMapping: "" | "xr-standard";
  119633. /**
  119634. * Base root node of this entire model
  119635. */
  119636. rootNodeName: string;
  119637. /**
  119638. * Defines the main button component id
  119639. */
  119640. selectComponentId: string;
  119641. }
  119642. /**
  119643. * A definition for the layout map in the input profile
  119644. */
  119645. export interface IMotionControllerLayoutMap {
  119646. /**
  119647. * Layouts with handedness type as a key
  119648. */
  119649. [handedness: string]: IMotionControllerLayout;
  119650. }
  119651. /**
  119652. * The XR Input profile schema
  119653. * Profiles can be found here:
  119654. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  119655. */
  119656. export interface IMotionControllerProfile {
  119657. /**
  119658. * fallback profiles for this profileId
  119659. */
  119660. fallbackProfileIds: string[];
  119661. /**
  119662. * The layout map, with handedness as key
  119663. */
  119664. layouts: IMotionControllerLayoutMap;
  119665. /**
  119666. * The id of this profile
  119667. * correlates to the profile(s) in the xrInput.profiles array
  119668. */
  119669. profileId: string;
  119670. }
  119671. /**
  119672. * A helper-interface for the 3 meshes needed for controller button animation
  119673. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  119674. */
  119675. export interface IMotionControllerButtonMeshMap {
  119676. /**
  119677. * the mesh that defines the pressed value mesh position.
  119678. * This is used to find the max-position of this button
  119679. */
  119680. pressedMesh: AbstractMesh;
  119681. /**
  119682. * the mesh that defines the unpressed value mesh position.
  119683. * This is used to find the min (or initial) position of this button
  119684. */
  119685. unpressedMesh: AbstractMesh;
  119686. /**
  119687. * The mesh that will be changed when value changes
  119688. */
  119689. valueMesh: AbstractMesh;
  119690. }
  119691. /**
  119692. * A helper-interface for the 3 meshes needed for controller axis animation.
  119693. * This will be expanded when touchpad animations are fully supported
  119694. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  119695. */
  119696. export interface IMotionControllerMeshMap {
  119697. /**
  119698. * the mesh that defines the maximum value mesh position.
  119699. */
  119700. maxMesh?: AbstractMesh;
  119701. /**
  119702. * the mesh that defines the minimum value mesh position.
  119703. */
  119704. minMesh?: AbstractMesh;
  119705. /**
  119706. * The mesh that will be changed when axis value changes
  119707. */
  119708. valueMesh: AbstractMesh;
  119709. }
  119710. /**
  119711. * The elements needed for change-detection of the gamepad objects in motion controllers
  119712. */
  119713. export interface IMinimalMotionControllerObject {
  119714. /**
  119715. * Available axes of this controller
  119716. */
  119717. axes: number[];
  119718. /**
  119719. * An array of available buttons
  119720. */
  119721. buttons: Array<{
  119722. /**
  119723. * Value of the button/trigger
  119724. */
  119725. value: number;
  119726. /**
  119727. * If the button/trigger is currently touched
  119728. */
  119729. touched: boolean;
  119730. /**
  119731. * If the button/trigger is currently pressed
  119732. */
  119733. pressed: boolean;
  119734. }>;
  119735. }
  119736. /**
  119737. * An Abstract Motion controller
  119738. * This class receives an xrInput and a profile layout and uses those to initialize the components
  119739. * Each component has an observable to check for changes in value and state
  119740. */
  119741. export abstract class WebXRAbstractMotionController implements IDisposable {
  119742. protected scene: Scene;
  119743. protected layout: IMotionControllerLayout;
  119744. /**
  119745. * The gamepad object correlating to this controller
  119746. */
  119747. gamepadObject: IMinimalMotionControllerObject;
  119748. /**
  119749. * handedness (left/right/none) of this controller
  119750. */
  119751. handedness: MotionControllerHandedness;
  119752. private _initComponent;
  119753. private _modelReady;
  119754. /**
  119755. * A map of components (WebXRControllerComponent) in this motion controller
  119756. * Components have a ComponentType and can also have both button and axis definitions
  119757. */
  119758. readonly components: {
  119759. [id: string]: WebXRControllerComponent;
  119760. };
  119761. /**
  119762. * Disable the model's animation. Can be set at any time.
  119763. */
  119764. disableAnimation: boolean;
  119765. /**
  119766. * Observers registered here will be triggered when the model of this controller is done loading
  119767. */
  119768. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  119769. /**
  119770. * The profile id of this motion controller
  119771. */
  119772. abstract profileId: string;
  119773. /**
  119774. * The root mesh of the model. It is null if the model was not yet initialized
  119775. */
  119776. rootMesh: Nullable<AbstractMesh>;
  119777. /**
  119778. * constructs a new abstract motion controller
  119779. * @param scene the scene to which the model of the controller will be added
  119780. * @param layout The profile layout to load
  119781. * @param gamepadObject The gamepad object correlating to this controller
  119782. * @param handedness handedness (left/right/none) of this controller
  119783. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  119784. */
  119785. constructor(scene: Scene, layout: IMotionControllerLayout,
  119786. /**
  119787. * The gamepad object correlating to this controller
  119788. */
  119789. gamepadObject: IMinimalMotionControllerObject,
  119790. /**
  119791. * handedness (left/right/none) of this controller
  119792. */
  119793. handedness: MotionControllerHandedness, _doNotLoadControllerMesh?: boolean);
  119794. /**
  119795. * Dispose this controller, the model mesh and all its components
  119796. */
  119797. dispose(): void;
  119798. /**
  119799. * Returns all components of specific type
  119800. * @param type the type to search for
  119801. * @return an array of components with this type
  119802. */
  119803. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  119804. /**
  119805. * get a component based an its component id as defined in layout.components
  119806. * @param id the id of the component
  119807. * @returns the component correlates to the id or undefined if not found
  119808. */
  119809. getComponent(id: string): WebXRControllerComponent;
  119810. /**
  119811. * Get the list of components available in this motion controller
  119812. * @returns an array of strings correlating to available components
  119813. */
  119814. getComponentIds(): string[];
  119815. /**
  119816. * Get the first component of specific type
  119817. * @param type type of component to find
  119818. * @return a controller component or null if not found
  119819. */
  119820. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  119821. /**
  119822. * Get the main (Select) component of this controller as defined in the layout
  119823. * @returns the main component of this controller
  119824. */
  119825. getMainComponent(): WebXRControllerComponent;
  119826. /**
  119827. * Loads the model correlating to this controller
  119828. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  119829. * @returns A promise fulfilled with the result of the model loading
  119830. */
  119831. loadModel(): Promise<boolean>;
  119832. /**
  119833. * Update this model using the current XRFrame
  119834. * @param xrFrame the current xr frame to use and update the model
  119835. */
  119836. updateFromXRFrame(xrFrame: XRFrame): void;
  119837. /**
  119838. * Backwards compatibility due to a deeply-integrated typo
  119839. */
  119840. get handness(): XREye;
  119841. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh;
  119842. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh;
  119843. /**
  119844. * Moves the axis on the controller mesh based on its current state
  119845. * @param axis the index of the axis
  119846. * @param axisValue the value of the axis which determines the meshes new position
  119847. * @hidden
  119848. */
  119849. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  119850. /**
  119851. * Update the model itself with the current frame data
  119852. * @param xrFrame the frame to use for updating the model mesh
  119853. */
  119854. protected updateModel(xrFrame: XRFrame): void;
  119855. /**
  119856. * Get the filename and path for this controller's model
  119857. * @returns a map of filename and path
  119858. */
  119859. protected abstract _getFilenameAndPath(): {
  119860. filename: string;
  119861. path: string;
  119862. };
  119863. /**
  119864. * This function is called before the mesh is loaded. It checks for loading constraints.
  119865. * For example, this function can check if the GLB loader is available
  119866. * If this function returns false, the generic controller will be loaded instead
  119867. * @returns Is the client ready to load the mesh
  119868. */
  119869. protected abstract _getModelLoadingConstraints(): boolean;
  119870. /**
  119871. * This function will be called after the model was successfully loaded and can be used
  119872. * for mesh transformations before it is available for the user
  119873. * @param meshes the loaded meshes
  119874. */
  119875. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  119876. /**
  119877. * Set the root mesh for this controller. Important for the WebXR controller class
  119878. * @param meshes the loaded meshes
  119879. */
  119880. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  119881. /**
  119882. * A function executed each frame that updates the mesh (if needed)
  119883. * @param xrFrame the current xrFrame
  119884. */
  119885. protected abstract _updateModel(xrFrame: XRFrame): void;
  119886. private _getGenericFilenameAndPath;
  119887. private _getGenericParentMesh;
  119888. }
  119889. }
  119890. declare module BABYLON {
  119891. /**
  119892. * A generic trigger-only motion controller for WebXR
  119893. */
  119894. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  119895. /**
  119896. * Static version of the profile id of this controller
  119897. */
  119898. static ProfileId: string;
  119899. profileId: string;
  119900. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  119901. protected _getFilenameAndPath(): {
  119902. filename: string;
  119903. path: string;
  119904. };
  119905. protected _getModelLoadingConstraints(): boolean;
  119906. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  119907. protected _setRootMesh(meshes: AbstractMesh[]): void;
  119908. protected _updateModel(): void;
  119909. }
  119910. }
  119911. declare module BABYLON {
  119912. /**
  119913. * Class containing static functions to help procedurally build meshes
  119914. */
  119915. export class SphereBuilder {
  119916. /**
  119917. * Creates a sphere mesh
  119918. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  119919. * * 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`)
  119920. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  119921. * * 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
  119922. * * 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)
  119923. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  119924. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  119925. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  119926. * @param name defines the name of the mesh
  119927. * @param options defines the options used to create the mesh
  119928. * @param scene defines the hosting scene
  119929. * @returns the sphere mesh
  119930. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  119931. */
  119932. static CreateSphere(name: string, options: {
  119933. segments?: number;
  119934. diameter?: number;
  119935. diameterX?: number;
  119936. diameterY?: number;
  119937. diameterZ?: number;
  119938. arc?: number;
  119939. slice?: number;
  119940. sideOrientation?: number;
  119941. frontUVs?: Vector4;
  119942. backUVs?: Vector4;
  119943. updatable?: boolean;
  119944. }, scene?: Nullable<Scene>): Mesh;
  119945. }
  119946. }
  119947. declare module BABYLON {
  119948. /**
  119949. * A profiled motion controller has its profile loaded from an online repository.
  119950. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  119951. */
  119952. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  119953. private _repositoryUrl;
  119954. private _buttonMeshMapping;
  119955. private _touchDots;
  119956. /**
  119957. * The profile ID of this controller. Will be populated when the controller initializes.
  119958. */
  119959. profileId: string;
  119960. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  119961. dispose(): void;
  119962. protected _getFilenameAndPath(): {
  119963. filename: string;
  119964. path: string;
  119965. };
  119966. protected _getModelLoadingConstraints(): boolean;
  119967. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  119968. protected _setRootMesh(meshes: AbstractMesh[]): void;
  119969. protected _updateModel(_xrFrame: XRFrame): void;
  119970. }
  119971. }
  119972. declare module BABYLON {
  119973. /**
  119974. * A construction function type to create a new controller based on an xrInput object
  119975. */
  119976. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  119977. /**
  119978. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  119979. *
  119980. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  119981. * it should be replaced with auto-loaded controllers.
  119982. *
  119983. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  119984. */
  119985. export class WebXRMotionControllerManager {
  119986. private static _AvailableControllers;
  119987. private static _Fallbacks;
  119988. private static _ProfileLoadingPromises;
  119989. private static _ProfilesList;
  119990. /**
  119991. * The base URL of the online controller repository. Can be changed at any time.
  119992. */
  119993. static BaseRepositoryUrl: string;
  119994. /**
  119995. * Which repository gets priority - local or online
  119996. */
  119997. static PrioritizeOnlineRepository: boolean;
  119998. /**
  119999. * Use the online repository, or use only locally-defined controllers
  120000. */
  120001. static UseOnlineRepository: boolean;
  120002. /**
  120003. * Clear the cache used for profile loading and reload when requested again
  120004. */
  120005. static ClearProfilesCache(): void;
  120006. /**
  120007. * Register the default fallbacks.
  120008. * This function is called automatically when this file is imported.
  120009. */
  120010. static DefaultFallbacks(): void;
  120011. /**
  120012. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  120013. * @param profileId the profile to which a fallback needs to be found
  120014. * @return an array with corresponding fallback profiles
  120015. */
  120016. static FindFallbackWithProfileId(profileId: string): string[];
  120017. /**
  120018. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  120019. * The order of search:
  120020. *
  120021. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  120022. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  120023. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  120024. * 4) return the generic trigger controller if none were found
  120025. *
  120026. * @param xrInput the xrInput to which a new controller is initialized
  120027. * @param scene the scene to which the model will be added
  120028. * @param forceProfile force a certain profile for this controller
  120029. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  120030. */
  120031. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  120032. /**
  120033. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  120034. *
  120035. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  120036. *
  120037. * @param type the profile type to register
  120038. * @param constructFunction the function to be called when loading this profile
  120039. */
  120040. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  120041. /**
  120042. * Register a fallback to a specific profile.
  120043. * @param profileId the profileId that will receive the fallbacks
  120044. * @param fallbacks A list of fallback profiles
  120045. */
  120046. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  120047. /**
  120048. * Will update the list of profiles available in the repository
  120049. * @return a promise that resolves to a map of profiles available online
  120050. */
  120051. static UpdateProfilesList(): Promise<{
  120052. [profile: string]: string;
  120053. }>;
  120054. private static _LoadProfileFromRepository;
  120055. private static _LoadProfilesFromAvailableControllers;
  120056. }
  120057. }
  120058. declare module BABYLON {
  120059. /**
  120060. * Configuration options for the WebXR controller creation
  120061. */
  120062. export interface IWebXRControllerOptions {
  120063. /**
  120064. * Should the controller mesh be animated when a user interacts with it
  120065. * The pressed buttons / thumbstick and touchpad animations will be disabled
  120066. */
  120067. disableMotionControllerAnimation?: boolean;
  120068. /**
  120069. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  120070. */
  120071. doNotLoadControllerMesh?: boolean;
  120072. /**
  120073. * Force a specific controller type for this controller.
  120074. * This can be used when creating your own profile or when testing different controllers
  120075. */
  120076. forceControllerProfile?: string;
  120077. }
  120078. /**
  120079. * Represents an XR controller
  120080. */
  120081. export class WebXRInputSource {
  120082. private _scene;
  120083. /** The underlying input source for the controller */
  120084. inputSource: XRInputSource;
  120085. private _options;
  120086. private _tmpQuaternion;
  120087. private _tmpVector;
  120088. private _uniqueId;
  120089. /**
  120090. * 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
  120091. */
  120092. grip?: AbstractMesh;
  120093. /**
  120094. * If available, this is the gamepad object related to this controller.
  120095. * Using this object it is possible to get click events and trackpad changes of the
  120096. * webxr controller that is currently being used.
  120097. */
  120098. motionController?: WebXRAbstractMotionController;
  120099. /**
  120100. * Event that fires when the controller is removed/disposed.
  120101. * The object provided as event data is this controller, after associated assets were disposed.
  120102. * uniqueId is still available.
  120103. */
  120104. onDisposeObservable: Observable<WebXRInputSource>;
  120105. /**
  120106. * Will be triggered when the mesh associated with the motion controller is done loading.
  120107. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  120108. * A shortened version of controller -> motion controller -> on mesh loaded.
  120109. */
  120110. onMeshLoadedObservable: Observable<AbstractMesh>;
  120111. /**
  120112. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  120113. */
  120114. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  120115. /**
  120116. * Pointer which can be used to select objects or attach a visible laser to
  120117. */
  120118. pointer: AbstractMesh;
  120119. /**
  120120. * Creates the controller
  120121. * @see https://doc.babylonjs.com/how_to/webxr
  120122. * @param _scene the scene which the controller should be associated to
  120123. * @param inputSource the underlying input source for the controller
  120124. * @param _options options for this controller creation
  120125. */
  120126. constructor(_scene: Scene,
  120127. /** The underlying input source for the controller */
  120128. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  120129. /**
  120130. * Get this controllers unique id
  120131. */
  120132. get uniqueId(): string;
  120133. /**
  120134. * Disposes of the object
  120135. */
  120136. dispose(): void;
  120137. /**
  120138. * Gets a world space ray coming from the pointer or grip
  120139. * @param result the resulting ray
  120140. * @param gripIfAvailable use the grip mesh instead of the pointer, if available
  120141. */
  120142. getWorldPointerRayToRef(result: Ray, gripIfAvailable?: boolean): void;
  120143. /**
  120144. * Updates the controller pose based on the given XRFrame
  120145. * @param xrFrame xr frame to update the pose with
  120146. * @param referenceSpace reference space to use
  120147. */
  120148. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  120149. }
  120150. }
  120151. declare module BABYLON {
  120152. /**
  120153. * The schema for initialization options of the XR Input class
  120154. */
  120155. export interface IWebXRInputOptions {
  120156. /**
  120157. * If set to true no model will be automatically loaded
  120158. */
  120159. doNotLoadControllerMeshes?: boolean;
  120160. /**
  120161. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  120162. * If not found, the xr input profile data will be used.
  120163. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  120164. */
  120165. forceInputProfile?: string;
  120166. /**
  120167. * Do not send a request to the controller repository to load the profile.
  120168. *
  120169. * Instead, use the controllers available in babylon itself.
  120170. */
  120171. disableOnlineControllerRepository?: boolean;
  120172. /**
  120173. * A custom URL for the controllers repository
  120174. */
  120175. customControllersRepositoryURL?: string;
  120176. /**
  120177. * Should the controller model's components not move according to the user input
  120178. */
  120179. disableControllerAnimation?: boolean;
  120180. }
  120181. /**
  120182. * XR input used to track XR inputs such as controllers/rays
  120183. */
  120184. export class WebXRInput implements IDisposable {
  120185. /**
  120186. * the xr session manager for this session
  120187. */
  120188. xrSessionManager: WebXRSessionManager;
  120189. /**
  120190. * the WebXR camera for this session. Mainly used for teleportation
  120191. */
  120192. xrCamera: WebXRCamera;
  120193. private readonly options;
  120194. /**
  120195. * XR controllers being tracked
  120196. */
  120197. controllers: Array<WebXRInputSource>;
  120198. private _frameObserver;
  120199. private _sessionEndedObserver;
  120200. private _sessionInitObserver;
  120201. /**
  120202. * Event when a controller has been connected/added
  120203. */
  120204. onControllerAddedObservable: Observable<WebXRInputSource>;
  120205. /**
  120206. * Event when a controller has been removed/disconnected
  120207. */
  120208. onControllerRemovedObservable: Observable<WebXRInputSource>;
  120209. /**
  120210. * Initializes the WebXRInput
  120211. * @param xrSessionManager the xr session manager for this session
  120212. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  120213. * @param options = initialization options for this xr input
  120214. */
  120215. constructor(
  120216. /**
  120217. * the xr session manager for this session
  120218. */
  120219. xrSessionManager: WebXRSessionManager,
  120220. /**
  120221. * the WebXR camera for this session. Mainly used for teleportation
  120222. */
  120223. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  120224. private _onInputSourcesChange;
  120225. private _addAndRemoveControllers;
  120226. /**
  120227. * Disposes of the object
  120228. */
  120229. dispose(): void;
  120230. }
  120231. }
  120232. declare module BABYLON {
  120233. /**
  120234. * This is the base class for all WebXR features.
  120235. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  120236. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  120237. */
  120238. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  120239. protected _xrSessionManager: WebXRSessionManager;
  120240. private _attached;
  120241. private _removeOnDetach;
  120242. /**
  120243. * Should auto-attach be disabled?
  120244. */
  120245. disableAutoAttach: boolean;
  120246. /**
  120247. * Construct a new (abstract) WebXR feature
  120248. * @param _xrSessionManager the xr session manager for this feature
  120249. */
  120250. constructor(_xrSessionManager: WebXRSessionManager);
  120251. /**
  120252. * Is this feature attached
  120253. */
  120254. get attached(): boolean;
  120255. /**
  120256. * attach this feature
  120257. *
  120258. * @param force should attachment be forced (even when already attached)
  120259. * @returns true if successful, false is failed or already attached
  120260. */
  120261. attach(force?: boolean): boolean;
  120262. /**
  120263. * detach this feature.
  120264. *
  120265. * @returns true if successful, false if failed or already detached
  120266. */
  120267. detach(): boolean;
  120268. /**
  120269. * Dispose this feature and all of the resources attached
  120270. */
  120271. dispose(): void;
  120272. /**
  120273. * This is used to register callbacks that will automatically be removed when detach is called.
  120274. * @param observable the observable to which the observer will be attached
  120275. * @param callback the callback to register
  120276. */
  120277. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  120278. /**
  120279. * Code in this function will be executed on each xrFrame received from the browser.
  120280. * This function will not execute after the feature is detached.
  120281. * @param _xrFrame the current frame
  120282. */
  120283. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  120284. }
  120285. }
  120286. declare module BABYLON {
  120287. /**
  120288. * Renders a layer on top of an existing scene
  120289. */
  120290. export class UtilityLayerRenderer implements IDisposable {
  120291. /** the original scene that will be rendered on top of */
  120292. originalScene: Scene;
  120293. private _pointerCaptures;
  120294. private _lastPointerEvents;
  120295. private static _DefaultUtilityLayer;
  120296. private static _DefaultKeepDepthUtilityLayer;
  120297. private _sharedGizmoLight;
  120298. private _renderCamera;
  120299. /**
  120300. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  120301. * @param getRigParentIfPossible if the current active camera is a rig camera, should its parent camera be returned
  120302. * @returns the camera that is used when rendering the utility layer
  120303. */
  120304. getRenderCamera(getRigParentIfPossible?: boolean): Camera;
  120305. /**
  120306. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  120307. * @param cam the camera that should be used when rendering the utility layer
  120308. */
  120309. setRenderCamera(cam: Nullable<Camera>): void;
  120310. /**
  120311. * @hidden
  120312. * Light which used by gizmos to get light shading
  120313. */
  120314. _getSharedGizmoLight(): HemisphericLight;
  120315. /**
  120316. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  120317. */
  120318. pickUtilitySceneFirst: boolean;
  120319. /**
  120320. * 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)
  120321. */
  120322. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  120323. /**
  120324. * 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)
  120325. */
  120326. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  120327. /**
  120328. * The scene that is rendered on top of the original scene
  120329. */
  120330. utilityLayerScene: Scene;
  120331. /**
  120332. * If the utility layer should automatically be rendered on top of existing scene
  120333. */
  120334. shouldRender: boolean;
  120335. /**
  120336. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  120337. */
  120338. onlyCheckPointerDownEvents: boolean;
  120339. /**
  120340. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  120341. */
  120342. processAllEvents: boolean;
  120343. /**
  120344. * Observable raised when the pointer move from the utility layer scene to the main scene
  120345. */
  120346. onPointerOutObservable: Observable<number>;
  120347. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  120348. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  120349. private _afterRenderObserver;
  120350. private _sceneDisposeObserver;
  120351. private _originalPointerObserver;
  120352. /**
  120353. * Instantiates a UtilityLayerRenderer
  120354. * @param originalScene the original scene that will be rendered on top of
  120355. * @param handleEvents boolean indicating if the utility layer should handle events
  120356. */
  120357. constructor(
  120358. /** the original scene that will be rendered on top of */
  120359. originalScene: Scene, handleEvents?: boolean);
  120360. private _notifyObservers;
  120361. /**
  120362. * Renders the utility layers scene on top of the original scene
  120363. */
  120364. render(): void;
  120365. /**
  120366. * Disposes of the renderer
  120367. */
  120368. dispose(): void;
  120369. private _updateCamera;
  120370. }
  120371. }
  120372. declare module BABYLON {
  120373. /**
  120374. * Options interface for the pointer selection module
  120375. */
  120376. export interface IWebXRControllerPointerSelectionOptions {
  120377. /**
  120378. * if provided, this scene will be used to render meshes.
  120379. */
  120380. customUtilityLayerScene?: Scene;
  120381. /**
  120382. * 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)
  120383. * If not disabled, the last picked point will be used to execute a pointer up event
  120384. * If disabled, pointer up event will be triggered right after the pointer down event.
  120385. * Used in screen and gaze target ray mode only
  120386. */
  120387. disablePointerUpOnTouchOut: boolean;
  120388. /**
  120389. * For gaze mode (time to select instead of press)
  120390. */
  120391. forceGazeMode: boolean;
  120392. /**
  120393. * 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
  120394. * to start a new countdown to the pointer down event.
  120395. * Defaults to 1.
  120396. */
  120397. gazeModePointerMovedFactor?: number;
  120398. /**
  120399. * Different button type to use instead of the main component
  120400. */
  120401. overrideButtonId?: string;
  120402. /**
  120403. * use this rendering group id for the meshes (optional)
  120404. */
  120405. renderingGroupId?: number;
  120406. /**
  120407. * The amount of time in milliseconds it takes between pick found something to a pointer down event.
  120408. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  120409. * 3000 means 3 seconds between pointing at something and selecting it
  120410. */
  120411. timeToSelect?: number;
  120412. /**
  120413. * Should meshes created here be added to a utility layer or the main scene
  120414. */
  120415. useUtilityLayer?: boolean;
  120416. /**
  120417. * the xr input to use with this pointer selection
  120418. */
  120419. xrInput: WebXRInput;
  120420. }
  120421. /**
  120422. * A module that will enable pointer selection for motion controllers of XR Input Sources
  120423. */
  120424. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  120425. private readonly _options;
  120426. private static _idCounter;
  120427. private _attachController;
  120428. private _controllers;
  120429. private _scene;
  120430. private _tmpVectorForPickCompare;
  120431. /**
  120432. * The module's name
  120433. */
  120434. static readonly Name: string;
  120435. /**
  120436. * The (Babylon) version of this module.
  120437. * This is an integer representing the implementation version.
  120438. * This number does not correspond to the WebXR specs version
  120439. */
  120440. static readonly Version: number;
  120441. /**
  120442. * Disable lighting on the laser pointer (so it will always be visible)
  120443. */
  120444. disablePointerLighting: boolean;
  120445. /**
  120446. * Disable lighting on the selection mesh (so it will always be visible)
  120447. */
  120448. disableSelectionMeshLighting: boolean;
  120449. /**
  120450. * Should the laser pointer be displayed
  120451. */
  120452. displayLaserPointer: boolean;
  120453. /**
  120454. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  120455. */
  120456. displaySelectionMesh: boolean;
  120457. /**
  120458. * This color will be set to the laser pointer when selection is triggered
  120459. */
  120460. laserPointerPickedColor: Color3;
  120461. /**
  120462. * Default color of the laser pointer
  120463. */
  120464. lasterPointerDefaultColor: Color3;
  120465. /**
  120466. * default color of the selection ring
  120467. */
  120468. selectionMeshDefaultColor: Color3;
  120469. /**
  120470. * This color will be applied to the selection ring when selection is triggered
  120471. */
  120472. selectionMeshPickedColor: Color3;
  120473. /**
  120474. * Optional filter to be used for ray selection. This predicate shares behavior with
  120475. * scene.pointerMovePredicate which takes priority if it is also assigned.
  120476. */
  120477. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  120478. /**
  120479. * constructs a new background remover module
  120480. * @param _xrSessionManager the session manager for this module
  120481. * @param _options read-only options to be used in this module
  120482. */
  120483. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  120484. /**
  120485. * attach this feature
  120486. * Will usually be called by the features manager
  120487. *
  120488. * @returns true if successful.
  120489. */
  120490. attach(): boolean;
  120491. /**
  120492. * detach this feature.
  120493. * Will usually be called by the features manager
  120494. *
  120495. * @returns true if successful.
  120496. */
  120497. detach(): boolean;
  120498. /**
  120499. * Will get the mesh under a specific pointer.
  120500. * `scene.meshUnderPointer` will only return one mesh - either left or right.
  120501. * @param controllerId the controllerId to check
  120502. * @returns The mesh under pointer or null if no mesh is under the pointer
  120503. */
  120504. getMeshUnderPointer(controllerId: string): Nullable<AbstractMesh>;
  120505. /**
  120506. * Get the xr controller that correlates to the pointer id in the pointer event
  120507. *
  120508. * @param id the pointer id to search for
  120509. * @returns the controller that correlates to this id or null if not found
  120510. */
  120511. getXRControllerByPointerId(id: number): Nullable<WebXRInputSource>;
  120512. protected _onXRFrame(_xrFrame: XRFrame): void;
  120513. private _attachGazeMode;
  120514. private _attachScreenRayMode;
  120515. private _attachTrackedPointerRayMode;
  120516. private _convertNormalToDirectionOfRay;
  120517. private _detachController;
  120518. private _generateNewMeshPair;
  120519. private _pickingMoved;
  120520. private _updatePointerDistance;
  120521. }
  120522. }
  120523. declare module BABYLON {
  120524. /**
  120525. * Button which can be used to enter a different mode of XR
  120526. */
  120527. export class WebXREnterExitUIButton {
  120528. /** button element */
  120529. element: HTMLElement;
  120530. /** XR initialization options for the button */
  120531. sessionMode: XRSessionMode;
  120532. /** Reference space type */
  120533. referenceSpaceType: XRReferenceSpaceType;
  120534. /**
  120535. * Creates a WebXREnterExitUIButton
  120536. * @param element button element
  120537. * @param sessionMode XR initialization session mode
  120538. * @param referenceSpaceType the type of reference space to be used
  120539. */
  120540. constructor(
  120541. /** button element */
  120542. element: HTMLElement,
  120543. /** XR initialization options for the button */
  120544. sessionMode: XRSessionMode,
  120545. /** Reference space type */
  120546. referenceSpaceType: XRReferenceSpaceType);
  120547. /**
  120548. * Extendable function which can be used to update the button's visuals when the state changes
  120549. * @param activeButton the current active button in the UI
  120550. */
  120551. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  120552. }
  120553. /**
  120554. * Options to create the webXR UI
  120555. */
  120556. export class WebXREnterExitUIOptions {
  120557. /**
  120558. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  120559. */
  120560. customButtons?: Array<WebXREnterExitUIButton>;
  120561. /**
  120562. * A reference space type to use when creating the default button.
  120563. * Default is local-floor
  120564. */
  120565. referenceSpaceType?: XRReferenceSpaceType;
  120566. /**
  120567. * Context to enter xr with
  120568. */
  120569. renderTarget?: Nullable<WebXRRenderTarget>;
  120570. /**
  120571. * A session mode to use when creating the default button.
  120572. * Default is immersive-vr
  120573. */
  120574. sessionMode?: XRSessionMode;
  120575. }
  120576. /**
  120577. * UI to allow the user to enter/exit XR mode
  120578. */
  120579. export class WebXREnterExitUI implements IDisposable {
  120580. private scene;
  120581. /** version of the options passed to this UI */
  120582. options: WebXREnterExitUIOptions;
  120583. private _activeButton;
  120584. private _buttons;
  120585. private _overlay;
  120586. /**
  120587. * Fired every time the active button is changed.
  120588. *
  120589. * When xr is entered via a button that launches xr that button will be the callback parameter
  120590. *
  120591. * When exiting xr the callback parameter will be null)
  120592. */
  120593. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  120594. /**
  120595. *
  120596. * @param scene babylon scene object to use
  120597. * @param options (read-only) version of the options passed to this UI
  120598. */
  120599. private constructor();
  120600. /**
  120601. * Creates UI to allow the user to enter/exit XR mode
  120602. * @param scene the scene to add the ui to
  120603. * @param helper the xr experience helper to enter/exit xr with
  120604. * @param options options to configure the UI
  120605. * @returns the created ui
  120606. */
  120607. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  120608. /**
  120609. * Disposes of the XR UI component
  120610. */
  120611. dispose(): void;
  120612. private _updateButtons;
  120613. }
  120614. }
  120615. declare module BABYLON {
  120616. /**
  120617. * Class containing static functions to help procedurally build meshes
  120618. */
  120619. export class LinesBuilder {
  120620. /**
  120621. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  120622. * * 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
  120623. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  120624. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  120625. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  120626. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  120627. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  120628. * * 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
  120629. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  120630. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  120631. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  120632. * @param name defines the name of the new line system
  120633. * @param options defines the options used to create the line system
  120634. * @param scene defines the hosting scene
  120635. * @returns a new line system mesh
  120636. */
  120637. static CreateLineSystem(name: string, options: {
  120638. lines: Vector3[][];
  120639. updatable?: boolean;
  120640. instance?: Nullable<LinesMesh>;
  120641. colors?: Nullable<Color4[][]>;
  120642. useVertexAlpha?: boolean;
  120643. }, scene: Nullable<Scene>): LinesMesh;
  120644. /**
  120645. * Creates a line mesh
  120646. * 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
  120647. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  120648. * * The parameter `points` is an array successive Vector3
  120649. * * 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
  120650. * * The optional parameter `colors` is an array of successive Color4, one per line point
  120651. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  120652. * * When updating an instance, remember that only point positions can change, not the number of points
  120653. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  120654. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  120655. * @param name defines the name of the new line system
  120656. * @param options defines the options used to create the line system
  120657. * @param scene defines the hosting scene
  120658. * @returns a new line mesh
  120659. */
  120660. static CreateLines(name: string, options: {
  120661. points: Vector3[];
  120662. updatable?: boolean;
  120663. instance?: Nullable<LinesMesh>;
  120664. colors?: Color4[];
  120665. useVertexAlpha?: boolean;
  120666. }, scene?: Nullable<Scene>): LinesMesh;
  120667. /**
  120668. * Creates a dashed line mesh
  120669. * * 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
  120670. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  120671. * * The parameter `points` is an array successive Vector3
  120672. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  120673. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  120674. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  120675. * * 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
  120676. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  120677. * * When updating an instance, remember that only point positions can change, not the number of points
  120678. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  120679. * @param name defines the name of the mesh
  120680. * @param options defines the options used to create the mesh
  120681. * @param scene defines the hosting scene
  120682. * @returns the dashed line mesh
  120683. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  120684. */
  120685. static CreateDashedLines(name: string, options: {
  120686. points: Vector3[];
  120687. dashSize?: number;
  120688. gapSize?: number;
  120689. dashNb?: number;
  120690. updatable?: boolean;
  120691. instance?: LinesMesh;
  120692. useVertexAlpha?: boolean;
  120693. }, scene?: Nullable<Scene>): LinesMesh;
  120694. }
  120695. }
  120696. declare module BABYLON {
  120697. /**
  120698. * The options container for the teleportation module
  120699. */
  120700. export interface IWebXRTeleportationOptions {
  120701. /**
  120702. * if provided, this scene will be used to render meshes.
  120703. */
  120704. customUtilityLayerScene?: Scene;
  120705. /**
  120706. * Values to configure the default target mesh
  120707. */
  120708. defaultTargetMeshOptions?: {
  120709. /**
  120710. * Fill color of the teleportation area
  120711. */
  120712. teleportationFillColor?: string;
  120713. /**
  120714. * Border color for the teleportation area
  120715. */
  120716. teleportationBorderColor?: string;
  120717. /**
  120718. * Disable the mesh's animation sequence
  120719. */
  120720. disableAnimation?: boolean;
  120721. /**
  120722. * Disable lighting on the material or the ring and arrow
  120723. */
  120724. disableLighting?: boolean;
  120725. /**
  120726. * Override the default material of the torus and arrow
  120727. */
  120728. torusArrowMaterial?: Material;
  120729. };
  120730. /**
  120731. * A list of meshes to use as floor meshes.
  120732. * Meshes can be added and removed after initializing the feature using the
  120733. * addFloorMesh and removeFloorMesh functions
  120734. * If empty, rotation will still work
  120735. */
  120736. floorMeshes?: AbstractMesh[];
  120737. /**
  120738. * use this rendering group id for the meshes (optional)
  120739. */
  120740. renderingGroupId?: number;
  120741. /**
  120742. * Should teleportation move only to snap points
  120743. */
  120744. snapPointsOnly?: boolean;
  120745. /**
  120746. * An array of points to which the teleportation will snap to.
  120747. * If the teleportation ray is in the proximity of one of those points, it will be corrected to this point.
  120748. */
  120749. snapPositions?: Vector3[];
  120750. /**
  120751. * How close should the teleportation ray be in order to snap to position.
  120752. * Default to 0.8 units (meters)
  120753. */
  120754. snapToPositionRadius?: number;
  120755. /**
  120756. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  120757. * If you want to support rotation, make sure your mesh has a direction indicator.
  120758. *
  120759. * When left untouched, the default mesh will be initialized.
  120760. */
  120761. teleportationTargetMesh?: AbstractMesh;
  120762. /**
  120763. * If main component is used (no thumbstick), how long should the "long press" take before teleport
  120764. */
  120765. timeToTeleport?: number;
  120766. /**
  120767. * Disable using the thumbstick and use the main component (usually trigger) on long press.
  120768. * This will be automatically true if the controller doesn't have a thumbstick or touchpad.
  120769. */
  120770. useMainComponentOnly?: boolean;
  120771. /**
  120772. * Should meshes created here be added to a utility layer or the main scene
  120773. */
  120774. useUtilityLayer?: boolean;
  120775. /**
  120776. * Babylon XR Input class for controller
  120777. */
  120778. xrInput: WebXRInput;
  120779. }
  120780. /**
  120781. * This is a teleportation feature to be used with WebXR-enabled motion controllers.
  120782. * When enabled and attached, the feature will allow a user to move around and rotate in the scene using
  120783. * the input of the attached controllers.
  120784. */
  120785. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  120786. private _options;
  120787. private _controllers;
  120788. private _currentTeleportationControllerId;
  120789. private _floorMeshes;
  120790. private _quadraticBezierCurve;
  120791. private _selectionFeature;
  120792. private _snapToPositions;
  120793. private _snappedToPoint;
  120794. private _teleportationRingMaterial?;
  120795. private _tmpRay;
  120796. private _tmpVector;
  120797. /**
  120798. * The module's name
  120799. */
  120800. static readonly Name: string;
  120801. /**
  120802. * The (Babylon) version of this module.
  120803. * This is an integer representing the implementation version.
  120804. * This number does not correspond to the webxr specs version
  120805. */
  120806. static readonly Version: number;
  120807. /**
  120808. * Is movement backwards enabled
  120809. */
  120810. backwardsMovementEnabled: boolean;
  120811. /**
  120812. * Distance to travel when moving backwards
  120813. */
  120814. backwardsTeleportationDistance: number;
  120815. /**
  120816. * The distance from the user to the inspection point in the direction of the controller
  120817. * A higher number will allow the user to move further
  120818. * defaults to 5 (meters, in xr units)
  120819. */
  120820. parabolicCheckRadius: number;
  120821. /**
  120822. * Should the module support parabolic ray on top of direct ray
  120823. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  120824. * Very helpful when moving between floors / different heights
  120825. */
  120826. parabolicRayEnabled: boolean;
  120827. /**
  120828. * How much rotation should be applied when rotating right and left
  120829. */
  120830. rotationAngle: number;
  120831. /**
  120832. * Is rotation enabled when moving forward?
  120833. * Disabling this feature will prevent the user from deciding the direction when teleporting
  120834. */
  120835. rotationEnabled: boolean;
  120836. /**
  120837. * constructs a new anchor system
  120838. * @param _xrSessionManager an instance of WebXRSessionManager
  120839. * @param _options configuration object for this feature
  120840. */
  120841. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  120842. /**
  120843. * Get the snapPointsOnly flag
  120844. */
  120845. get snapPointsOnly(): boolean;
  120846. /**
  120847. * Sets the snapPointsOnly flag
  120848. * @param snapToPoints should teleportation be exclusively to snap points
  120849. */
  120850. set snapPointsOnly(snapToPoints: boolean);
  120851. /**
  120852. * Add a new mesh to the floor meshes array
  120853. * @param mesh the mesh to use as floor mesh
  120854. */
  120855. addFloorMesh(mesh: AbstractMesh): void;
  120856. /**
  120857. * Add a new snap-to point to fix teleportation to this position
  120858. * @param newSnapPoint The new Snap-To point
  120859. */
  120860. addSnapPoint(newSnapPoint: Vector3): void;
  120861. attach(): boolean;
  120862. detach(): boolean;
  120863. dispose(): void;
  120864. /**
  120865. * Remove a mesh from the floor meshes array
  120866. * @param mesh the mesh to remove
  120867. */
  120868. removeFloorMesh(mesh: AbstractMesh): void;
  120869. /**
  120870. * Remove a mesh from the floor meshes array using its name
  120871. * @param name the mesh name to remove
  120872. */
  120873. removeFloorMeshByName(name: string): void;
  120874. /**
  120875. * 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
  120876. * @param snapPointToRemove the point (or a clone of it) to be removed from the array
  120877. * @returns was the point found and removed or not
  120878. */
  120879. removeSnapPoint(snapPointToRemove: Vector3): boolean;
  120880. /**
  120881. * This function sets a selection feature that will be disabled when
  120882. * the forward ray is shown and will be reattached when hidden.
  120883. * This is used to remove the selection rays when moving.
  120884. * @param selectionFeature the feature to disable when forward movement is enabled
  120885. */
  120886. setSelectionFeature(selectionFeature: IWebXRFeature): void;
  120887. protected _onXRFrame(_xrFrame: XRFrame): void;
  120888. private _attachController;
  120889. private _createDefaultTargetMesh;
  120890. private _detachController;
  120891. private _findClosestSnapPointWithRadius;
  120892. private _setTargetMeshPosition;
  120893. private _setTargetMeshVisibility;
  120894. private _showParabolicPath;
  120895. private _teleportForward;
  120896. }
  120897. }
  120898. declare module BABYLON {
  120899. /**
  120900. * Options for the default xr helper
  120901. */
  120902. export class WebXRDefaultExperienceOptions {
  120903. /**
  120904. * Enable or disable default UI to enter XR
  120905. */
  120906. disableDefaultUI?: boolean;
  120907. /**
  120908. * Should teleportation not initialize. defaults to false.
  120909. */
  120910. disableTeleportation?: boolean;
  120911. /**
  120912. * Floor meshes that will be used for teleport
  120913. */
  120914. floorMeshes?: Array<AbstractMesh>;
  120915. /**
  120916. * If set to true, the first frame will not be used to reset position
  120917. * The first frame is mainly used when copying transformation from the old camera
  120918. * Mainly used in AR
  120919. */
  120920. ignoreNativeCameraTransformation?: boolean;
  120921. /**
  120922. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  120923. */
  120924. inputOptions?: IWebXRInputOptions;
  120925. /**
  120926. * optional configuration for the output canvas
  120927. */
  120928. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  120929. /**
  120930. * optional UI options. This can be used among other to change session mode and reference space type
  120931. */
  120932. uiOptions?: WebXREnterExitUIOptions;
  120933. /**
  120934. * When loading teleportation and pointer select, use stable versions instead of latest.
  120935. */
  120936. useStablePlugins?: boolean;
  120937. }
  120938. /**
  120939. * Default experience which provides a similar setup to the previous webVRExperience
  120940. */
  120941. export class WebXRDefaultExperience {
  120942. /**
  120943. * Base experience
  120944. */
  120945. baseExperience: WebXRExperienceHelper;
  120946. /**
  120947. * Enables ui for entering/exiting xr
  120948. */
  120949. enterExitUI: WebXREnterExitUI;
  120950. /**
  120951. * Input experience extension
  120952. */
  120953. input: WebXRInput;
  120954. /**
  120955. * Enables laser pointer and selection
  120956. */
  120957. pointerSelection: WebXRControllerPointerSelection;
  120958. /**
  120959. * Default target xr should render to
  120960. */
  120961. renderTarget: WebXRRenderTarget;
  120962. /**
  120963. * Enables teleportation
  120964. */
  120965. teleportation: WebXRMotionControllerTeleportation;
  120966. private constructor();
  120967. /**
  120968. * Creates the default xr experience
  120969. * @param scene scene
  120970. * @param options options for basic configuration
  120971. * @returns resulting WebXRDefaultExperience
  120972. */
  120973. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  120974. /**
  120975. * DIsposes of the experience helper
  120976. */
  120977. dispose(): void;
  120978. }
  120979. }
  120980. declare module BABYLON {
  120981. /**
  120982. * Options to modify the vr teleportation behavior.
  120983. */
  120984. export interface VRTeleportationOptions {
  120985. /**
  120986. * The name of the mesh which should be used as the teleportation floor. (default: null)
  120987. */
  120988. floorMeshName?: string;
  120989. /**
  120990. * A list of meshes to be used as the teleportation floor. (default: empty)
  120991. */
  120992. floorMeshes?: Mesh[];
  120993. /**
  120994. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  120995. */
  120996. teleportationMode?: number;
  120997. /**
  120998. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  120999. */
  121000. teleportationTime?: number;
  121001. /**
  121002. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  121003. */
  121004. teleportationSpeed?: number;
  121005. /**
  121006. * The easing function used in the animation or null for Linear. (default CircleEase)
  121007. */
  121008. easingFunction?: EasingFunction;
  121009. }
  121010. /**
  121011. * Options to modify the vr experience helper's behavior.
  121012. */
  121013. export interface VRExperienceHelperOptions extends WebVROptions {
  121014. /**
  121015. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  121016. */
  121017. createDeviceOrientationCamera?: boolean;
  121018. /**
  121019. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  121020. */
  121021. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  121022. /**
  121023. * Uses the main button on the controller to toggle the laser casted. (default: true)
  121024. */
  121025. laserToggle?: boolean;
  121026. /**
  121027. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  121028. */
  121029. floorMeshes?: Mesh[];
  121030. /**
  121031. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  121032. */
  121033. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  121034. /**
  121035. * Defines if WebXR should be used instead of WebVR (if available)
  121036. */
  121037. useXR?: boolean;
  121038. }
  121039. /**
  121040. * Event containing information after VR has been entered
  121041. */
  121042. export class OnAfterEnteringVRObservableEvent {
  121043. /**
  121044. * If entering vr was successful
  121045. */
  121046. success: boolean;
  121047. }
  121048. /**
  121049. * Helps to quickly add VR support to an existing scene.
  121050. * See http://doc.babylonjs.com/how_to/webvr_helper
  121051. */
  121052. export class VRExperienceHelper {
  121053. /** Options to modify the vr experience helper's behavior. */
  121054. webVROptions: VRExperienceHelperOptions;
  121055. private _scene;
  121056. private _position;
  121057. private _btnVR;
  121058. private _btnVRDisplayed;
  121059. private _webVRsupported;
  121060. private _webVRready;
  121061. private _webVRrequesting;
  121062. private _webVRpresenting;
  121063. private _hasEnteredVR;
  121064. private _fullscreenVRpresenting;
  121065. private _inputElement;
  121066. private _webVRCamera;
  121067. private _vrDeviceOrientationCamera;
  121068. private _deviceOrientationCamera;
  121069. private _existingCamera;
  121070. private _onKeyDown;
  121071. private _onVrDisplayPresentChange;
  121072. private _onVRDisplayChanged;
  121073. private _onVRRequestPresentStart;
  121074. private _onVRRequestPresentComplete;
  121075. /**
  121076. * 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)
  121077. */
  121078. enableGazeEvenWhenNoPointerLock: boolean;
  121079. /**
  121080. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  121081. */
  121082. exitVROnDoubleTap: boolean;
  121083. /**
  121084. * Observable raised right before entering VR.
  121085. */
  121086. onEnteringVRObservable: Observable<VRExperienceHelper>;
  121087. /**
  121088. * Observable raised when entering VR has completed.
  121089. */
  121090. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  121091. /**
  121092. * Observable raised when exiting VR.
  121093. */
  121094. onExitingVRObservable: Observable<VRExperienceHelper>;
  121095. /**
  121096. * Observable raised when controller mesh is loaded.
  121097. */
  121098. onControllerMeshLoadedObservable: Observable<WebVRController>;
  121099. /** Return this.onEnteringVRObservable
  121100. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  121101. */
  121102. get onEnteringVR(): Observable<VRExperienceHelper>;
  121103. /** Return this.onExitingVRObservable
  121104. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  121105. */
  121106. get onExitingVR(): Observable<VRExperienceHelper>;
  121107. /** Return this.onControllerMeshLoadedObservable
  121108. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  121109. */
  121110. get onControllerMeshLoaded(): Observable<WebVRController>;
  121111. private _rayLength;
  121112. private _useCustomVRButton;
  121113. private _teleportationRequested;
  121114. private _teleportActive;
  121115. private _floorMeshName;
  121116. private _floorMeshesCollection;
  121117. private _teleportationMode;
  121118. private _teleportationTime;
  121119. private _teleportationSpeed;
  121120. private _teleportationEasing;
  121121. private _rotationAllowed;
  121122. private _teleportBackwardsVector;
  121123. private _teleportationTarget;
  121124. private _isDefaultTeleportationTarget;
  121125. private _postProcessMove;
  121126. private _teleportationFillColor;
  121127. private _teleportationBorderColor;
  121128. private _rotationAngle;
  121129. private _haloCenter;
  121130. private _cameraGazer;
  121131. private _padSensibilityUp;
  121132. private _padSensibilityDown;
  121133. private _leftController;
  121134. private _rightController;
  121135. private _gazeColor;
  121136. private _laserColor;
  121137. private _pickedLaserColor;
  121138. private _pickedGazeColor;
  121139. /**
  121140. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  121141. */
  121142. onNewMeshSelected: Observable<AbstractMesh>;
  121143. /**
  121144. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  121145. * This observable will provide the mesh and the controller used to select the mesh
  121146. */
  121147. onMeshSelectedWithController: Observable<{
  121148. mesh: AbstractMesh;
  121149. controller: WebVRController;
  121150. }>;
  121151. /**
  121152. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  121153. */
  121154. onNewMeshPicked: Observable<PickingInfo>;
  121155. private _circleEase;
  121156. /**
  121157. * Observable raised before camera teleportation
  121158. */
  121159. onBeforeCameraTeleport: Observable<Vector3>;
  121160. /**
  121161. * Observable raised after camera teleportation
  121162. */
  121163. onAfterCameraTeleport: Observable<Vector3>;
  121164. /**
  121165. * Observable raised when current selected mesh gets unselected
  121166. */
  121167. onSelectedMeshUnselected: Observable<AbstractMesh>;
  121168. private _raySelectionPredicate;
  121169. /**
  121170. * To be optionaly changed by user to define custom ray selection
  121171. */
  121172. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  121173. /**
  121174. * To be optionaly changed by user to define custom selection logic (after ray selection)
  121175. */
  121176. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  121177. /**
  121178. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  121179. */
  121180. teleportationEnabled: boolean;
  121181. private _defaultHeight;
  121182. private _teleportationInitialized;
  121183. private _interactionsEnabled;
  121184. private _interactionsRequested;
  121185. private _displayGaze;
  121186. private _displayLaserPointer;
  121187. /**
  121188. * The mesh used to display where the user is going to teleport.
  121189. */
  121190. get teleportationTarget(): Mesh;
  121191. /**
  121192. * Sets the mesh to be used to display where the user is going to teleport.
  121193. */
  121194. set teleportationTarget(value: Mesh);
  121195. /**
  121196. * 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
  121197. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  121198. * See http://doc.babylonjs.com/resources/baking_transformations
  121199. */
  121200. get gazeTrackerMesh(): Mesh;
  121201. set gazeTrackerMesh(value: Mesh);
  121202. /**
  121203. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  121204. */
  121205. updateGazeTrackerScale: boolean;
  121206. /**
  121207. * If the gaze trackers color should be updated when selecting meshes
  121208. */
  121209. updateGazeTrackerColor: boolean;
  121210. /**
  121211. * If the controller laser color should be updated when selecting meshes
  121212. */
  121213. updateControllerLaserColor: boolean;
  121214. /**
  121215. * The gaze tracking mesh corresponding to the left controller
  121216. */
  121217. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  121218. /**
  121219. * The gaze tracking mesh corresponding to the right controller
  121220. */
  121221. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  121222. /**
  121223. * If the ray of the gaze should be displayed.
  121224. */
  121225. get displayGaze(): boolean;
  121226. /**
  121227. * Sets if the ray of the gaze should be displayed.
  121228. */
  121229. set displayGaze(value: boolean);
  121230. /**
  121231. * If the ray of the LaserPointer should be displayed.
  121232. */
  121233. get displayLaserPointer(): boolean;
  121234. /**
  121235. * Sets if the ray of the LaserPointer should be displayed.
  121236. */
  121237. set displayLaserPointer(value: boolean);
  121238. /**
  121239. * The deviceOrientationCamera used as the camera when not in VR.
  121240. */
  121241. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  121242. /**
  121243. * Based on the current WebVR support, returns the current VR camera used.
  121244. */
  121245. get currentVRCamera(): Nullable<Camera>;
  121246. /**
  121247. * The webVRCamera which is used when in VR.
  121248. */
  121249. get webVRCamera(): WebVRFreeCamera;
  121250. /**
  121251. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  121252. */
  121253. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  121254. /**
  121255. * The html button that is used to trigger entering into VR.
  121256. */
  121257. get vrButton(): Nullable<HTMLButtonElement>;
  121258. private get _teleportationRequestInitiated();
  121259. /**
  121260. * Defines whether or not Pointer lock should be requested when switching to
  121261. * full screen.
  121262. */
  121263. requestPointerLockOnFullScreen: boolean;
  121264. /**
  121265. * If asking to force XR, this will be populated with the default xr experience
  121266. */
  121267. xr: WebXRDefaultExperience;
  121268. /**
  121269. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  121270. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  121271. */
  121272. xrTestDone: boolean;
  121273. /**
  121274. * Instantiates a VRExperienceHelper.
  121275. * Helps to quickly add VR support to an existing scene.
  121276. * @param scene The scene the VRExperienceHelper belongs to.
  121277. * @param webVROptions Options to modify the vr experience helper's behavior.
  121278. */
  121279. constructor(scene: Scene,
  121280. /** Options to modify the vr experience helper's behavior. */
  121281. webVROptions?: VRExperienceHelperOptions);
  121282. private completeVRInit;
  121283. private _onDefaultMeshLoaded;
  121284. private _onResize;
  121285. private _onFullscreenChange;
  121286. /**
  121287. * Gets a value indicating if we are currently in VR mode.
  121288. */
  121289. get isInVRMode(): boolean;
  121290. private onVrDisplayPresentChange;
  121291. private onVRDisplayChanged;
  121292. private moveButtonToBottomRight;
  121293. private displayVRButton;
  121294. private updateButtonVisibility;
  121295. private _cachedAngularSensibility;
  121296. /**
  121297. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  121298. * Otherwise, will use the fullscreen API.
  121299. */
  121300. enterVR(): void;
  121301. /**
  121302. * Attempt to exit VR, or fullscreen.
  121303. */
  121304. exitVR(): void;
  121305. /**
  121306. * The position of the vr experience helper.
  121307. */
  121308. get position(): Vector3;
  121309. /**
  121310. * Sets the position of the vr experience helper.
  121311. */
  121312. set position(value: Vector3);
  121313. /**
  121314. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  121315. */
  121316. enableInteractions(): void;
  121317. private get _noControllerIsActive();
  121318. private beforeRender;
  121319. private _isTeleportationFloor;
  121320. /**
  121321. * Adds a floor mesh to be used for teleportation.
  121322. * @param floorMesh the mesh to be used for teleportation.
  121323. */
  121324. addFloorMesh(floorMesh: Mesh): void;
  121325. /**
  121326. * Removes a floor mesh from being used for teleportation.
  121327. * @param floorMesh the mesh to be removed.
  121328. */
  121329. removeFloorMesh(floorMesh: Mesh): void;
  121330. /**
  121331. * Enables interactions and teleportation using the VR controllers and gaze.
  121332. * @param vrTeleportationOptions options to modify teleportation behavior.
  121333. */
  121334. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  121335. private _onNewGamepadConnected;
  121336. private _tryEnableInteractionOnController;
  121337. private _onNewGamepadDisconnected;
  121338. private _enableInteractionOnController;
  121339. private _checkTeleportWithRay;
  121340. private _checkRotate;
  121341. private _checkTeleportBackwards;
  121342. private _enableTeleportationOnController;
  121343. private _createTeleportationCircles;
  121344. private _displayTeleportationTarget;
  121345. private _hideTeleportationTarget;
  121346. private _rotateCamera;
  121347. private _moveTeleportationSelectorTo;
  121348. private _workingVector;
  121349. private _workingQuaternion;
  121350. private _workingMatrix;
  121351. /**
  121352. * Time Constant Teleportation Mode
  121353. */
  121354. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  121355. /**
  121356. * Speed Constant Teleportation Mode
  121357. */
  121358. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  121359. /**
  121360. * Teleports the users feet to the desired location
  121361. * @param location The location where the user's feet should be placed
  121362. */
  121363. teleportCamera(location: Vector3): void;
  121364. private _convertNormalToDirectionOfRay;
  121365. private _castRayAndSelectObject;
  121366. private _notifySelectedMeshUnselected;
  121367. /**
  121368. * Permanently set new colors for the laser pointer
  121369. * @param color the new laser color
  121370. * @param pickedColor the new laser color when picked mesh detected
  121371. */
  121372. setLaserColor(color: Color3, pickedColor?: Color3): void;
  121373. /**
  121374. * Set lighting enabled / disabled on the laser pointer of both controllers
  121375. * @param enabled should the lighting be enabled on the laser pointer
  121376. */
  121377. setLaserLightingState(enabled?: boolean): void;
  121378. /**
  121379. * Permanently set new colors for the gaze pointer
  121380. * @param color the new gaze color
  121381. * @param pickedColor the new gaze color when picked mesh detected
  121382. */
  121383. setGazeColor(color: Color3, pickedColor?: Color3): void;
  121384. /**
  121385. * Sets the color of the laser ray from the vr controllers.
  121386. * @param color new color for the ray.
  121387. */
  121388. changeLaserColor(color: Color3): void;
  121389. /**
  121390. * Sets the color of the ray from the vr headsets gaze.
  121391. * @param color new color for the ray.
  121392. */
  121393. changeGazeColor(color: Color3): void;
  121394. /**
  121395. * Exits VR and disposes of the vr experience helper
  121396. */
  121397. dispose(): void;
  121398. /**
  121399. * Gets the name of the VRExperienceHelper class
  121400. * @returns "VRExperienceHelper"
  121401. */
  121402. getClassName(): string;
  121403. }
  121404. }
  121405. declare module BABYLON {
  121406. /**
  121407. * Contains an array of blocks representing the octree
  121408. */
  121409. export interface IOctreeContainer<T> {
  121410. /**
  121411. * Blocks within the octree
  121412. */
  121413. blocks: Array<OctreeBlock<T>>;
  121414. }
  121415. /**
  121416. * Class used to store a cell in an octree
  121417. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  121418. */
  121419. export class OctreeBlock<T> {
  121420. /**
  121421. * Gets the content of the current block
  121422. */
  121423. entries: T[];
  121424. /**
  121425. * Gets the list of block children
  121426. */
  121427. blocks: Array<OctreeBlock<T>>;
  121428. private _depth;
  121429. private _maxDepth;
  121430. private _capacity;
  121431. private _minPoint;
  121432. private _maxPoint;
  121433. private _boundingVectors;
  121434. private _creationFunc;
  121435. /**
  121436. * Creates a new block
  121437. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  121438. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  121439. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  121440. * @param depth defines the current depth of this block in the octree
  121441. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  121442. * @param creationFunc defines a callback to call when an element is added to the block
  121443. */
  121444. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  121445. /**
  121446. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  121447. */
  121448. get capacity(): number;
  121449. /**
  121450. * Gets the minimum vector (in world space) of the block's bounding box
  121451. */
  121452. get minPoint(): Vector3;
  121453. /**
  121454. * Gets the maximum vector (in world space) of the block's bounding box
  121455. */
  121456. get maxPoint(): Vector3;
  121457. /**
  121458. * Add a new element to this block
  121459. * @param entry defines the element to add
  121460. */
  121461. addEntry(entry: T): void;
  121462. /**
  121463. * Remove an element from this block
  121464. * @param entry defines the element to remove
  121465. */
  121466. removeEntry(entry: T): void;
  121467. /**
  121468. * Add an array of elements to this block
  121469. * @param entries defines the array of elements to add
  121470. */
  121471. addEntries(entries: T[]): void;
  121472. /**
  121473. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  121474. * @param frustumPlanes defines the frustum planes to test
  121475. * @param selection defines the array to store current content if selection is positive
  121476. * @param allowDuplicate defines if the selection array can contains duplicated entries
  121477. */
  121478. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  121479. /**
  121480. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  121481. * @param sphereCenter defines the bounding sphere center
  121482. * @param sphereRadius defines the bounding sphere radius
  121483. * @param selection defines the array to store current content if selection is positive
  121484. * @param allowDuplicate defines if the selection array can contains duplicated entries
  121485. */
  121486. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  121487. /**
  121488. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  121489. * @param ray defines the ray to test with
  121490. * @param selection defines the array to store current content if selection is positive
  121491. */
  121492. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  121493. /**
  121494. * Subdivide the content into child blocks (this block will then be empty)
  121495. */
  121496. createInnerBlocks(): void;
  121497. /**
  121498. * @hidden
  121499. */
  121500. 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;
  121501. }
  121502. }
  121503. declare module BABYLON {
  121504. /**
  121505. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  121506. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  121507. */
  121508. export class Octree<T> {
  121509. /** 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.) */
  121510. maxDepth: number;
  121511. /**
  121512. * Blocks within the octree containing objects
  121513. */
  121514. blocks: Array<OctreeBlock<T>>;
  121515. /**
  121516. * Content stored in the octree
  121517. */
  121518. dynamicContent: T[];
  121519. private _maxBlockCapacity;
  121520. private _selectionContent;
  121521. private _creationFunc;
  121522. /**
  121523. * Creates a octree
  121524. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  121525. * @param creationFunc function to be used to instatiate the octree
  121526. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  121527. * @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.)
  121528. */
  121529. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  121530. /** 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.) */
  121531. maxDepth?: number);
  121532. /**
  121533. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  121534. * @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);
  121535. * @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);
  121536. * @param entries meshes to be added to the octree blocks
  121537. */
  121538. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  121539. /**
  121540. * Adds a mesh to the octree
  121541. * @param entry Mesh to add to the octree
  121542. */
  121543. addMesh(entry: T): void;
  121544. /**
  121545. * Remove an element from the octree
  121546. * @param entry defines the element to remove
  121547. */
  121548. removeMesh(entry: T): void;
  121549. /**
  121550. * Selects an array of meshes within the frustum
  121551. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  121552. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  121553. * @returns array of meshes within the frustum
  121554. */
  121555. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  121556. /**
  121557. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  121558. * @param sphereCenter defines the bounding sphere center
  121559. * @param sphereRadius defines the bounding sphere radius
  121560. * @param allowDuplicate defines if the selection array can contains duplicated entries
  121561. * @returns an array of objects that intersect the sphere
  121562. */
  121563. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  121564. /**
  121565. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  121566. * @param ray defines the ray to test with
  121567. * @returns array of intersected objects
  121568. */
  121569. intersectsRay(ray: Ray): SmartArray<T>;
  121570. /**
  121571. * Adds a mesh into the octree block if it intersects the block
  121572. */
  121573. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  121574. /**
  121575. * Adds a submesh into the octree block if it intersects the block
  121576. */
  121577. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  121578. }
  121579. }
  121580. declare module BABYLON {
  121581. interface Scene {
  121582. /**
  121583. * @hidden
  121584. * Backing Filed
  121585. */
  121586. _selectionOctree: Octree<AbstractMesh>;
  121587. /**
  121588. * Gets the octree used to boost mesh selection (picking)
  121589. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  121590. */
  121591. selectionOctree: Octree<AbstractMesh>;
  121592. /**
  121593. * Creates or updates the octree used to boost selection (picking)
  121594. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  121595. * @param maxCapacity defines the maximum capacity per leaf
  121596. * @param maxDepth defines the maximum depth of the octree
  121597. * @returns an octree of AbstractMesh
  121598. */
  121599. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  121600. }
  121601. interface AbstractMesh {
  121602. /**
  121603. * @hidden
  121604. * Backing Field
  121605. */
  121606. _submeshesOctree: Octree<SubMesh>;
  121607. /**
  121608. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  121609. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  121610. * @param maxCapacity defines the maximum size of each block (64 by default)
  121611. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  121612. * @returns the new octree
  121613. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  121614. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  121615. */
  121616. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  121617. }
  121618. /**
  121619. * Defines the octree scene component responsible to manage any octrees
  121620. * in a given scene.
  121621. */
  121622. export class OctreeSceneComponent {
  121623. /**
  121624. * The component name help to identify the component in the list of scene components.
  121625. */
  121626. readonly name: string;
  121627. /**
  121628. * The scene the component belongs to.
  121629. */
  121630. scene: Scene;
  121631. /**
  121632. * Indicates if the meshes have been checked to make sure they are isEnabled()
  121633. */
  121634. readonly checksIsEnabled: boolean;
  121635. /**
  121636. * Creates a new instance of the component for the given scene
  121637. * @param scene Defines the scene to register the component in
  121638. */
  121639. constructor(scene: Scene);
  121640. /**
  121641. * Registers the component in a given scene
  121642. */
  121643. register(): void;
  121644. /**
  121645. * Return the list of active meshes
  121646. * @returns the list of active meshes
  121647. */
  121648. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  121649. /**
  121650. * Return the list of active sub meshes
  121651. * @param mesh The mesh to get the candidates sub meshes from
  121652. * @returns the list of active sub meshes
  121653. */
  121654. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  121655. private _tempRay;
  121656. /**
  121657. * Return the list of sub meshes intersecting with a given local ray
  121658. * @param mesh defines the mesh to find the submesh for
  121659. * @param localRay defines the ray in local space
  121660. * @returns the list of intersecting sub meshes
  121661. */
  121662. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  121663. /**
  121664. * Return the list of sub meshes colliding with a collider
  121665. * @param mesh defines the mesh to find the submesh for
  121666. * @param collider defines the collider to evaluate the collision against
  121667. * @returns the list of colliding sub meshes
  121668. */
  121669. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  121670. /**
  121671. * Rebuilds the elements related to this component in case of
  121672. * context lost for instance.
  121673. */
  121674. rebuild(): void;
  121675. /**
  121676. * Disposes the component and the associated ressources.
  121677. */
  121678. dispose(): void;
  121679. }
  121680. }
  121681. declare module BABYLON {
  121682. /**
  121683. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  121684. */
  121685. export class Gizmo implements IDisposable {
  121686. /** The utility layer the gizmo will be added to */
  121687. gizmoLayer: UtilityLayerRenderer;
  121688. /**
  121689. * The root mesh of the gizmo
  121690. */
  121691. _rootMesh: Mesh;
  121692. private _attachedMesh;
  121693. /**
  121694. * Ratio for the scale of the gizmo (Default: 1)
  121695. */
  121696. scaleRatio: number;
  121697. /**
  121698. * If a custom mesh has been set (Default: false)
  121699. */
  121700. protected _customMeshSet: boolean;
  121701. /**
  121702. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  121703. * * When set, interactions will be enabled
  121704. */
  121705. get attachedMesh(): Nullable<AbstractMesh>;
  121706. set attachedMesh(value: Nullable<AbstractMesh>);
  121707. /**
  121708. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  121709. * @param mesh The mesh to replace the default mesh of the gizmo
  121710. */
  121711. setCustomMesh(mesh: Mesh): void;
  121712. /**
  121713. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  121714. */
  121715. updateGizmoRotationToMatchAttachedMesh: boolean;
  121716. /**
  121717. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  121718. */
  121719. updateGizmoPositionToMatchAttachedMesh: boolean;
  121720. /**
  121721. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  121722. */
  121723. updateScale: boolean;
  121724. protected _interactionsEnabled: boolean;
  121725. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  121726. private _beforeRenderObserver;
  121727. private _tempVector;
  121728. /**
  121729. * Creates a gizmo
  121730. * @param gizmoLayer The utility layer the gizmo will be added to
  121731. */
  121732. constructor(
  121733. /** The utility layer the gizmo will be added to */
  121734. gizmoLayer?: UtilityLayerRenderer);
  121735. /**
  121736. * Updates the gizmo to match the attached mesh's position/rotation
  121737. */
  121738. protected _update(): void;
  121739. /**
  121740. * Disposes of the gizmo
  121741. */
  121742. dispose(): void;
  121743. }
  121744. }
  121745. declare module BABYLON {
  121746. /**
  121747. * Single plane drag gizmo
  121748. */
  121749. export class PlaneDragGizmo extends Gizmo {
  121750. /**
  121751. * Drag behavior responsible for the gizmos dragging interactions
  121752. */
  121753. dragBehavior: PointerDragBehavior;
  121754. private _pointerObserver;
  121755. /**
  121756. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  121757. */
  121758. snapDistance: number;
  121759. /**
  121760. * Event that fires each time the gizmo snaps to a new location.
  121761. * * snapDistance is the the change in distance
  121762. */
  121763. onSnapObservable: Observable<{
  121764. snapDistance: number;
  121765. }>;
  121766. private _plane;
  121767. private _coloredMaterial;
  121768. private _hoverMaterial;
  121769. private _isEnabled;
  121770. private _parent;
  121771. /** @hidden */
  121772. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  121773. /** @hidden */
  121774. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  121775. /**
  121776. * Creates a PlaneDragGizmo
  121777. * @param gizmoLayer The utility layer the gizmo will be added to
  121778. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  121779. * @param color The color of the gizmo
  121780. */
  121781. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  121782. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  121783. /**
  121784. * If the gizmo is enabled
  121785. */
  121786. set isEnabled(value: boolean);
  121787. get isEnabled(): boolean;
  121788. /**
  121789. * Disposes of the gizmo
  121790. */
  121791. dispose(): void;
  121792. }
  121793. }
  121794. declare module BABYLON {
  121795. /**
  121796. * Gizmo that enables dragging a mesh along 3 axis
  121797. */
  121798. export class PositionGizmo extends Gizmo {
  121799. /**
  121800. * Internal gizmo used for interactions on the x axis
  121801. */
  121802. xGizmo: AxisDragGizmo;
  121803. /**
  121804. * Internal gizmo used for interactions on the y axis
  121805. */
  121806. yGizmo: AxisDragGizmo;
  121807. /**
  121808. * Internal gizmo used for interactions on the z axis
  121809. */
  121810. zGizmo: AxisDragGizmo;
  121811. /**
  121812. * Internal gizmo used for interactions on the yz plane
  121813. */
  121814. xPlaneGizmo: PlaneDragGizmo;
  121815. /**
  121816. * Internal gizmo used for interactions on the xz plane
  121817. */
  121818. yPlaneGizmo: PlaneDragGizmo;
  121819. /**
  121820. * Internal gizmo used for interactions on the xy plane
  121821. */
  121822. zPlaneGizmo: PlaneDragGizmo;
  121823. /**
  121824. * private variables
  121825. */
  121826. private _meshAttached;
  121827. private _updateGizmoRotationToMatchAttachedMesh;
  121828. private _snapDistance;
  121829. private _scaleRatio;
  121830. /** Fires an event when any of it's sub gizmos are dragged */
  121831. onDragStartObservable: Observable<unknown>;
  121832. /** Fires an event when any of it's sub gizmos are released from dragging */
  121833. onDragEndObservable: Observable<unknown>;
  121834. /**
  121835. * If set to true, planar drag is enabled
  121836. */
  121837. private _planarGizmoEnabled;
  121838. get attachedMesh(): Nullable<AbstractMesh>;
  121839. set attachedMesh(mesh: Nullable<AbstractMesh>);
  121840. /**
  121841. * Creates a PositionGizmo
  121842. * @param gizmoLayer The utility layer the gizmo will be added to
  121843. */
  121844. constructor(gizmoLayer?: UtilityLayerRenderer);
  121845. /**
  121846. * If the planar drag gizmo is enabled
  121847. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  121848. */
  121849. set planarGizmoEnabled(value: boolean);
  121850. get planarGizmoEnabled(): boolean;
  121851. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  121852. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  121853. /**
  121854. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  121855. */
  121856. set snapDistance(value: number);
  121857. get snapDistance(): number;
  121858. /**
  121859. * Ratio for the scale of the gizmo (Default: 1)
  121860. */
  121861. set scaleRatio(value: number);
  121862. get scaleRatio(): number;
  121863. /**
  121864. * Disposes of the gizmo
  121865. */
  121866. dispose(): void;
  121867. /**
  121868. * CustomMeshes are not supported by this gizmo
  121869. * @param mesh The mesh to replace the default mesh of the gizmo
  121870. */
  121871. setCustomMesh(mesh: Mesh): void;
  121872. }
  121873. }
  121874. declare module BABYLON {
  121875. /**
  121876. * Single axis drag gizmo
  121877. */
  121878. export class AxisDragGizmo extends Gizmo {
  121879. /**
  121880. * Drag behavior responsible for the gizmos dragging interactions
  121881. */
  121882. dragBehavior: PointerDragBehavior;
  121883. private _pointerObserver;
  121884. /**
  121885. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  121886. */
  121887. snapDistance: number;
  121888. /**
  121889. * Event that fires each time the gizmo snaps to a new location.
  121890. * * snapDistance is the the change in distance
  121891. */
  121892. onSnapObservable: Observable<{
  121893. snapDistance: number;
  121894. }>;
  121895. private _isEnabled;
  121896. private _parent;
  121897. private _arrow;
  121898. private _coloredMaterial;
  121899. private _hoverMaterial;
  121900. /** @hidden */
  121901. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  121902. /** @hidden */
  121903. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  121904. /**
  121905. * Creates an AxisDragGizmo
  121906. * @param gizmoLayer The utility layer the gizmo will be added to
  121907. * @param dragAxis The axis which the gizmo will be able to drag on
  121908. * @param color The color of the gizmo
  121909. */
  121910. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  121911. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  121912. /**
  121913. * If the gizmo is enabled
  121914. */
  121915. set isEnabled(value: boolean);
  121916. get isEnabled(): boolean;
  121917. /**
  121918. * Disposes of the gizmo
  121919. */
  121920. dispose(): void;
  121921. }
  121922. }
  121923. declare module BABYLON.Debug {
  121924. /**
  121925. * The Axes viewer will show 3 axes in a specific point in space
  121926. */
  121927. export class AxesViewer {
  121928. private _xAxis;
  121929. private _yAxis;
  121930. private _zAxis;
  121931. private _scaleLinesFactor;
  121932. private _instanced;
  121933. /**
  121934. * Gets the hosting scene
  121935. */
  121936. scene: Scene;
  121937. /**
  121938. * Gets or sets a number used to scale line length
  121939. */
  121940. scaleLines: number;
  121941. /** Gets the node hierarchy used to render x-axis */
  121942. get xAxis(): TransformNode;
  121943. /** Gets the node hierarchy used to render y-axis */
  121944. get yAxis(): TransformNode;
  121945. /** Gets the node hierarchy used to render z-axis */
  121946. get zAxis(): TransformNode;
  121947. /**
  121948. * Creates a new AxesViewer
  121949. * @param scene defines the hosting scene
  121950. * @param scaleLines defines a number used to scale line length (1 by default)
  121951. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  121952. * @param xAxis defines the node hierarchy used to render the x-axis
  121953. * @param yAxis defines the node hierarchy used to render the y-axis
  121954. * @param zAxis defines the node hierarchy used to render the z-axis
  121955. */
  121956. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  121957. /**
  121958. * Force the viewer to update
  121959. * @param position defines the position of the viewer
  121960. * @param xaxis defines the x axis of the viewer
  121961. * @param yaxis defines the y axis of the viewer
  121962. * @param zaxis defines the z axis of the viewer
  121963. */
  121964. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  121965. /**
  121966. * Creates an instance of this axes viewer.
  121967. * @returns a new axes viewer with instanced meshes
  121968. */
  121969. createInstance(): AxesViewer;
  121970. /** Releases resources */
  121971. dispose(): void;
  121972. private static _SetRenderingGroupId;
  121973. }
  121974. }
  121975. declare module BABYLON.Debug {
  121976. /**
  121977. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  121978. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  121979. */
  121980. export class BoneAxesViewer extends AxesViewer {
  121981. /**
  121982. * Gets or sets the target mesh where to display the axes viewer
  121983. */
  121984. mesh: Nullable<Mesh>;
  121985. /**
  121986. * Gets or sets the target bone where to display the axes viewer
  121987. */
  121988. bone: Nullable<Bone>;
  121989. /** Gets current position */
  121990. pos: Vector3;
  121991. /** Gets direction of X axis */
  121992. xaxis: Vector3;
  121993. /** Gets direction of Y axis */
  121994. yaxis: Vector3;
  121995. /** Gets direction of Z axis */
  121996. zaxis: Vector3;
  121997. /**
  121998. * Creates a new BoneAxesViewer
  121999. * @param scene defines the hosting scene
  122000. * @param bone defines the target bone
  122001. * @param mesh defines the target mesh
  122002. * @param scaleLines defines a scaling factor for line length (1 by default)
  122003. */
  122004. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  122005. /**
  122006. * Force the viewer to update
  122007. */
  122008. update(): void;
  122009. /** Releases resources */
  122010. dispose(): void;
  122011. }
  122012. }
  122013. declare module BABYLON {
  122014. /**
  122015. * Interface used to define scene explorer extensibility option
  122016. */
  122017. export interface IExplorerExtensibilityOption {
  122018. /**
  122019. * Define the option label
  122020. */
  122021. label: string;
  122022. /**
  122023. * Defines the action to execute on click
  122024. */
  122025. action: (entity: any) => void;
  122026. }
  122027. /**
  122028. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  122029. */
  122030. export interface IExplorerExtensibilityGroup {
  122031. /**
  122032. * Defines a predicate to test if a given type mut be extended
  122033. */
  122034. predicate: (entity: any) => boolean;
  122035. /**
  122036. * Gets the list of options added to a type
  122037. */
  122038. entries: IExplorerExtensibilityOption[];
  122039. }
  122040. /**
  122041. * Interface used to define the options to use to create the Inspector
  122042. */
  122043. export interface IInspectorOptions {
  122044. /**
  122045. * Display in overlay mode (default: false)
  122046. */
  122047. overlay?: boolean;
  122048. /**
  122049. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  122050. */
  122051. globalRoot?: HTMLElement;
  122052. /**
  122053. * Display the Scene explorer
  122054. */
  122055. showExplorer?: boolean;
  122056. /**
  122057. * Display the property inspector
  122058. */
  122059. showInspector?: boolean;
  122060. /**
  122061. * Display in embed mode (both panes on the right)
  122062. */
  122063. embedMode?: boolean;
  122064. /**
  122065. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  122066. */
  122067. handleResize?: boolean;
  122068. /**
  122069. * Allow the panes to popup (default: true)
  122070. */
  122071. enablePopup?: boolean;
  122072. /**
  122073. * Allow the panes to be closed by users (default: true)
  122074. */
  122075. enableClose?: boolean;
  122076. /**
  122077. * Optional list of extensibility entries
  122078. */
  122079. explorerExtensibility?: IExplorerExtensibilityGroup[];
  122080. /**
  122081. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  122082. */
  122083. inspectorURL?: string;
  122084. /**
  122085. * Optional initial tab (default to DebugLayerTab.Properties)
  122086. */
  122087. initialTab?: DebugLayerTab;
  122088. }
  122089. interface Scene {
  122090. /**
  122091. * @hidden
  122092. * Backing field
  122093. */
  122094. _debugLayer: DebugLayer;
  122095. /**
  122096. * Gets the debug layer (aka Inspector) associated with the scene
  122097. * @see http://doc.babylonjs.com/features/playground_debuglayer
  122098. */
  122099. debugLayer: DebugLayer;
  122100. }
  122101. /**
  122102. * Enum of inspector action tab
  122103. */
  122104. export enum DebugLayerTab {
  122105. /**
  122106. * Properties tag (default)
  122107. */
  122108. Properties = 0,
  122109. /**
  122110. * Debug tab
  122111. */
  122112. Debug = 1,
  122113. /**
  122114. * Statistics tab
  122115. */
  122116. Statistics = 2,
  122117. /**
  122118. * Tools tab
  122119. */
  122120. Tools = 3,
  122121. /**
  122122. * Settings tab
  122123. */
  122124. Settings = 4
  122125. }
  122126. /**
  122127. * The debug layer (aka Inspector) is the go to tool in order to better understand
  122128. * what is happening in your scene
  122129. * @see http://doc.babylonjs.com/features/playground_debuglayer
  122130. */
  122131. export class DebugLayer {
  122132. /**
  122133. * Define the url to get the inspector script from.
  122134. * By default it uses the babylonjs CDN.
  122135. * @ignoreNaming
  122136. */
  122137. static InspectorURL: string;
  122138. private _scene;
  122139. private BJSINSPECTOR;
  122140. private _onPropertyChangedObservable?;
  122141. /**
  122142. * Observable triggered when a property is changed through the inspector.
  122143. */
  122144. get onPropertyChangedObservable(): any;
  122145. /**
  122146. * Instantiates a new debug layer.
  122147. * The debug layer (aka Inspector) is the go to tool in order to better understand
  122148. * what is happening in your scene
  122149. * @see http://doc.babylonjs.com/features/playground_debuglayer
  122150. * @param scene Defines the scene to inspect
  122151. */
  122152. constructor(scene: Scene);
  122153. /** Creates the inspector window. */
  122154. private _createInspector;
  122155. /**
  122156. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  122157. * @param entity defines the entity to select
  122158. * @param lineContainerTitle defines the specific block to highlight
  122159. */
  122160. select(entity: any, lineContainerTitle?: string): void;
  122161. /** Get the inspector from bundle or global */
  122162. private _getGlobalInspector;
  122163. /**
  122164. * Get if the inspector is visible or not.
  122165. * @returns true if visible otherwise, false
  122166. */
  122167. isVisible(): boolean;
  122168. /**
  122169. * Hide the inspector and close its window.
  122170. */
  122171. hide(): void;
  122172. /**
  122173. * Launch the debugLayer.
  122174. * @param config Define the configuration of the inspector
  122175. * @return a promise fulfilled when the debug layer is visible
  122176. */
  122177. show(config?: IInspectorOptions): Promise<DebugLayer>;
  122178. }
  122179. }
  122180. declare module BABYLON {
  122181. /**
  122182. * Class containing static functions to help procedurally build meshes
  122183. */
  122184. export class BoxBuilder {
  122185. /**
  122186. * Creates a box mesh
  122187. * * The parameter `size` sets the size (float) of each box side (default 1)
  122188. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  122189. * * 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)
  122190. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  122191. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  122192. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  122193. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  122194. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  122195. * @param name defines the name of the mesh
  122196. * @param options defines the options used to create the mesh
  122197. * @param scene defines the hosting scene
  122198. * @returns the box mesh
  122199. */
  122200. static CreateBox(name: string, options: {
  122201. size?: number;
  122202. width?: number;
  122203. height?: number;
  122204. depth?: number;
  122205. faceUV?: Vector4[];
  122206. faceColors?: Color4[];
  122207. sideOrientation?: number;
  122208. frontUVs?: Vector4;
  122209. backUVs?: Vector4;
  122210. wrap?: boolean;
  122211. topBaseAt?: number;
  122212. bottomBaseAt?: number;
  122213. updatable?: boolean;
  122214. }, scene?: Nullable<Scene>): Mesh;
  122215. }
  122216. }
  122217. declare module BABYLON.Debug {
  122218. /**
  122219. * Used to show the physics impostor around the specific mesh
  122220. */
  122221. export class PhysicsViewer {
  122222. /** @hidden */
  122223. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  122224. /** @hidden */
  122225. protected _meshes: Array<Nullable<AbstractMesh>>;
  122226. /** @hidden */
  122227. protected _scene: Nullable<Scene>;
  122228. /** @hidden */
  122229. protected _numMeshes: number;
  122230. /** @hidden */
  122231. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  122232. private _renderFunction;
  122233. private _utilityLayer;
  122234. private _debugBoxMesh;
  122235. private _debugSphereMesh;
  122236. private _debugCylinderMesh;
  122237. private _debugMaterial;
  122238. private _debugMeshMeshes;
  122239. /**
  122240. * Creates a new PhysicsViewer
  122241. * @param scene defines the hosting scene
  122242. */
  122243. constructor(scene: Scene);
  122244. /** @hidden */
  122245. protected _updateDebugMeshes(): void;
  122246. /**
  122247. * Renders a specified physic impostor
  122248. * @param impostor defines the impostor to render
  122249. * @param targetMesh defines the mesh represented by the impostor
  122250. * @returns the new debug mesh used to render the impostor
  122251. */
  122252. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  122253. /**
  122254. * Hides a specified physic impostor
  122255. * @param impostor defines the impostor to hide
  122256. */
  122257. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  122258. private _getDebugMaterial;
  122259. private _getDebugBoxMesh;
  122260. private _getDebugSphereMesh;
  122261. private _getDebugCylinderMesh;
  122262. private _getDebugMeshMesh;
  122263. private _getDebugMesh;
  122264. /** Releases all resources */
  122265. dispose(): void;
  122266. }
  122267. }
  122268. declare module BABYLON {
  122269. /**
  122270. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  122271. * in order to better appreciate the issue one might have.
  122272. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  122273. */
  122274. export class RayHelper {
  122275. /**
  122276. * Defines the ray we are currently tryin to visualize.
  122277. */
  122278. ray: Nullable<Ray>;
  122279. private _renderPoints;
  122280. private _renderLine;
  122281. private _renderFunction;
  122282. private _scene;
  122283. private _updateToMeshFunction;
  122284. private _attachedToMesh;
  122285. private _meshSpaceDirection;
  122286. private _meshSpaceOrigin;
  122287. /**
  122288. * Helper function to create a colored helper in a scene in one line.
  122289. * @param ray Defines the ray we are currently tryin to visualize
  122290. * @param scene Defines the scene the ray is used in
  122291. * @param color Defines the color we want to see the ray in
  122292. * @returns The newly created ray helper.
  122293. */
  122294. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  122295. /**
  122296. * Instantiate a new ray helper.
  122297. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  122298. * in order to better appreciate the issue one might have.
  122299. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  122300. * @param ray Defines the ray we are currently tryin to visualize
  122301. */
  122302. constructor(ray: Ray);
  122303. /**
  122304. * Shows the ray we are willing to debug.
  122305. * @param scene Defines the scene the ray needs to be rendered in
  122306. * @param color Defines the color the ray needs to be rendered in
  122307. */
  122308. show(scene: Scene, color?: Color3): void;
  122309. /**
  122310. * Hides the ray we are debugging.
  122311. */
  122312. hide(): void;
  122313. private _render;
  122314. /**
  122315. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  122316. * @param mesh Defines the mesh we want the helper attached to
  122317. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  122318. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  122319. * @param length Defines the length of the ray
  122320. */
  122321. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  122322. /**
  122323. * Detach the ray helper from the mesh it has previously been attached to.
  122324. */
  122325. detachFromMesh(): void;
  122326. private _updateToMesh;
  122327. /**
  122328. * Dispose the helper and release its associated resources.
  122329. */
  122330. dispose(): void;
  122331. }
  122332. }
  122333. declare module BABYLON.Debug {
  122334. /**
  122335. * Class used to render a debug view of a given skeleton
  122336. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  122337. */
  122338. export class SkeletonViewer {
  122339. /** defines the skeleton to render */
  122340. skeleton: Skeleton;
  122341. /** defines the mesh attached to the skeleton */
  122342. mesh: AbstractMesh;
  122343. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  122344. autoUpdateBonesMatrices: boolean;
  122345. /** defines the rendering group id to use with the viewer */
  122346. renderingGroupId: number;
  122347. /** Gets or sets the color used to render the skeleton */
  122348. color: Color3;
  122349. private _scene;
  122350. private _debugLines;
  122351. private _debugMesh;
  122352. private _isEnabled;
  122353. private _renderFunction;
  122354. private _utilityLayer;
  122355. /**
  122356. * Returns the mesh used to render the bones
  122357. */
  122358. get debugMesh(): Nullable<LinesMesh>;
  122359. /**
  122360. * Creates a new SkeletonViewer
  122361. * @param skeleton defines the skeleton to render
  122362. * @param mesh defines the mesh attached to the skeleton
  122363. * @param scene defines the hosting scene
  122364. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  122365. * @param renderingGroupId defines the rendering group id to use with the viewer
  122366. */
  122367. constructor(
  122368. /** defines the skeleton to render */
  122369. skeleton: Skeleton,
  122370. /** defines the mesh attached to the skeleton */
  122371. mesh: AbstractMesh, scene: Scene,
  122372. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  122373. autoUpdateBonesMatrices?: boolean,
  122374. /** defines the rendering group id to use with the viewer */
  122375. renderingGroupId?: number);
  122376. /** Gets or sets a boolean indicating if the viewer is enabled */
  122377. set isEnabled(value: boolean);
  122378. get isEnabled(): boolean;
  122379. private _getBonePosition;
  122380. private _getLinesForBonesWithLength;
  122381. private _getLinesForBonesNoLength;
  122382. /** Update the viewer to sync with current skeleton state */
  122383. update(): void;
  122384. /** Release associated resources */
  122385. dispose(): void;
  122386. }
  122387. }
  122388. declare module BABYLON {
  122389. /**
  122390. * This class will take all inputs from Keyboard, Pointer, and
  122391. * any Gamepads and provide a polling system that all devices
  122392. * will use. This class assumes that there will only be one
  122393. * pointer device and one keyboard.
  122394. */
  122395. export class DeviceInputSystem implements IDisposable {
  122396. /** POINTER_DEVICE */
  122397. static readonly POINTER_DEVICE: string;
  122398. /** KEYBOARD_DEVICE */
  122399. static readonly KEYBOARD_DEVICE: string;
  122400. /**
  122401. * Observable to be triggered when a device is connected
  122402. */
  122403. onDeviceConnectedObservable: Observable<string>;
  122404. /**
  122405. * Observable to be triggered when a device is disconnected
  122406. */
  122407. onDeviceDisconnectedObservable: Observable<string>;
  122408. private _inputs;
  122409. private _gamepads;
  122410. private _keyboardActive;
  122411. private _pointerActive;
  122412. private _elementToAttachTo;
  122413. private _keyboardDownEvent;
  122414. private _keyboardUpEvent;
  122415. private _pointerMoveEvent;
  122416. private _pointerDownEvent;
  122417. private _pointerUpEvent;
  122418. private _gamepadConnectedEvent;
  122419. private _gamepadDisconnectedEvent;
  122420. private static _MAX_KEYCODES;
  122421. private static _MAX_POINTER_INPUTS;
  122422. /**
  122423. * Default Constructor
  122424. * @param engine - engine to pull input element from
  122425. */
  122426. constructor(engine: Engine);
  122427. /**
  122428. * Checks for current device input value, given an id and input index
  122429. * @param deviceName Id of connected device
  122430. * @param inputIndex Index of device input
  122431. * @returns Current value of input
  122432. */
  122433. pollInput(deviceName: string, inputIndex: number): Nullable<number>;
  122434. /**
  122435. * Dispose of all the eventlisteners and clears the observables
  122436. */
  122437. dispose(): void;
  122438. /**
  122439. * Add device and inputs to device map
  122440. * @param deviceName Assigned name of device (may be SN)
  122441. * @param numberOfInputs Number of input entries to create for given device
  122442. */
  122443. private _registerDevice;
  122444. /**
  122445. * Given a specific device name, remove that device from the device map
  122446. * @param deviceName Name of device to be removed
  122447. */
  122448. private _unregisterDevice;
  122449. /**
  122450. * Handle all actions that come from keyboard interaction
  122451. */
  122452. private _handleKeyActions;
  122453. /**
  122454. * Handle all actions that come from pointer interaction
  122455. */
  122456. private _handlePointerActions;
  122457. /**
  122458. * Handle all actions that come from gamepad interaction
  122459. */
  122460. private _handleGamepadActions;
  122461. /**
  122462. * Update all non-event based devices with each frame
  122463. */
  122464. private _updateDevice;
  122465. }
  122466. }
  122467. declare module BABYLON {
  122468. /**
  122469. * Options to create the null engine
  122470. */
  122471. export class NullEngineOptions {
  122472. /**
  122473. * Render width (Default: 512)
  122474. */
  122475. renderWidth: number;
  122476. /**
  122477. * Render height (Default: 256)
  122478. */
  122479. renderHeight: number;
  122480. /**
  122481. * Texture size (Default: 512)
  122482. */
  122483. textureSize: number;
  122484. /**
  122485. * If delta time between frames should be constant
  122486. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  122487. */
  122488. deterministicLockstep: boolean;
  122489. /**
  122490. * Maximum about of steps between frames (Default: 4)
  122491. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  122492. */
  122493. lockstepMaxSteps: number;
  122494. }
  122495. /**
  122496. * The null engine class provides support for headless version of babylon.js.
  122497. * This can be used in server side scenario or for testing purposes
  122498. */
  122499. export class NullEngine extends Engine {
  122500. private _options;
  122501. /**
  122502. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  122503. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  122504. * @returns true if engine is in deterministic lock step mode
  122505. */
  122506. isDeterministicLockStep(): boolean;
  122507. /**
  122508. * Gets the max steps when engine is running in deterministic lock step
  122509. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  122510. * @returns the max steps
  122511. */
  122512. getLockstepMaxSteps(): number;
  122513. /**
  122514. * Gets the current hardware scaling level.
  122515. * By default the hardware scaling level is computed from the window device ratio.
  122516. * 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.
  122517. * @returns a number indicating the current hardware scaling level
  122518. */
  122519. getHardwareScalingLevel(): number;
  122520. constructor(options?: NullEngineOptions);
  122521. /**
  122522. * Creates a vertex buffer
  122523. * @param vertices the data for the vertex buffer
  122524. * @returns the new WebGL static buffer
  122525. */
  122526. createVertexBuffer(vertices: FloatArray): DataBuffer;
  122527. /**
  122528. * Creates a new index buffer
  122529. * @param indices defines the content of the index buffer
  122530. * @param updatable defines if the index buffer must be updatable
  122531. * @returns a new webGL buffer
  122532. */
  122533. createIndexBuffer(indices: IndicesArray): DataBuffer;
  122534. /**
  122535. * Clear the current render buffer or the current render target (if any is set up)
  122536. * @param color defines the color to use
  122537. * @param backBuffer defines if the back buffer must be cleared
  122538. * @param depth defines if the depth buffer must be cleared
  122539. * @param stencil defines if the stencil buffer must be cleared
  122540. */
  122541. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  122542. /**
  122543. * Gets the current render width
  122544. * @param useScreen defines if screen size must be used (or the current render target if any)
  122545. * @returns a number defining the current render width
  122546. */
  122547. getRenderWidth(useScreen?: boolean): number;
  122548. /**
  122549. * Gets the current render height
  122550. * @param useScreen defines if screen size must be used (or the current render target if any)
  122551. * @returns a number defining the current render height
  122552. */
  122553. getRenderHeight(useScreen?: boolean): number;
  122554. /**
  122555. * Set the WebGL's viewport
  122556. * @param viewport defines the viewport element to be used
  122557. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  122558. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  122559. */
  122560. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  122561. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  122562. /**
  122563. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  122564. * @param pipelineContext defines the pipeline context to use
  122565. * @param uniformsNames defines the list of uniform names
  122566. * @returns an array of webGL uniform locations
  122567. */
  122568. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  122569. /**
  122570. * Gets the lsit of active attributes for a given webGL program
  122571. * @param pipelineContext defines the pipeline context to use
  122572. * @param attributesNames defines the list of attribute names to get
  122573. * @returns an array of indices indicating the offset of each attribute
  122574. */
  122575. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  122576. /**
  122577. * Binds an effect to the webGL context
  122578. * @param effect defines the effect to bind
  122579. */
  122580. bindSamplers(effect: Effect): void;
  122581. /**
  122582. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  122583. * @param effect defines the effect to activate
  122584. */
  122585. enableEffect(effect: Effect): void;
  122586. /**
  122587. * Set various states to the webGL context
  122588. * @param culling defines backface culling state
  122589. * @param zOffset defines the value to apply to zOffset (0 by default)
  122590. * @param force defines if states must be applied even if cache is up to date
  122591. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  122592. */
  122593. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  122594. /**
  122595. * Set the value of an uniform to an array of int32
  122596. * @param uniform defines the webGL uniform location where to store the value
  122597. * @param array defines the array of int32 to store
  122598. */
  122599. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  122600. /**
  122601. * Set the value of an uniform to an array of int32 (stored as vec2)
  122602. * @param uniform defines the webGL uniform location where to store the value
  122603. * @param array defines the array of int32 to store
  122604. */
  122605. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  122606. /**
  122607. * Set the value of an uniform to an array of int32 (stored as vec3)
  122608. * @param uniform defines the webGL uniform location where to store the value
  122609. * @param array defines the array of int32 to store
  122610. */
  122611. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  122612. /**
  122613. * Set the value of an uniform to an array of int32 (stored as vec4)
  122614. * @param uniform defines the webGL uniform location where to store the value
  122615. * @param array defines the array of int32 to store
  122616. */
  122617. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  122618. /**
  122619. * Set the value of an uniform to an array of float32
  122620. * @param uniform defines the webGL uniform location where to store the value
  122621. * @param array defines the array of float32 to store
  122622. */
  122623. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  122624. /**
  122625. * Set the value of an uniform to an array of float32 (stored as vec2)
  122626. * @param uniform defines the webGL uniform location where to store the value
  122627. * @param array defines the array of float32 to store
  122628. */
  122629. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  122630. /**
  122631. * Set the value of an uniform to an array of float32 (stored as vec3)
  122632. * @param uniform defines the webGL uniform location where to store the value
  122633. * @param array defines the array of float32 to store
  122634. */
  122635. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  122636. /**
  122637. * Set the value of an uniform to an array of float32 (stored as vec4)
  122638. * @param uniform defines the webGL uniform location where to store the value
  122639. * @param array defines the array of float32 to store
  122640. */
  122641. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  122642. /**
  122643. * Set the value of an uniform to an array of number
  122644. * @param uniform defines the webGL uniform location where to store the value
  122645. * @param array defines the array of number to store
  122646. */
  122647. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  122648. /**
  122649. * Set the value of an uniform to an array of number (stored as vec2)
  122650. * @param uniform defines the webGL uniform location where to store the value
  122651. * @param array defines the array of number to store
  122652. */
  122653. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  122654. /**
  122655. * Set the value of an uniform to an array of number (stored as vec3)
  122656. * @param uniform defines the webGL uniform location where to store the value
  122657. * @param array defines the array of number to store
  122658. */
  122659. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  122660. /**
  122661. * Set the value of an uniform to an array of number (stored as vec4)
  122662. * @param uniform defines the webGL uniform location where to store the value
  122663. * @param array defines the array of number to store
  122664. */
  122665. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  122666. /**
  122667. * Set the value of an uniform to an array of float32 (stored as matrices)
  122668. * @param uniform defines the webGL uniform location where to store the value
  122669. * @param matrices defines the array of float32 to store
  122670. */
  122671. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  122672. /**
  122673. * Set the value of an uniform to a matrix (3x3)
  122674. * @param uniform defines the webGL uniform location where to store the value
  122675. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  122676. */
  122677. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  122678. /**
  122679. * Set the value of an uniform to a matrix (2x2)
  122680. * @param uniform defines the webGL uniform location where to store the value
  122681. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  122682. */
  122683. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  122684. /**
  122685. * Set the value of an uniform to a number (float)
  122686. * @param uniform defines the webGL uniform location where to store the value
  122687. * @param value defines the float number to store
  122688. */
  122689. setFloat(uniform: WebGLUniformLocation, value: number): void;
  122690. /**
  122691. * Set the value of an uniform to a vec2
  122692. * @param uniform defines the webGL uniform location where to store the value
  122693. * @param x defines the 1st component of the value
  122694. * @param y defines the 2nd component of the value
  122695. */
  122696. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  122697. /**
  122698. * Set the value of an uniform to a vec3
  122699. * @param uniform defines the webGL uniform location where to store the value
  122700. * @param x defines the 1st component of the value
  122701. * @param y defines the 2nd component of the value
  122702. * @param z defines the 3rd component of the value
  122703. */
  122704. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  122705. /**
  122706. * Set the value of an uniform to a boolean
  122707. * @param uniform defines the webGL uniform location where to store the value
  122708. * @param bool defines the boolean to store
  122709. */
  122710. setBool(uniform: WebGLUniformLocation, bool: number): void;
  122711. /**
  122712. * Set the value of an uniform to a vec4
  122713. * @param uniform defines the webGL uniform location where to store the value
  122714. * @param x defines the 1st component of the value
  122715. * @param y defines the 2nd component of the value
  122716. * @param z defines the 3rd component of the value
  122717. * @param w defines the 4th component of the value
  122718. */
  122719. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  122720. /**
  122721. * Sets the current alpha mode
  122722. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  122723. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  122724. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  122725. */
  122726. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  122727. /**
  122728. * Bind webGl buffers directly to the webGL context
  122729. * @param vertexBuffers defines the vertex buffer to bind
  122730. * @param indexBuffer defines the index buffer to bind
  122731. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  122732. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  122733. * @param effect defines the effect associated with the vertex buffer
  122734. */
  122735. bindBuffers(vertexBuffers: {
  122736. [key: string]: VertexBuffer;
  122737. }, indexBuffer: DataBuffer, effect: Effect): void;
  122738. /**
  122739. * Force the entire cache to be cleared
  122740. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  122741. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  122742. */
  122743. wipeCaches(bruteForce?: boolean): void;
  122744. /**
  122745. * Send a draw order
  122746. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  122747. * @param indexStart defines the starting index
  122748. * @param indexCount defines the number of index to draw
  122749. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  122750. */
  122751. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  122752. /**
  122753. * Draw a list of indexed primitives
  122754. * @param fillMode defines the primitive to use
  122755. * @param indexStart defines the starting index
  122756. * @param indexCount defines the number of index to draw
  122757. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  122758. */
  122759. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  122760. /**
  122761. * Draw a list of unindexed primitives
  122762. * @param fillMode defines the primitive to use
  122763. * @param verticesStart defines the index of first vertex to draw
  122764. * @param verticesCount defines the count of vertices to draw
  122765. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  122766. */
  122767. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  122768. /** @hidden */
  122769. _createTexture(): WebGLTexture;
  122770. /** @hidden */
  122771. _releaseTexture(texture: InternalTexture): void;
  122772. /**
  122773. * Usually called from Texture.ts.
  122774. * Passed information to create a WebGLTexture
  122775. * @param urlArg defines a value which contains one of the following:
  122776. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  122777. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  122778. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  122779. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  122780. * @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)
  122781. * @param scene needed for loading to the correct scene
  122782. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  122783. * @param onLoad optional callback to be called upon successful completion
  122784. * @param onError optional callback to be called upon failure
  122785. * @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
  122786. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  122787. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  122788. * @param forcedExtension defines the extension to use to pick the right loader
  122789. * @param mimeType defines an optional mime type
  122790. * @returns a InternalTexture for assignment back into BABYLON.Texture
  122791. */
  122792. 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;
  122793. /**
  122794. * Creates a new render target texture
  122795. * @param size defines the size of the texture
  122796. * @param options defines the options used to create the texture
  122797. * @returns a new render target texture stored in an InternalTexture
  122798. */
  122799. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  122800. /**
  122801. * Update the sampling mode of a given texture
  122802. * @param samplingMode defines the required sampling mode
  122803. * @param texture defines the texture to update
  122804. */
  122805. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  122806. /**
  122807. * Binds the frame buffer to the specified texture.
  122808. * @param texture The texture to render to or null for the default canvas
  122809. * @param faceIndex The face of the texture to render to in case of cube texture
  122810. * @param requiredWidth The width of the target to render to
  122811. * @param requiredHeight The height of the target to render to
  122812. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  122813. * @param lodLevel defines le lod level to bind to the frame buffer
  122814. */
  122815. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  122816. /**
  122817. * Unbind the current render target texture from the webGL context
  122818. * @param texture defines the render target texture to unbind
  122819. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  122820. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  122821. */
  122822. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  122823. /**
  122824. * Creates a dynamic vertex buffer
  122825. * @param vertices the data for the dynamic vertex buffer
  122826. * @returns the new WebGL dynamic buffer
  122827. */
  122828. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  122829. /**
  122830. * Update the content of a dynamic texture
  122831. * @param texture defines the texture to update
  122832. * @param canvas defines the canvas containing the source
  122833. * @param invertY defines if data must be stored with Y axis inverted
  122834. * @param premulAlpha defines if alpha is stored as premultiplied
  122835. * @param format defines the format of the data
  122836. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  122837. */
  122838. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  122839. /**
  122840. * Gets a boolean indicating if all created effects are ready
  122841. * @returns true if all effects are ready
  122842. */
  122843. areAllEffectsReady(): boolean;
  122844. /**
  122845. * @hidden
  122846. * Get the current error code of the webGL context
  122847. * @returns the error code
  122848. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  122849. */
  122850. getError(): number;
  122851. /** @hidden */
  122852. _getUnpackAlignement(): number;
  122853. /** @hidden */
  122854. _unpackFlipY(value: boolean): void;
  122855. /**
  122856. * Update a dynamic index buffer
  122857. * @param indexBuffer defines the target index buffer
  122858. * @param indices defines the data to update
  122859. * @param offset defines the offset in the target index buffer where update should start
  122860. */
  122861. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  122862. /**
  122863. * Updates a dynamic vertex buffer.
  122864. * @param vertexBuffer the vertex buffer to update
  122865. * @param vertices the data used to update the vertex buffer
  122866. * @param byteOffset the byte offset of the data (optional)
  122867. * @param byteLength the byte length of the data (optional)
  122868. */
  122869. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  122870. /** @hidden */
  122871. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  122872. /** @hidden */
  122873. _bindTexture(channel: number, texture: InternalTexture): void;
  122874. protected _deleteBuffer(buffer: WebGLBuffer): void;
  122875. /**
  122876. * 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
  122877. */
  122878. releaseEffects(): void;
  122879. displayLoadingUI(): void;
  122880. hideLoadingUI(): void;
  122881. /** @hidden */
  122882. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  122883. /** @hidden */
  122884. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  122885. /** @hidden */
  122886. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  122887. /** @hidden */
  122888. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  122889. }
  122890. }
  122891. declare module BABYLON {
  122892. /**
  122893. * @hidden
  122894. **/
  122895. export class _TimeToken {
  122896. _startTimeQuery: Nullable<WebGLQuery>;
  122897. _endTimeQuery: Nullable<WebGLQuery>;
  122898. _timeElapsedQuery: Nullable<WebGLQuery>;
  122899. _timeElapsedQueryEnded: boolean;
  122900. }
  122901. }
  122902. declare module BABYLON {
  122903. /** @hidden */
  122904. export class _OcclusionDataStorage {
  122905. /** @hidden */
  122906. occlusionInternalRetryCounter: number;
  122907. /** @hidden */
  122908. isOcclusionQueryInProgress: boolean;
  122909. /** @hidden */
  122910. isOccluded: boolean;
  122911. /** @hidden */
  122912. occlusionRetryCount: number;
  122913. /** @hidden */
  122914. occlusionType: number;
  122915. /** @hidden */
  122916. occlusionQueryAlgorithmType: number;
  122917. }
  122918. interface Engine {
  122919. /**
  122920. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  122921. * @return the new query
  122922. */
  122923. createQuery(): WebGLQuery;
  122924. /**
  122925. * Delete and release a webGL query
  122926. * @param query defines the query to delete
  122927. * @return the current engine
  122928. */
  122929. deleteQuery(query: WebGLQuery): Engine;
  122930. /**
  122931. * Check if a given query has resolved and got its value
  122932. * @param query defines the query to check
  122933. * @returns true if the query got its value
  122934. */
  122935. isQueryResultAvailable(query: WebGLQuery): boolean;
  122936. /**
  122937. * Gets the value of a given query
  122938. * @param query defines the query to check
  122939. * @returns the value of the query
  122940. */
  122941. getQueryResult(query: WebGLQuery): number;
  122942. /**
  122943. * Initiates an occlusion query
  122944. * @param algorithmType defines the algorithm to use
  122945. * @param query defines the query to use
  122946. * @returns the current engine
  122947. * @see http://doc.babylonjs.com/features/occlusionquery
  122948. */
  122949. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  122950. /**
  122951. * Ends an occlusion query
  122952. * @see http://doc.babylonjs.com/features/occlusionquery
  122953. * @param algorithmType defines the algorithm to use
  122954. * @returns the current engine
  122955. */
  122956. endOcclusionQuery(algorithmType: number): Engine;
  122957. /**
  122958. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  122959. * Please note that only one query can be issued at a time
  122960. * @returns a time token used to track the time span
  122961. */
  122962. startTimeQuery(): Nullable<_TimeToken>;
  122963. /**
  122964. * Ends a time query
  122965. * @param token defines the token used to measure the time span
  122966. * @returns the time spent (in ns)
  122967. */
  122968. endTimeQuery(token: _TimeToken): int;
  122969. /** @hidden */
  122970. _currentNonTimestampToken: Nullable<_TimeToken>;
  122971. /** @hidden */
  122972. _createTimeQuery(): WebGLQuery;
  122973. /** @hidden */
  122974. _deleteTimeQuery(query: WebGLQuery): void;
  122975. /** @hidden */
  122976. _getGlAlgorithmType(algorithmType: number): number;
  122977. /** @hidden */
  122978. _getTimeQueryResult(query: WebGLQuery): any;
  122979. /** @hidden */
  122980. _getTimeQueryAvailability(query: WebGLQuery): any;
  122981. }
  122982. interface AbstractMesh {
  122983. /**
  122984. * Backing filed
  122985. * @hidden
  122986. */
  122987. __occlusionDataStorage: _OcclusionDataStorage;
  122988. /**
  122989. * Access property
  122990. * @hidden
  122991. */
  122992. _occlusionDataStorage: _OcclusionDataStorage;
  122993. /**
  122994. * 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.
  122995. * The default value is -1 which means don't break the query and wait till the result
  122996. * @see http://doc.babylonjs.com/features/occlusionquery
  122997. */
  122998. occlusionRetryCount: number;
  122999. /**
  123000. * 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:
  123001. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  123002. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  123003. * * 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.
  123004. * @see http://doc.babylonjs.com/features/occlusionquery
  123005. */
  123006. occlusionType: number;
  123007. /**
  123008. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  123009. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  123010. * * 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.
  123011. * @see http://doc.babylonjs.com/features/occlusionquery
  123012. */
  123013. occlusionQueryAlgorithmType: number;
  123014. /**
  123015. * 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
  123016. * @see http://doc.babylonjs.com/features/occlusionquery
  123017. */
  123018. isOccluded: boolean;
  123019. /**
  123020. * Flag to check the progress status of the query
  123021. * @see http://doc.babylonjs.com/features/occlusionquery
  123022. */
  123023. isOcclusionQueryInProgress: boolean;
  123024. }
  123025. }
  123026. declare module BABYLON {
  123027. /** @hidden */
  123028. export var _forceTransformFeedbackToBundle: boolean;
  123029. interface Engine {
  123030. /**
  123031. * Creates a webGL transform feedback object
  123032. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  123033. * @returns the webGL transform feedback object
  123034. */
  123035. createTransformFeedback(): WebGLTransformFeedback;
  123036. /**
  123037. * Delete a webGL transform feedback object
  123038. * @param value defines the webGL transform feedback object to delete
  123039. */
  123040. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  123041. /**
  123042. * Bind a webGL transform feedback object to the webgl context
  123043. * @param value defines the webGL transform feedback object to bind
  123044. */
  123045. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  123046. /**
  123047. * Begins a transform feedback operation
  123048. * @param usePoints defines if points or triangles must be used
  123049. */
  123050. beginTransformFeedback(usePoints: boolean): void;
  123051. /**
  123052. * Ends a transform feedback operation
  123053. */
  123054. endTransformFeedback(): void;
  123055. /**
  123056. * Specify the varyings to use with transform feedback
  123057. * @param program defines the associated webGL program
  123058. * @param value defines the list of strings representing the varying names
  123059. */
  123060. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  123061. /**
  123062. * Bind a webGL buffer for a transform feedback operation
  123063. * @param value defines the webGL buffer to bind
  123064. */
  123065. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  123066. }
  123067. }
  123068. declare module BABYLON {
  123069. /**
  123070. * Creation options of the multi render target texture.
  123071. */
  123072. export interface IMultiRenderTargetOptions {
  123073. /**
  123074. * Define if the texture needs to create mip maps after render.
  123075. */
  123076. generateMipMaps?: boolean;
  123077. /**
  123078. * Define the types of all the draw buffers we want to create
  123079. */
  123080. types?: number[];
  123081. /**
  123082. * Define the sampling modes of all the draw buffers we want to create
  123083. */
  123084. samplingModes?: number[];
  123085. /**
  123086. * Define if a depth buffer is required
  123087. */
  123088. generateDepthBuffer?: boolean;
  123089. /**
  123090. * Define if a stencil buffer is required
  123091. */
  123092. generateStencilBuffer?: boolean;
  123093. /**
  123094. * Define if a depth texture is required instead of a depth buffer
  123095. */
  123096. generateDepthTexture?: boolean;
  123097. /**
  123098. * Define the number of desired draw buffers
  123099. */
  123100. textureCount?: number;
  123101. /**
  123102. * Define if aspect ratio should be adapted to the texture or stay the scene one
  123103. */
  123104. doNotChangeAspectRatio?: boolean;
  123105. /**
  123106. * Define the default type of the buffers we are creating
  123107. */
  123108. defaultType?: number;
  123109. }
  123110. /**
  123111. * A multi render target, like a render target provides the ability to render to a texture.
  123112. * Unlike the render target, it can render to several draw buffers in one draw.
  123113. * This is specially interesting in deferred rendering or for any effects requiring more than
  123114. * just one color from a single pass.
  123115. */
  123116. export class MultiRenderTarget extends RenderTargetTexture {
  123117. private _internalTextures;
  123118. private _textures;
  123119. private _multiRenderTargetOptions;
  123120. /**
  123121. * Get if draw buffers are currently supported by the used hardware and browser.
  123122. */
  123123. get isSupported(): boolean;
  123124. /**
  123125. * Get the list of textures generated by the multi render target.
  123126. */
  123127. get textures(): Texture[];
  123128. /**
  123129. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  123130. */
  123131. get depthTexture(): Texture;
  123132. /**
  123133. * Set the wrapping mode on U of all the textures we are rendering to.
  123134. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  123135. */
  123136. set wrapU(wrap: number);
  123137. /**
  123138. * Set the wrapping mode on V of all the textures we are rendering to.
  123139. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  123140. */
  123141. set wrapV(wrap: number);
  123142. /**
  123143. * Instantiate a new multi render target texture.
  123144. * A multi render target, like a render target provides the ability to render to a texture.
  123145. * Unlike the render target, it can render to several draw buffers in one draw.
  123146. * This is specially interesting in deferred rendering or for any effects requiring more than
  123147. * just one color from a single pass.
  123148. * @param name Define the name of the texture
  123149. * @param size Define the size of the buffers to render to
  123150. * @param count Define the number of target we are rendering into
  123151. * @param scene Define the scene the texture belongs to
  123152. * @param options Define the options used to create the multi render target
  123153. */
  123154. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  123155. /** @hidden */
  123156. _rebuild(): void;
  123157. private _createInternalTextures;
  123158. private _createTextures;
  123159. /**
  123160. * Define the number of samples used if MSAA is enabled.
  123161. */
  123162. get samples(): number;
  123163. set samples(value: number);
  123164. /**
  123165. * Resize all the textures in the multi render target.
  123166. * Be carrefull as it will recreate all the data in the new texture.
  123167. * @param size Define the new size
  123168. */
  123169. resize(size: any): void;
  123170. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  123171. /**
  123172. * Dispose the render targets and their associated resources
  123173. */
  123174. dispose(): void;
  123175. /**
  123176. * Release all the underlying texture used as draw buffers.
  123177. */
  123178. releaseInternalTextures(): void;
  123179. }
  123180. }
  123181. declare module BABYLON {
  123182. interface ThinEngine {
  123183. /**
  123184. * Unbind a list of render target textures from the webGL context
  123185. * This is used only when drawBuffer extension or webGL2 are active
  123186. * @param textures defines the render target textures to unbind
  123187. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  123188. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  123189. */
  123190. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  123191. /**
  123192. * Create a multi render target texture
  123193. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  123194. * @param size defines the size of the texture
  123195. * @param options defines the creation options
  123196. * @returns the cube texture as an InternalTexture
  123197. */
  123198. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  123199. /**
  123200. * Update the sample count for a given multiple render target texture
  123201. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  123202. * @param textures defines the textures to update
  123203. * @param samples defines the sample count to set
  123204. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  123205. */
  123206. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  123207. }
  123208. }
  123209. declare module BABYLON {
  123210. /**
  123211. * Class used to define an additional view for the engine
  123212. * @see https://doc.babylonjs.com/how_to/multi_canvases
  123213. */
  123214. export class EngineView {
  123215. /** Defines the canvas where to render the view */
  123216. target: HTMLCanvasElement;
  123217. /** Defines an optional camera used to render the view (will use active camera else) */
  123218. camera?: Camera;
  123219. }
  123220. interface Engine {
  123221. /**
  123222. * Gets or sets the HTML element to use for attaching events
  123223. */
  123224. inputElement: Nullable<HTMLElement>;
  123225. /**
  123226. * Gets the current engine view
  123227. * @see https://doc.babylonjs.com/how_to/multi_canvases
  123228. */
  123229. activeView: Nullable<EngineView>;
  123230. /** Gets or sets the list of views */
  123231. views: EngineView[];
  123232. /**
  123233. * Register a new child canvas
  123234. * @param canvas defines the canvas to register
  123235. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  123236. * @returns the associated view
  123237. */
  123238. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  123239. /**
  123240. * Remove a registered child canvas
  123241. * @param canvas defines the canvas to remove
  123242. * @returns the current engine
  123243. */
  123244. unRegisterView(canvas: HTMLCanvasElement): Engine;
  123245. }
  123246. }
  123247. declare module BABYLON {
  123248. interface Engine {
  123249. /** @hidden */
  123250. _excludedCompressedTextures: string[];
  123251. /** @hidden */
  123252. _textureFormatInUse: string;
  123253. /**
  123254. * Gets the list of texture formats supported
  123255. */
  123256. readonly texturesSupported: Array<string>;
  123257. /**
  123258. * Gets the texture format in use
  123259. */
  123260. readonly textureFormatInUse: Nullable<string>;
  123261. /**
  123262. * Set the compressed texture extensions or file names to skip.
  123263. *
  123264. * @param skippedFiles defines the list of those texture files you want to skip
  123265. * Example: [".dds", ".env", "myfile.png"]
  123266. */
  123267. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  123268. /**
  123269. * Set the compressed texture format to use, based on the formats you have, and the formats
  123270. * supported by the hardware / browser.
  123271. *
  123272. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  123273. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  123274. * to API arguments needed to compressed textures. This puts the burden on the container
  123275. * generator to house the arcane code for determining these for current & future formats.
  123276. *
  123277. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  123278. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  123279. *
  123280. * Note: The result of this call is not taken into account when a texture is base64.
  123281. *
  123282. * @param formatsAvailable defines the list of those format families you have created
  123283. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  123284. *
  123285. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  123286. * @returns The extension selected.
  123287. */
  123288. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  123289. }
  123290. }
  123291. declare module BABYLON {
  123292. /**
  123293. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  123294. */
  123295. export interface CubeMapInfo {
  123296. /**
  123297. * The pixel array for the front face.
  123298. * This is stored in format, left to right, up to down format.
  123299. */
  123300. front: Nullable<ArrayBufferView>;
  123301. /**
  123302. * The pixel array for the back face.
  123303. * This is stored in format, left to right, up to down format.
  123304. */
  123305. back: Nullable<ArrayBufferView>;
  123306. /**
  123307. * The pixel array for the left face.
  123308. * This is stored in format, left to right, up to down format.
  123309. */
  123310. left: Nullable<ArrayBufferView>;
  123311. /**
  123312. * The pixel array for the right face.
  123313. * This is stored in format, left to right, up to down format.
  123314. */
  123315. right: Nullable<ArrayBufferView>;
  123316. /**
  123317. * The pixel array for the up face.
  123318. * This is stored in format, left to right, up to down format.
  123319. */
  123320. up: Nullable<ArrayBufferView>;
  123321. /**
  123322. * The pixel array for the down face.
  123323. * This is stored in format, left to right, up to down format.
  123324. */
  123325. down: Nullable<ArrayBufferView>;
  123326. /**
  123327. * The size of the cubemap stored.
  123328. *
  123329. * Each faces will be size * size pixels.
  123330. */
  123331. size: number;
  123332. /**
  123333. * The format of the texture.
  123334. *
  123335. * RGBA, RGB.
  123336. */
  123337. format: number;
  123338. /**
  123339. * The type of the texture data.
  123340. *
  123341. * UNSIGNED_INT, FLOAT.
  123342. */
  123343. type: number;
  123344. /**
  123345. * Specifies whether the texture is in gamma space.
  123346. */
  123347. gammaSpace: boolean;
  123348. }
  123349. /**
  123350. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  123351. */
  123352. export class PanoramaToCubeMapTools {
  123353. private static FACE_FRONT;
  123354. private static FACE_BACK;
  123355. private static FACE_RIGHT;
  123356. private static FACE_LEFT;
  123357. private static FACE_DOWN;
  123358. private static FACE_UP;
  123359. /**
  123360. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  123361. *
  123362. * @param float32Array The source data.
  123363. * @param inputWidth The width of the input panorama.
  123364. * @param inputHeight The height of the input panorama.
  123365. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  123366. * @return The cubemap data
  123367. */
  123368. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  123369. private static CreateCubemapTexture;
  123370. private static CalcProjectionSpherical;
  123371. }
  123372. }
  123373. declare module BABYLON {
  123374. /**
  123375. * Helper class dealing with the extraction of spherical polynomial dataArray
  123376. * from a cube map.
  123377. */
  123378. export class CubeMapToSphericalPolynomialTools {
  123379. private static FileFaces;
  123380. /**
  123381. * Converts a texture to the according Spherical Polynomial data.
  123382. * This extracts the first 3 orders only as they are the only one used in the lighting.
  123383. *
  123384. * @param texture The texture to extract the information from.
  123385. * @return The Spherical Polynomial data.
  123386. */
  123387. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  123388. /**
  123389. * Converts a cubemap to the according Spherical Polynomial data.
  123390. * This extracts the first 3 orders only as they are the only one used in the lighting.
  123391. *
  123392. * @param cubeInfo The Cube map to extract the information from.
  123393. * @return The Spherical Polynomial data.
  123394. */
  123395. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  123396. }
  123397. }
  123398. declare module BABYLON {
  123399. interface BaseTexture {
  123400. /**
  123401. * Get the polynomial representation of the texture data.
  123402. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  123403. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  123404. */
  123405. sphericalPolynomial: Nullable<SphericalPolynomial>;
  123406. }
  123407. }
  123408. declare module BABYLON {
  123409. /** @hidden */
  123410. export var rgbdEncodePixelShader: {
  123411. name: string;
  123412. shader: string;
  123413. };
  123414. }
  123415. declare module BABYLON {
  123416. /** @hidden */
  123417. export var rgbdDecodePixelShader: {
  123418. name: string;
  123419. shader: string;
  123420. };
  123421. }
  123422. declare module BABYLON {
  123423. /**
  123424. * Raw texture data and descriptor sufficient for WebGL texture upload
  123425. */
  123426. export interface EnvironmentTextureInfo {
  123427. /**
  123428. * Version of the environment map
  123429. */
  123430. version: number;
  123431. /**
  123432. * Width of image
  123433. */
  123434. width: number;
  123435. /**
  123436. * Irradiance information stored in the file.
  123437. */
  123438. irradiance: any;
  123439. /**
  123440. * Specular information stored in the file.
  123441. */
  123442. specular: any;
  123443. }
  123444. /**
  123445. * Defines One Image in the file. It requires only the position in the file
  123446. * as well as the length.
  123447. */
  123448. interface BufferImageData {
  123449. /**
  123450. * Length of the image data.
  123451. */
  123452. length: number;
  123453. /**
  123454. * Position of the data from the null terminator delimiting the end of the JSON.
  123455. */
  123456. position: number;
  123457. }
  123458. /**
  123459. * Defines the specular data enclosed in the file.
  123460. * This corresponds to the version 1 of the data.
  123461. */
  123462. export interface EnvironmentTextureSpecularInfoV1 {
  123463. /**
  123464. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  123465. */
  123466. specularDataPosition?: number;
  123467. /**
  123468. * This contains all the images data needed to reconstruct the cubemap.
  123469. */
  123470. mipmaps: Array<BufferImageData>;
  123471. /**
  123472. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  123473. */
  123474. lodGenerationScale: number;
  123475. }
  123476. /**
  123477. * Sets of helpers addressing the serialization and deserialization of environment texture
  123478. * stored in a BabylonJS env file.
  123479. * Those files are usually stored as .env files.
  123480. */
  123481. export class EnvironmentTextureTools {
  123482. /**
  123483. * Magic number identifying the env file.
  123484. */
  123485. private static _MagicBytes;
  123486. /**
  123487. * Gets the environment info from an env file.
  123488. * @param data The array buffer containing the .env bytes.
  123489. * @returns the environment file info (the json header) if successfully parsed.
  123490. */
  123491. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  123492. /**
  123493. * Creates an environment texture from a loaded cube texture.
  123494. * @param texture defines the cube texture to convert in env file
  123495. * @return a promise containing the environment data if succesfull.
  123496. */
  123497. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  123498. /**
  123499. * Creates a JSON representation of the spherical data.
  123500. * @param texture defines the texture containing the polynomials
  123501. * @return the JSON representation of the spherical info
  123502. */
  123503. private static _CreateEnvTextureIrradiance;
  123504. /**
  123505. * Creates the ArrayBufferViews used for initializing environment texture image data.
  123506. * @param data the image data
  123507. * @param info parameters that determine what views will be created for accessing the underlying buffer
  123508. * @return the views described by info providing access to the underlying buffer
  123509. */
  123510. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  123511. /**
  123512. * Uploads the texture info contained in the env file to the GPU.
  123513. * @param texture defines the internal texture to upload to
  123514. * @param data defines the data to load
  123515. * @param info defines the texture info retrieved through the GetEnvInfo method
  123516. * @returns a promise
  123517. */
  123518. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  123519. private static _OnImageReadyAsync;
  123520. /**
  123521. * Uploads the levels of image data to the GPU.
  123522. * @param texture defines the internal texture to upload to
  123523. * @param imageData defines the array buffer views of image data [mipmap][face]
  123524. * @returns a promise
  123525. */
  123526. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  123527. /**
  123528. * Uploads spherical polynomials information to the texture.
  123529. * @param texture defines the texture we are trying to upload the information to
  123530. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  123531. */
  123532. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  123533. /** @hidden */
  123534. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  123535. }
  123536. }
  123537. declare module BABYLON {
  123538. /**
  123539. * Contains position and normal vectors for a vertex
  123540. */
  123541. export class PositionNormalVertex {
  123542. /** the position of the vertex (defaut: 0,0,0) */
  123543. position: Vector3;
  123544. /** the normal of the vertex (defaut: 0,1,0) */
  123545. normal: Vector3;
  123546. /**
  123547. * Creates a PositionNormalVertex
  123548. * @param position the position of the vertex (defaut: 0,0,0)
  123549. * @param normal the normal of the vertex (defaut: 0,1,0)
  123550. */
  123551. constructor(
  123552. /** the position of the vertex (defaut: 0,0,0) */
  123553. position?: Vector3,
  123554. /** the normal of the vertex (defaut: 0,1,0) */
  123555. normal?: Vector3);
  123556. /**
  123557. * Clones the PositionNormalVertex
  123558. * @returns the cloned PositionNormalVertex
  123559. */
  123560. clone(): PositionNormalVertex;
  123561. }
  123562. /**
  123563. * Contains position, normal and uv vectors for a vertex
  123564. */
  123565. export class PositionNormalTextureVertex {
  123566. /** the position of the vertex (defaut: 0,0,0) */
  123567. position: Vector3;
  123568. /** the normal of the vertex (defaut: 0,1,0) */
  123569. normal: Vector3;
  123570. /** the uv of the vertex (default: 0,0) */
  123571. uv: Vector2;
  123572. /**
  123573. * Creates a PositionNormalTextureVertex
  123574. * @param position the position of the vertex (defaut: 0,0,0)
  123575. * @param normal the normal of the vertex (defaut: 0,1,0)
  123576. * @param uv the uv of the vertex (default: 0,0)
  123577. */
  123578. constructor(
  123579. /** the position of the vertex (defaut: 0,0,0) */
  123580. position?: Vector3,
  123581. /** the normal of the vertex (defaut: 0,1,0) */
  123582. normal?: Vector3,
  123583. /** the uv of the vertex (default: 0,0) */
  123584. uv?: Vector2);
  123585. /**
  123586. * Clones the PositionNormalTextureVertex
  123587. * @returns the cloned PositionNormalTextureVertex
  123588. */
  123589. clone(): PositionNormalTextureVertex;
  123590. }
  123591. }
  123592. declare module BABYLON {
  123593. /** @hidden */
  123594. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  123595. private _genericAttributeLocation;
  123596. private _varyingLocationCount;
  123597. private _varyingLocationMap;
  123598. private _replacements;
  123599. private _textureCount;
  123600. private _uniforms;
  123601. lineProcessor(line: string): string;
  123602. attributeProcessor(attribute: string): string;
  123603. varyingProcessor(varying: string, isFragment: boolean): string;
  123604. uniformProcessor(uniform: string): string;
  123605. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  123606. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  123607. }
  123608. }
  123609. declare module BABYLON {
  123610. /**
  123611. * Container for accessors for natively-stored mesh data buffers.
  123612. */
  123613. class NativeDataBuffer extends DataBuffer {
  123614. /**
  123615. * Accessor value used to identify/retrieve a natively-stored index buffer.
  123616. */
  123617. nativeIndexBuffer?: any;
  123618. /**
  123619. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  123620. */
  123621. nativeVertexBuffer?: any;
  123622. }
  123623. /** @hidden */
  123624. class NativeTexture extends InternalTexture {
  123625. getInternalTexture(): InternalTexture;
  123626. getViewCount(): number;
  123627. }
  123628. /** @hidden */
  123629. export class NativeEngine extends Engine {
  123630. private readonly _native;
  123631. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  123632. private readonly INVALID_HANDLE;
  123633. getHardwareScalingLevel(): number;
  123634. constructor();
  123635. dispose(): void;
  123636. /**
  123637. * Can be used to override the current requestAnimationFrame requester.
  123638. * @hidden
  123639. */
  123640. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  123641. /**
  123642. * Override default engine behavior.
  123643. * @param color
  123644. * @param backBuffer
  123645. * @param depth
  123646. * @param stencil
  123647. */
  123648. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  123649. /**
  123650. * Gets host document
  123651. * @returns the host document object
  123652. */
  123653. getHostDocument(): Nullable<Document>;
  123654. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  123655. createIndexBuffer(indices: IndicesArray): NativeDataBuffer;
  123656. createVertexBuffer(data: DataArray): NativeDataBuffer;
  123657. recordVertexArrayObject(vertexBuffers: {
  123658. [key: string]: VertexBuffer;
  123659. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  123660. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  123661. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  123662. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  123663. /**
  123664. * Draw a list of indexed primitives
  123665. * @param fillMode defines the primitive to use
  123666. * @param indexStart defines the starting index
  123667. * @param indexCount defines the number of index to draw
  123668. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  123669. */
  123670. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  123671. /**
  123672. * Draw a list of unindexed primitives
  123673. * @param fillMode defines the primitive to use
  123674. * @param verticesStart defines the index of first vertex to draw
  123675. * @param verticesCount defines the count of vertices to draw
  123676. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  123677. */
  123678. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  123679. createPipelineContext(): IPipelineContext;
  123680. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  123681. /** @hidden */
  123682. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  123683. /** @hidden */
  123684. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  123685. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  123686. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  123687. protected _setProgram(program: WebGLProgram): void;
  123688. _releaseEffect(effect: Effect): void;
  123689. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  123690. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  123691. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  123692. bindSamplers(effect: Effect): void;
  123693. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  123694. getRenderWidth(useScreen?: boolean): number;
  123695. getRenderHeight(useScreen?: boolean): number;
  123696. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  123697. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  123698. /**
  123699. * Set the z offset to apply to current rendering
  123700. * @param value defines the offset to apply
  123701. */
  123702. setZOffset(value: number): void;
  123703. /**
  123704. * Gets the current value of the zOffset
  123705. * @returns the current zOffset state
  123706. */
  123707. getZOffset(): number;
  123708. /**
  123709. * Enable or disable depth buffering
  123710. * @param enable defines the state to set
  123711. */
  123712. setDepthBuffer(enable: boolean): void;
  123713. /**
  123714. * Gets a boolean indicating if depth writing is enabled
  123715. * @returns the current depth writing state
  123716. */
  123717. getDepthWrite(): boolean;
  123718. /**
  123719. * Enable or disable depth writing
  123720. * @param enable defines the state to set
  123721. */
  123722. setDepthWrite(enable: boolean): void;
  123723. /**
  123724. * Enable or disable color writing
  123725. * @param enable defines the state to set
  123726. */
  123727. setColorWrite(enable: boolean): void;
  123728. /**
  123729. * Gets a boolean indicating if color writing is enabled
  123730. * @returns the current color writing state
  123731. */
  123732. getColorWrite(): boolean;
  123733. /**
  123734. * Sets alpha constants used by some alpha blending modes
  123735. * @param r defines the red component
  123736. * @param g defines the green component
  123737. * @param b defines the blue component
  123738. * @param a defines the alpha component
  123739. */
  123740. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  123741. /**
  123742. * Sets the current alpha mode
  123743. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  123744. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  123745. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  123746. */
  123747. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  123748. /**
  123749. * Gets the current alpha mode
  123750. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  123751. * @returns the current alpha mode
  123752. */
  123753. getAlphaMode(): number;
  123754. setInt(uniform: WebGLUniformLocation, int: number): void;
  123755. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  123756. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  123757. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  123758. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  123759. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  123760. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  123761. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  123762. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  123763. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  123764. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  123765. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  123766. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  123767. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  123768. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  123769. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  123770. setFloat(uniform: WebGLUniformLocation, value: number): void;
  123771. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  123772. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  123773. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  123774. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  123775. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  123776. wipeCaches(bruteForce?: boolean): void;
  123777. _createTexture(): WebGLTexture;
  123778. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  123779. /**
  123780. * Usually called from Texture.ts.
  123781. * Passed information to create a WebGLTexture
  123782. * @param url defines a value which contains one of the following:
  123783. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  123784. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  123785. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  123786. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  123787. * @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)
  123788. * @param scene needed for loading to the correct scene
  123789. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  123790. * @param onLoad optional callback to be called upon successful completion
  123791. * @param onError optional callback to be called upon failure
  123792. * @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
  123793. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  123794. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  123795. * @param forcedExtension defines the extension to use to pick the right loader
  123796. * @param mimeType defines an optional mime type
  123797. * @returns a InternalTexture for assignment back into BABYLON.Texture
  123798. */
  123799. 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;
  123800. /**
  123801. * Creates a cube texture
  123802. * @param rootUrl defines the url where the files to load is located
  123803. * @param scene defines the current scene
  123804. * @param files defines the list of files to load (1 per face)
  123805. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  123806. * @param onLoad defines an optional callback raised when the texture is loaded
  123807. * @param onError defines an optional callback raised if there is an issue to load the texture
  123808. * @param format defines the format of the data
  123809. * @param forcedExtension defines the extension to use to pick the right loader
  123810. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  123811. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  123812. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  123813. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  123814. * @returns the cube texture as an InternalTexture
  123815. */
  123816. 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;
  123817. private _getSamplingFilter;
  123818. private static _GetNativeTextureFormat;
  123819. createRenderTargetTexture(size: number | {
  123820. width: number;
  123821. height: number;
  123822. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  123823. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  123824. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  123825. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  123826. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  123827. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  123828. /**
  123829. * Updates a dynamic vertex buffer.
  123830. * @param vertexBuffer the vertex buffer to update
  123831. * @param data the data used to update the vertex buffer
  123832. * @param byteOffset the byte offset of the data (optional)
  123833. * @param byteLength the byte length of the data (optional)
  123834. */
  123835. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  123836. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  123837. private _updateAnisotropicLevel;
  123838. private _getAddressMode;
  123839. /** @hidden */
  123840. _bindTexture(channel: number, texture: InternalTexture): void;
  123841. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  123842. releaseEffects(): void;
  123843. /** @hidden */
  123844. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  123845. /** @hidden */
  123846. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  123847. /** @hidden */
  123848. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  123849. /** @hidden */
  123850. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  123851. }
  123852. }
  123853. declare module BABYLON {
  123854. /**
  123855. * Gather the list of clipboard event types as constants.
  123856. */
  123857. export class ClipboardEventTypes {
  123858. /**
  123859. * The clipboard event is fired when a copy command is active (pressed).
  123860. */
  123861. static readonly COPY: number;
  123862. /**
  123863. * The clipboard event is fired when a cut command is active (pressed).
  123864. */
  123865. static readonly CUT: number;
  123866. /**
  123867. * The clipboard event is fired when a paste command is active (pressed).
  123868. */
  123869. static readonly PASTE: number;
  123870. }
  123871. /**
  123872. * This class is used to store clipboard related info for the onClipboardObservable event.
  123873. */
  123874. export class ClipboardInfo {
  123875. /**
  123876. * Defines the type of event (BABYLON.ClipboardEventTypes)
  123877. */
  123878. type: number;
  123879. /**
  123880. * Defines the related dom event
  123881. */
  123882. event: ClipboardEvent;
  123883. /**
  123884. *Creates an instance of ClipboardInfo.
  123885. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  123886. * @param event Defines the related dom event
  123887. */
  123888. constructor(
  123889. /**
  123890. * Defines the type of event (BABYLON.ClipboardEventTypes)
  123891. */
  123892. type: number,
  123893. /**
  123894. * Defines the related dom event
  123895. */
  123896. event: ClipboardEvent);
  123897. /**
  123898. * Get the clipboard event's type from the keycode.
  123899. * @param keyCode Defines the keyCode for the current keyboard event.
  123900. * @return {number}
  123901. */
  123902. static GetTypeFromCharacter(keyCode: number): number;
  123903. }
  123904. }
  123905. declare module BABYLON {
  123906. /**
  123907. * Google Daydream controller
  123908. */
  123909. export class DaydreamController extends WebVRController {
  123910. /**
  123911. * Base Url for the controller model.
  123912. */
  123913. static MODEL_BASE_URL: string;
  123914. /**
  123915. * File name for the controller model.
  123916. */
  123917. static MODEL_FILENAME: string;
  123918. /**
  123919. * Gamepad Id prefix used to identify Daydream Controller.
  123920. */
  123921. static readonly GAMEPAD_ID_PREFIX: string;
  123922. /**
  123923. * Creates a new DaydreamController from a gamepad
  123924. * @param vrGamepad the gamepad that the controller should be created from
  123925. */
  123926. constructor(vrGamepad: any);
  123927. /**
  123928. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  123929. * @param scene scene in which to add meshes
  123930. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  123931. */
  123932. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  123933. /**
  123934. * Called once for each button that changed state since the last frame
  123935. * @param buttonIdx Which button index changed
  123936. * @param state New state of the button
  123937. * @param changes Which properties on the state changed since last frame
  123938. */
  123939. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  123940. }
  123941. }
  123942. declare module BABYLON {
  123943. /**
  123944. * Gear VR Controller
  123945. */
  123946. export class GearVRController extends WebVRController {
  123947. /**
  123948. * Base Url for the controller model.
  123949. */
  123950. static MODEL_BASE_URL: string;
  123951. /**
  123952. * File name for the controller model.
  123953. */
  123954. static MODEL_FILENAME: string;
  123955. /**
  123956. * Gamepad Id prefix used to identify this controller.
  123957. */
  123958. static readonly GAMEPAD_ID_PREFIX: string;
  123959. private readonly _buttonIndexToObservableNameMap;
  123960. /**
  123961. * Creates a new GearVRController from a gamepad
  123962. * @param vrGamepad the gamepad that the controller should be created from
  123963. */
  123964. constructor(vrGamepad: any);
  123965. /**
  123966. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  123967. * @param scene scene in which to add meshes
  123968. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  123969. */
  123970. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  123971. /**
  123972. * Called once for each button that changed state since the last frame
  123973. * @param buttonIdx Which button index changed
  123974. * @param state New state of the button
  123975. * @param changes Which properties on the state changed since last frame
  123976. */
  123977. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  123978. }
  123979. }
  123980. declare module BABYLON {
  123981. /**
  123982. * Generic Controller
  123983. */
  123984. export class GenericController extends WebVRController {
  123985. /**
  123986. * Base Url for the controller model.
  123987. */
  123988. static readonly MODEL_BASE_URL: string;
  123989. /**
  123990. * File name for the controller model.
  123991. */
  123992. static readonly MODEL_FILENAME: string;
  123993. /**
  123994. * Creates a new GenericController from a gamepad
  123995. * @param vrGamepad the gamepad that the controller should be created from
  123996. */
  123997. constructor(vrGamepad: any);
  123998. /**
  123999. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  124000. * @param scene scene in which to add meshes
  124001. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  124002. */
  124003. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  124004. /**
  124005. * Called once for each button that changed state since the last frame
  124006. * @param buttonIdx Which button index changed
  124007. * @param state New state of the button
  124008. * @param changes Which properties on the state changed since last frame
  124009. */
  124010. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  124011. }
  124012. }
  124013. declare module BABYLON {
  124014. /**
  124015. * Oculus Touch Controller
  124016. */
  124017. export class OculusTouchController extends WebVRController {
  124018. /**
  124019. * Base Url for the controller model.
  124020. */
  124021. static MODEL_BASE_URL: string;
  124022. /**
  124023. * File name for the left controller model.
  124024. */
  124025. static MODEL_LEFT_FILENAME: string;
  124026. /**
  124027. * File name for the right controller model.
  124028. */
  124029. static MODEL_RIGHT_FILENAME: string;
  124030. /**
  124031. * Base Url for the Quest controller model.
  124032. */
  124033. static QUEST_MODEL_BASE_URL: string;
  124034. /**
  124035. * @hidden
  124036. * If the controllers are running on a device that needs the updated Quest controller models
  124037. */
  124038. static _IsQuest: boolean;
  124039. /**
  124040. * Fired when the secondary trigger on this controller is modified
  124041. */
  124042. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  124043. /**
  124044. * Fired when the thumb rest on this controller is modified
  124045. */
  124046. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  124047. /**
  124048. * Creates a new OculusTouchController from a gamepad
  124049. * @param vrGamepad the gamepad that the controller should be created from
  124050. */
  124051. constructor(vrGamepad: any);
  124052. /**
  124053. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  124054. * @param scene scene in which to add meshes
  124055. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  124056. */
  124057. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  124058. /**
  124059. * Fired when the A button on this controller is modified
  124060. */
  124061. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  124062. /**
  124063. * Fired when the B button on this controller is modified
  124064. */
  124065. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  124066. /**
  124067. * Fired when the X button on this controller is modified
  124068. */
  124069. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  124070. /**
  124071. * Fired when the Y button on this controller is modified
  124072. */
  124073. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  124074. /**
  124075. * Called once for each button that changed state since the last frame
  124076. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  124077. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  124078. * 2) secondary trigger (same)
  124079. * 3) A (right) X (left), touch, pressed = value
  124080. * 4) B / Y
  124081. * 5) thumb rest
  124082. * @param buttonIdx Which button index changed
  124083. * @param state New state of the button
  124084. * @param changes Which properties on the state changed since last frame
  124085. */
  124086. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  124087. }
  124088. }
  124089. declare module BABYLON {
  124090. /**
  124091. * Vive Controller
  124092. */
  124093. export class ViveController extends WebVRController {
  124094. /**
  124095. * Base Url for the controller model.
  124096. */
  124097. static MODEL_BASE_URL: string;
  124098. /**
  124099. * File name for the controller model.
  124100. */
  124101. static MODEL_FILENAME: string;
  124102. /**
  124103. * Creates a new ViveController from a gamepad
  124104. * @param vrGamepad the gamepad that the controller should be created from
  124105. */
  124106. constructor(vrGamepad: any);
  124107. /**
  124108. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  124109. * @param scene scene in which to add meshes
  124110. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  124111. */
  124112. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  124113. /**
  124114. * Fired when the left button on this controller is modified
  124115. */
  124116. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  124117. /**
  124118. * Fired when the right button on this controller is modified
  124119. */
  124120. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  124121. /**
  124122. * Fired when the menu button on this controller is modified
  124123. */
  124124. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  124125. /**
  124126. * Called once for each button that changed state since the last frame
  124127. * Vive mapping:
  124128. * 0: touchpad
  124129. * 1: trigger
  124130. * 2: left AND right buttons
  124131. * 3: menu button
  124132. * @param buttonIdx Which button index changed
  124133. * @param state New state of the button
  124134. * @param changes Which properties on the state changed since last frame
  124135. */
  124136. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  124137. }
  124138. }
  124139. declare module BABYLON {
  124140. /**
  124141. * Defines the WindowsMotionController object that the state of the windows motion controller
  124142. */
  124143. export class WindowsMotionController extends WebVRController {
  124144. /**
  124145. * The base url used to load the left and right controller models
  124146. */
  124147. static MODEL_BASE_URL: string;
  124148. /**
  124149. * The name of the left controller model file
  124150. */
  124151. static MODEL_LEFT_FILENAME: string;
  124152. /**
  124153. * The name of the right controller model file
  124154. */
  124155. static MODEL_RIGHT_FILENAME: string;
  124156. /**
  124157. * The controller name prefix for this controller type
  124158. */
  124159. static readonly GAMEPAD_ID_PREFIX: string;
  124160. /**
  124161. * The controller id pattern for this controller type
  124162. */
  124163. private static readonly GAMEPAD_ID_PATTERN;
  124164. private _loadedMeshInfo;
  124165. protected readonly _mapping: {
  124166. buttons: string[];
  124167. buttonMeshNames: {
  124168. trigger: string;
  124169. menu: string;
  124170. grip: string;
  124171. thumbstick: string;
  124172. trackpad: string;
  124173. };
  124174. buttonObservableNames: {
  124175. trigger: string;
  124176. menu: string;
  124177. grip: string;
  124178. thumbstick: string;
  124179. trackpad: string;
  124180. };
  124181. axisMeshNames: string[];
  124182. pointingPoseMeshName: string;
  124183. };
  124184. /**
  124185. * Fired when the trackpad on this controller is clicked
  124186. */
  124187. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  124188. /**
  124189. * Fired when the trackpad on this controller is modified
  124190. */
  124191. onTrackpadValuesChangedObservable: Observable<StickValues>;
  124192. /**
  124193. * The current x and y values of this controller's trackpad
  124194. */
  124195. trackpad: StickValues;
  124196. /**
  124197. * Creates a new WindowsMotionController from a gamepad
  124198. * @param vrGamepad the gamepad that the controller should be created from
  124199. */
  124200. constructor(vrGamepad: any);
  124201. /**
  124202. * Fired when the trigger on this controller is modified
  124203. */
  124204. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  124205. /**
  124206. * Fired when the menu button on this controller is modified
  124207. */
  124208. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  124209. /**
  124210. * Fired when the grip button on this controller is modified
  124211. */
  124212. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  124213. /**
  124214. * Fired when the thumbstick button on this controller is modified
  124215. */
  124216. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  124217. /**
  124218. * Fired when the touchpad button on this controller is modified
  124219. */
  124220. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  124221. /**
  124222. * Fired when the touchpad values on this controller are modified
  124223. */
  124224. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  124225. protected _updateTrackpad(): void;
  124226. /**
  124227. * Called once per frame by the engine.
  124228. */
  124229. update(): void;
  124230. /**
  124231. * Called once for each button that changed state since the last frame
  124232. * @param buttonIdx Which button index changed
  124233. * @param state New state of the button
  124234. * @param changes Which properties on the state changed since last frame
  124235. */
  124236. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  124237. /**
  124238. * Moves the buttons on the controller mesh based on their current state
  124239. * @param buttonName the name of the button to move
  124240. * @param buttonValue the value of the button which determines the buttons new position
  124241. */
  124242. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  124243. /**
  124244. * Moves the axis on the controller mesh based on its current state
  124245. * @param axis the index of the axis
  124246. * @param axisValue the value of the axis which determines the meshes new position
  124247. * @hidden
  124248. */
  124249. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  124250. /**
  124251. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  124252. * @param scene scene in which to add meshes
  124253. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  124254. */
  124255. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  124256. /**
  124257. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  124258. * can be transformed by button presses and axes values, based on this._mapping.
  124259. *
  124260. * @param scene scene in which the meshes exist
  124261. * @param meshes list of meshes that make up the controller model to process
  124262. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  124263. */
  124264. private processModel;
  124265. private createMeshInfo;
  124266. /**
  124267. * Gets the ray of the controller in the direction the controller is pointing
  124268. * @param length the length the resulting ray should be
  124269. * @returns a ray in the direction the controller is pointing
  124270. */
  124271. getForwardRay(length?: number): Ray;
  124272. /**
  124273. * Disposes of the controller
  124274. */
  124275. dispose(): void;
  124276. }
  124277. /**
  124278. * This class represents a new windows motion controller in XR.
  124279. */
  124280. export class XRWindowsMotionController extends WindowsMotionController {
  124281. /**
  124282. * Changing the original WIndowsMotionController mapping to fir the new mapping
  124283. */
  124284. protected readonly _mapping: {
  124285. buttons: string[];
  124286. buttonMeshNames: {
  124287. trigger: string;
  124288. menu: string;
  124289. grip: string;
  124290. thumbstick: string;
  124291. trackpad: string;
  124292. };
  124293. buttonObservableNames: {
  124294. trigger: string;
  124295. menu: string;
  124296. grip: string;
  124297. thumbstick: string;
  124298. trackpad: string;
  124299. };
  124300. axisMeshNames: string[];
  124301. pointingPoseMeshName: string;
  124302. };
  124303. /**
  124304. * Construct a new XR-Based windows motion controller
  124305. *
  124306. * @param gamepadInfo the gamepad object from the browser
  124307. */
  124308. constructor(gamepadInfo: any);
  124309. /**
  124310. * holds the thumbstick values (X,Y)
  124311. */
  124312. thumbstickValues: StickValues;
  124313. /**
  124314. * Fired when the thumbstick on this controller is clicked
  124315. */
  124316. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  124317. /**
  124318. * Fired when the thumbstick on this controller is modified
  124319. */
  124320. onThumbstickValuesChangedObservable: Observable<StickValues>;
  124321. /**
  124322. * Fired when the touchpad button on this controller is modified
  124323. */
  124324. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  124325. /**
  124326. * Fired when the touchpad values on this controller are modified
  124327. */
  124328. onTrackpadValuesChangedObservable: Observable<StickValues>;
  124329. /**
  124330. * Fired when the thumbstick button on this controller is modified
  124331. * here to prevent breaking changes
  124332. */
  124333. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  124334. /**
  124335. * updating the thumbstick(!) and not the trackpad.
  124336. * This is named this way due to the difference between WebVR and XR and to avoid
  124337. * changing the parent class.
  124338. */
  124339. protected _updateTrackpad(): void;
  124340. /**
  124341. * Disposes the class with joy
  124342. */
  124343. dispose(): void;
  124344. }
  124345. }
  124346. declare module BABYLON {
  124347. /**
  124348. * Class containing static functions to help procedurally build meshes
  124349. */
  124350. export class PolyhedronBuilder {
  124351. /**
  124352. * Creates a polyhedron mesh
  124353. * * 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
  124354. * * The parameter `size` (positive float, default 1) sets the polygon size
  124355. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  124356. * * 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`
  124357. * * 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
  124358. * * 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)`)
  124359. * * 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
  124360. * * 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
  124361. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  124362. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  124363. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  124364. * @param name defines the name of the mesh
  124365. * @param options defines the options used to create the mesh
  124366. * @param scene defines the hosting scene
  124367. * @returns the polyhedron mesh
  124368. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  124369. */
  124370. static CreatePolyhedron(name: string, options: {
  124371. type?: number;
  124372. size?: number;
  124373. sizeX?: number;
  124374. sizeY?: number;
  124375. sizeZ?: number;
  124376. custom?: any;
  124377. faceUV?: Vector4[];
  124378. faceColors?: Color4[];
  124379. flat?: boolean;
  124380. updatable?: boolean;
  124381. sideOrientation?: number;
  124382. frontUVs?: Vector4;
  124383. backUVs?: Vector4;
  124384. }, scene?: Nullable<Scene>): Mesh;
  124385. }
  124386. }
  124387. declare module BABYLON {
  124388. /**
  124389. * Gizmo that enables scaling a mesh along 3 axis
  124390. */
  124391. export class ScaleGizmo extends Gizmo {
  124392. /**
  124393. * Internal gizmo used for interactions on the x axis
  124394. */
  124395. xGizmo: AxisScaleGizmo;
  124396. /**
  124397. * Internal gizmo used for interactions on the y axis
  124398. */
  124399. yGizmo: AxisScaleGizmo;
  124400. /**
  124401. * Internal gizmo used for interactions on the z axis
  124402. */
  124403. zGizmo: AxisScaleGizmo;
  124404. /**
  124405. * Internal gizmo used to scale all axis equally
  124406. */
  124407. uniformScaleGizmo: AxisScaleGizmo;
  124408. private _meshAttached;
  124409. private _updateGizmoRotationToMatchAttachedMesh;
  124410. private _snapDistance;
  124411. private _scaleRatio;
  124412. private _uniformScalingMesh;
  124413. private _octahedron;
  124414. private _sensitivity;
  124415. /** Fires an event when any of it's sub gizmos are dragged */
  124416. onDragStartObservable: Observable<unknown>;
  124417. /** Fires an event when any of it's sub gizmos are released from dragging */
  124418. onDragEndObservable: Observable<unknown>;
  124419. get attachedMesh(): Nullable<AbstractMesh>;
  124420. set attachedMesh(mesh: Nullable<AbstractMesh>);
  124421. /**
  124422. * Creates a ScaleGizmo
  124423. * @param gizmoLayer The utility layer the gizmo will be added to
  124424. */
  124425. constructor(gizmoLayer?: UtilityLayerRenderer);
  124426. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  124427. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  124428. /**
  124429. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  124430. */
  124431. set snapDistance(value: number);
  124432. get snapDistance(): number;
  124433. /**
  124434. * Ratio for the scale of the gizmo (Default: 1)
  124435. */
  124436. set scaleRatio(value: number);
  124437. get scaleRatio(): number;
  124438. /**
  124439. * Sensitivity factor for dragging (Default: 1)
  124440. */
  124441. set sensitivity(value: number);
  124442. get sensitivity(): number;
  124443. /**
  124444. * Disposes of the gizmo
  124445. */
  124446. dispose(): void;
  124447. }
  124448. }
  124449. declare module BABYLON {
  124450. /**
  124451. * Single axis scale gizmo
  124452. */
  124453. export class AxisScaleGizmo extends Gizmo {
  124454. /**
  124455. * Drag behavior responsible for the gizmos dragging interactions
  124456. */
  124457. dragBehavior: PointerDragBehavior;
  124458. private _pointerObserver;
  124459. /**
  124460. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  124461. */
  124462. snapDistance: number;
  124463. /**
  124464. * Event that fires each time the gizmo snaps to a new location.
  124465. * * snapDistance is the the change in distance
  124466. */
  124467. onSnapObservable: Observable<{
  124468. snapDistance: number;
  124469. }>;
  124470. /**
  124471. * If the scaling operation should be done on all axis (default: false)
  124472. */
  124473. uniformScaling: boolean;
  124474. /**
  124475. * Custom sensitivity value for the drag strength
  124476. */
  124477. sensitivity: number;
  124478. private _isEnabled;
  124479. private _parent;
  124480. private _arrow;
  124481. private _coloredMaterial;
  124482. private _hoverMaterial;
  124483. /**
  124484. * Creates an AxisScaleGizmo
  124485. * @param gizmoLayer The utility layer the gizmo will be added to
  124486. * @param dragAxis The axis which the gizmo will be able to scale on
  124487. * @param color The color of the gizmo
  124488. */
  124489. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  124490. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  124491. /**
  124492. * If the gizmo is enabled
  124493. */
  124494. set isEnabled(value: boolean);
  124495. get isEnabled(): boolean;
  124496. /**
  124497. * Disposes of the gizmo
  124498. */
  124499. dispose(): void;
  124500. /**
  124501. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  124502. * @param mesh The mesh to replace the default mesh of the gizmo
  124503. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  124504. */
  124505. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  124506. }
  124507. }
  124508. declare module BABYLON {
  124509. /**
  124510. * Bounding box gizmo
  124511. */
  124512. export class BoundingBoxGizmo extends Gizmo {
  124513. private _lineBoundingBox;
  124514. private _rotateSpheresParent;
  124515. private _scaleBoxesParent;
  124516. private _boundingDimensions;
  124517. private _renderObserver;
  124518. private _pointerObserver;
  124519. private _scaleDragSpeed;
  124520. private _tmpQuaternion;
  124521. private _tmpVector;
  124522. private _tmpRotationMatrix;
  124523. /**
  124524. * 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)
  124525. */
  124526. ignoreChildren: boolean;
  124527. /**
  124528. * 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)
  124529. */
  124530. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  124531. /**
  124532. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  124533. */
  124534. rotationSphereSize: number;
  124535. /**
  124536. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  124537. */
  124538. scaleBoxSize: number;
  124539. /**
  124540. * 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)
  124541. */
  124542. fixedDragMeshScreenSize: boolean;
  124543. /**
  124544. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  124545. */
  124546. fixedDragMeshScreenSizeDistanceFactor: number;
  124547. /**
  124548. * Fired when a rotation sphere or scale box is dragged
  124549. */
  124550. onDragStartObservable: Observable<{}>;
  124551. /**
  124552. * Fired when a scale box is dragged
  124553. */
  124554. onScaleBoxDragObservable: Observable<{}>;
  124555. /**
  124556. * Fired when a scale box drag is ended
  124557. */
  124558. onScaleBoxDragEndObservable: Observable<{}>;
  124559. /**
  124560. * Fired when a rotation sphere is dragged
  124561. */
  124562. onRotationSphereDragObservable: Observable<{}>;
  124563. /**
  124564. * Fired when a rotation sphere drag is ended
  124565. */
  124566. onRotationSphereDragEndObservable: Observable<{}>;
  124567. /**
  124568. * 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)
  124569. */
  124570. scalePivot: Nullable<Vector3>;
  124571. /**
  124572. * Mesh used as a pivot to rotate the attached mesh
  124573. */
  124574. private _anchorMesh;
  124575. private _existingMeshScale;
  124576. private _dragMesh;
  124577. private pointerDragBehavior;
  124578. private coloredMaterial;
  124579. private hoverColoredMaterial;
  124580. /**
  124581. * Sets the color of the bounding box gizmo
  124582. * @param color the color to set
  124583. */
  124584. setColor(color: Color3): void;
  124585. /**
  124586. * Creates an BoundingBoxGizmo
  124587. * @param gizmoLayer The utility layer the gizmo will be added to
  124588. * @param color The color of the gizmo
  124589. */
  124590. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  124591. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  124592. private _selectNode;
  124593. /**
  124594. * Updates the bounding box information for the Gizmo
  124595. */
  124596. updateBoundingBox(): void;
  124597. private _updateRotationSpheres;
  124598. private _updateScaleBoxes;
  124599. /**
  124600. * Enables rotation on the specified axis and disables rotation on the others
  124601. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  124602. */
  124603. setEnabledRotationAxis(axis: string): void;
  124604. /**
  124605. * Enables/disables scaling
  124606. * @param enable if scaling should be enabled
  124607. * @param homogeneousScaling defines if scaling should only be homogeneous
  124608. */
  124609. setEnabledScaling(enable: boolean, homogeneousScaling?: boolean): void;
  124610. private _updateDummy;
  124611. /**
  124612. * Enables a pointer drag behavior on the bounding box of the gizmo
  124613. */
  124614. enableDragBehavior(): void;
  124615. /**
  124616. * Disposes of the gizmo
  124617. */
  124618. dispose(): void;
  124619. /**
  124620. * 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)
  124621. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  124622. * @returns the bounding box mesh with the passed in mesh as a child
  124623. */
  124624. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  124625. /**
  124626. * CustomMeshes are not supported by this gizmo
  124627. * @param mesh The mesh to replace the default mesh of the gizmo
  124628. */
  124629. setCustomMesh(mesh: Mesh): void;
  124630. }
  124631. }
  124632. declare module BABYLON {
  124633. /**
  124634. * Single plane rotation gizmo
  124635. */
  124636. export class PlaneRotationGizmo extends Gizmo {
  124637. /**
  124638. * Drag behavior responsible for the gizmos dragging interactions
  124639. */
  124640. dragBehavior: PointerDragBehavior;
  124641. private _pointerObserver;
  124642. /**
  124643. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  124644. */
  124645. snapDistance: number;
  124646. /**
  124647. * Event that fires each time the gizmo snaps to a new location.
  124648. * * snapDistance is the the change in distance
  124649. */
  124650. onSnapObservable: Observable<{
  124651. snapDistance: number;
  124652. }>;
  124653. private _isEnabled;
  124654. private _parent;
  124655. /**
  124656. * Creates a PlaneRotationGizmo
  124657. * @param gizmoLayer The utility layer the gizmo will be added to
  124658. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  124659. * @param color The color of the gizmo
  124660. * @param tessellation Amount of tessellation to be used when creating rotation circles
  124661. * @param useEulerRotation Use and update Euler angle instead of quaternion
  124662. */
  124663. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  124664. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  124665. /**
  124666. * If the gizmo is enabled
  124667. */
  124668. set isEnabled(value: boolean);
  124669. get isEnabled(): boolean;
  124670. /**
  124671. * Disposes of the gizmo
  124672. */
  124673. dispose(): void;
  124674. }
  124675. }
  124676. declare module BABYLON {
  124677. /**
  124678. * Gizmo that enables rotating a mesh along 3 axis
  124679. */
  124680. export class RotationGizmo extends Gizmo {
  124681. /**
  124682. * Internal gizmo used for interactions on the x axis
  124683. */
  124684. xGizmo: PlaneRotationGizmo;
  124685. /**
  124686. * Internal gizmo used for interactions on the y axis
  124687. */
  124688. yGizmo: PlaneRotationGizmo;
  124689. /**
  124690. * Internal gizmo used for interactions on the z axis
  124691. */
  124692. zGizmo: PlaneRotationGizmo;
  124693. /** Fires an event when any of it's sub gizmos are dragged */
  124694. onDragStartObservable: Observable<unknown>;
  124695. /** Fires an event when any of it's sub gizmos are released from dragging */
  124696. onDragEndObservable: Observable<unknown>;
  124697. private _meshAttached;
  124698. get attachedMesh(): Nullable<AbstractMesh>;
  124699. set attachedMesh(mesh: Nullable<AbstractMesh>);
  124700. /**
  124701. * Creates a RotationGizmo
  124702. * @param gizmoLayer The utility layer the gizmo will be added to
  124703. * @param tessellation Amount of tessellation to be used when creating rotation circles
  124704. * @param useEulerRotation Use and update Euler angle instead of quaternion
  124705. */
  124706. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  124707. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  124708. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  124709. /**
  124710. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  124711. */
  124712. set snapDistance(value: number);
  124713. get snapDistance(): number;
  124714. /**
  124715. * Ratio for the scale of the gizmo (Default: 1)
  124716. */
  124717. set scaleRatio(value: number);
  124718. get scaleRatio(): number;
  124719. /**
  124720. * Disposes of the gizmo
  124721. */
  124722. dispose(): void;
  124723. /**
  124724. * CustomMeshes are not supported by this gizmo
  124725. * @param mesh The mesh to replace the default mesh of the gizmo
  124726. */
  124727. setCustomMesh(mesh: Mesh): void;
  124728. }
  124729. }
  124730. declare module BABYLON {
  124731. /**
  124732. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  124733. */
  124734. export class GizmoManager implements IDisposable {
  124735. private scene;
  124736. /**
  124737. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  124738. */
  124739. gizmos: {
  124740. positionGizmo: Nullable<PositionGizmo>;
  124741. rotationGizmo: Nullable<RotationGizmo>;
  124742. scaleGizmo: Nullable<ScaleGizmo>;
  124743. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  124744. };
  124745. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  124746. clearGizmoOnEmptyPointerEvent: boolean;
  124747. /** Fires an event when the manager is attached to a mesh */
  124748. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  124749. private _gizmosEnabled;
  124750. private _pointerObserver;
  124751. private _attachedMesh;
  124752. private _boundingBoxColor;
  124753. private _defaultUtilityLayer;
  124754. private _defaultKeepDepthUtilityLayer;
  124755. /**
  124756. * When bounding box gizmo is enabled, this can be used to track drag/end events
  124757. */
  124758. boundingBoxDragBehavior: SixDofDragBehavior;
  124759. /**
  124760. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  124761. */
  124762. attachableMeshes: Nullable<Array<AbstractMesh>>;
  124763. /**
  124764. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  124765. */
  124766. usePointerToAttachGizmos: boolean;
  124767. /**
  124768. * Utility layer that the bounding box gizmo belongs to
  124769. */
  124770. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  124771. /**
  124772. * Utility layer that all gizmos besides bounding box belong to
  124773. */
  124774. get utilityLayer(): UtilityLayerRenderer;
  124775. /**
  124776. * Instatiates a gizmo manager
  124777. * @param scene the scene to overlay the gizmos on top of
  124778. */
  124779. constructor(scene: Scene);
  124780. /**
  124781. * Attaches a set of gizmos to the specified mesh
  124782. * @param mesh The mesh the gizmo's should be attached to
  124783. */
  124784. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  124785. /**
  124786. * If the position gizmo is enabled
  124787. */
  124788. set positionGizmoEnabled(value: boolean);
  124789. get positionGizmoEnabled(): boolean;
  124790. /**
  124791. * If the rotation gizmo is enabled
  124792. */
  124793. set rotationGizmoEnabled(value: boolean);
  124794. get rotationGizmoEnabled(): boolean;
  124795. /**
  124796. * If the scale gizmo is enabled
  124797. */
  124798. set scaleGizmoEnabled(value: boolean);
  124799. get scaleGizmoEnabled(): boolean;
  124800. /**
  124801. * If the boundingBox gizmo is enabled
  124802. */
  124803. set boundingBoxGizmoEnabled(value: boolean);
  124804. get boundingBoxGizmoEnabled(): boolean;
  124805. /**
  124806. * Disposes of the gizmo manager
  124807. */
  124808. dispose(): void;
  124809. }
  124810. }
  124811. declare module BABYLON {
  124812. /**
  124813. * A directional light is defined by a direction (what a surprise!).
  124814. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  124815. * 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.
  124816. * Documentation: https://doc.babylonjs.com/babylon101/lights
  124817. */
  124818. export class DirectionalLight extends ShadowLight {
  124819. private _shadowFrustumSize;
  124820. /**
  124821. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  124822. */
  124823. get shadowFrustumSize(): number;
  124824. /**
  124825. * Specifies a fix frustum size for the shadow generation.
  124826. */
  124827. set shadowFrustumSize(value: number);
  124828. private _shadowOrthoScale;
  124829. /**
  124830. * Gets the shadow projection scale against the optimal computed one.
  124831. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  124832. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  124833. */
  124834. get shadowOrthoScale(): number;
  124835. /**
  124836. * Sets the shadow projection scale against the optimal computed one.
  124837. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  124838. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  124839. */
  124840. set shadowOrthoScale(value: number);
  124841. /**
  124842. * Automatically compute the projection matrix to best fit (including all the casters)
  124843. * on each frame.
  124844. */
  124845. autoUpdateExtends: boolean;
  124846. /**
  124847. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  124848. * on each frame. autoUpdateExtends must be set to true for this to work
  124849. */
  124850. autoCalcShadowZBounds: boolean;
  124851. private _orthoLeft;
  124852. private _orthoRight;
  124853. private _orthoTop;
  124854. private _orthoBottom;
  124855. /**
  124856. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  124857. * The directional light is emitted from everywhere in the given direction.
  124858. * It can cast shadows.
  124859. * Documentation : https://doc.babylonjs.com/babylon101/lights
  124860. * @param name The friendly name of the light
  124861. * @param direction The direction of the light
  124862. * @param scene The scene the light belongs to
  124863. */
  124864. constructor(name: string, direction: Vector3, scene: Scene);
  124865. /**
  124866. * Returns the string "DirectionalLight".
  124867. * @return The class name
  124868. */
  124869. getClassName(): string;
  124870. /**
  124871. * Returns the integer 1.
  124872. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  124873. */
  124874. getTypeID(): number;
  124875. /**
  124876. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  124877. * Returns the DirectionalLight Shadow projection matrix.
  124878. */
  124879. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  124880. /**
  124881. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  124882. * Returns the DirectionalLight Shadow projection matrix.
  124883. */
  124884. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  124885. /**
  124886. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  124887. * Returns the DirectionalLight Shadow projection matrix.
  124888. */
  124889. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  124890. protected _buildUniformLayout(): void;
  124891. /**
  124892. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  124893. * @param effect The effect to update
  124894. * @param lightIndex The index of the light in the effect to update
  124895. * @returns The directional light
  124896. */
  124897. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  124898. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  124899. /**
  124900. * Gets the minZ used for shadow according to both the scene and the light.
  124901. *
  124902. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  124903. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  124904. * @param activeCamera The camera we are returning the min for
  124905. * @returns the depth min z
  124906. */
  124907. getDepthMinZ(activeCamera: Camera): number;
  124908. /**
  124909. * Gets the maxZ used for shadow according to both the scene and the light.
  124910. *
  124911. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  124912. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  124913. * @param activeCamera The camera we are returning the max for
  124914. * @returns the depth max z
  124915. */
  124916. getDepthMaxZ(activeCamera: Camera): number;
  124917. /**
  124918. * Prepares the list of defines specific to the light type.
  124919. * @param defines the list of defines
  124920. * @param lightIndex defines the index of the light for the effect
  124921. */
  124922. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  124923. }
  124924. }
  124925. declare module BABYLON {
  124926. /**
  124927. * Class containing static functions to help procedurally build meshes
  124928. */
  124929. export class HemisphereBuilder {
  124930. /**
  124931. * Creates a hemisphere mesh
  124932. * @param name defines the name of the mesh
  124933. * @param options defines the options used to create the mesh
  124934. * @param scene defines the hosting scene
  124935. * @returns the hemisphere mesh
  124936. */
  124937. static CreateHemisphere(name: string, options: {
  124938. segments?: number;
  124939. diameter?: number;
  124940. sideOrientation?: number;
  124941. }, scene: any): Mesh;
  124942. }
  124943. }
  124944. declare module BABYLON {
  124945. /**
  124946. * A spot light is defined by a position, a direction, an angle, and an exponent.
  124947. * These values define a cone of light starting from the position, emitting toward the direction.
  124948. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  124949. * and the exponent defines the speed of the decay of the light with distance (reach).
  124950. * Documentation: https://doc.babylonjs.com/babylon101/lights
  124951. */
  124952. export class SpotLight extends ShadowLight {
  124953. private _angle;
  124954. private _innerAngle;
  124955. private _cosHalfAngle;
  124956. private _lightAngleScale;
  124957. private _lightAngleOffset;
  124958. /**
  124959. * Gets the cone angle of the spot light in Radians.
  124960. */
  124961. get angle(): number;
  124962. /**
  124963. * Sets the cone angle of the spot light in Radians.
  124964. */
  124965. set angle(value: number);
  124966. /**
  124967. * Only used in gltf falloff mode, this defines the angle where
  124968. * the directional falloff will start before cutting at angle which could be seen
  124969. * as outer angle.
  124970. */
  124971. get innerAngle(): number;
  124972. /**
  124973. * Only used in gltf falloff mode, this defines the angle where
  124974. * the directional falloff will start before cutting at angle which could be seen
  124975. * as outer angle.
  124976. */
  124977. set innerAngle(value: number);
  124978. private _shadowAngleScale;
  124979. /**
  124980. * Allows scaling the angle of the light for shadow generation only.
  124981. */
  124982. get shadowAngleScale(): number;
  124983. /**
  124984. * Allows scaling the angle of the light for shadow generation only.
  124985. */
  124986. set shadowAngleScale(value: number);
  124987. /**
  124988. * The light decay speed with the distance from the emission spot.
  124989. */
  124990. exponent: number;
  124991. private _projectionTextureMatrix;
  124992. /**
  124993. * Allows reading the projecton texture
  124994. */
  124995. get projectionTextureMatrix(): Matrix;
  124996. protected _projectionTextureLightNear: number;
  124997. /**
  124998. * Gets the near clip of the Spotlight for texture projection.
  124999. */
  125000. get projectionTextureLightNear(): number;
  125001. /**
  125002. * Sets the near clip of the Spotlight for texture projection.
  125003. */
  125004. set projectionTextureLightNear(value: number);
  125005. protected _projectionTextureLightFar: number;
  125006. /**
  125007. * Gets the far clip of the Spotlight for texture projection.
  125008. */
  125009. get projectionTextureLightFar(): number;
  125010. /**
  125011. * Sets the far clip of the Spotlight for texture projection.
  125012. */
  125013. set projectionTextureLightFar(value: number);
  125014. protected _projectionTextureUpDirection: Vector3;
  125015. /**
  125016. * Gets the Up vector of the Spotlight for texture projection.
  125017. */
  125018. get projectionTextureUpDirection(): Vector3;
  125019. /**
  125020. * Sets the Up vector of the Spotlight for texture projection.
  125021. */
  125022. set projectionTextureUpDirection(value: Vector3);
  125023. private _projectionTexture;
  125024. /**
  125025. * Gets the projection texture of the light.
  125026. */
  125027. get projectionTexture(): Nullable<BaseTexture>;
  125028. /**
  125029. * Sets the projection texture of the light.
  125030. */
  125031. set projectionTexture(value: Nullable<BaseTexture>);
  125032. private _projectionTextureViewLightDirty;
  125033. private _projectionTextureProjectionLightDirty;
  125034. private _projectionTextureDirty;
  125035. private _projectionTextureViewTargetVector;
  125036. private _projectionTextureViewLightMatrix;
  125037. private _projectionTextureProjectionLightMatrix;
  125038. private _projectionTextureScalingMatrix;
  125039. /**
  125040. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  125041. * It can cast shadows.
  125042. * Documentation : https://doc.babylonjs.com/babylon101/lights
  125043. * @param name The light friendly name
  125044. * @param position The position of the spot light in the scene
  125045. * @param direction The direction of the light in the scene
  125046. * @param angle The cone angle of the light in Radians
  125047. * @param exponent The light decay speed with the distance from the emission spot
  125048. * @param scene The scene the lights belongs to
  125049. */
  125050. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  125051. /**
  125052. * Returns the string "SpotLight".
  125053. * @returns the class name
  125054. */
  125055. getClassName(): string;
  125056. /**
  125057. * Returns the integer 2.
  125058. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  125059. */
  125060. getTypeID(): number;
  125061. /**
  125062. * Overrides the direction setter to recompute the projection texture view light Matrix.
  125063. */
  125064. protected _setDirection(value: Vector3): void;
  125065. /**
  125066. * Overrides the position setter to recompute the projection texture view light Matrix.
  125067. */
  125068. protected _setPosition(value: Vector3): void;
  125069. /**
  125070. * 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.
  125071. * Returns the SpotLight.
  125072. */
  125073. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  125074. protected _computeProjectionTextureViewLightMatrix(): void;
  125075. protected _computeProjectionTextureProjectionLightMatrix(): void;
  125076. /**
  125077. * Main function for light texture projection matrix computing.
  125078. */
  125079. protected _computeProjectionTextureMatrix(): void;
  125080. protected _buildUniformLayout(): void;
  125081. private _computeAngleValues;
  125082. /**
  125083. * Sets the passed Effect "effect" with the Light textures.
  125084. * @param effect The effect to update
  125085. * @param lightIndex The index of the light in the effect to update
  125086. * @returns The light
  125087. */
  125088. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  125089. /**
  125090. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  125091. * @param effect The effect to update
  125092. * @param lightIndex The index of the light in the effect to update
  125093. * @returns The spot light
  125094. */
  125095. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  125096. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  125097. /**
  125098. * Disposes the light and the associated resources.
  125099. */
  125100. dispose(): void;
  125101. /**
  125102. * Prepares the list of defines specific to the light type.
  125103. * @param defines the list of defines
  125104. * @param lightIndex defines the index of the light for the effect
  125105. */
  125106. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  125107. }
  125108. }
  125109. declare module BABYLON {
  125110. /**
  125111. * Gizmo that enables viewing a light
  125112. */
  125113. export class LightGizmo extends Gizmo {
  125114. private _lightMesh;
  125115. private _material;
  125116. private _cachedPosition;
  125117. private _cachedForward;
  125118. private _attachedMeshParent;
  125119. /**
  125120. * Creates a LightGizmo
  125121. * @param gizmoLayer The utility layer the gizmo will be added to
  125122. */
  125123. constructor(gizmoLayer?: UtilityLayerRenderer);
  125124. private _light;
  125125. /**
  125126. * The light that the gizmo is attached to
  125127. */
  125128. set light(light: Nullable<Light>);
  125129. get light(): Nullable<Light>;
  125130. /**
  125131. * Gets the material used to render the light gizmo
  125132. */
  125133. get material(): StandardMaterial;
  125134. /**
  125135. * @hidden
  125136. * Updates the gizmo to match the attached mesh's position/rotation
  125137. */
  125138. protected _update(): void;
  125139. private static _Scale;
  125140. /**
  125141. * Creates the lines for a light mesh
  125142. */
  125143. private static _CreateLightLines;
  125144. /**
  125145. * Disposes of the light gizmo
  125146. */
  125147. dispose(): void;
  125148. private static _CreateHemisphericLightMesh;
  125149. private static _CreatePointLightMesh;
  125150. private static _CreateSpotLightMesh;
  125151. private static _CreateDirectionalLightMesh;
  125152. }
  125153. }
  125154. declare module BABYLON {
  125155. /** @hidden */
  125156. export var backgroundFragmentDeclaration: {
  125157. name: string;
  125158. shader: string;
  125159. };
  125160. }
  125161. declare module BABYLON {
  125162. /** @hidden */
  125163. export var backgroundUboDeclaration: {
  125164. name: string;
  125165. shader: string;
  125166. };
  125167. }
  125168. declare module BABYLON {
  125169. /** @hidden */
  125170. export var backgroundPixelShader: {
  125171. name: string;
  125172. shader: string;
  125173. };
  125174. }
  125175. declare module BABYLON {
  125176. /** @hidden */
  125177. export var backgroundVertexDeclaration: {
  125178. name: string;
  125179. shader: string;
  125180. };
  125181. }
  125182. declare module BABYLON {
  125183. /** @hidden */
  125184. export var backgroundVertexShader: {
  125185. name: string;
  125186. shader: string;
  125187. };
  125188. }
  125189. declare module BABYLON {
  125190. /**
  125191. * Background material used to create an efficient environement around your scene.
  125192. */
  125193. export class BackgroundMaterial extends PushMaterial {
  125194. /**
  125195. * Standard reflectance value at parallel view angle.
  125196. */
  125197. static StandardReflectance0: number;
  125198. /**
  125199. * Standard reflectance value at grazing angle.
  125200. */
  125201. static StandardReflectance90: number;
  125202. protected _primaryColor: Color3;
  125203. /**
  125204. * Key light Color (multiply against the environement texture)
  125205. */
  125206. primaryColor: Color3;
  125207. protected __perceptualColor: Nullable<Color3>;
  125208. /**
  125209. * Experimental Internal Use Only.
  125210. *
  125211. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  125212. * This acts as a helper to set the primary color to a more "human friendly" value.
  125213. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  125214. * output color as close as possible from the chosen value.
  125215. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  125216. * part of lighting setup.)
  125217. */
  125218. get _perceptualColor(): Nullable<Color3>;
  125219. set _perceptualColor(value: Nullable<Color3>);
  125220. protected _primaryColorShadowLevel: float;
  125221. /**
  125222. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  125223. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  125224. */
  125225. get primaryColorShadowLevel(): float;
  125226. set primaryColorShadowLevel(value: float);
  125227. protected _primaryColorHighlightLevel: float;
  125228. /**
  125229. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  125230. * The primary color is used at the level chosen to define what the white area would look.
  125231. */
  125232. get primaryColorHighlightLevel(): float;
  125233. set primaryColorHighlightLevel(value: float);
  125234. protected _reflectionTexture: Nullable<BaseTexture>;
  125235. /**
  125236. * Reflection Texture used in the material.
  125237. * Should be author in a specific way for the best result (refer to the documentation).
  125238. */
  125239. reflectionTexture: Nullable<BaseTexture>;
  125240. protected _reflectionBlur: float;
  125241. /**
  125242. * Reflection Texture level of blur.
  125243. *
  125244. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  125245. * texture twice.
  125246. */
  125247. reflectionBlur: float;
  125248. protected _diffuseTexture: Nullable<BaseTexture>;
  125249. /**
  125250. * Diffuse Texture used in the material.
  125251. * Should be author in a specific way for the best result (refer to the documentation).
  125252. */
  125253. diffuseTexture: Nullable<BaseTexture>;
  125254. protected _shadowLights: Nullable<IShadowLight[]>;
  125255. /**
  125256. * Specify the list of lights casting shadow on the material.
  125257. * All scene shadow lights will be included if null.
  125258. */
  125259. shadowLights: Nullable<IShadowLight[]>;
  125260. protected _shadowLevel: float;
  125261. /**
  125262. * Helps adjusting the shadow to a softer level if required.
  125263. * 0 means black shadows and 1 means no shadows.
  125264. */
  125265. shadowLevel: float;
  125266. protected _sceneCenter: Vector3;
  125267. /**
  125268. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  125269. * It is usually zero but might be interesting to modify according to your setup.
  125270. */
  125271. sceneCenter: Vector3;
  125272. protected _opacityFresnel: boolean;
  125273. /**
  125274. * This helps specifying that the material is falling off to the sky box at grazing angle.
  125275. * This helps ensuring a nice transition when the camera goes under the ground.
  125276. */
  125277. opacityFresnel: boolean;
  125278. protected _reflectionFresnel: boolean;
  125279. /**
  125280. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  125281. * This helps adding a mirror texture on the ground.
  125282. */
  125283. reflectionFresnel: boolean;
  125284. protected _reflectionFalloffDistance: number;
  125285. /**
  125286. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  125287. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  125288. */
  125289. reflectionFalloffDistance: number;
  125290. protected _reflectionAmount: number;
  125291. /**
  125292. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  125293. */
  125294. reflectionAmount: number;
  125295. protected _reflectionReflectance0: number;
  125296. /**
  125297. * This specifies the weight of the reflection at grazing angle.
  125298. */
  125299. reflectionReflectance0: number;
  125300. protected _reflectionReflectance90: number;
  125301. /**
  125302. * This specifies the weight of the reflection at a perpendicular point of view.
  125303. */
  125304. reflectionReflectance90: number;
  125305. /**
  125306. * Sets the reflection reflectance fresnel values according to the default standard
  125307. * empirically know to work well :-)
  125308. */
  125309. set reflectionStandardFresnelWeight(value: number);
  125310. protected _useRGBColor: boolean;
  125311. /**
  125312. * Helps to directly use the maps channels instead of their level.
  125313. */
  125314. useRGBColor: boolean;
  125315. protected _enableNoise: boolean;
  125316. /**
  125317. * This helps reducing the banding effect that could occur on the background.
  125318. */
  125319. enableNoise: boolean;
  125320. /**
  125321. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  125322. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  125323. * Recommended to be keep at 1.0 except for special cases.
  125324. */
  125325. get fovMultiplier(): number;
  125326. set fovMultiplier(value: number);
  125327. private _fovMultiplier;
  125328. /**
  125329. * Enable the FOV adjustment feature controlled by fovMultiplier.
  125330. */
  125331. useEquirectangularFOV: boolean;
  125332. private _maxSimultaneousLights;
  125333. /**
  125334. * Number of Simultaneous lights allowed on the material.
  125335. */
  125336. maxSimultaneousLights: int;
  125337. /**
  125338. * Default configuration related to image processing available in the Background Material.
  125339. */
  125340. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  125341. /**
  125342. * Keep track of the image processing observer to allow dispose and replace.
  125343. */
  125344. private _imageProcessingObserver;
  125345. /**
  125346. * Attaches a new image processing configuration to the PBR Material.
  125347. * @param configuration (if null the scene configuration will be use)
  125348. */
  125349. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  125350. /**
  125351. * Gets the image processing configuration used either in this material.
  125352. */
  125353. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  125354. /**
  125355. * Sets the Default image processing configuration used either in the this material.
  125356. *
  125357. * If sets to null, the scene one is in use.
  125358. */
  125359. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  125360. /**
  125361. * Gets wether the color curves effect is enabled.
  125362. */
  125363. get cameraColorCurvesEnabled(): boolean;
  125364. /**
  125365. * Sets wether the color curves effect is enabled.
  125366. */
  125367. set cameraColorCurvesEnabled(value: boolean);
  125368. /**
  125369. * Gets wether the color grading effect is enabled.
  125370. */
  125371. get cameraColorGradingEnabled(): boolean;
  125372. /**
  125373. * Gets wether the color grading effect is enabled.
  125374. */
  125375. set cameraColorGradingEnabled(value: boolean);
  125376. /**
  125377. * Gets wether tonemapping is enabled or not.
  125378. */
  125379. get cameraToneMappingEnabled(): boolean;
  125380. /**
  125381. * Sets wether tonemapping is enabled or not
  125382. */
  125383. set cameraToneMappingEnabled(value: boolean);
  125384. /**
  125385. * The camera exposure used on this material.
  125386. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  125387. * This corresponds to a photographic exposure.
  125388. */
  125389. get cameraExposure(): float;
  125390. /**
  125391. * The camera exposure used on this material.
  125392. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  125393. * This corresponds to a photographic exposure.
  125394. */
  125395. set cameraExposure(value: float);
  125396. /**
  125397. * Gets The camera contrast used on this material.
  125398. */
  125399. get cameraContrast(): float;
  125400. /**
  125401. * Sets The camera contrast used on this material.
  125402. */
  125403. set cameraContrast(value: float);
  125404. /**
  125405. * Gets the Color Grading 2D Lookup Texture.
  125406. */
  125407. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  125408. /**
  125409. * Sets the Color Grading 2D Lookup Texture.
  125410. */
  125411. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  125412. /**
  125413. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  125414. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  125415. * 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;
  125416. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  125417. */
  125418. get cameraColorCurves(): Nullable<ColorCurves>;
  125419. /**
  125420. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  125421. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  125422. * 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;
  125423. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  125424. */
  125425. set cameraColorCurves(value: Nullable<ColorCurves>);
  125426. /**
  125427. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  125428. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  125429. */
  125430. switchToBGR: boolean;
  125431. private _renderTargets;
  125432. private _reflectionControls;
  125433. private _white;
  125434. private _primaryShadowColor;
  125435. private _primaryHighlightColor;
  125436. /**
  125437. * Instantiates a Background Material in the given scene
  125438. * @param name The friendly name of the material
  125439. * @param scene The scene to add the material to
  125440. */
  125441. constructor(name: string, scene: Scene);
  125442. /**
  125443. * Gets a boolean indicating that current material needs to register RTT
  125444. */
  125445. get hasRenderTargetTextures(): boolean;
  125446. /**
  125447. * The entire material has been created in order to prevent overdraw.
  125448. * @returns false
  125449. */
  125450. needAlphaTesting(): boolean;
  125451. /**
  125452. * The entire material has been created in order to prevent overdraw.
  125453. * @returns true if blending is enable
  125454. */
  125455. needAlphaBlending(): boolean;
  125456. /**
  125457. * Checks wether the material is ready to be rendered for a given mesh.
  125458. * @param mesh The mesh to render
  125459. * @param subMesh The submesh to check against
  125460. * @param useInstances Specify wether or not the material is used with instances
  125461. * @returns true if all the dependencies are ready (Textures, Effects...)
  125462. */
  125463. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  125464. /**
  125465. * Compute the primary color according to the chosen perceptual color.
  125466. */
  125467. private _computePrimaryColorFromPerceptualColor;
  125468. /**
  125469. * Compute the highlights and shadow colors according to their chosen levels.
  125470. */
  125471. private _computePrimaryColors;
  125472. /**
  125473. * Build the uniform buffer used in the material.
  125474. */
  125475. buildUniformLayout(): void;
  125476. /**
  125477. * Unbind the material.
  125478. */
  125479. unbind(): void;
  125480. /**
  125481. * Bind only the world matrix to the material.
  125482. * @param world The world matrix to bind.
  125483. */
  125484. bindOnlyWorldMatrix(world: Matrix): void;
  125485. /**
  125486. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  125487. * @param world The world matrix to bind.
  125488. * @param subMesh The submesh to bind for.
  125489. */
  125490. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  125491. /**
  125492. * Checks to see if a texture is used in the material.
  125493. * @param texture - Base texture to use.
  125494. * @returns - Boolean specifying if a texture is used in the material.
  125495. */
  125496. hasTexture(texture: BaseTexture): boolean;
  125497. /**
  125498. * Dispose the material.
  125499. * @param forceDisposeEffect Force disposal of the associated effect.
  125500. * @param forceDisposeTextures Force disposal of the associated textures.
  125501. */
  125502. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  125503. /**
  125504. * Clones the material.
  125505. * @param name The cloned name.
  125506. * @returns The cloned material.
  125507. */
  125508. clone(name: string): BackgroundMaterial;
  125509. /**
  125510. * Serializes the current material to its JSON representation.
  125511. * @returns The JSON representation.
  125512. */
  125513. serialize(): any;
  125514. /**
  125515. * Gets the class name of the material
  125516. * @returns "BackgroundMaterial"
  125517. */
  125518. getClassName(): string;
  125519. /**
  125520. * Parse a JSON input to create back a background material.
  125521. * @param source The JSON data to parse
  125522. * @param scene The scene to create the parsed material in
  125523. * @param rootUrl The root url of the assets the material depends upon
  125524. * @returns the instantiated BackgroundMaterial.
  125525. */
  125526. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  125527. }
  125528. }
  125529. declare module BABYLON {
  125530. /**
  125531. * Represents the different options available during the creation of
  125532. * a Environment helper.
  125533. *
  125534. * This can control the default ground, skybox and image processing setup of your scene.
  125535. */
  125536. export interface IEnvironmentHelperOptions {
  125537. /**
  125538. * Specifies whether or not to create a ground.
  125539. * True by default.
  125540. */
  125541. createGround: boolean;
  125542. /**
  125543. * Specifies the ground size.
  125544. * 15 by default.
  125545. */
  125546. groundSize: number;
  125547. /**
  125548. * The texture used on the ground for the main color.
  125549. * Comes from the BabylonJS CDN by default.
  125550. *
  125551. * Remarks: Can be either a texture or a url.
  125552. */
  125553. groundTexture: string | BaseTexture;
  125554. /**
  125555. * The color mixed in the ground texture by default.
  125556. * BabylonJS clearColor by default.
  125557. */
  125558. groundColor: Color3;
  125559. /**
  125560. * Specifies the ground opacity.
  125561. * 1 by default.
  125562. */
  125563. groundOpacity: number;
  125564. /**
  125565. * Enables the ground to receive shadows.
  125566. * True by default.
  125567. */
  125568. enableGroundShadow: boolean;
  125569. /**
  125570. * Helps preventing the shadow to be fully black on the ground.
  125571. * 0.5 by default.
  125572. */
  125573. groundShadowLevel: number;
  125574. /**
  125575. * Creates a mirror texture attach to the ground.
  125576. * false by default.
  125577. */
  125578. enableGroundMirror: boolean;
  125579. /**
  125580. * Specifies the ground mirror size ratio.
  125581. * 0.3 by default as the default kernel is 64.
  125582. */
  125583. groundMirrorSizeRatio: number;
  125584. /**
  125585. * Specifies the ground mirror blur kernel size.
  125586. * 64 by default.
  125587. */
  125588. groundMirrorBlurKernel: number;
  125589. /**
  125590. * Specifies the ground mirror visibility amount.
  125591. * 1 by default
  125592. */
  125593. groundMirrorAmount: number;
  125594. /**
  125595. * Specifies the ground mirror reflectance weight.
  125596. * This uses the standard weight of the background material to setup the fresnel effect
  125597. * of the mirror.
  125598. * 1 by default.
  125599. */
  125600. groundMirrorFresnelWeight: number;
  125601. /**
  125602. * Specifies the ground mirror Falloff distance.
  125603. * This can helps reducing the size of the reflection.
  125604. * 0 by Default.
  125605. */
  125606. groundMirrorFallOffDistance: number;
  125607. /**
  125608. * Specifies the ground mirror texture type.
  125609. * Unsigned Int by Default.
  125610. */
  125611. groundMirrorTextureType: number;
  125612. /**
  125613. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  125614. * the shown objects.
  125615. */
  125616. groundYBias: number;
  125617. /**
  125618. * Specifies whether or not to create a skybox.
  125619. * True by default.
  125620. */
  125621. createSkybox: boolean;
  125622. /**
  125623. * Specifies the skybox size.
  125624. * 20 by default.
  125625. */
  125626. skyboxSize: number;
  125627. /**
  125628. * The texture used on the skybox for the main color.
  125629. * Comes from the BabylonJS CDN by default.
  125630. *
  125631. * Remarks: Can be either a texture or a url.
  125632. */
  125633. skyboxTexture: string | BaseTexture;
  125634. /**
  125635. * The color mixed in the skybox texture by default.
  125636. * BabylonJS clearColor by default.
  125637. */
  125638. skyboxColor: Color3;
  125639. /**
  125640. * The background rotation around the Y axis of the scene.
  125641. * This helps aligning the key lights of your scene with the background.
  125642. * 0 by default.
  125643. */
  125644. backgroundYRotation: number;
  125645. /**
  125646. * Compute automatically the size of the elements to best fit with the scene.
  125647. */
  125648. sizeAuto: boolean;
  125649. /**
  125650. * Default position of the rootMesh if autoSize is not true.
  125651. */
  125652. rootPosition: Vector3;
  125653. /**
  125654. * Sets up the image processing in the scene.
  125655. * true by default.
  125656. */
  125657. setupImageProcessing: boolean;
  125658. /**
  125659. * The texture used as your environment texture in the scene.
  125660. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  125661. *
  125662. * Remarks: Can be either a texture or a url.
  125663. */
  125664. environmentTexture: string | BaseTexture;
  125665. /**
  125666. * The value of the exposure to apply to the scene.
  125667. * 0.6 by default if setupImageProcessing is true.
  125668. */
  125669. cameraExposure: number;
  125670. /**
  125671. * The value of the contrast to apply to the scene.
  125672. * 1.6 by default if setupImageProcessing is true.
  125673. */
  125674. cameraContrast: number;
  125675. /**
  125676. * Specifies whether or not tonemapping should be enabled in the scene.
  125677. * true by default if setupImageProcessing is true.
  125678. */
  125679. toneMappingEnabled: boolean;
  125680. }
  125681. /**
  125682. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  125683. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  125684. * It also helps with the default setup of your imageProcessing configuration.
  125685. */
  125686. export class EnvironmentHelper {
  125687. /**
  125688. * Default ground texture URL.
  125689. */
  125690. private static _groundTextureCDNUrl;
  125691. /**
  125692. * Default skybox texture URL.
  125693. */
  125694. private static _skyboxTextureCDNUrl;
  125695. /**
  125696. * Default environment texture URL.
  125697. */
  125698. private static _environmentTextureCDNUrl;
  125699. /**
  125700. * Creates the default options for the helper.
  125701. */
  125702. private static _getDefaultOptions;
  125703. private _rootMesh;
  125704. /**
  125705. * Gets the root mesh created by the helper.
  125706. */
  125707. get rootMesh(): Mesh;
  125708. private _skybox;
  125709. /**
  125710. * Gets the skybox created by the helper.
  125711. */
  125712. get skybox(): Nullable<Mesh>;
  125713. private _skyboxTexture;
  125714. /**
  125715. * Gets the skybox texture created by the helper.
  125716. */
  125717. get skyboxTexture(): Nullable<BaseTexture>;
  125718. private _skyboxMaterial;
  125719. /**
  125720. * Gets the skybox material created by the helper.
  125721. */
  125722. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  125723. private _ground;
  125724. /**
  125725. * Gets the ground mesh created by the helper.
  125726. */
  125727. get ground(): Nullable<Mesh>;
  125728. private _groundTexture;
  125729. /**
  125730. * Gets the ground texture created by the helper.
  125731. */
  125732. get groundTexture(): Nullable<BaseTexture>;
  125733. private _groundMirror;
  125734. /**
  125735. * Gets the ground mirror created by the helper.
  125736. */
  125737. get groundMirror(): Nullable<MirrorTexture>;
  125738. /**
  125739. * Gets the ground mirror render list to helps pushing the meshes
  125740. * you wish in the ground reflection.
  125741. */
  125742. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  125743. private _groundMaterial;
  125744. /**
  125745. * Gets the ground material created by the helper.
  125746. */
  125747. get groundMaterial(): Nullable<BackgroundMaterial>;
  125748. /**
  125749. * Stores the creation options.
  125750. */
  125751. private readonly _scene;
  125752. private _options;
  125753. /**
  125754. * This observable will be notified with any error during the creation of the environment,
  125755. * mainly texture creation errors.
  125756. */
  125757. onErrorObservable: Observable<{
  125758. message?: string;
  125759. exception?: any;
  125760. }>;
  125761. /**
  125762. * constructor
  125763. * @param options Defines the options we want to customize the helper
  125764. * @param scene The scene to add the material to
  125765. */
  125766. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  125767. /**
  125768. * Updates the background according to the new options
  125769. * @param options
  125770. */
  125771. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  125772. /**
  125773. * Sets the primary color of all the available elements.
  125774. * @param color the main color to affect to the ground and the background
  125775. */
  125776. setMainColor(color: Color3): void;
  125777. /**
  125778. * Setup the image processing according to the specified options.
  125779. */
  125780. private _setupImageProcessing;
  125781. /**
  125782. * Setup the environment texture according to the specified options.
  125783. */
  125784. private _setupEnvironmentTexture;
  125785. /**
  125786. * Setup the background according to the specified options.
  125787. */
  125788. private _setupBackground;
  125789. /**
  125790. * Get the scene sizes according to the setup.
  125791. */
  125792. private _getSceneSize;
  125793. /**
  125794. * Setup the ground according to the specified options.
  125795. */
  125796. private _setupGround;
  125797. /**
  125798. * Setup the ground material according to the specified options.
  125799. */
  125800. private _setupGroundMaterial;
  125801. /**
  125802. * Setup the ground diffuse texture according to the specified options.
  125803. */
  125804. private _setupGroundDiffuseTexture;
  125805. /**
  125806. * Setup the ground mirror texture according to the specified options.
  125807. */
  125808. private _setupGroundMirrorTexture;
  125809. /**
  125810. * Setup the ground to receive the mirror texture.
  125811. */
  125812. private _setupMirrorInGroundMaterial;
  125813. /**
  125814. * Setup the skybox according to the specified options.
  125815. */
  125816. private _setupSkybox;
  125817. /**
  125818. * Setup the skybox material according to the specified options.
  125819. */
  125820. private _setupSkyboxMaterial;
  125821. /**
  125822. * Setup the skybox reflection texture according to the specified options.
  125823. */
  125824. private _setupSkyboxReflectionTexture;
  125825. private _errorHandler;
  125826. /**
  125827. * Dispose all the elements created by the Helper.
  125828. */
  125829. dispose(): void;
  125830. }
  125831. }
  125832. declare module BABYLON {
  125833. /**
  125834. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  125835. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  125836. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  125837. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  125838. */
  125839. export class PhotoDome extends TransformNode {
  125840. /**
  125841. * Define the image as a Monoscopic panoramic 360 image.
  125842. */
  125843. static readonly MODE_MONOSCOPIC: number;
  125844. /**
  125845. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  125846. */
  125847. static readonly MODE_TOPBOTTOM: number;
  125848. /**
  125849. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  125850. */
  125851. static readonly MODE_SIDEBYSIDE: number;
  125852. private _useDirectMapping;
  125853. /**
  125854. * The texture being displayed on the sphere
  125855. */
  125856. protected _photoTexture: Texture;
  125857. /**
  125858. * Gets or sets the texture being displayed on the sphere
  125859. */
  125860. get photoTexture(): Texture;
  125861. set photoTexture(value: Texture);
  125862. /**
  125863. * Observable raised when an error occured while loading the 360 image
  125864. */
  125865. onLoadErrorObservable: Observable<string>;
  125866. /**
  125867. * The skybox material
  125868. */
  125869. protected _material: BackgroundMaterial;
  125870. /**
  125871. * The surface used for the skybox
  125872. */
  125873. protected _mesh: Mesh;
  125874. /**
  125875. * Gets the mesh used for the skybox.
  125876. */
  125877. get mesh(): Mesh;
  125878. /**
  125879. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  125880. * Also see the options.resolution property.
  125881. */
  125882. get fovMultiplier(): number;
  125883. set fovMultiplier(value: number);
  125884. private _imageMode;
  125885. /**
  125886. * Gets or set the current video mode for the video. It can be:
  125887. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  125888. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  125889. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  125890. */
  125891. get imageMode(): number;
  125892. set imageMode(value: number);
  125893. /**
  125894. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  125895. * @param name Element's name, child elements will append suffixes for their own names.
  125896. * @param urlsOfPhoto defines the url of the photo to display
  125897. * @param options defines an object containing optional or exposed sub element properties
  125898. * @param onError defines a callback called when an error occured while loading the texture
  125899. */
  125900. constructor(name: string, urlOfPhoto: string, options: {
  125901. resolution?: number;
  125902. size?: number;
  125903. useDirectMapping?: boolean;
  125904. faceForward?: boolean;
  125905. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  125906. private _onBeforeCameraRenderObserver;
  125907. private _changeImageMode;
  125908. /**
  125909. * Releases resources associated with this node.
  125910. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  125911. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  125912. */
  125913. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  125914. }
  125915. }
  125916. declare module BABYLON {
  125917. /**
  125918. * Class used to host RGBD texture specific utilities
  125919. */
  125920. export class RGBDTextureTools {
  125921. /**
  125922. * Expand the RGBD Texture from RGBD to Half Float if possible.
  125923. * @param texture the texture to expand.
  125924. */
  125925. static ExpandRGBDTexture(texture: Texture): void;
  125926. }
  125927. }
  125928. declare module BABYLON {
  125929. /**
  125930. * Class used to host texture specific utilities
  125931. */
  125932. export class BRDFTextureTools {
  125933. /**
  125934. * Prevents texture cache collision
  125935. */
  125936. private static _instanceNumber;
  125937. /**
  125938. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  125939. * @param scene defines the hosting scene
  125940. * @returns the environment BRDF texture
  125941. */
  125942. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  125943. private static _environmentBRDFBase64Texture;
  125944. }
  125945. }
  125946. declare module BABYLON {
  125947. /**
  125948. * @hidden
  125949. */
  125950. export interface IMaterialClearCoatDefines {
  125951. CLEARCOAT: boolean;
  125952. CLEARCOAT_DEFAULTIOR: boolean;
  125953. CLEARCOAT_TEXTURE: boolean;
  125954. CLEARCOAT_TEXTUREDIRECTUV: number;
  125955. CLEARCOAT_BUMP: boolean;
  125956. CLEARCOAT_BUMPDIRECTUV: number;
  125957. CLEARCOAT_TINT: boolean;
  125958. CLEARCOAT_TINT_TEXTURE: boolean;
  125959. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  125960. /** @hidden */
  125961. _areTexturesDirty: boolean;
  125962. }
  125963. /**
  125964. * Define the code related to the clear coat parameters of the pbr material.
  125965. */
  125966. export class PBRClearCoatConfiguration {
  125967. /**
  125968. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  125969. * The default fits with a polyurethane material.
  125970. */
  125971. private static readonly _DefaultIndexOfRefraction;
  125972. private _isEnabled;
  125973. /**
  125974. * Defines if the clear coat is enabled in the material.
  125975. */
  125976. isEnabled: boolean;
  125977. /**
  125978. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  125979. */
  125980. intensity: number;
  125981. /**
  125982. * Defines the clear coat layer roughness.
  125983. */
  125984. roughness: number;
  125985. private _indexOfRefraction;
  125986. /**
  125987. * Defines the index of refraction of the clear coat.
  125988. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  125989. * The default fits with a polyurethane material.
  125990. * Changing the default value is more performance intensive.
  125991. */
  125992. indexOfRefraction: number;
  125993. private _texture;
  125994. /**
  125995. * Stores the clear coat values in a texture.
  125996. */
  125997. texture: Nullable<BaseTexture>;
  125998. private _bumpTexture;
  125999. /**
  126000. * Define the clear coat specific bump texture.
  126001. */
  126002. bumpTexture: Nullable<BaseTexture>;
  126003. private _isTintEnabled;
  126004. /**
  126005. * Defines if the clear coat tint is enabled in the material.
  126006. */
  126007. isTintEnabled: boolean;
  126008. /**
  126009. * Defines the clear coat tint of the material.
  126010. * This is only use if tint is enabled
  126011. */
  126012. tintColor: Color3;
  126013. /**
  126014. * Defines the distance at which the tint color should be found in the
  126015. * clear coat media.
  126016. * This is only use if tint is enabled
  126017. */
  126018. tintColorAtDistance: number;
  126019. /**
  126020. * Defines the clear coat layer thickness.
  126021. * This is only use if tint is enabled
  126022. */
  126023. tintThickness: number;
  126024. private _tintTexture;
  126025. /**
  126026. * Stores the clear tint values in a texture.
  126027. * rgb is tint
  126028. * a is a thickness factor
  126029. */
  126030. tintTexture: Nullable<BaseTexture>;
  126031. /** @hidden */
  126032. private _internalMarkAllSubMeshesAsTexturesDirty;
  126033. /** @hidden */
  126034. _markAllSubMeshesAsTexturesDirty(): void;
  126035. /**
  126036. * Instantiate a new istance of clear coat configuration.
  126037. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  126038. */
  126039. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  126040. /**
  126041. * Gets wehter the submesh is ready to be used or not.
  126042. * @param defines the list of "defines" to update.
  126043. * @param scene defines the scene the material belongs to.
  126044. * @param engine defines the engine the material belongs to.
  126045. * @param disableBumpMap defines wether the material disables bump or not.
  126046. * @returns - boolean indicating that the submesh is ready or not.
  126047. */
  126048. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  126049. /**
  126050. * Checks to see if a texture is used in the material.
  126051. * @param defines the list of "defines" to update.
  126052. * @param scene defines the scene to the material belongs to.
  126053. */
  126054. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  126055. /**
  126056. * Binds the material data.
  126057. * @param uniformBuffer defines the Uniform buffer to fill in.
  126058. * @param scene defines the scene the material belongs to.
  126059. * @param engine defines the engine the material belongs to.
  126060. * @param disableBumpMap defines wether the material disables bump or not.
  126061. * @param isFrozen defines wether the material is frozen or not.
  126062. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  126063. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  126064. */
  126065. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  126066. /**
  126067. * Checks to see if a texture is used in the material.
  126068. * @param texture - Base texture to use.
  126069. * @returns - Boolean specifying if a texture is used in the material.
  126070. */
  126071. hasTexture(texture: BaseTexture): boolean;
  126072. /**
  126073. * Returns an array of the actively used textures.
  126074. * @param activeTextures Array of BaseTextures
  126075. */
  126076. getActiveTextures(activeTextures: BaseTexture[]): void;
  126077. /**
  126078. * Returns the animatable textures.
  126079. * @param animatables Array of animatable textures.
  126080. */
  126081. getAnimatables(animatables: IAnimatable[]): void;
  126082. /**
  126083. * Disposes the resources of the material.
  126084. * @param forceDisposeTextures - Forces the disposal of all textures.
  126085. */
  126086. dispose(forceDisposeTextures?: boolean): void;
  126087. /**
  126088. * Get the current class name of the texture useful for serialization or dynamic coding.
  126089. * @returns "PBRClearCoatConfiguration"
  126090. */
  126091. getClassName(): string;
  126092. /**
  126093. * Add fallbacks to the effect fallbacks list.
  126094. * @param defines defines the Base texture to use.
  126095. * @param fallbacks defines the current fallback list.
  126096. * @param currentRank defines the current fallback rank.
  126097. * @returns the new fallback rank.
  126098. */
  126099. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  126100. /**
  126101. * Add the required uniforms to the current list.
  126102. * @param uniforms defines the current uniform list.
  126103. */
  126104. static AddUniforms(uniforms: string[]): void;
  126105. /**
  126106. * Add the required samplers to the current list.
  126107. * @param samplers defines the current sampler list.
  126108. */
  126109. static AddSamplers(samplers: string[]): void;
  126110. /**
  126111. * Add the required uniforms to the current buffer.
  126112. * @param uniformBuffer defines the current uniform buffer.
  126113. */
  126114. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  126115. /**
  126116. * Makes a duplicate of the current configuration into another one.
  126117. * @param clearCoatConfiguration define the config where to copy the info
  126118. */
  126119. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  126120. /**
  126121. * Serializes this clear coat configuration.
  126122. * @returns - An object with the serialized config.
  126123. */
  126124. serialize(): any;
  126125. /**
  126126. * Parses a anisotropy Configuration from a serialized object.
  126127. * @param source - Serialized object.
  126128. * @param scene Defines the scene we are parsing for
  126129. * @param rootUrl Defines the rootUrl to load from
  126130. */
  126131. parse(source: any, scene: Scene, rootUrl: string): void;
  126132. }
  126133. }
  126134. declare module BABYLON {
  126135. /**
  126136. * @hidden
  126137. */
  126138. export interface IMaterialAnisotropicDefines {
  126139. ANISOTROPIC: boolean;
  126140. ANISOTROPIC_TEXTURE: boolean;
  126141. ANISOTROPIC_TEXTUREDIRECTUV: number;
  126142. MAINUV1: boolean;
  126143. _areTexturesDirty: boolean;
  126144. _needUVs: boolean;
  126145. }
  126146. /**
  126147. * Define the code related to the anisotropic parameters of the pbr material.
  126148. */
  126149. export class PBRAnisotropicConfiguration {
  126150. private _isEnabled;
  126151. /**
  126152. * Defines if the anisotropy is enabled in the material.
  126153. */
  126154. isEnabled: boolean;
  126155. /**
  126156. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  126157. */
  126158. intensity: number;
  126159. /**
  126160. * Defines if the effect is along the tangents, bitangents or in between.
  126161. * By default, the effect is "strectching" the highlights along the tangents.
  126162. */
  126163. direction: Vector2;
  126164. private _texture;
  126165. /**
  126166. * Stores the anisotropy values in a texture.
  126167. * rg is direction (like normal from -1 to 1)
  126168. * b is a intensity
  126169. */
  126170. texture: Nullable<BaseTexture>;
  126171. /** @hidden */
  126172. private _internalMarkAllSubMeshesAsTexturesDirty;
  126173. /** @hidden */
  126174. _markAllSubMeshesAsTexturesDirty(): void;
  126175. /**
  126176. * Instantiate a new istance of anisotropy configuration.
  126177. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  126178. */
  126179. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  126180. /**
  126181. * Specifies that the submesh is ready to be used.
  126182. * @param defines the list of "defines" to update.
  126183. * @param scene defines the scene the material belongs to.
  126184. * @returns - boolean indicating that the submesh is ready or not.
  126185. */
  126186. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  126187. /**
  126188. * Checks to see if a texture is used in the material.
  126189. * @param defines the list of "defines" to update.
  126190. * @param mesh the mesh we are preparing the defines for.
  126191. * @param scene defines the scene the material belongs to.
  126192. */
  126193. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  126194. /**
  126195. * Binds the material data.
  126196. * @param uniformBuffer defines the Uniform buffer to fill in.
  126197. * @param scene defines the scene the material belongs to.
  126198. * @param isFrozen defines wether the material is frozen or not.
  126199. */
  126200. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  126201. /**
  126202. * Checks to see if a texture is used in the material.
  126203. * @param texture - Base texture to use.
  126204. * @returns - Boolean specifying if a texture is used in the material.
  126205. */
  126206. hasTexture(texture: BaseTexture): boolean;
  126207. /**
  126208. * Returns an array of the actively used textures.
  126209. * @param activeTextures Array of BaseTextures
  126210. */
  126211. getActiveTextures(activeTextures: BaseTexture[]): void;
  126212. /**
  126213. * Returns the animatable textures.
  126214. * @param animatables Array of animatable textures.
  126215. */
  126216. getAnimatables(animatables: IAnimatable[]): void;
  126217. /**
  126218. * Disposes the resources of the material.
  126219. * @param forceDisposeTextures - Forces the disposal of all textures.
  126220. */
  126221. dispose(forceDisposeTextures?: boolean): void;
  126222. /**
  126223. * Get the current class name of the texture useful for serialization or dynamic coding.
  126224. * @returns "PBRAnisotropicConfiguration"
  126225. */
  126226. getClassName(): string;
  126227. /**
  126228. * Add fallbacks to the effect fallbacks list.
  126229. * @param defines defines the Base texture to use.
  126230. * @param fallbacks defines the current fallback list.
  126231. * @param currentRank defines the current fallback rank.
  126232. * @returns the new fallback rank.
  126233. */
  126234. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  126235. /**
  126236. * Add the required uniforms to the current list.
  126237. * @param uniforms defines the current uniform list.
  126238. */
  126239. static AddUniforms(uniforms: string[]): void;
  126240. /**
  126241. * Add the required uniforms to the current buffer.
  126242. * @param uniformBuffer defines the current uniform buffer.
  126243. */
  126244. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  126245. /**
  126246. * Add the required samplers to the current list.
  126247. * @param samplers defines the current sampler list.
  126248. */
  126249. static AddSamplers(samplers: string[]): void;
  126250. /**
  126251. * Makes a duplicate of the current configuration into another one.
  126252. * @param anisotropicConfiguration define the config where to copy the info
  126253. */
  126254. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  126255. /**
  126256. * Serializes this anisotropy configuration.
  126257. * @returns - An object with the serialized config.
  126258. */
  126259. serialize(): any;
  126260. /**
  126261. * Parses a anisotropy Configuration from a serialized object.
  126262. * @param source - Serialized object.
  126263. * @param scene Defines the scene we are parsing for
  126264. * @param rootUrl Defines the rootUrl to load from
  126265. */
  126266. parse(source: any, scene: Scene, rootUrl: string): void;
  126267. }
  126268. }
  126269. declare module BABYLON {
  126270. /**
  126271. * @hidden
  126272. */
  126273. export interface IMaterialBRDFDefines {
  126274. BRDF_V_HEIGHT_CORRELATED: boolean;
  126275. MS_BRDF_ENERGY_CONSERVATION: boolean;
  126276. SPHERICAL_HARMONICS: boolean;
  126277. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  126278. /** @hidden */
  126279. _areMiscDirty: boolean;
  126280. }
  126281. /**
  126282. * Define the code related to the BRDF parameters of the pbr material.
  126283. */
  126284. export class PBRBRDFConfiguration {
  126285. /**
  126286. * Default value used for the energy conservation.
  126287. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  126288. */
  126289. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  126290. /**
  126291. * Default value used for the Smith Visibility Height Correlated mode.
  126292. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  126293. */
  126294. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  126295. /**
  126296. * Default value used for the IBL diffuse part.
  126297. * This can help switching back to the polynomials mode globally which is a tiny bit
  126298. * less GPU intensive at the drawback of a lower quality.
  126299. */
  126300. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  126301. /**
  126302. * Default value used for activating energy conservation for the specular workflow.
  126303. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  126304. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  126305. */
  126306. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  126307. private _useEnergyConservation;
  126308. /**
  126309. * Defines if the material uses energy conservation.
  126310. */
  126311. useEnergyConservation: boolean;
  126312. private _useSmithVisibilityHeightCorrelated;
  126313. /**
  126314. * LEGACY Mode set to false
  126315. * Defines if the material uses height smith correlated visibility term.
  126316. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  126317. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  126318. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  126319. * Not relying on height correlated will also disable energy conservation.
  126320. */
  126321. useSmithVisibilityHeightCorrelated: boolean;
  126322. private _useSphericalHarmonics;
  126323. /**
  126324. * LEGACY Mode set to false
  126325. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  126326. * diffuse part of the IBL.
  126327. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  126328. * to the ground truth.
  126329. */
  126330. useSphericalHarmonics: boolean;
  126331. private _useSpecularGlossinessInputEnergyConservation;
  126332. /**
  126333. * Defines if the material uses energy conservation, when the specular workflow is active.
  126334. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  126335. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  126336. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  126337. */
  126338. useSpecularGlossinessInputEnergyConservation: boolean;
  126339. /** @hidden */
  126340. private _internalMarkAllSubMeshesAsMiscDirty;
  126341. /** @hidden */
  126342. _markAllSubMeshesAsMiscDirty(): void;
  126343. /**
  126344. * Instantiate a new istance of clear coat configuration.
  126345. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  126346. */
  126347. constructor(markAllSubMeshesAsMiscDirty: () => void);
  126348. /**
  126349. * Checks to see if a texture is used in the material.
  126350. * @param defines the list of "defines" to update.
  126351. */
  126352. prepareDefines(defines: IMaterialBRDFDefines): void;
  126353. /**
  126354. * Get the current class name of the texture useful for serialization or dynamic coding.
  126355. * @returns "PBRClearCoatConfiguration"
  126356. */
  126357. getClassName(): string;
  126358. /**
  126359. * Makes a duplicate of the current configuration into another one.
  126360. * @param brdfConfiguration define the config where to copy the info
  126361. */
  126362. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  126363. /**
  126364. * Serializes this BRDF configuration.
  126365. * @returns - An object with the serialized config.
  126366. */
  126367. serialize(): any;
  126368. /**
  126369. * Parses a anisotropy Configuration from a serialized object.
  126370. * @param source - Serialized object.
  126371. * @param scene Defines the scene we are parsing for
  126372. * @param rootUrl Defines the rootUrl to load from
  126373. */
  126374. parse(source: any, scene: Scene, rootUrl: string): void;
  126375. }
  126376. }
  126377. declare module BABYLON {
  126378. /**
  126379. * @hidden
  126380. */
  126381. export interface IMaterialSheenDefines {
  126382. SHEEN: boolean;
  126383. SHEEN_TEXTURE: boolean;
  126384. SHEEN_TEXTUREDIRECTUV: number;
  126385. SHEEN_LINKWITHALBEDO: boolean;
  126386. SHEEN_ROUGHNESS: boolean;
  126387. SHEEN_ALBEDOSCALING: boolean;
  126388. /** @hidden */
  126389. _areTexturesDirty: boolean;
  126390. }
  126391. /**
  126392. * Define the code related to the Sheen parameters of the pbr material.
  126393. */
  126394. export class PBRSheenConfiguration {
  126395. private _isEnabled;
  126396. /**
  126397. * Defines if the material uses sheen.
  126398. */
  126399. isEnabled: boolean;
  126400. private _linkSheenWithAlbedo;
  126401. /**
  126402. * Defines if the sheen is linked to the sheen color.
  126403. */
  126404. linkSheenWithAlbedo: boolean;
  126405. /**
  126406. * Defines the sheen intensity.
  126407. */
  126408. intensity: number;
  126409. /**
  126410. * Defines the sheen color.
  126411. */
  126412. color: Color3;
  126413. private _texture;
  126414. /**
  126415. * Stores the sheen tint values in a texture.
  126416. * rgb is tint
  126417. * a is a intensity
  126418. */
  126419. texture: Nullable<BaseTexture>;
  126420. private _roughness;
  126421. /**
  126422. * Defines the sheen roughness.
  126423. * It is not taken into account if linkSheenWithAlbedo is true.
  126424. * To stay backward compatible, material roughness is used instead if sheen roughness = null
  126425. */
  126426. roughness: Nullable<number>;
  126427. private _albedoScaling;
  126428. /**
  126429. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  126430. * It allows the strength of the sheen effect to not depend on the base color of the material,
  126431. * making it easier to setup and tweak the effect
  126432. */
  126433. albedoScaling: boolean;
  126434. /** @hidden */
  126435. private _internalMarkAllSubMeshesAsTexturesDirty;
  126436. /** @hidden */
  126437. _markAllSubMeshesAsTexturesDirty(): void;
  126438. /**
  126439. * Instantiate a new istance of clear coat configuration.
  126440. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  126441. */
  126442. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  126443. /**
  126444. * Specifies that the submesh is ready to be used.
  126445. * @param defines the list of "defines" to update.
  126446. * @param scene defines the scene the material belongs to.
  126447. * @returns - boolean indicating that the submesh is ready or not.
  126448. */
  126449. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  126450. /**
  126451. * Checks to see if a texture is used in the material.
  126452. * @param defines the list of "defines" to update.
  126453. * @param scene defines the scene the material belongs to.
  126454. */
  126455. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  126456. /**
  126457. * Binds the material data.
  126458. * @param uniformBuffer defines the Uniform buffer to fill in.
  126459. * @param scene defines the scene the material belongs to.
  126460. * @param isFrozen defines wether the material is frozen or not.
  126461. */
  126462. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  126463. /**
  126464. * Checks to see if a texture is used in the material.
  126465. * @param texture - Base texture to use.
  126466. * @returns - Boolean specifying if a texture is used in the material.
  126467. */
  126468. hasTexture(texture: BaseTexture): boolean;
  126469. /**
  126470. * Returns an array of the actively used textures.
  126471. * @param activeTextures Array of BaseTextures
  126472. */
  126473. getActiveTextures(activeTextures: BaseTexture[]): void;
  126474. /**
  126475. * Returns the animatable textures.
  126476. * @param animatables Array of animatable textures.
  126477. */
  126478. getAnimatables(animatables: IAnimatable[]): void;
  126479. /**
  126480. * Disposes the resources of the material.
  126481. * @param forceDisposeTextures - Forces the disposal of all textures.
  126482. */
  126483. dispose(forceDisposeTextures?: boolean): void;
  126484. /**
  126485. * Get the current class name of the texture useful for serialization or dynamic coding.
  126486. * @returns "PBRSheenConfiguration"
  126487. */
  126488. getClassName(): string;
  126489. /**
  126490. * Add fallbacks to the effect fallbacks list.
  126491. * @param defines defines the Base texture to use.
  126492. * @param fallbacks defines the current fallback list.
  126493. * @param currentRank defines the current fallback rank.
  126494. * @returns the new fallback rank.
  126495. */
  126496. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  126497. /**
  126498. * Add the required uniforms to the current list.
  126499. * @param uniforms defines the current uniform list.
  126500. */
  126501. static AddUniforms(uniforms: string[]): void;
  126502. /**
  126503. * Add the required uniforms to the current buffer.
  126504. * @param uniformBuffer defines the current uniform buffer.
  126505. */
  126506. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  126507. /**
  126508. * Add the required samplers to the current list.
  126509. * @param samplers defines the current sampler list.
  126510. */
  126511. static AddSamplers(samplers: string[]): void;
  126512. /**
  126513. * Makes a duplicate of the current configuration into another one.
  126514. * @param sheenConfiguration define the config where to copy the info
  126515. */
  126516. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  126517. /**
  126518. * Serializes this BRDF configuration.
  126519. * @returns - An object with the serialized config.
  126520. */
  126521. serialize(): any;
  126522. /**
  126523. * Parses a anisotropy Configuration from a serialized object.
  126524. * @param source - Serialized object.
  126525. * @param scene Defines the scene we are parsing for
  126526. * @param rootUrl Defines the rootUrl to load from
  126527. */
  126528. parse(source: any, scene: Scene, rootUrl: string): void;
  126529. }
  126530. }
  126531. declare module BABYLON {
  126532. /**
  126533. * @hidden
  126534. */
  126535. export interface IMaterialSubSurfaceDefines {
  126536. SUBSURFACE: boolean;
  126537. SS_REFRACTION: boolean;
  126538. SS_TRANSLUCENCY: boolean;
  126539. SS_SCATERRING: boolean;
  126540. SS_THICKNESSANDMASK_TEXTURE: boolean;
  126541. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  126542. SS_REFRACTIONMAP_3D: boolean;
  126543. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  126544. SS_LODINREFRACTIONALPHA: boolean;
  126545. SS_GAMMAREFRACTION: boolean;
  126546. SS_RGBDREFRACTION: boolean;
  126547. SS_LINEARSPECULARREFRACTION: boolean;
  126548. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  126549. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  126550. /** @hidden */
  126551. _areTexturesDirty: boolean;
  126552. }
  126553. /**
  126554. * Define the code related to the sub surface parameters of the pbr material.
  126555. */
  126556. export class PBRSubSurfaceConfiguration {
  126557. private _isRefractionEnabled;
  126558. /**
  126559. * Defines if the refraction is enabled in the material.
  126560. */
  126561. isRefractionEnabled: boolean;
  126562. private _isTranslucencyEnabled;
  126563. /**
  126564. * Defines if the translucency is enabled in the material.
  126565. */
  126566. isTranslucencyEnabled: boolean;
  126567. private _isScatteringEnabled;
  126568. /**
  126569. * Defines the refraction intensity of the material.
  126570. * The refraction when enabled replaces the Diffuse part of the material.
  126571. * The intensity helps transitionning between diffuse and refraction.
  126572. */
  126573. refractionIntensity: number;
  126574. /**
  126575. * Defines the translucency intensity of the material.
  126576. * When translucency has been enabled, this defines how much of the "translucency"
  126577. * is addded to the diffuse part of the material.
  126578. */
  126579. translucencyIntensity: number;
  126580. /**
  126581. * Defines the scattering intensity of the material.
  126582. * When scattering has been enabled, this defines how much of the "scattered light"
  126583. * is addded to the diffuse part of the material.
  126584. */
  126585. scatteringIntensity: number;
  126586. private _thicknessTexture;
  126587. /**
  126588. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  126589. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  126590. * 0 would mean minimumThickness
  126591. * 1 would mean maximumThickness
  126592. * The other channels might be use as a mask to vary the different effects intensity.
  126593. */
  126594. thicknessTexture: Nullable<BaseTexture>;
  126595. private _refractionTexture;
  126596. /**
  126597. * Defines the texture to use for refraction.
  126598. */
  126599. refractionTexture: Nullable<BaseTexture>;
  126600. private _indexOfRefraction;
  126601. /**
  126602. * Defines the index of refraction used in the material.
  126603. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  126604. */
  126605. indexOfRefraction: number;
  126606. private _invertRefractionY;
  126607. /**
  126608. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  126609. */
  126610. invertRefractionY: boolean;
  126611. private _linkRefractionWithTransparency;
  126612. /**
  126613. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  126614. * Materials half opaque for instance using refraction could benefit from this control.
  126615. */
  126616. linkRefractionWithTransparency: boolean;
  126617. /**
  126618. * Defines the minimum thickness stored in the thickness map.
  126619. * If no thickness map is defined, this value will be used to simulate thickness.
  126620. */
  126621. minimumThickness: number;
  126622. /**
  126623. * Defines the maximum thickness stored in the thickness map.
  126624. */
  126625. maximumThickness: number;
  126626. /**
  126627. * Defines the volume tint of the material.
  126628. * This is used for both translucency and scattering.
  126629. */
  126630. tintColor: Color3;
  126631. /**
  126632. * Defines the distance at which the tint color should be found in the media.
  126633. * This is used for refraction only.
  126634. */
  126635. tintColorAtDistance: number;
  126636. /**
  126637. * Defines how far each channel transmit through the media.
  126638. * It is defined as a color to simplify it selection.
  126639. */
  126640. diffusionDistance: Color3;
  126641. private _useMaskFromThicknessTexture;
  126642. /**
  126643. * Stores the intensity of the different subsurface effects in the thickness texture.
  126644. * * the green channel is the translucency intensity.
  126645. * * the blue channel is the scattering intensity.
  126646. * * the alpha channel is the refraction intensity.
  126647. */
  126648. useMaskFromThicknessTexture: boolean;
  126649. /** @hidden */
  126650. private _internalMarkAllSubMeshesAsTexturesDirty;
  126651. /** @hidden */
  126652. _markAllSubMeshesAsTexturesDirty(): void;
  126653. /**
  126654. * Instantiate a new istance of sub surface configuration.
  126655. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  126656. */
  126657. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  126658. /**
  126659. * Gets wehter the submesh is ready to be used or not.
  126660. * @param defines the list of "defines" to update.
  126661. * @param scene defines the scene the material belongs to.
  126662. * @returns - boolean indicating that the submesh is ready or not.
  126663. */
  126664. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  126665. /**
  126666. * Checks to see if a texture is used in the material.
  126667. * @param defines the list of "defines" to update.
  126668. * @param scene defines the scene to the material belongs to.
  126669. */
  126670. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  126671. /**
  126672. * Binds the material data.
  126673. * @param uniformBuffer defines the Uniform buffer to fill in.
  126674. * @param scene defines the scene the material belongs to.
  126675. * @param engine defines the engine the material belongs to.
  126676. * @param isFrozen defines wether the material is frozen or not.
  126677. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  126678. */
  126679. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  126680. /**
  126681. * Unbinds the material from the mesh.
  126682. * @param activeEffect defines the effect that should be unbound from.
  126683. * @returns true if unbound, otherwise false
  126684. */
  126685. unbind(activeEffect: Effect): boolean;
  126686. /**
  126687. * Returns the texture used for refraction or null if none is used.
  126688. * @param scene defines the scene the material belongs to.
  126689. * @returns - Refraction texture if present. If no refraction texture and refraction
  126690. * is linked with transparency, returns environment texture. Otherwise, returns null.
  126691. */
  126692. private _getRefractionTexture;
  126693. /**
  126694. * Returns true if alpha blending should be disabled.
  126695. */
  126696. get disableAlphaBlending(): boolean;
  126697. /**
  126698. * Fills the list of render target textures.
  126699. * @param renderTargets the list of render targets to update
  126700. */
  126701. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  126702. /**
  126703. * Checks to see if a texture is used in the material.
  126704. * @param texture - Base texture to use.
  126705. * @returns - Boolean specifying if a texture is used in the material.
  126706. */
  126707. hasTexture(texture: BaseTexture): boolean;
  126708. /**
  126709. * Gets a boolean indicating that current material needs to register RTT
  126710. * @returns true if this uses a render target otherwise false.
  126711. */
  126712. hasRenderTargetTextures(): boolean;
  126713. /**
  126714. * Returns an array of the actively used textures.
  126715. * @param activeTextures Array of BaseTextures
  126716. */
  126717. getActiveTextures(activeTextures: BaseTexture[]): void;
  126718. /**
  126719. * Returns the animatable textures.
  126720. * @param animatables Array of animatable textures.
  126721. */
  126722. getAnimatables(animatables: IAnimatable[]): void;
  126723. /**
  126724. * Disposes the resources of the material.
  126725. * @param forceDisposeTextures - Forces the disposal of all textures.
  126726. */
  126727. dispose(forceDisposeTextures?: boolean): void;
  126728. /**
  126729. * Get the current class name of the texture useful for serialization or dynamic coding.
  126730. * @returns "PBRSubSurfaceConfiguration"
  126731. */
  126732. getClassName(): string;
  126733. /**
  126734. * Add fallbacks to the effect fallbacks list.
  126735. * @param defines defines the Base texture to use.
  126736. * @param fallbacks defines the current fallback list.
  126737. * @param currentRank defines the current fallback rank.
  126738. * @returns the new fallback rank.
  126739. */
  126740. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  126741. /**
  126742. * Add the required uniforms to the current list.
  126743. * @param uniforms defines the current uniform list.
  126744. */
  126745. static AddUniforms(uniforms: string[]): void;
  126746. /**
  126747. * Add the required samplers to the current list.
  126748. * @param samplers defines the current sampler list.
  126749. */
  126750. static AddSamplers(samplers: string[]): void;
  126751. /**
  126752. * Add the required uniforms to the current buffer.
  126753. * @param uniformBuffer defines the current uniform buffer.
  126754. */
  126755. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  126756. /**
  126757. * Makes a duplicate of the current configuration into another one.
  126758. * @param configuration define the config where to copy the info
  126759. */
  126760. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  126761. /**
  126762. * Serializes this Sub Surface configuration.
  126763. * @returns - An object with the serialized config.
  126764. */
  126765. serialize(): any;
  126766. /**
  126767. * Parses a anisotropy Configuration from a serialized object.
  126768. * @param source - Serialized object.
  126769. * @param scene Defines the scene we are parsing for
  126770. * @param rootUrl Defines the rootUrl to load from
  126771. */
  126772. parse(source: any, scene: Scene, rootUrl: string): void;
  126773. }
  126774. }
  126775. declare module BABYLON {
  126776. /** @hidden */
  126777. export var pbrFragmentDeclaration: {
  126778. name: string;
  126779. shader: string;
  126780. };
  126781. }
  126782. declare module BABYLON {
  126783. /** @hidden */
  126784. export var pbrUboDeclaration: {
  126785. name: string;
  126786. shader: string;
  126787. };
  126788. }
  126789. declare module BABYLON {
  126790. /** @hidden */
  126791. export var pbrFragmentExtraDeclaration: {
  126792. name: string;
  126793. shader: string;
  126794. };
  126795. }
  126796. declare module BABYLON {
  126797. /** @hidden */
  126798. export var pbrFragmentSamplersDeclaration: {
  126799. name: string;
  126800. shader: string;
  126801. };
  126802. }
  126803. declare module BABYLON {
  126804. /** @hidden */
  126805. export var pbrHelperFunctions: {
  126806. name: string;
  126807. shader: string;
  126808. };
  126809. }
  126810. declare module BABYLON {
  126811. /** @hidden */
  126812. export var harmonicsFunctions: {
  126813. name: string;
  126814. shader: string;
  126815. };
  126816. }
  126817. declare module BABYLON {
  126818. /** @hidden */
  126819. export var pbrDirectLightingSetupFunctions: {
  126820. name: string;
  126821. shader: string;
  126822. };
  126823. }
  126824. declare module BABYLON {
  126825. /** @hidden */
  126826. export var pbrDirectLightingFalloffFunctions: {
  126827. name: string;
  126828. shader: string;
  126829. };
  126830. }
  126831. declare module BABYLON {
  126832. /** @hidden */
  126833. export var pbrBRDFFunctions: {
  126834. name: string;
  126835. shader: string;
  126836. };
  126837. }
  126838. declare module BABYLON {
  126839. /** @hidden */
  126840. export var pbrDirectLightingFunctions: {
  126841. name: string;
  126842. shader: string;
  126843. };
  126844. }
  126845. declare module BABYLON {
  126846. /** @hidden */
  126847. export var pbrIBLFunctions: {
  126848. name: string;
  126849. shader: string;
  126850. };
  126851. }
  126852. declare module BABYLON {
  126853. /** @hidden */
  126854. export var pbrBlockAlbedoOpacity: {
  126855. name: string;
  126856. shader: string;
  126857. };
  126858. }
  126859. declare module BABYLON {
  126860. /** @hidden */
  126861. export var pbrBlockReflectivity: {
  126862. name: string;
  126863. shader: string;
  126864. };
  126865. }
  126866. declare module BABYLON {
  126867. /** @hidden */
  126868. export var pbrBlockAmbientOcclusion: {
  126869. name: string;
  126870. shader: string;
  126871. };
  126872. }
  126873. declare module BABYLON {
  126874. /** @hidden */
  126875. export var pbrBlockAlphaFresnel: {
  126876. name: string;
  126877. shader: string;
  126878. };
  126879. }
  126880. declare module BABYLON {
  126881. /** @hidden */
  126882. export var pbrBlockAnisotropic: {
  126883. name: string;
  126884. shader: string;
  126885. };
  126886. }
  126887. declare module BABYLON {
  126888. /** @hidden */
  126889. export var pbrBlockReflection: {
  126890. name: string;
  126891. shader: string;
  126892. };
  126893. }
  126894. declare module BABYLON {
  126895. /** @hidden */
  126896. export var pbrBlockSheen: {
  126897. name: string;
  126898. shader: string;
  126899. };
  126900. }
  126901. declare module BABYLON {
  126902. /** @hidden */
  126903. export var pbrBlockClearcoat: {
  126904. name: string;
  126905. shader: string;
  126906. };
  126907. }
  126908. declare module BABYLON {
  126909. /** @hidden */
  126910. export var pbrBlockSubSurface: {
  126911. name: string;
  126912. shader: string;
  126913. };
  126914. }
  126915. declare module BABYLON {
  126916. /** @hidden */
  126917. export var pbrBlockNormalGeometric: {
  126918. name: string;
  126919. shader: string;
  126920. };
  126921. }
  126922. declare module BABYLON {
  126923. /** @hidden */
  126924. export var pbrBlockNormalFinal: {
  126925. name: string;
  126926. shader: string;
  126927. };
  126928. }
  126929. declare module BABYLON {
  126930. /** @hidden */
  126931. export var pbrBlockGeometryInfo: {
  126932. name: string;
  126933. shader: string;
  126934. };
  126935. }
  126936. declare module BABYLON {
  126937. /** @hidden */
  126938. export var pbrBlockReflectance0: {
  126939. name: string;
  126940. shader: string;
  126941. };
  126942. }
  126943. declare module BABYLON {
  126944. /** @hidden */
  126945. export var pbrBlockReflectance: {
  126946. name: string;
  126947. shader: string;
  126948. };
  126949. }
  126950. declare module BABYLON {
  126951. /** @hidden */
  126952. export var pbrBlockDirectLighting: {
  126953. name: string;
  126954. shader: string;
  126955. };
  126956. }
  126957. declare module BABYLON {
  126958. /** @hidden */
  126959. export var pbrBlockFinalLitComponents: {
  126960. name: string;
  126961. shader: string;
  126962. };
  126963. }
  126964. declare module BABYLON {
  126965. /** @hidden */
  126966. export var pbrBlockFinalUnlitComponents: {
  126967. name: string;
  126968. shader: string;
  126969. };
  126970. }
  126971. declare module BABYLON {
  126972. /** @hidden */
  126973. export var pbrBlockFinalColorComposition: {
  126974. name: string;
  126975. shader: string;
  126976. };
  126977. }
  126978. declare module BABYLON {
  126979. /** @hidden */
  126980. export var pbrBlockImageProcessing: {
  126981. name: string;
  126982. shader: string;
  126983. };
  126984. }
  126985. declare module BABYLON {
  126986. /** @hidden */
  126987. export var pbrDebug: {
  126988. name: string;
  126989. shader: string;
  126990. };
  126991. }
  126992. declare module BABYLON {
  126993. /** @hidden */
  126994. export var pbrPixelShader: {
  126995. name: string;
  126996. shader: string;
  126997. };
  126998. }
  126999. declare module BABYLON {
  127000. /** @hidden */
  127001. export var pbrVertexDeclaration: {
  127002. name: string;
  127003. shader: string;
  127004. };
  127005. }
  127006. declare module BABYLON {
  127007. /** @hidden */
  127008. export var pbrVertexShader: {
  127009. name: string;
  127010. shader: string;
  127011. };
  127012. }
  127013. declare module BABYLON {
  127014. /**
  127015. * Manages the defines for the PBR Material.
  127016. * @hidden
  127017. */
  127018. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  127019. PBR: boolean;
  127020. MAINUV1: boolean;
  127021. MAINUV2: boolean;
  127022. UV1: boolean;
  127023. UV2: boolean;
  127024. ALBEDO: boolean;
  127025. GAMMAALBEDO: boolean;
  127026. ALBEDODIRECTUV: number;
  127027. VERTEXCOLOR: boolean;
  127028. AMBIENT: boolean;
  127029. AMBIENTDIRECTUV: number;
  127030. AMBIENTINGRAYSCALE: boolean;
  127031. OPACITY: boolean;
  127032. VERTEXALPHA: boolean;
  127033. OPACITYDIRECTUV: number;
  127034. OPACITYRGB: boolean;
  127035. ALPHATEST: boolean;
  127036. DEPTHPREPASS: boolean;
  127037. ALPHABLEND: boolean;
  127038. ALPHAFROMALBEDO: boolean;
  127039. ALPHATESTVALUE: string;
  127040. SPECULAROVERALPHA: boolean;
  127041. RADIANCEOVERALPHA: boolean;
  127042. ALPHAFRESNEL: boolean;
  127043. LINEARALPHAFRESNEL: boolean;
  127044. PREMULTIPLYALPHA: boolean;
  127045. EMISSIVE: boolean;
  127046. EMISSIVEDIRECTUV: number;
  127047. REFLECTIVITY: boolean;
  127048. REFLECTIVITYDIRECTUV: number;
  127049. SPECULARTERM: boolean;
  127050. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  127051. MICROSURFACEAUTOMATIC: boolean;
  127052. LODBASEDMICROSFURACE: boolean;
  127053. MICROSURFACEMAP: boolean;
  127054. MICROSURFACEMAPDIRECTUV: number;
  127055. METALLICWORKFLOW: boolean;
  127056. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  127057. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  127058. METALLNESSSTOREINMETALMAPBLUE: boolean;
  127059. AOSTOREINMETALMAPRED: boolean;
  127060. METALLICF0FACTORFROMMETALLICMAP: boolean;
  127061. ENVIRONMENTBRDF: boolean;
  127062. ENVIRONMENTBRDF_RGBD: boolean;
  127063. NORMAL: boolean;
  127064. TANGENT: boolean;
  127065. BUMP: boolean;
  127066. BUMPDIRECTUV: number;
  127067. OBJECTSPACE_NORMALMAP: boolean;
  127068. PARALLAX: boolean;
  127069. PARALLAXOCCLUSION: boolean;
  127070. NORMALXYSCALE: boolean;
  127071. LIGHTMAP: boolean;
  127072. LIGHTMAPDIRECTUV: number;
  127073. USELIGHTMAPASSHADOWMAP: boolean;
  127074. GAMMALIGHTMAP: boolean;
  127075. RGBDLIGHTMAP: boolean;
  127076. REFLECTION: boolean;
  127077. REFLECTIONMAP_3D: boolean;
  127078. REFLECTIONMAP_SPHERICAL: boolean;
  127079. REFLECTIONMAP_PLANAR: boolean;
  127080. REFLECTIONMAP_CUBIC: boolean;
  127081. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  127082. REFLECTIONMAP_PROJECTION: boolean;
  127083. REFLECTIONMAP_SKYBOX: boolean;
  127084. REFLECTIONMAP_EXPLICIT: boolean;
  127085. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  127086. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  127087. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  127088. INVERTCUBICMAP: boolean;
  127089. USESPHERICALFROMREFLECTIONMAP: boolean;
  127090. USEIRRADIANCEMAP: boolean;
  127091. SPHERICAL_HARMONICS: boolean;
  127092. USESPHERICALINVERTEX: boolean;
  127093. REFLECTIONMAP_OPPOSITEZ: boolean;
  127094. LODINREFLECTIONALPHA: boolean;
  127095. GAMMAREFLECTION: boolean;
  127096. RGBDREFLECTION: boolean;
  127097. LINEARSPECULARREFLECTION: boolean;
  127098. RADIANCEOCCLUSION: boolean;
  127099. HORIZONOCCLUSION: boolean;
  127100. INSTANCES: boolean;
  127101. NUM_BONE_INFLUENCERS: number;
  127102. BonesPerMesh: number;
  127103. BONETEXTURE: boolean;
  127104. NONUNIFORMSCALING: boolean;
  127105. MORPHTARGETS: boolean;
  127106. MORPHTARGETS_NORMAL: boolean;
  127107. MORPHTARGETS_TANGENT: boolean;
  127108. MORPHTARGETS_UV: boolean;
  127109. NUM_MORPH_INFLUENCERS: number;
  127110. IMAGEPROCESSING: boolean;
  127111. VIGNETTE: boolean;
  127112. VIGNETTEBLENDMODEMULTIPLY: boolean;
  127113. VIGNETTEBLENDMODEOPAQUE: boolean;
  127114. TONEMAPPING: boolean;
  127115. TONEMAPPING_ACES: boolean;
  127116. CONTRAST: boolean;
  127117. COLORCURVES: boolean;
  127118. COLORGRADING: boolean;
  127119. COLORGRADING3D: boolean;
  127120. SAMPLER3DGREENDEPTH: boolean;
  127121. SAMPLER3DBGRMAP: boolean;
  127122. IMAGEPROCESSINGPOSTPROCESS: boolean;
  127123. EXPOSURE: boolean;
  127124. MULTIVIEW: boolean;
  127125. USEPHYSICALLIGHTFALLOFF: boolean;
  127126. USEGLTFLIGHTFALLOFF: boolean;
  127127. TWOSIDEDLIGHTING: boolean;
  127128. SHADOWFLOAT: boolean;
  127129. CLIPPLANE: boolean;
  127130. CLIPPLANE2: boolean;
  127131. CLIPPLANE3: boolean;
  127132. CLIPPLANE4: boolean;
  127133. CLIPPLANE5: boolean;
  127134. CLIPPLANE6: boolean;
  127135. POINTSIZE: boolean;
  127136. FOG: boolean;
  127137. LOGARITHMICDEPTH: boolean;
  127138. FORCENORMALFORWARD: boolean;
  127139. SPECULARAA: boolean;
  127140. CLEARCOAT: boolean;
  127141. CLEARCOAT_DEFAULTIOR: boolean;
  127142. CLEARCOAT_TEXTURE: boolean;
  127143. CLEARCOAT_TEXTUREDIRECTUV: number;
  127144. CLEARCOAT_BUMP: boolean;
  127145. CLEARCOAT_BUMPDIRECTUV: number;
  127146. CLEARCOAT_TINT: boolean;
  127147. CLEARCOAT_TINT_TEXTURE: boolean;
  127148. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  127149. ANISOTROPIC: boolean;
  127150. ANISOTROPIC_TEXTURE: boolean;
  127151. ANISOTROPIC_TEXTUREDIRECTUV: number;
  127152. BRDF_V_HEIGHT_CORRELATED: boolean;
  127153. MS_BRDF_ENERGY_CONSERVATION: boolean;
  127154. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  127155. SHEEN: boolean;
  127156. SHEEN_TEXTURE: boolean;
  127157. SHEEN_TEXTUREDIRECTUV: number;
  127158. SHEEN_LINKWITHALBEDO: boolean;
  127159. SHEEN_ROUGHNESS: boolean;
  127160. SHEEN_ALBEDOSCALING: boolean;
  127161. SUBSURFACE: boolean;
  127162. SS_REFRACTION: boolean;
  127163. SS_TRANSLUCENCY: boolean;
  127164. SS_SCATERRING: boolean;
  127165. SS_THICKNESSANDMASK_TEXTURE: boolean;
  127166. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  127167. SS_REFRACTIONMAP_3D: boolean;
  127168. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  127169. SS_LODINREFRACTIONALPHA: boolean;
  127170. SS_GAMMAREFRACTION: boolean;
  127171. SS_RGBDREFRACTION: boolean;
  127172. SS_LINEARSPECULARREFRACTION: boolean;
  127173. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  127174. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  127175. UNLIT: boolean;
  127176. DEBUGMODE: number;
  127177. /**
  127178. * Initializes the PBR Material defines.
  127179. */
  127180. constructor();
  127181. /**
  127182. * Resets the PBR Material defines.
  127183. */
  127184. reset(): void;
  127185. }
  127186. /**
  127187. * The Physically based material base class of BJS.
  127188. *
  127189. * This offers the main features of a standard PBR material.
  127190. * For more information, please refer to the documentation :
  127191. * https://doc.babylonjs.com/how_to/physically_based_rendering
  127192. */
  127193. export abstract class PBRBaseMaterial extends PushMaterial {
  127194. /**
  127195. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  127196. */
  127197. static readonly PBRMATERIAL_OPAQUE: number;
  127198. /**
  127199. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  127200. */
  127201. static readonly PBRMATERIAL_ALPHATEST: number;
  127202. /**
  127203. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  127204. */
  127205. static readonly PBRMATERIAL_ALPHABLEND: number;
  127206. /**
  127207. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  127208. * They are also discarded below the alpha cutoff threshold to improve performances.
  127209. */
  127210. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  127211. /**
  127212. * Defines the default value of how much AO map is occluding the analytical lights
  127213. * (point spot...).
  127214. */
  127215. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  127216. /**
  127217. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  127218. */
  127219. static readonly LIGHTFALLOFF_PHYSICAL: number;
  127220. /**
  127221. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  127222. * to enhance interoperability with other engines.
  127223. */
  127224. static readonly LIGHTFALLOFF_GLTF: number;
  127225. /**
  127226. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  127227. * to enhance interoperability with other materials.
  127228. */
  127229. static readonly LIGHTFALLOFF_STANDARD: number;
  127230. /**
  127231. * Intensity of the direct lights e.g. the four lights available in your scene.
  127232. * This impacts both the direct diffuse and specular highlights.
  127233. */
  127234. protected _directIntensity: number;
  127235. /**
  127236. * Intensity of the emissive part of the material.
  127237. * This helps controlling the emissive effect without modifying the emissive color.
  127238. */
  127239. protected _emissiveIntensity: number;
  127240. /**
  127241. * Intensity of the environment e.g. how much the environment will light the object
  127242. * either through harmonics for rough material or through the refelction for shiny ones.
  127243. */
  127244. protected _environmentIntensity: number;
  127245. /**
  127246. * This is a special control allowing the reduction of the specular highlights coming from the
  127247. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  127248. */
  127249. protected _specularIntensity: number;
  127250. /**
  127251. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  127252. */
  127253. private _lightingInfos;
  127254. /**
  127255. * Debug Control allowing disabling the bump map on this material.
  127256. */
  127257. protected _disableBumpMap: boolean;
  127258. /**
  127259. * AKA Diffuse Texture in standard nomenclature.
  127260. */
  127261. protected _albedoTexture: Nullable<BaseTexture>;
  127262. /**
  127263. * AKA Occlusion Texture in other nomenclature.
  127264. */
  127265. protected _ambientTexture: Nullable<BaseTexture>;
  127266. /**
  127267. * AKA Occlusion Texture Intensity in other nomenclature.
  127268. */
  127269. protected _ambientTextureStrength: number;
  127270. /**
  127271. * Defines how much the AO map is occluding the analytical lights (point spot...).
  127272. * 1 means it completely occludes it
  127273. * 0 mean it has no impact
  127274. */
  127275. protected _ambientTextureImpactOnAnalyticalLights: number;
  127276. /**
  127277. * Stores the alpha values in a texture.
  127278. */
  127279. protected _opacityTexture: Nullable<BaseTexture>;
  127280. /**
  127281. * Stores the reflection values in a texture.
  127282. */
  127283. protected _reflectionTexture: Nullable<BaseTexture>;
  127284. /**
  127285. * Stores the emissive values in a texture.
  127286. */
  127287. protected _emissiveTexture: Nullable<BaseTexture>;
  127288. /**
  127289. * AKA Specular texture in other nomenclature.
  127290. */
  127291. protected _reflectivityTexture: Nullable<BaseTexture>;
  127292. /**
  127293. * Used to switch from specular/glossiness to metallic/roughness workflow.
  127294. */
  127295. protected _metallicTexture: Nullable<BaseTexture>;
  127296. /**
  127297. * Specifies the metallic scalar of the metallic/roughness workflow.
  127298. * Can also be used to scale the metalness values of the metallic texture.
  127299. */
  127300. protected _metallic: Nullable<number>;
  127301. /**
  127302. * Specifies the roughness scalar of the metallic/roughness workflow.
  127303. * Can also be used to scale the roughness values of the metallic texture.
  127304. */
  127305. protected _roughness: Nullable<number>;
  127306. /**
  127307. * Specifies the an F0 factor to help configuring the material F0.
  127308. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  127309. * to 0.5 the previously hard coded value stays the same.
  127310. * Can also be used to scale the F0 values of the metallic texture.
  127311. */
  127312. protected _metallicF0Factor: number;
  127313. /**
  127314. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  127315. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  127316. * your expectation as it multiplies with the texture data.
  127317. */
  127318. protected _useMetallicF0FactorFromMetallicTexture: boolean;
  127319. /**
  127320. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  127321. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  127322. */
  127323. protected _microSurfaceTexture: Nullable<BaseTexture>;
  127324. /**
  127325. * Stores surface normal data used to displace a mesh in a texture.
  127326. */
  127327. protected _bumpTexture: Nullable<BaseTexture>;
  127328. /**
  127329. * Stores the pre-calculated light information of a mesh in a texture.
  127330. */
  127331. protected _lightmapTexture: Nullable<BaseTexture>;
  127332. /**
  127333. * The color of a material in ambient lighting.
  127334. */
  127335. protected _ambientColor: Color3;
  127336. /**
  127337. * AKA Diffuse Color in other nomenclature.
  127338. */
  127339. protected _albedoColor: Color3;
  127340. /**
  127341. * AKA Specular Color in other nomenclature.
  127342. */
  127343. protected _reflectivityColor: Color3;
  127344. /**
  127345. * The color applied when light is reflected from a material.
  127346. */
  127347. protected _reflectionColor: Color3;
  127348. /**
  127349. * The color applied when light is emitted from a material.
  127350. */
  127351. protected _emissiveColor: Color3;
  127352. /**
  127353. * AKA Glossiness in other nomenclature.
  127354. */
  127355. protected _microSurface: number;
  127356. /**
  127357. * Specifies that the material will use the light map as a show map.
  127358. */
  127359. protected _useLightmapAsShadowmap: boolean;
  127360. /**
  127361. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  127362. * makes the reflect vector face the model (under horizon).
  127363. */
  127364. protected _useHorizonOcclusion: boolean;
  127365. /**
  127366. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  127367. * too much the area relying on ambient texture to define their ambient occlusion.
  127368. */
  127369. protected _useRadianceOcclusion: boolean;
  127370. /**
  127371. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  127372. */
  127373. protected _useAlphaFromAlbedoTexture: boolean;
  127374. /**
  127375. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  127376. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  127377. */
  127378. protected _useSpecularOverAlpha: boolean;
  127379. /**
  127380. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  127381. */
  127382. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  127383. /**
  127384. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  127385. */
  127386. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  127387. /**
  127388. * Specifies if the metallic texture contains the roughness information in its green channel.
  127389. */
  127390. protected _useRoughnessFromMetallicTextureGreen: boolean;
  127391. /**
  127392. * Specifies if the metallic texture contains the metallness information in its blue channel.
  127393. */
  127394. protected _useMetallnessFromMetallicTextureBlue: boolean;
  127395. /**
  127396. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  127397. */
  127398. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  127399. /**
  127400. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  127401. */
  127402. protected _useAmbientInGrayScale: boolean;
  127403. /**
  127404. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  127405. * The material will try to infer what glossiness each pixel should be.
  127406. */
  127407. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  127408. /**
  127409. * Defines the falloff type used in this material.
  127410. * It by default is Physical.
  127411. */
  127412. protected _lightFalloff: number;
  127413. /**
  127414. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  127415. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  127416. */
  127417. protected _useRadianceOverAlpha: boolean;
  127418. /**
  127419. * Allows using an object space normal map (instead of tangent space).
  127420. */
  127421. protected _useObjectSpaceNormalMap: boolean;
  127422. /**
  127423. * Allows using the bump map in parallax mode.
  127424. */
  127425. protected _useParallax: boolean;
  127426. /**
  127427. * Allows using the bump map in parallax occlusion mode.
  127428. */
  127429. protected _useParallaxOcclusion: boolean;
  127430. /**
  127431. * Controls the scale bias of the parallax mode.
  127432. */
  127433. protected _parallaxScaleBias: number;
  127434. /**
  127435. * If sets to true, disables all the lights affecting the material.
  127436. */
  127437. protected _disableLighting: boolean;
  127438. /**
  127439. * Number of Simultaneous lights allowed on the material.
  127440. */
  127441. protected _maxSimultaneousLights: number;
  127442. /**
  127443. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  127444. */
  127445. protected _invertNormalMapX: boolean;
  127446. /**
  127447. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  127448. */
  127449. protected _invertNormalMapY: boolean;
  127450. /**
  127451. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  127452. */
  127453. protected _twoSidedLighting: boolean;
  127454. /**
  127455. * Defines the alpha limits in alpha test mode.
  127456. */
  127457. protected _alphaCutOff: number;
  127458. /**
  127459. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  127460. */
  127461. protected _forceAlphaTest: boolean;
  127462. /**
  127463. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  127464. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  127465. */
  127466. protected _useAlphaFresnel: boolean;
  127467. /**
  127468. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  127469. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  127470. */
  127471. protected _useLinearAlphaFresnel: boolean;
  127472. /**
  127473. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  127474. * from cos thetav and roughness:
  127475. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  127476. */
  127477. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  127478. /**
  127479. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  127480. */
  127481. protected _forceIrradianceInFragment: boolean;
  127482. /**
  127483. * Force normal to face away from face.
  127484. */
  127485. protected _forceNormalForward: boolean;
  127486. /**
  127487. * Enables specular anti aliasing in the PBR shader.
  127488. * It will both interacts on the Geometry for analytical and IBL lighting.
  127489. * It also prefilter the roughness map based on the bump values.
  127490. */
  127491. protected _enableSpecularAntiAliasing: boolean;
  127492. /**
  127493. * Default configuration related to image processing available in the PBR Material.
  127494. */
  127495. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  127496. /**
  127497. * Keep track of the image processing observer to allow dispose and replace.
  127498. */
  127499. private _imageProcessingObserver;
  127500. /**
  127501. * Attaches a new image processing configuration to the PBR Material.
  127502. * @param configuration
  127503. */
  127504. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  127505. /**
  127506. * Stores the available render targets.
  127507. */
  127508. private _renderTargets;
  127509. /**
  127510. * Sets the global ambient color for the material used in lighting calculations.
  127511. */
  127512. private _globalAmbientColor;
  127513. /**
  127514. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  127515. */
  127516. private _useLogarithmicDepth;
  127517. /**
  127518. * If set to true, no lighting calculations will be applied.
  127519. */
  127520. private _unlit;
  127521. private _debugMode;
  127522. /**
  127523. * @hidden
  127524. * This is reserved for the inspector.
  127525. * Defines the material debug mode.
  127526. * It helps seeing only some components of the material while troubleshooting.
  127527. */
  127528. debugMode: number;
  127529. /**
  127530. * @hidden
  127531. * This is reserved for the inspector.
  127532. * Specify from where on screen the debug mode should start.
  127533. * The value goes from -1 (full screen) to 1 (not visible)
  127534. * It helps with side by side comparison against the final render
  127535. * This defaults to -1
  127536. */
  127537. private debugLimit;
  127538. /**
  127539. * @hidden
  127540. * This is reserved for the inspector.
  127541. * As the default viewing range might not be enough (if the ambient is really small for instance)
  127542. * You can use the factor to better multiply the final value.
  127543. */
  127544. private debugFactor;
  127545. /**
  127546. * Defines the clear coat layer parameters for the material.
  127547. */
  127548. readonly clearCoat: PBRClearCoatConfiguration;
  127549. /**
  127550. * Defines the anisotropic parameters for the material.
  127551. */
  127552. readonly anisotropy: PBRAnisotropicConfiguration;
  127553. /**
  127554. * Defines the BRDF parameters for the material.
  127555. */
  127556. readonly brdf: PBRBRDFConfiguration;
  127557. /**
  127558. * Defines the Sheen parameters for the material.
  127559. */
  127560. readonly sheen: PBRSheenConfiguration;
  127561. /**
  127562. * Defines the SubSurface parameters for the material.
  127563. */
  127564. readonly subSurface: PBRSubSurfaceConfiguration;
  127565. protected _rebuildInParallel: boolean;
  127566. /**
  127567. * Instantiates a new PBRMaterial instance.
  127568. *
  127569. * @param name The material name
  127570. * @param scene The scene the material will be use in.
  127571. */
  127572. constructor(name: string, scene: Scene);
  127573. /**
  127574. * Gets a boolean indicating that current material needs to register RTT
  127575. */
  127576. get hasRenderTargetTextures(): boolean;
  127577. /**
  127578. * Gets the name of the material class.
  127579. */
  127580. getClassName(): string;
  127581. /**
  127582. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  127583. */
  127584. get useLogarithmicDepth(): boolean;
  127585. /**
  127586. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  127587. */
  127588. set useLogarithmicDepth(value: boolean);
  127589. /**
  127590. * Returns true if alpha blending should be disabled.
  127591. */
  127592. protected get _disableAlphaBlending(): boolean;
  127593. /**
  127594. * Specifies whether or not this material should be rendered in alpha blend mode.
  127595. */
  127596. needAlphaBlending(): boolean;
  127597. /**
  127598. * Specifies whether or not this material should be rendered in alpha test mode.
  127599. */
  127600. needAlphaTesting(): boolean;
  127601. /**
  127602. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  127603. */
  127604. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  127605. /**
  127606. * Gets the texture used for the alpha test.
  127607. */
  127608. getAlphaTestTexture(): Nullable<BaseTexture>;
  127609. /**
  127610. * Specifies that the submesh is ready to be used.
  127611. * @param mesh - BJS mesh.
  127612. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  127613. * @param useInstances - Specifies that instances should be used.
  127614. * @returns - boolean indicating that the submesh is ready or not.
  127615. */
  127616. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  127617. /**
  127618. * Specifies if the material uses metallic roughness workflow.
  127619. * @returns boolean specifiying if the material uses metallic roughness workflow.
  127620. */
  127621. isMetallicWorkflow(): boolean;
  127622. private _prepareEffect;
  127623. private _prepareDefines;
  127624. /**
  127625. * Force shader compilation
  127626. */
  127627. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  127628. /**
  127629. * Initializes the uniform buffer layout for the shader.
  127630. */
  127631. buildUniformLayout(): void;
  127632. /**
  127633. * Unbinds the material from the mesh
  127634. */
  127635. unbind(): void;
  127636. /**
  127637. * Binds the submesh data.
  127638. * @param world - The world matrix.
  127639. * @param mesh - The BJS mesh.
  127640. * @param subMesh - A submesh of the BJS mesh.
  127641. */
  127642. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  127643. /**
  127644. * Returns the animatable textures.
  127645. * @returns - Array of animatable textures.
  127646. */
  127647. getAnimatables(): IAnimatable[];
  127648. /**
  127649. * Returns the texture used for reflections.
  127650. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  127651. */
  127652. private _getReflectionTexture;
  127653. /**
  127654. * Returns an array of the actively used textures.
  127655. * @returns - Array of BaseTextures
  127656. */
  127657. getActiveTextures(): BaseTexture[];
  127658. /**
  127659. * Checks to see if a texture is used in the material.
  127660. * @param texture - Base texture to use.
  127661. * @returns - Boolean specifying if a texture is used in the material.
  127662. */
  127663. hasTexture(texture: BaseTexture): boolean;
  127664. /**
  127665. * Disposes the resources of the material.
  127666. * @param forceDisposeEffect - Forces the disposal of effects.
  127667. * @param forceDisposeTextures - Forces the disposal of all textures.
  127668. */
  127669. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  127670. }
  127671. }
  127672. declare module BABYLON {
  127673. /**
  127674. * The Physically based material of BJS.
  127675. *
  127676. * This offers the main features of a standard PBR material.
  127677. * For more information, please refer to the documentation :
  127678. * https://doc.babylonjs.com/how_to/physically_based_rendering
  127679. */
  127680. export class PBRMaterial extends PBRBaseMaterial {
  127681. /**
  127682. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  127683. */
  127684. static readonly PBRMATERIAL_OPAQUE: number;
  127685. /**
  127686. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  127687. */
  127688. static readonly PBRMATERIAL_ALPHATEST: number;
  127689. /**
  127690. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  127691. */
  127692. static readonly PBRMATERIAL_ALPHABLEND: number;
  127693. /**
  127694. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  127695. * They are also discarded below the alpha cutoff threshold to improve performances.
  127696. */
  127697. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  127698. /**
  127699. * Defines the default value of how much AO map is occluding the analytical lights
  127700. * (point spot...).
  127701. */
  127702. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  127703. /**
  127704. * Intensity of the direct lights e.g. the four lights available in your scene.
  127705. * This impacts both the direct diffuse and specular highlights.
  127706. */
  127707. directIntensity: number;
  127708. /**
  127709. * Intensity of the emissive part of the material.
  127710. * This helps controlling the emissive effect without modifying the emissive color.
  127711. */
  127712. emissiveIntensity: number;
  127713. /**
  127714. * Intensity of the environment e.g. how much the environment will light the object
  127715. * either through harmonics for rough material or through the refelction for shiny ones.
  127716. */
  127717. environmentIntensity: number;
  127718. /**
  127719. * This is a special control allowing the reduction of the specular highlights coming from the
  127720. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  127721. */
  127722. specularIntensity: number;
  127723. /**
  127724. * Debug Control allowing disabling the bump map on this material.
  127725. */
  127726. disableBumpMap: boolean;
  127727. /**
  127728. * AKA Diffuse Texture in standard nomenclature.
  127729. */
  127730. albedoTexture: BaseTexture;
  127731. /**
  127732. * AKA Occlusion Texture in other nomenclature.
  127733. */
  127734. ambientTexture: BaseTexture;
  127735. /**
  127736. * AKA Occlusion Texture Intensity in other nomenclature.
  127737. */
  127738. ambientTextureStrength: number;
  127739. /**
  127740. * Defines how much the AO map is occluding the analytical lights (point spot...).
  127741. * 1 means it completely occludes it
  127742. * 0 mean it has no impact
  127743. */
  127744. ambientTextureImpactOnAnalyticalLights: number;
  127745. /**
  127746. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  127747. */
  127748. opacityTexture: BaseTexture;
  127749. /**
  127750. * Stores the reflection values in a texture.
  127751. */
  127752. reflectionTexture: Nullable<BaseTexture>;
  127753. /**
  127754. * Stores the emissive values in a texture.
  127755. */
  127756. emissiveTexture: BaseTexture;
  127757. /**
  127758. * AKA Specular texture in other nomenclature.
  127759. */
  127760. reflectivityTexture: BaseTexture;
  127761. /**
  127762. * Used to switch from specular/glossiness to metallic/roughness workflow.
  127763. */
  127764. metallicTexture: BaseTexture;
  127765. /**
  127766. * Specifies the metallic scalar of the metallic/roughness workflow.
  127767. * Can also be used to scale the metalness values of the metallic texture.
  127768. */
  127769. metallic: Nullable<number>;
  127770. /**
  127771. * Specifies the roughness scalar of the metallic/roughness workflow.
  127772. * Can also be used to scale the roughness values of the metallic texture.
  127773. */
  127774. roughness: Nullable<number>;
  127775. /**
  127776. * Specifies the an F0 factor to help configuring the material F0.
  127777. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  127778. * to 0.5 the previously hard coded value stays the same.
  127779. * Can also be used to scale the F0 values of the metallic texture.
  127780. */
  127781. metallicF0Factor: number;
  127782. /**
  127783. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  127784. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  127785. * your expectation as it multiplies with the texture data.
  127786. */
  127787. useMetallicF0FactorFromMetallicTexture: boolean;
  127788. /**
  127789. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  127790. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  127791. */
  127792. microSurfaceTexture: BaseTexture;
  127793. /**
  127794. * Stores surface normal data used to displace a mesh in a texture.
  127795. */
  127796. bumpTexture: BaseTexture;
  127797. /**
  127798. * Stores the pre-calculated light information of a mesh in a texture.
  127799. */
  127800. lightmapTexture: BaseTexture;
  127801. /**
  127802. * Stores the refracted light information in a texture.
  127803. */
  127804. get refractionTexture(): Nullable<BaseTexture>;
  127805. set refractionTexture(value: Nullable<BaseTexture>);
  127806. /**
  127807. * The color of a material in ambient lighting.
  127808. */
  127809. ambientColor: Color3;
  127810. /**
  127811. * AKA Diffuse Color in other nomenclature.
  127812. */
  127813. albedoColor: Color3;
  127814. /**
  127815. * AKA Specular Color in other nomenclature.
  127816. */
  127817. reflectivityColor: Color3;
  127818. /**
  127819. * The color reflected from the material.
  127820. */
  127821. reflectionColor: Color3;
  127822. /**
  127823. * The color emitted from the material.
  127824. */
  127825. emissiveColor: Color3;
  127826. /**
  127827. * AKA Glossiness in other nomenclature.
  127828. */
  127829. microSurface: number;
  127830. /**
  127831. * source material index of refraction (IOR)' / 'destination material IOR.
  127832. */
  127833. get indexOfRefraction(): number;
  127834. set indexOfRefraction(value: number);
  127835. /**
  127836. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  127837. */
  127838. get invertRefractionY(): boolean;
  127839. set invertRefractionY(value: boolean);
  127840. /**
  127841. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  127842. * Materials half opaque for instance using refraction could benefit from this control.
  127843. */
  127844. get linkRefractionWithTransparency(): boolean;
  127845. set linkRefractionWithTransparency(value: boolean);
  127846. /**
  127847. * If true, the light map contains occlusion information instead of lighting info.
  127848. */
  127849. useLightmapAsShadowmap: boolean;
  127850. /**
  127851. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  127852. */
  127853. useAlphaFromAlbedoTexture: boolean;
  127854. /**
  127855. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  127856. */
  127857. forceAlphaTest: boolean;
  127858. /**
  127859. * Defines the alpha limits in alpha test mode.
  127860. */
  127861. alphaCutOff: number;
  127862. /**
  127863. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  127864. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  127865. */
  127866. useSpecularOverAlpha: boolean;
  127867. /**
  127868. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  127869. */
  127870. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  127871. /**
  127872. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  127873. */
  127874. useRoughnessFromMetallicTextureAlpha: boolean;
  127875. /**
  127876. * Specifies if the metallic texture contains the roughness information in its green channel.
  127877. */
  127878. useRoughnessFromMetallicTextureGreen: boolean;
  127879. /**
  127880. * Specifies if the metallic texture contains the metallness information in its blue channel.
  127881. */
  127882. useMetallnessFromMetallicTextureBlue: boolean;
  127883. /**
  127884. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  127885. */
  127886. useAmbientOcclusionFromMetallicTextureRed: boolean;
  127887. /**
  127888. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  127889. */
  127890. useAmbientInGrayScale: boolean;
  127891. /**
  127892. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  127893. * The material will try to infer what glossiness each pixel should be.
  127894. */
  127895. useAutoMicroSurfaceFromReflectivityMap: boolean;
  127896. /**
  127897. * BJS is using an harcoded light falloff based on a manually sets up range.
  127898. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  127899. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  127900. */
  127901. get usePhysicalLightFalloff(): boolean;
  127902. /**
  127903. * BJS is using an harcoded light falloff based on a manually sets up range.
  127904. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  127905. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  127906. */
  127907. set usePhysicalLightFalloff(value: boolean);
  127908. /**
  127909. * In order to support the falloff compatibility with gltf, a special mode has been added
  127910. * to reproduce the gltf light falloff.
  127911. */
  127912. get useGLTFLightFalloff(): boolean;
  127913. /**
  127914. * In order to support the falloff compatibility with gltf, a special mode has been added
  127915. * to reproduce the gltf light falloff.
  127916. */
  127917. set useGLTFLightFalloff(value: boolean);
  127918. /**
  127919. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  127920. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  127921. */
  127922. useRadianceOverAlpha: boolean;
  127923. /**
  127924. * Allows using an object space normal map (instead of tangent space).
  127925. */
  127926. useObjectSpaceNormalMap: boolean;
  127927. /**
  127928. * Allows using the bump map in parallax mode.
  127929. */
  127930. useParallax: boolean;
  127931. /**
  127932. * Allows using the bump map in parallax occlusion mode.
  127933. */
  127934. useParallaxOcclusion: boolean;
  127935. /**
  127936. * Controls the scale bias of the parallax mode.
  127937. */
  127938. parallaxScaleBias: number;
  127939. /**
  127940. * If sets to true, disables all the lights affecting the material.
  127941. */
  127942. disableLighting: boolean;
  127943. /**
  127944. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  127945. */
  127946. forceIrradianceInFragment: boolean;
  127947. /**
  127948. * Number of Simultaneous lights allowed on the material.
  127949. */
  127950. maxSimultaneousLights: number;
  127951. /**
  127952. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  127953. */
  127954. invertNormalMapX: boolean;
  127955. /**
  127956. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  127957. */
  127958. invertNormalMapY: boolean;
  127959. /**
  127960. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  127961. */
  127962. twoSidedLighting: boolean;
  127963. /**
  127964. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  127965. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  127966. */
  127967. useAlphaFresnel: boolean;
  127968. /**
  127969. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  127970. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  127971. */
  127972. useLinearAlphaFresnel: boolean;
  127973. /**
  127974. * Let user defines the brdf lookup texture used for IBL.
  127975. * A default 8bit version is embedded but you could point at :
  127976. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  127977. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  127978. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  127979. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  127980. */
  127981. environmentBRDFTexture: Nullable<BaseTexture>;
  127982. /**
  127983. * Force normal to face away from face.
  127984. */
  127985. forceNormalForward: boolean;
  127986. /**
  127987. * Enables specular anti aliasing in the PBR shader.
  127988. * It will both interacts on the Geometry for analytical and IBL lighting.
  127989. * It also prefilter the roughness map based on the bump values.
  127990. */
  127991. enableSpecularAntiAliasing: boolean;
  127992. /**
  127993. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  127994. * makes the reflect vector face the model (under horizon).
  127995. */
  127996. useHorizonOcclusion: boolean;
  127997. /**
  127998. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  127999. * too much the area relying on ambient texture to define their ambient occlusion.
  128000. */
  128001. useRadianceOcclusion: boolean;
  128002. /**
  128003. * If set to true, no lighting calculations will be applied.
  128004. */
  128005. unlit: boolean;
  128006. /**
  128007. * Gets the image processing configuration used either in this material.
  128008. */
  128009. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  128010. /**
  128011. * Sets the Default image processing configuration used either in the this material.
  128012. *
  128013. * If sets to null, the scene one is in use.
  128014. */
  128015. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  128016. /**
  128017. * Gets wether the color curves effect is enabled.
  128018. */
  128019. get cameraColorCurvesEnabled(): boolean;
  128020. /**
  128021. * Sets wether the color curves effect is enabled.
  128022. */
  128023. set cameraColorCurvesEnabled(value: boolean);
  128024. /**
  128025. * Gets wether the color grading effect is enabled.
  128026. */
  128027. get cameraColorGradingEnabled(): boolean;
  128028. /**
  128029. * Gets wether the color grading effect is enabled.
  128030. */
  128031. set cameraColorGradingEnabled(value: boolean);
  128032. /**
  128033. * Gets wether tonemapping is enabled or not.
  128034. */
  128035. get cameraToneMappingEnabled(): boolean;
  128036. /**
  128037. * Sets wether tonemapping is enabled or not
  128038. */
  128039. set cameraToneMappingEnabled(value: boolean);
  128040. /**
  128041. * The camera exposure used on this material.
  128042. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  128043. * This corresponds to a photographic exposure.
  128044. */
  128045. get cameraExposure(): number;
  128046. /**
  128047. * The camera exposure used on this material.
  128048. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  128049. * This corresponds to a photographic exposure.
  128050. */
  128051. set cameraExposure(value: number);
  128052. /**
  128053. * Gets The camera contrast used on this material.
  128054. */
  128055. get cameraContrast(): number;
  128056. /**
  128057. * Sets The camera contrast used on this material.
  128058. */
  128059. set cameraContrast(value: number);
  128060. /**
  128061. * Gets the Color Grading 2D Lookup Texture.
  128062. */
  128063. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  128064. /**
  128065. * Sets the Color Grading 2D Lookup Texture.
  128066. */
  128067. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  128068. /**
  128069. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  128070. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  128071. * 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;
  128072. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  128073. */
  128074. get cameraColorCurves(): Nullable<ColorCurves>;
  128075. /**
  128076. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  128077. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  128078. * 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;
  128079. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  128080. */
  128081. set cameraColorCurves(value: Nullable<ColorCurves>);
  128082. /**
  128083. * Instantiates a new PBRMaterial instance.
  128084. *
  128085. * @param name The material name
  128086. * @param scene The scene the material will be use in.
  128087. */
  128088. constructor(name: string, scene: Scene);
  128089. /**
  128090. * Returns the name of this material class.
  128091. */
  128092. getClassName(): string;
  128093. /**
  128094. * Makes a duplicate of the current material.
  128095. * @param name - name to use for the new material.
  128096. */
  128097. clone(name: string): PBRMaterial;
  128098. /**
  128099. * Serializes this PBR Material.
  128100. * @returns - An object with the serialized material.
  128101. */
  128102. serialize(): any;
  128103. /**
  128104. * Parses a PBR Material from a serialized object.
  128105. * @param source - Serialized object.
  128106. * @param scene - BJS scene instance.
  128107. * @param rootUrl - url for the scene object
  128108. * @returns - PBRMaterial
  128109. */
  128110. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  128111. }
  128112. }
  128113. declare module BABYLON {
  128114. /**
  128115. * Direct draw surface info
  128116. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  128117. */
  128118. export interface DDSInfo {
  128119. /**
  128120. * Width of the texture
  128121. */
  128122. width: number;
  128123. /**
  128124. * Width of the texture
  128125. */
  128126. height: number;
  128127. /**
  128128. * Number of Mipmaps for the texture
  128129. * @see https://en.wikipedia.org/wiki/Mipmap
  128130. */
  128131. mipmapCount: number;
  128132. /**
  128133. * If the textures format is a known fourCC format
  128134. * @see https://www.fourcc.org/
  128135. */
  128136. isFourCC: boolean;
  128137. /**
  128138. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  128139. */
  128140. isRGB: boolean;
  128141. /**
  128142. * If the texture is a lumincance format
  128143. */
  128144. isLuminance: boolean;
  128145. /**
  128146. * If this is a cube texture
  128147. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  128148. */
  128149. isCube: boolean;
  128150. /**
  128151. * If the texture is a compressed format eg. FOURCC_DXT1
  128152. */
  128153. isCompressed: boolean;
  128154. /**
  128155. * The dxgiFormat of the texture
  128156. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  128157. */
  128158. dxgiFormat: number;
  128159. /**
  128160. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  128161. */
  128162. textureType: number;
  128163. /**
  128164. * Sphericle polynomial created for the dds texture
  128165. */
  128166. sphericalPolynomial?: SphericalPolynomial;
  128167. }
  128168. /**
  128169. * Class used to provide DDS decompression tools
  128170. */
  128171. export class DDSTools {
  128172. /**
  128173. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  128174. */
  128175. static StoreLODInAlphaChannel: boolean;
  128176. /**
  128177. * Gets DDS information from an array buffer
  128178. * @param data defines the array buffer view to read data from
  128179. * @returns the DDS information
  128180. */
  128181. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  128182. private static _FloatView;
  128183. private static _Int32View;
  128184. private static _ToHalfFloat;
  128185. private static _FromHalfFloat;
  128186. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  128187. private static _GetHalfFloatRGBAArrayBuffer;
  128188. private static _GetFloatRGBAArrayBuffer;
  128189. private static _GetFloatAsUIntRGBAArrayBuffer;
  128190. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  128191. private static _GetRGBAArrayBuffer;
  128192. private static _ExtractLongWordOrder;
  128193. private static _GetRGBArrayBuffer;
  128194. private static _GetLuminanceArrayBuffer;
  128195. /**
  128196. * Uploads DDS Levels to a Babylon Texture
  128197. * @hidden
  128198. */
  128199. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  128200. }
  128201. interface ThinEngine {
  128202. /**
  128203. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  128204. * @param rootUrl defines the url where the file to load is located
  128205. * @param scene defines the current scene
  128206. * @param lodScale defines scale to apply to the mip map selection
  128207. * @param lodOffset defines offset to apply to the mip map selection
  128208. * @param onLoad defines an optional callback raised when the texture is loaded
  128209. * @param onError defines an optional callback raised if there is an issue to load the texture
  128210. * @param format defines the format of the data
  128211. * @param forcedExtension defines the extension to use to pick the right loader
  128212. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  128213. * @returns the cube texture as an InternalTexture
  128214. */
  128215. 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;
  128216. }
  128217. }
  128218. declare module BABYLON {
  128219. /**
  128220. * Implementation of the DDS Texture Loader.
  128221. * @hidden
  128222. */
  128223. export class _DDSTextureLoader implements IInternalTextureLoader {
  128224. /**
  128225. * Defines wether the loader supports cascade loading the different faces.
  128226. */
  128227. readonly supportCascades: boolean;
  128228. /**
  128229. * This returns if the loader support the current file information.
  128230. * @param extension defines the file extension of the file being loaded
  128231. * @returns true if the loader can load the specified file
  128232. */
  128233. canLoad(extension: string): boolean;
  128234. /**
  128235. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  128236. * @param data contains the texture data
  128237. * @param texture defines the BabylonJS internal texture
  128238. * @param createPolynomials will be true if polynomials have been requested
  128239. * @param onLoad defines the callback to trigger once the texture is ready
  128240. * @param onError defines the callback to trigger in case of error
  128241. */
  128242. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  128243. /**
  128244. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  128245. * @param data contains the texture data
  128246. * @param texture defines the BabylonJS internal texture
  128247. * @param callback defines the method to call once ready to upload
  128248. */
  128249. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  128250. }
  128251. }
  128252. declare module BABYLON {
  128253. /**
  128254. * Implementation of the ENV Texture Loader.
  128255. * @hidden
  128256. */
  128257. export class _ENVTextureLoader implements IInternalTextureLoader {
  128258. /**
  128259. * Defines wether the loader supports cascade loading the different faces.
  128260. */
  128261. readonly supportCascades: boolean;
  128262. /**
  128263. * This returns if the loader support the current file information.
  128264. * @param extension defines the file extension of the file being loaded
  128265. * @returns true if the loader can load the specified file
  128266. */
  128267. canLoad(extension: string): boolean;
  128268. /**
  128269. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  128270. * @param data contains the texture data
  128271. * @param texture defines the BabylonJS internal texture
  128272. * @param createPolynomials will be true if polynomials have been requested
  128273. * @param onLoad defines the callback to trigger once the texture is ready
  128274. * @param onError defines the callback to trigger in case of error
  128275. */
  128276. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  128277. /**
  128278. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  128279. * @param data contains the texture data
  128280. * @param texture defines the BabylonJS internal texture
  128281. * @param callback defines the method to call once ready to upload
  128282. */
  128283. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  128284. }
  128285. }
  128286. declare module BABYLON {
  128287. /**
  128288. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  128289. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  128290. */
  128291. export class KhronosTextureContainer {
  128292. /** contents of the KTX container file */
  128293. data: ArrayBufferView;
  128294. private static HEADER_LEN;
  128295. private static COMPRESSED_2D;
  128296. private static COMPRESSED_3D;
  128297. private static TEX_2D;
  128298. private static TEX_3D;
  128299. /**
  128300. * Gets the openGL type
  128301. */
  128302. glType: number;
  128303. /**
  128304. * Gets the openGL type size
  128305. */
  128306. glTypeSize: number;
  128307. /**
  128308. * Gets the openGL format
  128309. */
  128310. glFormat: number;
  128311. /**
  128312. * Gets the openGL internal format
  128313. */
  128314. glInternalFormat: number;
  128315. /**
  128316. * Gets the base internal format
  128317. */
  128318. glBaseInternalFormat: number;
  128319. /**
  128320. * Gets image width in pixel
  128321. */
  128322. pixelWidth: number;
  128323. /**
  128324. * Gets image height in pixel
  128325. */
  128326. pixelHeight: number;
  128327. /**
  128328. * Gets image depth in pixels
  128329. */
  128330. pixelDepth: number;
  128331. /**
  128332. * Gets the number of array elements
  128333. */
  128334. numberOfArrayElements: number;
  128335. /**
  128336. * Gets the number of faces
  128337. */
  128338. numberOfFaces: number;
  128339. /**
  128340. * Gets the number of mipmap levels
  128341. */
  128342. numberOfMipmapLevels: number;
  128343. /**
  128344. * Gets the bytes of key value data
  128345. */
  128346. bytesOfKeyValueData: number;
  128347. /**
  128348. * Gets the load type
  128349. */
  128350. loadType: number;
  128351. /**
  128352. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  128353. */
  128354. isInvalid: boolean;
  128355. /**
  128356. * Creates a new KhronosTextureContainer
  128357. * @param data contents of the KTX container file
  128358. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  128359. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  128360. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  128361. */
  128362. constructor(
  128363. /** contents of the KTX container file */
  128364. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  128365. /**
  128366. * Uploads KTX content to a Babylon Texture.
  128367. * It is assumed that the texture has already been created & is currently bound
  128368. * @hidden
  128369. */
  128370. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  128371. private _upload2DCompressedLevels;
  128372. /**
  128373. * Checks if the given data starts with a KTX file identifier.
  128374. * @param data the data to check
  128375. * @returns true if the data is a KTX file or false otherwise
  128376. */
  128377. static IsValid(data: ArrayBufferView): boolean;
  128378. }
  128379. }
  128380. declare module BABYLON {
  128381. /**
  128382. * Class for loading KTX2 files
  128383. * !!! Experimental Extension Subject to Changes !!!
  128384. * @hidden
  128385. */
  128386. export class KhronosTextureContainer2 {
  128387. private static _ModulePromise;
  128388. private static _TranscodeFormat;
  128389. constructor(engine: ThinEngine);
  128390. uploadAsync(data: ArrayBufferView, internalTexture: InternalTexture): Promise<void>;
  128391. private _determineTranscodeFormat;
  128392. /**
  128393. * Checks if the given data starts with a KTX2 file identifier.
  128394. * @param data the data to check
  128395. * @returns true if the data is a KTX2 file or false otherwise
  128396. */
  128397. static IsValid(data: ArrayBufferView): boolean;
  128398. }
  128399. }
  128400. declare module BABYLON {
  128401. /**
  128402. * Implementation of the KTX Texture Loader.
  128403. * @hidden
  128404. */
  128405. export class _KTXTextureLoader implements IInternalTextureLoader {
  128406. /**
  128407. * Defines wether the loader supports cascade loading the different faces.
  128408. */
  128409. readonly supportCascades: boolean;
  128410. /**
  128411. * This returns if the loader support the current file information.
  128412. * @param extension defines the file extension of the file being loaded
  128413. * @returns true if the loader can load the specified file
  128414. */
  128415. canLoad(extension: string): boolean;
  128416. /**
  128417. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  128418. * @param data contains the texture data
  128419. * @param texture defines the BabylonJS internal texture
  128420. * @param createPolynomials will be true if polynomials have been requested
  128421. * @param onLoad defines the callback to trigger once the texture is ready
  128422. * @param onError defines the callback to trigger in case of error
  128423. */
  128424. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  128425. /**
  128426. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  128427. * @param data contains the texture data
  128428. * @param texture defines the BabylonJS internal texture
  128429. * @param callback defines the method to call once ready to upload
  128430. */
  128431. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  128432. }
  128433. }
  128434. declare module BABYLON {
  128435. /** @hidden */
  128436. export var _forceSceneHelpersToBundle: boolean;
  128437. interface Scene {
  128438. /**
  128439. * Creates a default light for the scene.
  128440. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  128441. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  128442. */
  128443. createDefaultLight(replace?: boolean): void;
  128444. /**
  128445. * Creates a default camera for the scene.
  128446. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  128447. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  128448. * @param replace has default false, when true replaces the active camera in the scene
  128449. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  128450. */
  128451. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  128452. /**
  128453. * Creates a default camera and a default light.
  128454. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  128455. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  128456. * @param replace has the default false, when true replaces the active camera/light in the scene
  128457. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  128458. */
  128459. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  128460. /**
  128461. * Creates a new sky box
  128462. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  128463. * @param environmentTexture defines the texture to use as environment texture
  128464. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  128465. * @param scale defines the overall scale of the skybox
  128466. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  128467. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  128468. * @returns a new mesh holding the sky box
  128469. */
  128470. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  128471. /**
  128472. * Creates a new environment
  128473. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  128474. * @param options defines the options you can use to configure the environment
  128475. * @returns the new EnvironmentHelper
  128476. */
  128477. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  128478. /**
  128479. * Creates a new VREXperienceHelper
  128480. * @see http://doc.babylonjs.com/how_to/webvr_helper
  128481. * @param webVROptions defines the options used to create the new VREXperienceHelper
  128482. * @returns a new VREXperienceHelper
  128483. */
  128484. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  128485. /**
  128486. * Creates a new WebXRDefaultExperience
  128487. * @see http://doc.babylonjs.com/how_to/webxr
  128488. * @param options experience options
  128489. * @returns a promise for a new WebXRDefaultExperience
  128490. */
  128491. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  128492. }
  128493. }
  128494. declare module BABYLON {
  128495. /**
  128496. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  128497. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  128498. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  128499. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  128500. */
  128501. export class VideoDome extends TransformNode {
  128502. /**
  128503. * Define the video source as a Monoscopic panoramic 360 video.
  128504. */
  128505. static readonly MODE_MONOSCOPIC: number;
  128506. /**
  128507. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  128508. */
  128509. static readonly MODE_TOPBOTTOM: number;
  128510. /**
  128511. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  128512. */
  128513. static readonly MODE_SIDEBYSIDE: number;
  128514. private _halfDome;
  128515. private _useDirectMapping;
  128516. /**
  128517. * The video texture being displayed on the sphere
  128518. */
  128519. protected _videoTexture: VideoTexture;
  128520. /**
  128521. * Gets the video texture being displayed on the sphere
  128522. */
  128523. get videoTexture(): VideoTexture;
  128524. /**
  128525. * The skybox material
  128526. */
  128527. protected _material: BackgroundMaterial;
  128528. /**
  128529. * The surface used for the skybox
  128530. */
  128531. protected _mesh: Mesh;
  128532. /**
  128533. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  128534. */
  128535. private _halfDomeMask;
  128536. /**
  128537. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  128538. * Also see the options.resolution property.
  128539. */
  128540. get fovMultiplier(): number;
  128541. set fovMultiplier(value: number);
  128542. private _videoMode;
  128543. /**
  128544. * Gets or set the current video mode for the video. It can be:
  128545. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  128546. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  128547. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  128548. */
  128549. get videoMode(): number;
  128550. set videoMode(value: number);
  128551. /**
  128552. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  128553. *
  128554. */
  128555. get halfDome(): boolean;
  128556. /**
  128557. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  128558. */
  128559. set halfDome(enabled: boolean);
  128560. /**
  128561. * Oberserver used in Stereoscopic VR Mode.
  128562. */
  128563. private _onBeforeCameraRenderObserver;
  128564. /**
  128565. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  128566. * @param name Element's name, child elements will append suffixes for their own names.
  128567. * @param urlsOrVideo defines the url(s) or the video element to use
  128568. * @param options An object containing optional or exposed sub element properties
  128569. */
  128570. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  128571. resolution?: number;
  128572. clickToPlay?: boolean;
  128573. autoPlay?: boolean;
  128574. loop?: boolean;
  128575. size?: number;
  128576. poster?: string;
  128577. faceForward?: boolean;
  128578. useDirectMapping?: boolean;
  128579. halfDomeMode?: boolean;
  128580. }, scene: Scene);
  128581. private _changeVideoMode;
  128582. /**
  128583. * Releases resources associated with this node.
  128584. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  128585. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  128586. */
  128587. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  128588. }
  128589. }
  128590. declare module BABYLON {
  128591. /**
  128592. * This class can be used to get instrumentation data from a Babylon engine
  128593. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  128594. */
  128595. export class EngineInstrumentation implements IDisposable {
  128596. /**
  128597. * Define the instrumented engine.
  128598. */
  128599. engine: Engine;
  128600. private _captureGPUFrameTime;
  128601. private _gpuFrameTimeToken;
  128602. private _gpuFrameTime;
  128603. private _captureShaderCompilationTime;
  128604. private _shaderCompilationTime;
  128605. private _onBeginFrameObserver;
  128606. private _onEndFrameObserver;
  128607. private _onBeforeShaderCompilationObserver;
  128608. private _onAfterShaderCompilationObserver;
  128609. /**
  128610. * Gets the perf counter used for GPU frame time
  128611. */
  128612. get gpuFrameTimeCounter(): PerfCounter;
  128613. /**
  128614. * Gets the GPU frame time capture status
  128615. */
  128616. get captureGPUFrameTime(): boolean;
  128617. /**
  128618. * Enable or disable the GPU frame time capture
  128619. */
  128620. set captureGPUFrameTime(value: boolean);
  128621. /**
  128622. * Gets the perf counter used for shader compilation time
  128623. */
  128624. get shaderCompilationTimeCounter(): PerfCounter;
  128625. /**
  128626. * Gets the shader compilation time capture status
  128627. */
  128628. get captureShaderCompilationTime(): boolean;
  128629. /**
  128630. * Enable or disable the shader compilation time capture
  128631. */
  128632. set captureShaderCompilationTime(value: boolean);
  128633. /**
  128634. * Instantiates a new engine instrumentation.
  128635. * This class can be used to get instrumentation data from a Babylon engine
  128636. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  128637. * @param engine Defines the engine to instrument
  128638. */
  128639. constructor(
  128640. /**
  128641. * Define the instrumented engine.
  128642. */
  128643. engine: Engine);
  128644. /**
  128645. * Dispose and release associated resources.
  128646. */
  128647. dispose(): void;
  128648. }
  128649. }
  128650. declare module BABYLON {
  128651. /**
  128652. * This class can be used to get instrumentation data from a Babylon engine
  128653. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  128654. */
  128655. export class SceneInstrumentation implements IDisposable {
  128656. /**
  128657. * Defines the scene to instrument
  128658. */
  128659. scene: Scene;
  128660. private _captureActiveMeshesEvaluationTime;
  128661. private _activeMeshesEvaluationTime;
  128662. private _captureRenderTargetsRenderTime;
  128663. private _renderTargetsRenderTime;
  128664. private _captureFrameTime;
  128665. private _frameTime;
  128666. private _captureRenderTime;
  128667. private _renderTime;
  128668. private _captureInterFrameTime;
  128669. private _interFrameTime;
  128670. private _captureParticlesRenderTime;
  128671. private _particlesRenderTime;
  128672. private _captureSpritesRenderTime;
  128673. private _spritesRenderTime;
  128674. private _capturePhysicsTime;
  128675. private _physicsTime;
  128676. private _captureAnimationsTime;
  128677. private _animationsTime;
  128678. private _captureCameraRenderTime;
  128679. private _cameraRenderTime;
  128680. private _onBeforeActiveMeshesEvaluationObserver;
  128681. private _onAfterActiveMeshesEvaluationObserver;
  128682. private _onBeforeRenderTargetsRenderObserver;
  128683. private _onAfterRenderTargetsRenderObserver;
  128684. private _onAfterRenderObserver;
  128685. private _onBeforeDrawPhaseObserver;
  128686. private _onAfterDrawPhaseObserver;
  128687. private _onBeforeAnimationsObserver;
  128688. private _onBeforeParticlesRenderingObserver;
  128689. private _onAfterParticlesRenderingObserver;
  128690. private _onBeforeSpritesRenderingObserver;
  128691. private _onAfterSpritesRenderingObserver;
  128692. private _onBeforePhysicsObserver;
  128693. private _onAfterPhysicsObserver;
  128694. private _onAfterAnimationsObserver;
  128695. private _onBeforeCameraRenderObserver;
  128696. private _onAfterCameraRenderObserver;
  128697. /**
  128698. * Gets the perf counter used for active meshes evaluation time
  128699. */
  128700. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  128701. /**
  128702. * Gets the active meshes evaluation time capture status
  128703. */
  128704. get captureActiveMeshesEvaluationTime(): boolean;
  128705. /**
  128706. * Enable or disable the active meshes evaluation time capture
  128707. */
  128708. set captureActiveMeshesEvaluationTime(value: boolean);
  128709. /**
  128710. * Gets the perf counter used for render targets render time
  128711. */
  128712. get renderTargetsRenderTimeCounter(): PerfCounter;
  128713. /**
  128714. * Gets the render targets render time capture status
  128715. */
  128716. get captureRenderTargetsRenderTime(): boolean;
  128717. /**
  128718. * Enable or disable the render targets render time capture
  128719. */
  128720. set captureRenderTargetsRenderTime(value: boolean);
  128721. /**
  128722. * Gets the perf counter used for particles render time
  128723. */
  128724. get particlesRenderTimeCounter(): PerfCounter;
  128725. /**
  128726. * Gets the particles render time capture status
  128727. */
  128728. get captureParticlesRenderTime(): boolean;
  128729. /**
  128730. * Enable or disable the particles render time capture
  128731. */
  128732. set captureParticlesRenderTime(value: boolean);
  128733. /**
  128734. * Gets the perf counter used for sprites render time
  128735. */
  128736. get spritesRenderTimeCounter(): PerfCounter;
  128737. /**
  128738. * Gets the sprites render time capture status
  128739. */
  128740. get captureSpritesRenderTime(): boolean;
  128741. /**
  128742. * Enable or disable the sprites render time capture
  128743. */
  128744. set captureSpritesRenderTime(value: boolean);
  128745. /**
  128746. * Gets the perf counter used for physics time
  128747. */
  128748. get physicsTimeCounter(): PerfCounter;
  128749. /**
  128750. * Gets the physics time capture status
  128751. */
  128752. get capturePhysicsTime(): boolean;
  128753. /**
  128754. * Enable or disable the physics time capture
  128755. */
  128756. set capturePhysicsTime(value: boolean);
  128757. /**
  128758. * Gets the perf counter used for animations time
  128759. */
  128760. get animationsTimeCounter(): PerfCounter;
  128761. /**
  128762. * Gets the animations time capture status
  128763. */
  128764. get captureAnimationsTime(): boolean;
  128765. /**
  128766. * Enable or disable the animations time capture
  128767. */
  128768. set captureAnimationsTime(value: boolean);
  128769. /**
  128770. * Gets the perf counter used for frame time capture
  128771. */
  128772. get frameTimeCounter(): PerfCounter;
  128773. /**
  128774. * Gets the frame time capture status
  128775. */
  128776. get captureFrameTime(): boolean;
  128777. /**
  128778. * Enable or disable the frame time capture
  128779. */
  128780. set captureFrameTime(value: boolean);
  128781. /**
  128782. * Gets the perf counter used for inter-frames time capture
  128783. */
  128784. get interFrameTimeCounter(): PerfCounter;
  128785. /**
  128786. * Gets the inter-frames time capture status
  128787. */
  128788. get captureInterFrameTime(): boolean;
  128789. /**
  128790. * Enable or disable the inter-frames time capture
  128791. */
  128792. set captureInterFrameTime(value: boolean);
  128793. /**
  128794. * Gets the perf counter used for render time capture
  128795. */
  128796. get renderTimeCounter(): PerfCounter;
  128797. /**
  128798. * Gets the render time capture status
  128799. */
  128800. get captureRenderTime(): boolean;
  128801. /**
  128802. * Enable or disable the render time capture
  128803. */
  128804. set captureRenderTime(value: boolean);
  128805. /**
  128806. * Gets the perf counter used for camera render time capture
  128807. */
  128808. get cameraRenderTimeCounter(): PerfCounter;
  128809. /**
  128810. * Gets the camera render time capture status
  128811. */
  128812. get captureCameraRenderTime(): boolean;
  128813. /**
  128814. * Enable or disable the camera render time capture
  128815. */
  128816. set captureCameraRenderTime(value: boolean);
  128817. /**
  128818. * Gets the perf counter used for draw calls
  128819. */
  128820. get drawCallsCounter(): PerfCounter;
  128821. /**
  128822. * Instantiates a new scene instrumentation.
  128823. * This class can be used to get instrumentation data from a Babylon engine
  128824. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  128825. * @param scene Defines the scene to instrument
  128826. */
  128827. constructor(
  128828. /**
  128829. * Defines the scene to instrument
  128830. */
  128831. scene: Scene);
  128832. /**
  128833. * Dispose and release associated resources.
  128834. */
  128835. dispose(): void;
  128836. }
  128837. }
  128838. declare module BABYLON {
  128839. /** @hidden */
  128840. export var glowMapGenerationPixelShader: {
  128841. name: string;
  128842. shader: string;
  128843. };
  128844. }
  128845. declare module BABYLON {
  128846. /** @hidden */
  128847. export var glowMapGenerationVertexShader: {
  128848. name: string;
  128849. shader: string;
  128850. };
  128851. }
  128852. declare module BABYLON {
  128853. /**
  128854. * Effect layer options. This helps customizing the behaviour
  128855. * of the effect layer.
  128856. */
  128857. export interface IEffectLayerOptions {
  128858. /**
  128859. * Multiplication factor apply to the canvas size to compute the render target size
  128860. * used to generated the objects (the smaller the faster).
  128861. */
  128862. mainTextureRatio: number;
  128863. /**
  128864. * Enforces a fixed size texture to ensure effect stability across devices.
  128865. */
  128866. mainTextureFixedSize?: number;
  128867. /**
  128868. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  128869. */
  128870. alphaBlendingMode: number;
  128871. /**
  128872. * The camera attached to the layer.
  128873. */
  128874. camera: Nullable<Camera>;
  128875. /**
  128876. * The rendering group to draw the layer in.
  128877. */
  128878. renderingGroupId: number;
  128879. }
  128880. /**
  128881. * The effect layer Helps adding post process effect blended with the main pass.
  128882. *
  128883. * This can be for instance use to generate glow or higlight effects on the scene.
  128884. *
  128885. * The effect layer class can not be used directly and is intented to inherited from to be
  128886. * customized per effects.
  128887. */
  128888. export abstract class EffectLayer {
  128889. private _vertexBuffers;
  128890. private _indexBuffer;
  128891. private _cachedDefines;
  128892. private _effectLayerMapGenerationEffect;
  128893. private _effectLayerOptions;
  128894. private _mergeEffect;
  128895. protected _scene: Scene;
  128896. protected _engine: Engine;
  128897. protected _maxSize: number;
  128898. protected _mainTextureDesiredSize: ISize;
  128899. protected _mainTexture: RenderTargetTexture;
  128900. protected _shouldRender: boolean;
  128901. protected _postProcesses: PostProcess[];
  128902. protected _textures: BaseTexture[];
  128903. protected _emissiveTextureAndColor: {
  128904. texture: Nullable<BaseTexture>;
  128905. color: Color4;
  128906. };
  128907. /**
  128908. * The name of the layer
  128909. */
  128910. name: string;
  128911. /**
  128912. * The clear color of the texture used to generate the glow map.
  128913. */
  128914. neutralColor: Color4;
  128915. /**
  128916. * Specifies whether the highlight layer is enabled or not.
  128917. */
  128918. isEnabled: boolean;
  128919. /**
  128920. * Gets the camera attached to the layer.
  128921. */
  128922. get camera(): Nullable<Camera>;
  128923. /**
  128924. * Gets the rendering group id the layer should render in.
  128925. */
  128926. get renderingGroupId(): number;
  128927. set renderingGroupId(renderingGroupId: number);
  128928. /**
  128929. * An event triggered when the effect layer has been disposed.
  128930. */
  128931. onDisposeObservable: Observable<EffectLayer>;
  128932. /**
  128933. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  128934. */
  128935. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  128936. /**
  128937. * An event triggered when the generated texture is being merged in the scene.
  128938. */
  128939. onBeforeComposeObservable: Observable<EffectLayer>;
  128940. /**
  128941. * An event triggered when the mesh is rendered into the effect render target.
  128942. */
  128943. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  128944. /**
  128945. * An event triggered after the mesh has been rendered into the effect render target.
  128946. */
  128947. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  128948. /**
  128949. * An event triggered when the generated texture has been merged in the scene.
  128950. */
  128951. onAfterComposeObservable: Observable<EffectLayer>;
  128952. /**
  128953. * An event triggered when the efffect layer changes its size.
  128954. */
  128955. onSizeChangedObservable: Observable<EffectLayer>;
  128956. /** @hidden */
  128957. static _SceneComponentInitialization: (scene: Scene) => void;
  128958. /**
  128959. * Instantiates a new effect Layer and references it in the scene.
  128960. * @param name The name of the layer
  128961. * @param scene The scene to use the layer in
  128962. */
  128963. constructor(
  128964. /** The Friendly of the effect in the scene */
  128965. name: string, scene: Scene);
  128966. /**
  128967. * Get the effect name of the layer.
  128968. * @return The effect name
  128969. */
  128970. abstract getEffectName(): string;
  128971. /**
  128972. * Checks for the readiness of the element composing the layer.
  128973. * @param subMesh the mesh to check for
  128974. * @param useInstances specify whether or not to use instances to render the mesh
  128975. * @return true if ready otherwise, false
  128976. */
  128977. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  128978. /**
  128979. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  128980. * @returns true if the effect requires stencil during the main canvas render pass.
  128981. */
  128982. abstract needStencil(): boolean;
  128983. /**
  128984. * Create the merge effect. This is the shader use to blit the information back
  128985. * to the main canvas at the end of the scene rendering.
  128986. * @returns The effect containing the shader used to merge the effect on the main canvas
  128987. */
  128988. protected abstract _createMergeEffect(): Effect;
  128989. /**
  128990. * Creates the render target textures and post processes used in the effect layer.
  128991. */
  128992. protected abstract _createTextureAndPostProcesses(): void;
  128993. /**
  128994. * Implementation specific of rendering the generating effect on the main canvas.
  128995. * @param effect The effect used to render through
  128996. */
  128997. protected abstract _internalRender(effect: Effect): void;
  128998. /**
  128999. * Sets the required values for both the emissive texture and and the main color.
  129000. */
  129001. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  129002. /**
  129003. * Free any resources and references associated to a mesh.
  129004. * Internal use
  129005. * @param mesh The mesh to free.
  129006. */
  129007. abstract _disposeMesh(mesh: Mesh): void;
  129008. /**
  129009. * Serializes this layer (Glow or Highlight for example)
  129010. * @returns a serialized layer object
  129011. */
  129012. abstract serialize?(): any;
  129013. /**
  129014. * Initializes the effect layer with the required options.
  129015. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  129016. */
  129017. protected _init(options: Partial<IEffectLayerOptions>): void;
  129018. /**
  129019. * Generates the index buffer of the full screen quad blending to the main canvas.
  129020. */
  129021. private _generateIndexBuffer;
  129022. /**
  129023. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  129024. */
  129025. private _generateVertexBuffer;
  129026. /**
  129027. * Sets the main texture desired size which is the closest power of two
  129028. * of the engine canvas size.
  129029. */
  129030. private _setMainTextureSize;
  129031. /**
  129032. * Creates the main texture for the effect layer.
  129033. */
  129034. protected _createMainTexture(): void;
  129035. /**
  129036. * Adds specific effects defines.
  129037. * @param defines The defines to add specifics to.
  129038. */
  129039. protected _addCustomEffectDefines(defines: string[]): void;
  129040. /**
  129041. * Checks for the readiness of the element composing the layer.
  129042. * @param subMesh the mesh to check for
  129043. * @param useInstances specify whether or not to use instances to render the mesh
  129044. * @param emissiveTexture the associated emissive texture used to generate the glow
  129045. * @return true if ready otherwise, false
  129046. */
  129047. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  129048. /**
  129049. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  129050. */
  129051. render(): void;
  129052. /**
  129053. * Determine if a given mesh will be used in the current effect.
  129054. * @param mesh mesh to test
  129055. * @returns true if the mesh will be used
  129056. */
  129057. hasMesh(mesh: AbstractMesh): boolean;
  129058. /**
  129059. * Returns true if the layer contains information to display, otherwise false.
  129060. * @returns true if the glow layer should be rendered
  129061. */
  129062. shouldRender(): boolean;
  129063. /**
  129064. * Returns true if the mesh should render, otherwise false.
  129065. * @param mesh The mesh to render
  129066. * @returns true if it should render otherwise false
  129067. */
  129068. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  129069. /**
  129070. * Returns true if the mesh can be rendered, otherwise false.
  129071. * @param mesh The mesh to render
  129072. * @param material The material used on the mesh
  129073. * @returns true if it can be rendered otherwise false
  129074. */
  129075. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  129076. /**
  129077. * Returns true if the mesh should render, otherwise false.
  129078. * @param mesh The mesh to render
  129079. * @returns true if it should render otherwise false
  129080. */
  129081. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  129082. /**
  129083. * Renders the submesh passed in parameter to the generation map.
  129084. */
  129085. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  129086. /**
  129087. * Defines whether the current material of the mesh should be use to render the effect.
  129088. * @param mesh defines the current mesh to render
  129089. */
  129090. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  129091. /**
  129092. * Rebuild the required buffers.
  129093. * @hidden Internal use only.
  129094. */
  129095. _rebuild(): void;
  129096. /**
  129097. * Dispose only the render target textures and post process.
  129098. */
  129099. private _disposeTextureAndPostProcesses;
  129100. /**
  129101. * Dispose the highlight layer and free resources.
  129102. */
  129103. dispose(): void;
  129104. /**
  129105. * Gets the class name of the effect layer
  129106. * @returns the string with the class name of the effect layer
  129107. */
  129108. getClassName(): string;
  129109. /**
  129110. * Creates an effect layer from parsed effect layer data
  129111. * @param parsedEffectLayer defines effect layer data
  129112. * @param scene defines the current scene
  129113. * @param rootUrl defines the root URL containing the effect layer information
  129114. * @returns a parsed effect Layer
  129115. */
  129116. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  129117. }
  129118. }
  129119. declare module BABYLON {
  129120. interface AbstractScene {
  129121. /**
  129122. * The list of effect layers (highlights/glow) added to the scene
  129123. * @see http://doc.babylonjs.com/how_to/highlight_layer
  129124. * @see http://doc.babylonjs.com/how_to/glow_layer
  129125. */
  129126. effectLayers: Array<EffectLayer>;
  129127. /**
  129128. * Removes the given effect layer from this scene.
  129129. * @param toRemove defines the effect layer to remove
  129130. * @returns the index of the removed effect layer
  129131. */
  129132. removeEffectLayer(toRemove: EffectLayer): number;
  129133. /**
  129134. * Adds the given effect layer to this scene
  129135. * @param newEffectLayer defines the effect layer to add
  129136. */
  129137. addEffectLayer(newEffectLayer: EffectLayer): void;
  129138. }
  129139. /**
  129140. * Defines the layer scene component responsible to manage any effect layers
  129141. * in a given scene.
  129142. */
  129143. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  129144. /**
  129145. * The component name helpfull to identify the component in the list of scene components.
  129146. */
  129147. readonly name: string;
  129148. /**
  129149. * The scene the component belongs to.
  129150. */
  129151. scene: Scene;
  129152. private _engine;
  129153. private _renderEffects;
  129154. private _needStencil;
  129155. private _previousStencilState;
  129156. /**
  129157. * Creates a new instance of the component for the given scene
  129158. * @param scene Defines the scene to register the component in
  129159. */
  129160. constructor(scene: Scene);
  129161. /**
  129162. * Registers the component in a given scene
  129163. */
  129164. register(): void;
  129165. /**
  129166. * Rebuilds the elements related to this component in case of
  129167. * context lost for instance.
  129168. */
  129169. rebuild(): void;
  129170. /**
  129171. * Serializes the component data to the specified json object
  129172. * @param serializationObject The object to serialize to
  129173. */
  129174. serialize(serializationObject: any): void;
  129175. /**
  129176. * Adds all the elements from the container to the scene
  129177. * @param container the container holding the elements
  129178. */
  129179. addFromContainer(container: AbstractScene): void;
  129180. /**
  129181. * Removes all the elements in the container from the scene
  129182. * @param container contains the elements to remove
  129183. * @param dispose if the removed element should be disposed (default: false)
  129184. */
  129185. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  129186. /**
  129187. * Disposes the component and the associated ressources.
  129188. */
  129189. dispose(): void;
  129190. private _isReadyForMesh;
  129191. private _renderMainTexture;
  129192. private _setStencil;
  129193. private _setStencilBack;
  129194. private _draw;
  129195. private _drawCamera;
  129196. private _drawRenderingGroup;
  129197. }
  129198. }
  129199. declare module BABYLON {
  129200. /** @hidden */
  129201. export var glowMapMergePixelShader: {
  129202. name: string;
  129203. shader: string;
  129204. };
  129205. }
  129206. declare module BABYLON {
  129207. /** @hidden */
  129208. export var glowMapMergeVertexShader: {
  129209. name: string;
  129210. shader: string;
  129211. };
  129212. }
  129213. declare module BABYLON {
  129214. interface AbstractScene {
  129215. /**
  129216. * Return a the first highlight layer of the scene with a given name.
  129217. * @param name The name of the highlight layer to look for.
  129218. * @return The highlight layer if found otherwise null.
  129219. */
  129220. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  129221. }
  129222. /**
  129223. * Glow layer options. This helps customizing the behaviour
  129224. * of the glow layer.
  129225. */
  129226. export interface IGlowLayerOptions {
  129227. /**
  129228. * Multiplication factor apply to the canvas size to compute the render target size
  129229. * used to generated the glowing objects (the smaller the faster).
  129230. */
  129231. mainTextureRatio: number;
  129232. /**
  129233. * Enforces a fixed size texture to ensure resize independant blur.
  129234. */
  129235. mainTextureFixedSize?: number;
  129236. /**
  129237. * How big is the kernel of the blur texture.
  129238. */
  129239. blurKernelSize: number;
  129240. /**
  129241. * The camera attached to the layer.
  129242. */
  129243. camera: Nullable<Camera>;
  129244. /**
  129245. * Enable MSAA by chosing the number of samples.
  129246. */
  129247. mainTextureSamples?: number;
  129248. /**
  129249. * The rendering group to draw the layer in.
  129250. */
  129251. renderingGroupId: number;
  129252. }
  129253. /**
  129254. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  129255. *
  129256. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  129257. *
  129258. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  129259. */
  129260. export class GlowLayer extends EffectLayer {
  129261. /**
  129262. * Effect Name of the layer.
  129263. */
  129264. static readonly EffectName: string;
  129265. /**
  129266. * The default blur kernel size used for the glow.
  129267. */
  129268. static DefaultBlurKernelSize: number;
  129269. /**
  129270. * The default texture size ratio used for the glow.
  129271. */
  129272. static DefaultTextureRatio: number;
  129273. /**
  129274. * Sets the kernel size of the blur.
  129275. */
  129276. set blurKernelSize(value: number);
  129277. /**
  129278. * Gets the kernel size of the blur.
  129279. */
  129280. get blurKernelSize(): number;
  129281. /**
  129282. * Sets the glow intensity.
  129283. */
  129284. set intensity(value: number);
  129285. /**
  129286. * Gets the glow intensity.
  129287. */
  129288. get intensity(): number;
  129289. private _options;
  129290. private _intensity;
  129291. private _horizontalBlurPostprocess1;
  129292. private _verticalBlurPostprocess1;
  129293. private _horizontalBlurPostprocess2;
  129294. private _verticalBlurPostprocess2;
  129295. private _blurTexture1;
  129296. private _blurTexture2;
  129297. private _postProcesses1;
  129298. private _postProcesses2;
  129299. private _includedOnlyMeshes;
  129300. private _excludedMeshes;
  129301. private _meshesUsingTheirOwnMaterials;
  129302. /**
  129303. * Callback used to let the user override the color selection on a per mesh basis
  129304. */
  129305. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  129306. /**
  129307. * Callback used to let the user override the texture selection on a per mesh basis
  129308. */
  129309. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  129310. /**
  129311. * Instantiates a new glow Layer and references it to the scene.
  129312. * @param name The name of the layer
  129313. * @param scene The scene to use the layer in
  129314. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  129315. */
  129316. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  129317. /**
  129318. * Get the effect name of the layer.
  129319. * @return The effect name
  129320. */
  129321. getEffectName(): string;
  129322. /**
  129323. * Create the merge effect. This is the shader use to blit the information back
  129324. * to the main canvas at the end of the scene rendering.
  129325. */
  129326. protected _createMergeEffect(): Effect;
  129327. /**
  129328. * Creates the render target textures and post processes used in the glow layer.
  129329. */
  129330. protected _createTextureAndPostProcesses(): void;
  129331. /**
  129332. * Checks for the readiness of the element composing the layer.
  129333. * @param subMesh the mesh to check for
  129334. * @param useInstances specify wether or not to use instances to render the mesh
  129335. * @param emissiveTexture the associated emissive texture used to generate the glow
  129336. * @return true if ready otherwise, false
  129337. */
  129338. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  129339. /**
  129340. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  129341. */
  129342. needStencil(): boolean;
  129343. /**
  129344. * Returns true if the mesh can be rendered, otherwise false.
  129345. * @param mesh The mesh to render
  129346. * @param material The material used on the mesh
  129347. * @returns true if it can be rendered otherwise false
  129348. */
  129349. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  129350. /**
  129351. * Implementation specific of rendering the generating effect on the main canvas.
  129352. * @param effect The effect used to render through
  129353. */
  129354. protected _internalRender(effect: Effect): void;
  129355. /**
  129356. * Sets the required values for both the emissive texture and and the main color.
  129357. */
  129358. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  129359. /**
  129360. * Returns true if the mesh should render, otherwise false.
  129361. * @param mesh The mesh to render
  129362. * @returns true if it should render otherwise false
  129363. */
  129364. protected _shouldRenderMesh(mesh: Mesh): boolean;
  129365. /**
  129366. * Adds specific effects defines.
  129367. * @param defines The defines to add specifics to.
  129368. */
  129369. protected _addCustomEffectDefines(defines: string[]): void;
  129370. /**
  129371. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  129372. * @param mesh The mesh to exclude from the glow layer
  129373. */
  129374. addExcludedMesh(mesh: Mesh): void;
  129375. /**
  129376. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  129377. * @param mesh The mesh to remove
  129378. */
  129379. removeExcludedMesh(mesh: Mesh): void;
  129380. /**
  129381. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  129382. * @param mesh The mesh to include in the glow layer
  129383. */
  129384. addIncludedOnlyMesh(mesh: Mesh): void;
  129385. /**
  129386. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  129387. * @param mesh The mesh to remove
  129388. */
  129389. removeIncludedOnlyMesh(mesh: Mesh): void;
  129390. /**
  129391. * Determine if a given mesh will be used in the glow layer
  129392. * @param mesh The mesh to test
  129393. * @returns true if the mesh will be highlighted by the current glow layer
  129394. */
  129395. hasMesh(mesh: AbstractMesh): boolean;
  129396. /**
  129397. * Defines whether the current material of the mesh should be use to render the effect.
  129398. * @param mesh defines the current mesh to render
  129399. */
  129400. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  129401. /**
  129402. * Add a mesh to be rendered through its own material and not with emissive only.
  129403. * @param mesh The mesh for which we need to use its material
  129404. */
  129405. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  129406. /**
  129407. * Remove a mesh from being rendered through its own material and not with emissive only.
  129408. * @param mesh The mesh for which we need to not use its material
  129409. */
  129410. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  129411. /**
  129412. * Free any resources and references associated to a mesh.
  129413. * Internal use
  129414. * @param mesh The mesh to free.
  129415. * @hidden
  129416. */
  129417. _disposeMesh(mesh: Mesh): void;
  129418. /**
  129419. * Gets the class name of the effect layer
  129420. * @returns the string with the class name of the effect layer
  129421. */
  129422. getClassName(): string;
  129423. /**
  129424. * Serializes this glow layer
  129425. * @returns a serialized glow layer object
  129426. */
  129427. serialize(): any;
  129428. /**
  129429. * Creates a Glow Layer from parsed glow layer data
  129430. * @param parsedGlowLayer defines glow layer data
  129431. * @param scene defines the current scene
  129432. * @param rootUrl defines the root URL containing the glow layer information
  129433. * @returns a parsed Glow Layer
  129434. */
  129435. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  129436. }
  129437. }
  129438. declare module BABYLON {
  129439. /** @hidden */
  129440. export var glowBlurPostProcessPixelShader: {
  129441. name: string;
  129442. shader: string;
  129443. };
  129444. }
  129445. declare module BABYLON {
  129446. interface AbstractScene {
  129447. /**
  129448. * Return a the first highlight layer of the scene with a given name.
  129449. * @param name The name of the highlight layer to look for.
  129450. * @return The highlight layer if found otherwise null.
  129451. */
  129452. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  129453. }
  129454. /**
  129455. * Highlight layer options. This helps customizing the behaviour
  129456. * of the highlight layer.
  129457. */
  129458. export interface IHighlightLayerOptions {
  129459. /**
  129460. * Multiplication factor apply to the canvas size to compute the render target size
  129461. * used to generated the glowing objects (the smaller the faster).
  129462. */
  129463. mainTextureRatio: number;
  129464. /**
  129465. * Enforces a fixed size texture to ensure resize independant blur.
  129466. */
  129467. mainTextureFixedSize?: number;
  129468. /**
  129469. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  129470. * of the picture to blur (the smaller the faster).
  129471. */
  129472. blurTextureSizeRatio: number;
  129473. /**
  129474. * How big in texel of the blur texture is the vertical blur.
  129475. */
  129476. blurVerticalSize: number;
  129477. /**
  129478. * How big in texel of the blur texture is the horizontal blur.
  129479. */
  129480. blurHorizontalSize: number;
  129481. /**
  129482. * Alpha blending mode used to apply the blur. Default is combine.
  129483. */
  129484. alphaBlendingMode: number;
  129485. /**
  129486. * The camera attached to the layer.
  129487. */
  129488. camera: Nullable<Camera>;
  129489. /**
  129490. * Should we display highlight as a solid stroke?
  129491. */
  129492. isStroke?: boolean;
  129493. /**
  129494. * The rendering group to draw the layer in.
  129495. */
  129496. renderingGroupId: number;
  129497. }
  129498. /**
  129499. * The highlight layer Helps adding a glow effect around a mesh.
  129500. *
  129501. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  129502. * glowy meshes to your scene.
  129503. *
  129504. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  129505. */
  129506. export class HighlightLayer extends EffectLayer {
  129507. name: string;
  129508. /**
  129509. * Effect Name of the highlight layer.
  129510. */
  129511. static readonly EffectName: string;
  129512. /**
  129513. * The neutral color used during the preparation of the glow effect.
  129514. * This is black by default as the blend operation is a blend operation.
  129515. */
  129516. static NeutralColor: Color4;
  129517. /**
  129518. * Stencil value used for glowing meshes.
  129519. */
  129520. static GlowingMeshStencilReference: number;
  129521. /**
  129522. * Stencil value used for the other meshes in the scene.
  129523. */
  129524. static NormalMeshStencilReference: number;
  129525. /**
  129526. * Specifies whether or not the inner glow is ACTIVE in the layer.
  129527. */
  129528. innerGlow: boolean;
  129529. /**
  129530. * Specifies whether or not the outer glow is ACTIVE in the layer.
  129531. */
  129532. outerGlow: boolean;
  129533. /**
  129534. * Specifies the horizontal size of the blur.
  129535. */
  129536. set blurHorizontalSize(value: number);
  129537. /**
  129538. * Specifies the vertical size of the blur.
  129539. */
  129540. set blurVerticalSize(value: number);
  129541. /**
  129542. * Gets the horizontal size of the blur.
  129543. */
  129544. get blurHorizontalSize(): number;
  129545. /**
  129546. * Gets the vertical size of the blur.
  129547. */
  129548. get blurVerticalSize(): number;
  129549. /**
  129550. * An event triggered when the highlight layer is being blurred.
  129551. */
  129552. onBeforeBlurObservable: Observable<HighlightLayer>;
  129553. /**
  129554. * An event triggered when the highlight layer has been blurred.
  129555. */
  129556. onAfterBlurObservable: Observable<HighlightLayer>;
  129557. private _instanceGlowingMeshStencilReference;
  129558. private _options;
  129559. private _downSamplePostprocess;
  129560. private _horizontalBlurPostprocess;
  129561. private _verticalBlurPostprocess;
  129562. private _blurTexture;
  129563. private _meshes;
  129564. private _excludedMeshes;
  129565. /**
  129566. * Instantiates a new highlight Layer and references it to the scene..
  129567. * @param name The name of the layer
  129568. * @param scene The scene to use the layer in
  129569. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  129570. */
  129571. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  129572. /**
  129573. * Get the effect name of the layer.
  129574. * @return The effect name
  129575. */
  129576. getEffectName(): string;
  129577. /**
  129578. * Create the merge effect. This is the shader use to blit the information back
  129579. * to the main canvas at the end of the scene rendering.
  129580. */
  129581. protected _createMergeEffect(): Effect;
  129582. /**
  129583. * Creates the render target textures and post processes used in the highlight layer.
  129584. */
  129585. protected _createTextureAndPostProcesses(): void;
  129586. /**
  129587. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  129588. */
  129589. needStencil(): boolean;
  129590. /**
  129591. * Checks for the readiness of the element composing the layer.
  129592. * @param subMesh the mesh to check for
  129593. * @param useInstances specify wether or not to use instances to render the mesh
  129594. * @param emissiveTexture the associated emissive texture used to generate the glow
  129595. * @return true if ready otherwise, false
  129596. */
  129597. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  129598. /**
  129599. * Implementation specific of rendering the generating effect on the main canvas.
  129600. * @param effect The effect used to render through
  129601. */
  129602. protected _internalRender(effect: Effect): void;
  129603. /**
  129604. * Returns true if the layer contains information to display, otherwise false.
  129605. */
  129606. shouldRender(): boolean;
  129607. /**
  129608. * Returns true if the mesh should render, otherwise false.
  129609. * @param mesh The mesh to render
  129610. * @returns true if it should render otherwise false
  129611. */
  129612. protected _shouldRenderMesh(mesh: Mesh): boolean;
  129613. /**
  129614. * Adds specific effects defines.
  129615. * @param defines The defines to add specifics to.
  129616. */
  129617. protected _addCustomEffectDefines(defines: string[]): void;
  129618. /**
  129619. * Sets the required values for both the emissive texture and and the main color.
  129620. */
  129621. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  129622. /**
  129623. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  129624. * @param mesh The mesh to exclude from the highlight layer
  129625. */
  129626. addExcludedMesh(mesh: Mesh): void;
  129627. /**
  129628. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  129629. * @param mesh The mesh to highlight
  129630. */
  129631. removeExcludedMesh(mesh: Mesh): void;
  129632. /**
  129633. * Determine if a given mesh will be highlighted by the current HighlightLayer
  129634. * @param mesh mesh to test
  129635. * @returns true if the mesh will be highlighted by the current HighlightLayer
  129636. */
  129637. hasMesh(mesh: AbstractMesh): boolean;
  129638. /**
  129639. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  129640. * @param mesh The mesh to highlight
  129641. * @param color The color of the highlight
  129642. * @param glowEmissiveOnly Extract the glow from the emissive texture
  129643. */
  129644. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  129645. /**
  129646. * Remove a mesh from the highlight layer in order to make it stop glowing.
  129647. * @param mesh The mesh to highlight
  129648. */
  129649. removeMesh(mesh: Mesh): void;
  129650. /**
  129651. * Remove all the meshes currently referenced in the highlight layer
  129652. */
  129653. removeAllMeshes(): void;
  129654. /**
  129655. * Force the stencil to the normal expected value for none glowing parts
  129656. */
  129657. private _defaultStencilReference;
  129658. /**
  129659. * Free any resources and references associated to a mesh.
  129660. * Internal use
  129661. * @param mesh The mesh to free.
  129662. * @hidden
  129663. */
  129664. _disposeMesh(mesh: Mesh): void;
  129665. /**
  129666. * Dispose the highlight layer and free resources.
  129667. */
  129668. dispose(): void;
  129669. /**
  129670. * Gets the class name of the effect layer
  129671. * @returns the string with the class name of the effect layer
  129672. */
  129673. getClassName(): string;
  129674. /**
  129675. * Serializes this Highlight layer
  129676. * @returns a serialized Highlight layer object
  129677. */
  129678. serialize(): any;
  129679. /**
  129680. * Creates a Highlight layer from parsed Highlight layer data
  129681. * @param parsedHightlightLayer defines the Highlight layer data
  129682. * @param scene defines the current scene
  129683. * @param rootUrl defines the root URL containing the Highlight layer information
  129684. * @returns a parsed Highlight layer
  129685. */
  129686. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  129687. }
  129688. }
  129689. declare module BABYLON {
  129690. interface AbstractScene {
  129691. /**
  129692. * The list of layers (background and foreground) of the scene
  129693. */
  129694. layers: Array<Layer>;
  129695. }
  129696. /**
  129697. * Defines the layer scene component responsible to manage any layers
  129698. * in a given scene.
  129699. */
  129700. export class LayerSceneComponent implements ISceneComponent {
  129701. /**
  129702. * The component name helpfull to identify the component in the list of scene components.
  129703. */
  129704. readonly name: string;
  129705. /**
  129706. * The scene the component belongs to.
  129707. */
  129708. scene: Scene;
  129709. private _engine;
  129710. /**
  129711. * Creates a new instance of the component for the given scene
  129712. * @param scene Defines the scene to register the component in
  129713. */
  129714. constructor(scene: Scene);
  129715. /**
  129716. * Registers the component in a given scene
  129717. */
  129718. register(): void;
  129719. /**
  129720. * Rebuilds the elements related to this component in case of
  129721. * context lost for instance.
  129722. */
  129723. rebuild(): void;
  129724. /**
  129725. * Disposes the component and the associated ressources.
  129726. */
  129727. dispose(): void;
  129728. private _draw;
  129729. private _drawCameraPredicate;
  129730. private _drawCameraBackground;
  129731. private _drawCameraForeground;
  129732. private _drawRenderTargetPredicate;
  129733. private _drawRenderTargetBackground;
  129734. private _drawRenderTargetForeground;
  129735. /**
  129736. * Adds all the elements from the container to the scene
  129737. * @param container the container holding the elements
  129738. */
  129739. addFromContainer(container: AbstractScene): void;
  129740. /**
  129741. * Removes all the elements in the container from the scene
  129742. * @param container contains the elements to remove
  129743. * @param dispose if the removed element should be disposed (default: false)
  129744. */
  129745. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  129746. }
  129747. }
  129748. declare module BABYLON {
  129749. /** @hidden */
  129750. export var layerPixelShader: {
  129751. name: string;
  129752. shader: string;
  129753. };
  129754. }
  129755. declare module BABYLON {
  129756. /** @hidden */
  129757. export var layerVertexShader: {
  129758. name: string;
  129759. shader: string;
  129760. };
  129761. }
  129762. declare module BABYLON {
  129763. /**
  129764. * This represents a full screen 2d layer.
  129765. * This can be useful to display a picture in the background of your scene for instance.
  129766. * @see https://www.babylonjs-playground.com/#08A2BS#1
  129767. */
  129768. export class Layer {
  129769. /**
  129770. * Define the name of the layer.
  129771. */
  129772. name: string;
  129773. /**
  129774. * Define the texture the layer should display.
  129775. */
  129776. texture: Nullable<Texture>;
  129777. /**
  129778. * Is the layer in background or foreground.
  129779. */
  129780. isBackground: boolean;
  129781. /**
  129782. * Define the color of the layer (instead of texture).
  129783. */
  129784. color: Color4;
  129785. /**
  129786. * Define the scale of the layer in order to zoom in out of the texture.
  129787. */
  129788. scale: Vector2;
  129789. /**
  129790. * Define an offset for the layer in order to shift the texture.
  129791. */
  129792. offset: Vector2;
  129793. /**
  129794. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  129795. */
  129796. alphaBlendingMode: number;
  129797. /**
  129798. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  129799. * Alpha test will not mix with the background color in case of transparency.
  129800. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  129801. */
  129802. alphaTest: boolean;
  129803. /**
  129804. * Define a mask to restrict the layer to only some of the scene cameras.
  129805. */
  129806. layerMask: number;
  129807. /**
  129808. * Define the list of render target the layer is visible into.
  129809. */
  129810. renderTargetTextures: RenderTargetTexture[];
  129811. /**
  129812. * Define if the layer is only used in renderTarget or if it also
  129813. * renders in the main frame buffer of the canvas.
  129814. */
  129815. renderOnlyInRenderTargetTextures: boolean;
  129816. private _scene;
  129817. private _vertexBuffers;
  129818. private _indexBuffer;
  129819. private _effect;
  129820. private _previousDefines;
  129821. /**
  129822. * An event triggered when the layer is disposed.
  129823. */
  129824. onDisposeObservable: Observable<Layer>;
  129825. private _onDisposeObserver;
  129826. /**
  129827. * Back compatibility with callback before the onDisposeObservable existed.
  129828. * The set callback will be triggered when the layer has been disposed.
  129829. */
  129830. set onDispose(callback: () => void);
  129831. /**
  129832. * An event triggered before rendering the scene
  129833. */
  129834. onBeforeRenderObservable: Observable<Layer>;
  129835. private _onBeforeRenderObserver;
  129836. /**
  129837. * Back compatibility with callback before the onBeforeRenderObservable existed.
  129838. * The set callback will be triggered just before rendering the layer.
  129839. */
  129840. set onBeforeRender(callback: () => void);
  129841. /**
  129842. * An event triggered after rendering the scene
  129843. */
  129844. onAfterRenderObservable: Observable<Layer>;
  129845. private _onAfterRenderObserver;
  129846. /**
  129847. * Back compatibility with callback before the onAfterRenderObservable existed.
  129848. * The set callback will be triggered just after rendering the layer.
  129849. */
  129850. set onAfterRender(callback: () => void);
  129851. /**
  129852. * Instantiates a new layer.
  129853. * This represents a full screen 2d layer.
  129854. * This can be useful to display a picture in the background of your scene for instance.
  129855. * @see https://www.babylonjs-playground.com/#08A2BS#1
  129856. * @param name Define the name of the layer in the scene
  129857. * @param imgUrl Define the url of the texture to display in the layer
  129858. * @param scene Define the scene the layer belongs to
  129859. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  129860. * @param color Defines a color for the layer
  129861. */
  129862. constructor(
  129863. /**
  129864. * Define the name of the layer.
  129865. */
  129866. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  129867. private _createIndexBuffer;
  129868. /** @hidden */
  129869. _rebuild(): void;
  129870. /**
  129871. * Renders the layer in the scene.
  129872. */
  129873. render(): void;
  129874. /**
  129875. * Disposes and releases the associated ressources.
  129876. */
  129877. dispose(): void;
  129878. }
  129879. }
  129880. declare module BABYLON {
  129881. /** @hidden */
  129882. export var lensFlarePixelShader: {
  129883. name: string;
  129884. shader: string;
  129885. };
  129886. }
  129887. declare module BABYLON {
  129888. /** @hidden */
  129889. export var lensFlareVertexShader: {
  129890. name: string;
  129891. shader: string;
  129892. };
  129893. }
  129894. declare module BABYLON {
  129895. /**
  129896. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  129897. * It is usually composed of several `lensFlare`.
  129898. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  129899. */
  129900. export class LensFlareSystem {
  129901. /**
  129902. * Define the name of the lens flare system
  129903. */
  129904. name: string;
  129905. /**
  129906. * List of lens flares used in this system.
  129907. */
  129908. lensFlares: LensFlare[];
  129909. /**
  129910. * Define a limit from the border the lens flare can be visible.
  129911. */
  129912. borderLimit: number;
  129913. /**
  129914. * Define a viewport border we do not want to see the lens flare in.
  129915. */
  129916. viewportBorder: number;
  129917. /**
  129918. * Define a predicate which could limit the list of meshes able to occlude the effect.
  129919. */
  129920. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  129921. /**
  129922. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  129923. */
  129924. layerMask: number;
  129925. /**
  129926. * Define the id of the lens flare system in the scene.
  129927. * (equal to name by default)
  129928. */
  129929. id: string;
  129930. private _scene;
  129931. private _emitter;
  129932. private _vertexBuffers;
  129933. private _indexBuffer;
  129934. private _effect;
  129935. private _positionX;
  129936. private _positionY;
  129937. private _isEnabled;
  129938. /** @hidden */
  129939. static _SceneComponentInitialization: (scene: Scene) => void;
  129940. /**
  129941. * Instantiates a lens flare system.
  129942. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  129943. * It is usually composed of several `lensFlare`.
  129944. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  129945. * @param name Define the name of the lens flare system in the scene
  129946. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  129947. * @param scene Define the scene the lens flare system belongs to
  129948. */
  129949. constructor(
  129950. /**
  129951. * Define the name of the lens flare system
  129952. */
  129953. name: string, emitter: any, scene: Scene);
  129954. /**
  129955. * Define if the lens flare system is enabled.
  129956. */
  129957. get isEnabled(): boolean;
  129958. set isEnabled(value: boolean);
  129959. /**
  129960. * Get the scene the effects belongs to.
  129961. * @returns the scene holding the lens flare system
  129962. */
  129963. getScene(): Scene;
  129964. /**
  129965. * Get the emitter of the lens flare system.
  129966. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  129967. * @returns the emitter of the lens flare system
  129968. */
  129969. getEmitter(): any;
  129970. /**
  129971. * Set the emitter of the lens flare system.
  129972. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  129973. * @param newEmitter Define the new emitter of the system
  129974. */
  129975. setEmitter(newEmitter: any): void;
  129976. /**
  129977. * Get the lens flare system emitter position.
  129978. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  129979. * @returns the position
  129980. */
  129981. getEmitterPosition(): Vector3;
  129982. /**
  129983. * @hidden
  129984. */
  129985. computeEffectivePosition(globalViewport: Viewport): boolean;
  129986. /** @hidden */
  129987. _isVisible(): boolean;
  129988. /**
  129989. * @hidden
  129990. */
  129991. render(): boolean;
  129992. /**
  129993. * Dispose and release the lens flare with its associated resources.
  129994. */
  129995. dispose(): void;
  129996. /**
  129997. * Parse a lens flare system from a JSON repressentation
  129998. * @param parsedLensFlareSystem Define the JSON to parse
  129999. * @param scene Define the scene the parsed system should be instantiated in
  130000. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  130001. * @returns the parsed system
  130002. */
  130003. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  130004. /**
  130005. * Serialize the current Lens Flare System into a JSON representation.
  130006. * @returns the serialized JSON
  130007. */
  130008. serialize(): any;
  130009. }
  130010. }
  130011. declare module BABYLON {
  130012. /**
  130013. * This represents one of the lens effect in a `lensFlareSystem`.
  130014. * It controls one of the indiviual texture used in the effect.
  130015. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  130016. */
  130017. export class LensFlare {
  130018. /**
  130019. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  130020. */
  130021. size: number;
  130022. /**
  130023. * 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.
  130024. */
  130025. position: number;
  130026. /**
  130027. * Define the lens color.
  130028. */
  130029. color: Color3;
  130030. /**
  130031. * Define the lens texture.
  130032. */
  130033. texture: Nullable<Texture>;
  130034. /**
  130035. * Define the alpha mode to render this particular lens.
  130036. */
  130037. alphaMode: number;
  130038. private _system;
  130039. /**
  130040. * Creates a new Lens Flare.
  130041. * This represents one of the lens effect in a `lensFlareSystem`.
  130042. * It controls one of the indiviual texture used in the effect.
  130043. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  130044. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  130045. * @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.
  130046. * @param color Define the lens color
  130047. * @param imgUrl Define the lens texture url
  130048. * @param system Define the `lensFlareSystem` this flare is part of
  130049. * @returns The newly created Lens Flare
  130050. */
  130051. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  130052. /**
  130053. * Instantiates a new Lens Flare.
  130054. * This represents one of the lens effect in a `lensFlareSystem`.
  130055. * It controls one of the indiviual texture used in the effect.
  130056. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  130057. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  130058. * @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.
  130059. * @param color Define the lens color
  130060. * @param imgUrl Define the lens texture url
  130061. * @param system Define the `lensFlareSystem` this flare is part of
  130062. */
  130063. constructor(
  130064. /**
  130065. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  130066. */
  130067. size: number,
  130068. /**
  130069. * 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.
  130070. */
  130071. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  130072. /**
  130073. * Dispose and release the lens flare with its associated resources.
  130074. */
  130075. dispose(): void;
  130076. }
  130077. }
  130078. declare module BABYLON {
  130079. interface AbstractScene {
  130080. /**
  130081. * The list of lens flare system added to the scene
  130082. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  130083. */
  130084. lensFlareSystems: Array<LensFlareSystem>;
  130085. /**
  130086. * Removes the given lens flare system from this scene.
  130087. * @param toRemove The lens flare system to remove
  130088. * @returns The index of the removed lens flare system
  130089. */
  130090. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  130091. /**
  130092. * Adds the given lens flare system to this scene
  130093. * @param newLensFlareSystem The lens flare system to add
  130094. */
  130095. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  130096. /**
  130097. * Gets a lens flare system using its name
  130098. * @param name defines the name to look for
  130099. * @returns the lens flare system or null if not found
  130100. */
  130101. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  130102. /**
  130103. * Gets a lens flare system using its id
  130104. * @param id defines the id to look for
  130105. * @returns the lens flare system or null if not found
  130106. */
  130107. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  130108. }
  130109. /**
  130110. * Defines the lens flare scene component responsible to manage any lens flares
  130111. * in a given scene.
  130112. */
  130113. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  130114. /**
  130115. * The component name helpfull to identify the component in the list of scene components.
  130116. */
  130117. readonly name: string;
  130118. /**
  130119. * The scene the component belongs to.
  130120. */
  130121. scene: Scene;
  130122. /**
  130123. * Creates a new instance of the component for the given scene
  130124. * @param scene Defines the scene to register the component in
  130125. */
  130126. constructor(scene: Scene);
  130127. /**
  130128. * Registers the component in a given scene
  130129. */
  130130. register(): void;
  130131. /**
  130132. * Rebuilds the elements related to this component in case of
  130133. * context lost for instance.
  130134. */
  130135. rebuild(): void;
  130136. /**
  130137. * Adds all the elements from the container to the scene
  130138. * @param container the container holding the elements
  130139. */
  130140. addFromContainer(container: AbstractScene): void;
  130141. /**
  130142. * Removes all the elements in the container from the scene
  130143. * @param container contains the elements to remove
  130144. * @param dispose if the removed element should be disposed (default: false)
  130145. */
  130146. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  130147. /**
  130148. * Serializes the component data to the specified json object
  130149. * @param serializationObject The object to serialize to
  130150. */
  130151. serialize(serializationObject: any): void;
  130152. /**
  130153. * Disposes the component and the associated ressources.
  130154. */
  130155. dispose(): void;
  130156. private _draw;
  130157. }
  130158. }
  130159. declare module BABYLON {
  130160. /** @hidden */
  130161. export var depthPixelShader: {
  130162. name: string;
  130163. shader: string;
  130164. };
  130165. }
  130166. declare module BABYLON {
  130167. /** @hidden */
  130168. export var depthVertexShader: {
  130169. name: string;
  130170. shader: string;
  130171. };
  130172. }
  130173. declare module BABYLON {
  130174. /**
  130175. * This represents a depth renderer in Babylon.
  130176. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  130177. */
  130178. export class DepthRenderer {
  130179. private _scene;
  130180. private _depthMap;
  130181. private _effect;
  130182. private readonly _storeNonLinearDepth;
  130183. private readonly _clearColor;
  130184. /** Get if the depth renderer is using packed depth or not */
  130185. readonly isPacked: boolean;
  130186. private _cachedDefines;
  130187. private _camera;
  130188. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  130189. enabled: boolean;
  130190. /**
  130191. * Specifiess that the depth renderer will only be used within
  130192. * the camera it is created for.
  130193. * This can help forcing its rendering during the camera processing.
  130194. */
  130195. useOnlyInActiveCamera: boolean;
  130196. /** @hidden */
  130197. static _SceneComponentInitialization: (scene: Scene) => void;
  130198. /**
  130199. * Instantiates a depth renderer
  130200. * @param scene The scene the renderer belongs to
  130201. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  130202. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  130203. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  130204. */
  130205. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  130206. /**
  130207. * Creates the depth rendering effect and checks if the effect is ready.
  130208. * @param subMesh The submesh to be used to render the depth map of
  130209. * @param useInstances If multiple world instances should be used
  130210. * @returns if the depth renderer is ready to render the depth map
  130211. */
  130212. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  130213. /**
  130214. * Gets the texture which the depth map will be written to.
  130215. * @returns The depth map texture
  130216. */
  130217. getDepthMap(): RenderTargetTexture;
  130218. /**
  130219. * Disposes of the depth renderer.
  130220. */
  130221. dispose(): void;
  130222. }
  130223. }
  130224. declare module BABYLON {
  130225. /** @hidden */
  130226. export var minmaxReduxPixelShader: {
  130227. name: string;
  130228. shader: string;
  130229. };
  130230. }
  130231. declare module BABYLON {
  130232. /**
  130233. * This class computes a min/max reduction from a texture: it means it computes the minimum
  130234. * and maximum values from all values of the texture.
  130235. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  130236. * The source values are read from the red channel of the texture.
  130237. */
  130238. export class MinMaxReducer {
  130239. /**
  130240. * Observable triggered when the computation has been performed
  130241. */
  130242. onAfterReductionPerformed: Observable<{
  130243. min: number;
  130244. max: number;
  130245. }>;
  130246. protected _camera: Camera;
  130247. protected _sourceTexture: Nullable<RenderTargetTexture>;
  130248. protected _reductionSteps: Nullable<Array<PostProcess>>;
  130249. protected _postProcessManager: PostProcessManager;
  130250. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  130251. protected _forceFullscreenViewport: boolean;
  130252. /**
  130253. * Creates a min/max reducer
  130254. * @param camera The camera to use for the post processes
  130255. */
  130256. constructor(camera: Camera);
  130257. /**
  130258. * Gets the texture used to read the values from.
  130259. */
  130260. get sourceTexture(): Nullable<RenderTargetTexture>;
  130261. /**
  130262. * Sets the source texture to read the values from.
  130263. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  130264. * because in such textures '1' value must not be taken into account to compute the maximum
  130265. * as this value is used to clear the texture.
  130266. * Note that the computation is not activated by calling this function, you must call activate() for that!
  130267. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  130268. * @param depthRedux Indicates if the texture is a depth texture or not
  130269. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  130270. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  130271. */
  130272. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  130273. /**
  130274. * Defines the refresh rate of the computation.
  130275. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  130276. */
  130277. get refreshRate(): number;
  130278. set refreshRate(value: number);
  130279. protected _activated: boolean;
  130280. /**
  130281. * Gets the activation status of the reducer
  130282. */
  130283. get activated(): boolean;
  130284. /**
  130285. * Activates the reduction computation.
  130286. * When activated, the observers registered in onAfterReductionPerformed are
  130287. * called after the compuation is performed
  130288. */
  130289. activate(): void;
  130290. /**
  130291. * Deactivates the reduction computation.
  130292. */
  130293. deactivate(): void;
  130294. /**
  130295. * Disposes the min/max reducer
  130296. * @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.
  130297. */
  130298. dispose(disposeAll?: boolean): void;
  130299. }
  130300. }
  130301. declare module BABYLON {
  130302. /**
  130303. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  130304. */
  130305. export class DepthReducer extends MinMaxReducer {
  130306. private _depthRenderer;
  130307. private _depthRendererId;
  130308. /**
  130309. * Gets the depth renderer used for the computation.
  130310. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  130311. */
  130312. get depthRenderer(): Nullable<DepthRenderer>;
  130313. /**
  130314. * Creates a depth reducer
  130315. * @param camera The camera used to render the depth texture
  130316. */
  130317. constructor(camera: Camera);
  130318. /**
  130319. * Sets the depth renderer to use to generate the depth map
  130320. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  130321. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  130322. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  130323. */
  130324. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  130325. /** @hidden */
  130326. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  130327. /**
  130328. * Activates the reduction computation.
  130329. * When activated, the observers registered in onAfterReductionPerformed are
  130330. * called after the compuation is performed
  130331. */
  130332. activate(): void;
  130333. /**
  130334. * Deactivates the reduction computation.
  130335. */
  130336. deactivate(): void;
  130337. /**
  130338. * Disposes the depth reducer
  130339. * @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.
  130340. */
  130341. dispose(disposeAll?: boolean): void;
  130342. }
  130343. }
  130344. declare module BABYLON {
  130345. /**
  130346. * A CSM implementation allowing casting shadows on large scenes.
  130347. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  130348. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  130349. */
  130350. export class CascadedShadowGenerator extends ShadowGenerator {
  130351. private static readonly frustumCornersNDCSpace;
  130352. /**
  130353. * Name of the CSM class
  130354. */
  130355. static CLASSNAME: string;
  130356. /**
  130357. * Defines the default number of cascades used by the CSM.
  130358. */
  130359. static readonly DEFAULT_CASCADES_COUNT: number;
  130360. /**
  130361. * Defines the minimum number of cascades used by the CSM.
  130362. */
  130363. static readonly MIN_CASCADES_COUNT: number;
  130364. /**
  130365. * Defines the maximum number of cascades used by the CSM.
  130366. */
  130367. static readonly MAX_CASCADES_COUNT: number;
  130368. protected _validateFilter(filter: number): number;
  130369. /**
  130370. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  130371. */
  130372. penumbraDarkness: number;
  130373. private _numCascades;
  130374. /**
  130375. * Gets or set the number of cascades used by the CSM.
  130376. */
  130377. get numCascades(): number;
  130378. set numCascades(value: number);
  130379. /**
  130380. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  130381. * The trade off is that you loose some precision in the shadow rendering when enabling this setting.
  130382. */
  130383. stabilizeCascades: boolean;
  130384. private _freezeShadowCastersBoundingInfo;
  130385. private _freezeShadowCastersBoundingInfoObservable;
  130386. /**
  130387. * Enables or disables the shadow casters bounding info computation.
  130388. * If your shadow casters don't move, you can disable this feature.
  130389. * If it is enabled, the bounding box computation is done every frame.
  130390. */
  130391. get freezeShadowCastersBoundingInfo(): boolean;
  130392. set freezeShadowCastersBoundingInfo(freeze: boolean);
  130393. private _scbiMin;
  130394. private _scbiMax;
  130395. protected _computeShadowCastersBoundingInfo(): void;
  130396. protected _shadowCastersBoundingInfo: BoundingInfo;
  130397. /**
  130398. * Gets or sets the shadow casters bounding info.
  130399. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  130400. * so that the system won't overwrite the bounds you provide
  130401. */
  130402. get shadowCastersBoundingInfo(): BoundingInfo;
  130403. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  130404. protected _breaksAreDirty: boolean;
  130405. protected _minDistance: number;
  130406. protected _maxDistance: number;
  130407. /**
  130408. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  130409. *
  130410. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  130411. * If you don't know these values, simply leave them to their defaults and don't call this function.
  130412. * @param min minimal distance for the breaks (default to 0.)
  130413. * @param max maximal distance for the breaks (default to 1.)
  130414. */
  130415. setMinMaxDistance(min: number, max: number): void;
  130416. /** Gets the minimal distance used in the cascade break computation */
  130417. get minDistance(): number;
  130418. /** Gets the maximal distance used in the cascade break computation */
  130419. get maxDistance(): number;
  130420. /**
  130421. * Gets the class name of that object
  130422. * @returns "CascadedShadowGenerator"
  130423. */
  130424. getClassName(): string;
  130425. private _cascadeMinExtents;
  130426. private _cascadeMaxExtents;
  130427. /**
  130428. * Gets a cascade minimum extents
  130429. * @param cascadeIndex index of the cascade
  130430. * @returns the minimum cascade extents
  130431. */
  130432. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  130433. /**
  130434. * Gets a cascade maximum extents
  130435. * @param cascadeIndex index of the cascade
  130436. * @returns the maximum cascade extents
  130437. */
  130438. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  130439. private _cascades;
  130440. private _currentLayer;
  130441. private _viewSpaceFrustumsZ;
  130442. private _viewMatrices;
  130443. private _projectionMatrices;
  130444. private _transformMatrices;
  130445. private _transformMatricesAsArray;
  130446. private _frustumLengths;
  130447. private _lightSizeUVCorrection;
  130448. private _depthCorrection;
  130449. private _frustumCornersWorldSpace;
  130450. private _frustumCenter;
  130451. private _shadowCameraPos;
  130452. private _shadowMaxZ;
  130453. /**
  130454. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  130455. * It defaults to camera.maxZ
  130456. */
  130457. get shadowMaxZ(): number;
  130458. /**
  130459. * Sets the shadow max z distance.
  130460. */
  130461. set shadowMaxZ(value: number);
  130462. protected _debug: boolean;
  130463. /**
  130464. * Gets or sets the debug flag.
  130465. * When enabled, the cascades are materialized by different colors on the screen.
  130466. */
  130467. get debug(): boolean;
  130468. set debug(dbg: boolean);
  130469. private _depthClamp;
  130470. /**
  130471. * Gets or sets the depth clamping value.
  130472. *
  130473. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  130474. * to account for the shadow casters far away.
  130475. *
  130476. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  130477. */
  130478. get depthClamp(): boolean;
  130479. set depthClamp(value: boolean);
  130480. private _cascadeBlendPercentage;
  130481. /**
  130482. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  130483. * It defaults to 0.1 (10% blending).
  130484. */
  130485. get cascadeBlendPercentage(): number;
  130486. set cascadeBlendPercentage(value: number);
  130487. private _lambda;
  130488. /**
  130489. * Gets or set the lambda parameter.
  130490. * This parameter is used to split the camera frustum and create the cascades.
  130491. * 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.
  130492. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  130493. */
  130494. get lambda(): number;
  130495. set lambda(value: number);
  130496. /**
  130497. * Gets the view matrix corresponding to a given cascade
  130498. * @param cascadeNum cascade to retrieve the view matrix from
  130499. * @returns the cascade view matrix
  130500. */
  130501. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  130502. /**
  130503. * Gets the projection matrix corresponding to a given cascade
  130504. * @param cascadeNum cascade to retrieve the projection matrix from
  130505. * @returns the cascade projection matrix
  130506. */
  130507. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  130508. /**
  130509. * Gets the transformation matrix corresponding to a given cascade
  130510. * @param cascadeNum cascade to retrieve the transformation matrix from
  130511. * @returns the cascade transformation matrix
  130512. */
  130513. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  130514. private _depthRenderer;
  130515. /**
  130516. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  130517. *
  130518. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  130519. *
  130520. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  130521. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  130522. * @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
  130523. */
  130524. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  130525. private _depthReducer;
  130526. private _autoCalcDepthBounds;
  130527. /**
  130528. * Gets or sets the autoCalcDepthBounds property.
  130529. *
  130530. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  130531. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  130532. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  130533. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  130534. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  130535. */
  130536. get autoCalcDepthBounds(): boolean;
  130537. set autoCalcDepthBounds(value: boolean);
  130538. /**
  130539. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  130540. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  130541. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  130542. * for setting the refresh rate on the renderer yourself!
  130543. */
  130544. get autoCalcDepthBoundsRefreshRate(): number;
  130545. set autoCalcDepthBoundsRefreshRate(value: number);
  130546. /**
  130547. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  130548. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  130549. * you change the camera near/far planes!
  130550. */
  130551. splitFrustum(): void;
  130552. private _splitFrustum;
  130553. private _computeMatrices;
  130554. private _computeFrustumInWorldSpace;
  130555. private _computeCascadeFrustum;
  130556. /**
  130557. * Support test.
  130558. */
  130559. static get IsSupported(): boolean;
  130560. /** @hidden */
  130561. static _SceneComponentInitialization: (scene: Scene) => void;
  130562. /**
  130563. * Creates a Cascaded Shadow Generator object.
  130564. * A ShadowGenerator is the required tool to use the shadows.
  130565. * Each directional light casting shadows needs to use its own ShadowGenerator.
  130566. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  130567. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  130568. * @param light The directional light object generating the shadows.
  130569. * @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.
  130570. */
  130571. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  130572. protected _initializeGenerator(): void;
  130573. protected _createTargetRenderTexture(): void;
  130574. protected _initializeShadowMap(): void;
  130575. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  130576. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  130577. /**
  130578. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  130579. * @param defines Defines of the material we want to update
  130580. * @param lightIndex Index of the light in the enabled light list of the material
  130581. */
  130582. prepareDefines(defines: any, lightIndex: number): void;
  130583. /**
  130584. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  130585. * defined in the generator but impacting the effect).
  130586. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  130587. * @param effect The effect we are binfing the information for
  130588. */
  130589. bindShadowLight(lightIndex: string, effect: Effect): void;
  130590. /**
  130591. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  130592. * (eq to view projection * shadow projection matrices)
  130593. * @returns The transform matrix used to create the shadow map
  130594. */
  130595. getTransformMatrix(): Matrix;
  130596. /**
  130597. * Disposes the ShadowGenerator.
  130598. * Returns nothing.
  130599. */
  130600. dispose(): void;
  130601. /**
  130602. * Serializes the shadow generator setup to a json object.
  130603. * @returns The serialized JSON object
  130604. */
  130605. serialize(): any;
  130606. /**
  130607. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  130608. * @param parsedShadowGenerator The JSON object to parse
  130609. * @param scene The scene to create the shadow map for
  130610. * @returns The parsed shadow generator
  130611. */
  130612. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  130613. }
  130614. }
  130615. declare module BABYLON {
  130616. /**
  130617. * Defines the shadow generator component responsible to manage any shadow generators
  130618. * in a given scene.
  130619. */
  130620. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  130621. /**
  130622. * The component name helpfull to identify the component in the list of scene components.
  130623. */
  130624. readonly name: string;
  130625. /**
  130626. * The scene the component belongs to.
  130627. */
  130628. scene: Scene;
  130629. /**
  130630. * Creates a new instance of the component for the given scene
  130631. * @param scene Defines the scene to register the component in
  130632. */
  130633. constructor(scene: Scene);
  130634. /**
  130635. * Registers the component in a given scene
  130636. */
  130637. register(): void;
  130638. /**
  130639. * Rebuilds the elements related to this component in case of
  130640. * context lost for instance.
  130641. */
  130642. rebuild(): void;
  130643. /**
  130644. * Serializes the component data to the specified json object
  130645. * @param serializationObject The object to serialize to
  130646. */
  130647. serialize(serializationObject: any): void;
  130648. /**
  130649. * Adds all the elements from the container to the scene
  130650. * @param container the container holding the elements
  130651. */
  130652. addFromContainer(container: AbstractScene): void;
  130653. /**
  130654. * Removes all the elements in the container from the scene
  130655. * @param container contains the elements to remove
  130656. * @param dispose if the removed element should be disposed (default: false)
  130657. */
  130658. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  130659. /**
  130660. * Rebuilds the elements related to this component in case of
  130661. * context lost for instance.
  130662. */
  130663. dispose(): void;
  130664. private _gatherRenderTargets;
  130665. }
  130666. }
  130667. declare module BABYLON {
  130668. /**
  130669. * A point light is a light defined by an unique point in world space.
  130670. * The light is emitted in every direction from this point.
  130671. * A good example of a point light is a standard light bulb.
  130672. * Documentation: https://doc.babylonjs.com/babylon101/lights
  130673. */
  130674. export class PointLight extends ShadowLight {
  130675. private _shadowAngle;
  130676. /**
  130677. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  130678. * This specifies what angle the shadow will use to be created.
  130679. *
  130680. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  130681. */
  130682. get shadowAngle(): number;
  130683. /**
  130684. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  130685. * This specifies what angle the shadow will use to be created.
  130686. *
  130687. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  130688. */
  130689. set shadowAngle(value: number);
  130690. /**
  130691. * Gets the direction if it has been set.
  130692. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  130693. */
  130694. get direction(): Vector3;
  130695. /**
  130696. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  130697. */
  130698. set direction(value: Vector3);
  130699. /**
  130700. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  130701. * A PointLight emits the light in every direction.
  130702. * It can cast shadows.
  130703. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  130704. * ```javascript
  130705. * var pointLight = new PointLight("pl", camera.position, scene);
  130706. * ```
  130707. * Documentation : https://doc.babylonjs.com/babylon101/lights
  130708. * @param name The light friendly name
  130709. * @param position The position of the point light in the scene
  130710. * @param scene The scene the lights belongs to
  130711. */
  130712. constructor(name: string, position: Vector3, scene: Scene);
  130713. /**
  130714. * Returns the string "PointLight"
  130715. * @returns the class name
  130716. */
  130717. getClassName(): string;
  130718. /**
  130719. * Returns the integer 0.
  130720. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  130721. */
  130722. getTypeID(): number;
  130723. /**
  130724. * Specifies wether or not the shadowmap should be a cube texture.
  130725. * @returns true if the shadowmap needs to be a cube texture.
  130726. */
  130727. needCube(): boolean;
  130728. /**
  130729. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  130730. * @param faceIndex The index of the face we are computed the direction to generate shadow
  130731. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  130732. */
  130733. getShadowDirection(faceIndex?: number): Vector3;
  130734. /**
  130735. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  130736. * - fov = PI / 2
  130737. * - aspect ratio : 1.0
  130738. * - z-near and far equal to the active camera minZ and maxZ.
  130739. * Returns the PointLight.
  130740. */
  130741. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  130742. protected _buildUniformLayout(): void;
  130743. /**
  130744. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  130745. * @param effect The effect to update
  130746. * @param lightIndex The index of the light in the effect to update
  130747. * @returns The point light
  130748. */
  130749. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  130750. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  130751. /**
  130752. * Prepares the list of defines specific to the light type.
  130753. * @param defines the list of defines
  130754. * @param lightIndex defines the index of the light for the effect
  130755. */
  130756. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  130757. }
  130758. }
  130759. declare module BABYLON {
  130760. /**
  130761. * Header information of HDR texture files.
  130762. */
  130763. export interface HDRInfo {
  130764. /**
  130765. * The height of the texture in pixels.
  130766. */
  130767. height: number;
  130768. /**
  130769. * The width of the texture in pixels.
  130770. */
  130771. width: number;
  130772. /**
  130773. * The index of the beginning of the data in the binary file.
  130774. */
  130775. dataPosition: number;
  130776. }
  130777. /**
  130778. * This groups tools to convert HDR texture to native colors array.
  130779. */
  130780. export class HDRTools {
  130781. private static Ldexp;
  130782. private static Rgbe2float;
  130783. private static readStringLine;
  130784. /**
  130785. * Reads header information from an RGBE texture stored in a native array.
  130786. * More information on this format are available here:
  130787. * https://en.wikipedia.org/wiki/RGBE_image_format
  130788. *
  130789. * @param uint8array The binary file stored in native array.
  130790. * @return The header information.
  130791. */
  130792. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  130793. /**
  130794. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  130795. * This RGBE texture needs to store the information as a panorama.
  130796. *
  130797. * More information on this format are available here:
  130798. * https://en.wikipedia.org/wiki/RGBE_image_format
  130799. *
  130800. * @param buffer The binary file stored in an array buffer.
  130801. * @param size The expected size of the extracted cubemap.
  130802. * @return The Cube Map information.
  130803. */
  130804. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  130805. /**
  130806. * Returns the pixels data extracted from an RGBE texture.
  130807. * This pixels will be stored left to right up to down in the R G B order in one array.
  130808. *
  130809. * More information on this format are available here:
  130810. * https://en.wikipedia.org/wiki/RGBE_image_format
  130811. *
  130812. * @param uint8array The binary file stored in an array buffer.
  130813. * @param hdrInfo The header information of the file.
  130814. * @return The pixels data in RGB right to left up to down order.
  130815. */
  130816. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  130817. private static RGBE_ReadPixels_RLE;
  130818. }
  130819. }
  130820. declare module BABYLON {
  130821. /**
  130822. * This represents a texture coming from an HDR input.
  130823. *
  130824. * The only supported format is currently panorama picture stored in RGBE format.
  130825. * Example of such files can be found on HDRLib: http://hdrlib.com/
  130826. */
  130827. export class HDRCubeTexture extends BaseTexture {
  130828. private static _facesMapping;
  130829. private _generateHarmonics;
  130830. private _noMipmap;
  130831. private _textureMatrix;
  130832. private _size;
  130833. private _onLoad;
  130834. private _onError;
  130835. /**
  130836. * The texture URL.
  130837. */
  130838. url: string;
  130839. /**
  130840. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  130841. */
  130842. coordinatesMode: number;
  130843. protected _isBlocking: boolean;
  130844. /**
  130845. * Sets wether or not the texture is blocking during loading.
  130846. */
  130847. set isBlocking(value: boolean);
  130848. /**
  130849. * Gets wether or not the texture is blocking during loading.
  130850. */
  130851. get isBlocking(): boolean;
  130852. protected _rotationY: number;
  130853. /**
  130854. * Sets texture matrix rotation angle around Y axis in radians.
  130855. */
  130856. set rotationY(value: number);
  130857. /**
  130858. * Gets texture matrix rotation angle around Y axis radians.
  130859. */
  130860. get rotationY(): number;
  130861. /**
  130862. * Gets or sets the center of the bounding box associated with the cube texture
  130863. * It must define where the camera used to render the texture was set
  130864. */
  130865. boundingBoxPosition: Vector3;
  130866. private _boundingBoxSize;
  130867. /**
  130868. * Gets or sets the size of the bounding box associated with the cube texture
  130869. * When defined, the cubemap will switch to local mode
  130870. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  130871. * @example https://www.babylonjs-playground.com/#RNASML
  130872. */
  130873. set boundingBoxSize(value: Vector3);
  130874. get boundingBoxSize(): Vector3;
  130875. /**
  130876. * Instantiates an HDRTexture from the following parameters.
  130877. *
  130878. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  130879. * @param scene The scene the texture will be used in
  130880. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  130881. * @param noMipmap Forces to not generate the mipmap if true
  130882. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  130883. * @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)
  130884. * @param reserved Reserved flag for internal use.
  130885. */
  130886. 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>);
  130887. /**
  130888. * Get the current class name of the texture useful for serialization or dynamic coding.
  130889. * @returns "HDRCubeTexture"
  130890. */
  130891. getClassName(): string;
  130892. /**
  130893. * Occurs when the file is raw .hdr file.
  130894. */
  130895. private loadTexture;
  130896. clone(): HDRCubeTexture;
  130897. delayLoad(): void;
  130898. /**
  130899. * Get the texture reflection matrix used to rotate/transform the reflection.
  130900. * @returns the reflection matrix
  130901. */
  130902. getReflectionTextureMatrix(): Matrix;
  130903. /**
  130904. * Set the texture reflection matrix used to rotate/transform the reflection.
  130905. * @param value Define the reflection matrix to set
  130906. */
  130907. setReflectionTextureMatrix(value: Matrix): void;
  130908. /**
  130909. * Parses a JSON representation of an HDR Texture in order to create the texture
  130910. * @param parsedTexture Define the JSON representation
  130911. * @param scene Define the scene the texture should be created in
  130912. * @param rootUrl Define the root url in case we need to load relative dependencies
  130913. * @returns the newly created texture after parsing
  130914. */
  130915. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  130916. serialize(): any;
  130917. }
  130918. }
  130919. declare module BABYLON {
  130920. /**
  130921. * Class used to control physics engine
  130922. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  130923. */
  130924. export class PhysicsEngine implements IPhysicsEngine {
  130925. private _physicsPlugin;
  130926. /**
  130927. * Global value used to control the smallest number supported by the simulation
  130928. */
  130929. static Epsilon: number;
  130930. private _impostors;
  130931. private _joints;
  130932. private _subTimeStep;
  130933. /**
  130934. * Gets the gravity vector used by the simulation
  130935. */
  130936. gravity: Vector3;
  130937. /**
  130938. * Factory used to create the default physics plugin.
  130939. * @returns The default physics plugin
  130940. */
  130941. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  130942. /**
  130943. * Creates a new Physics Engine
  130944. * @param gravity defines the gravity vector used by the simulation
  130945. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  130946. */
  130947. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  130948. /**
  130949. * Sets the gravity vector used by the simulation
  130950. * @param gravity defines the gravity vector to use
  130951. */
  130952. setGravity(gravity: Vector3): void;
  130953. /**
  130954. * Set the time step of the physics engine.
  130955. * Default is 1/60.
  130956. * To slow it down, enter 1/600 for example.
  130957. * To speed it up, 1/30
  130958. * @param newTimeStep defines the new timestep to apply to this world.
  130959. */
  130960. setTimeStep(newTimeStep?: number): void;
  130961. /**
  130962. * Get the time step of the physics engine.
  130963. * @returns the current time step
  130964. */
  130965. getTimeStep(): number;
  130966. /**
  130967. * Set the sub time step of the physics engine.
  130968. * Default is 0 meaning there is no sub steps
  130969. * To increase physics resolution precision, set a small value (like 1 ms)
  130970. * @param subTimeStep defines the new sub timestep used for physics resolution.
  130971. */
  130972. setSubTimeStep(subTimeStep?: number): void;
  130973. /**
  130974. * Get the sub time step of the physics engine.
  130975. * @returns the current sub time step
  130976. */
  130977. getSubTimeStep(): number;
  130978. /**
  130979. * Release all resources
  130980. */
  130981. dispose(): void;
  130982. /**
  130983. * Gets the name of the current physics plugin
  130984. * @returns the name of the plugin
  130985. */
  130986. getPhysicsPluginName(): string;
  130987. /**
  130988. * Adding a new impostor for the impostor tracking.
  130989. * This will be done by the impostor itself.
  130990. * @param impostor the impostor to add
  130991. */
  130992. addImpostor(impostor: PhysicsImpostor): void;
  130993. /**
  130994. * Remove an impostor from the engine.
  130995. * This impostor and its mesh will not longer be updated by the physics engine.
  130996. * @param impostor the impostor to remove
  130997. */
  130998. removeImpostor(impostor: PhysicsImpostor): void;
  130999. /**
  131000. * Add a joint to the physics engine
  131001. * @param mainImpostor defines the main impostor to which the joint is added.
  131002. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  131003. * @param joint defines the joint that will connect both impostors.
  131004. */
  131005. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  131006. /**
  131007. * Removes a joint from the simulation
  131008. * @param mainImpostor defines the impostor used with the joint
  131009. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  131010. * @param joint defines the joint to remove
  131011. */
  131012. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  131013. /**
  131014. * Called by the scene. No need to call it.
  131015. * @param delta defines the timespam between frames
  131016. */
  131017. _step(delta: number): void;
  131018. /**
  131019. * Gets the current plugin used to run the simulation
  131020. * @returns current plugin
  131021. */
  131022. getPhysicsPlugin(): IPhysicsEnginePlugin;
  131023. /**
  131024. * Gets the list of physic impostors
  131025. * @returns an array of PhysicsImpostor
  131026. */
  131027. getImpostors(): Array<PhysicsImpostor>;
  131028. /**
  131029. * Gets the impostor for a physics enabled object
  131030. * @param object defines the object impersonated by the impostor
  131031. * @returns the PhysicsImpostor or null if not found
  131032. */
  131033. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  131034. /**
  131035. * Gets the impostor for a physics body object
  131036. * @param body defines physics body used by the impostor
  131037. * @returns the PhysicsImpostor or null if not found
  131038. */
  131039. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  131040. /**
  131041. * Does a raycast in the physics world
  131042. * @param from when should the ray start?
  131043. * @param to when should the ray end?
  131044. * @returns PhysicsRaycastResult
  131045. */
  131046. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  131047. }
  131048. }
  131049. declare module BABYLON {
  131050. /** @hidden */
  131051. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  131052. private _useDeltaForWorldStep;
  131053. world: any;
  131054. name: string;
  131055. private _physicsMaterials;
  131056. private _fixedTimeStep;
  131057. private _cannonRaycastResult;
  131058. private _raycastResult;
  131059. private _physicsBodysToRemoveAfterStep;
  131060. BJSCANNON: any;
  131061. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  131062. setGravity(gravity: Vector3): void;
  131063. setTimeStep(timeStep: number): void;
  131064. getTimeStep(): number;
  131065. executeStep(delta: number): void;
  131066. private _removeMarkedPhysicsBodiesFromWorld;
  131067. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  131068. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  131069. generatePhysicsBody(impostor: PhysicsImpostor): void;
  131070. private _processChildMeshes;
  131071. removePhysicsBody(impostor: PhysicsImpostor): void;
  131072. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  131073. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  131074. private _addMaterial;
  131075. private _checkWithEpsilon;
  131076. private _createShape;
  131077. private _createHeightmap;
  131078. private _minus90X;
  131079. private _plus90X;
  131080. private _tmpPosition;
  131081. private _tmpDeltaPosition;
  131082. private _tmpUnityRotation;
  131083. private _updatePhysicsBodyTransformation;
  131084. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  131085. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  131086. isSupported(): boolean;
  131087. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  131088. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  131089. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  131090. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  131091. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  131092. getBodyMass(impostor: PhysicsImpostor): number;
  131093. getBodyFriction(impostor: PhysicsImpostor): number;
  131094. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  131095. getBodyRestitution(impostor: PhysicsImpostor): number;
  131096. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  131097. sleepBody(impostor: PhysicsImpostor): void;
  131098. wakeUpBody(impostor: PhysicsImpostor): void;
  131099. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  131100. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  131101. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  131102. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  131103. getRadius(impostor: PhysicsImpostor): number;
  131104. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  131105. dispose(): void;
  131106. private _extendNamespace;
  131107. /**
  131108. * Does a raycast in the physics world
  131109. * @param from when should the ray start?
  131110. * @param to when should the ray end?
  131111. * @returns PhysicsRaycastResult
  131112. */
  131113. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  131114. }
  131115. }
  131116. declare module BABYLON {
  131117. /** @hidden */
  131118. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  131119. private _useDeltaForWorldStep;
  131120. world: any;
  131121. name: string;
  131122. BJSOIMO: any;
  131123. private _raycastResult;
  131124. private _fixedTimeStep;
  131125. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, oimoInjection?: any);
  131126. setGravity(gravity: Vector3): void;
  131127. setTimeStep(timeStep: number): void;
  131128. getTimeStep(): number;
  131129. private _tmpImpostorsArray;
  131130. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  131131. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  131132. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  131133. generatePhysicsBody(impostor: PhysicsImpostor): void;
  131134. private _tmpPositionVector;
  131135. removePhysicsBody(impostor: PhysicsImpostor): void;
  131136. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  131137. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  131138. isSupported(): boolean;
  131139. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  131140. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  131141. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  131142. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  131143. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  131144. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  131145. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  131146. getBodyMass(impostor: PhysicsImpostor): number;
  131147. getBodyFriction(impostor: PhysicsImpostor): number;
  131148. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  131149. getBodyRestitution(impostor: PhysicsImpostor): number;
  131150. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  131151. sleepBody(impostor: PhysicsImpostor): void;
  131152. wakeUpBody(impostor: PhysicsImpostor): void;
  131153. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  131154. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  131155. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  131156. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  131157. getRadius(impostor: PhysicsImpostor): number;
  131158. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  131159. dispose(): void;
  131160. /**
  131161. * Does a raycast in the physics world
  131162. * @param from when should the ray start?
  131163. * @param to when should the ray end?
  131164. * @returns PhysicsRaycastResult
  131165. */
  131166. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  131167. }
  131168. }
  131169. declare module BABYLON {
  131170. /**
  131171. * Class containing static functions to help procedurally build meshes
  131172. */
  131173. export class RibbonBuilder {
  131174. /**
  131175. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  131176. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  131177. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  131178. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  131179. * * 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
  131180. * * 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
  131181. * * 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
  131182. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  131183. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  131184. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  131185. * * 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
  131186. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  131187. * * 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
  131188. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  131189. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  131190. * @param name defines the name of the mesh
  131191. * @param options defines the options used to create the mesh
  131192. * @param scene defines the hosting scene
  131193. * @returns the ribbon mesh
  131194. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  131195. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  131196. */
  131197. static CreateRibbon(name: string, options: {
  131198. pathArray: Vector3[][];
  131199. closeArray?: boolean;
  131200. closePath?: boolean;
  131201. offset?: number;
  131202. updatable?: boolean;
  131203. sideOrientation?: number;
  131204. frontUVs?: Vector4;
  131205. backUVs?: Vector4;
  131206. instance?: Mesh;
  131207. invertUV?: boolean;
  131208. uvs?: Vector2[];
  131209. colors?: Color4[];
  131210. }, scene?: Nullable<Scene>): Mesh;
  131211. }
  131212. }
  131213. declare module BABYLON {
  131214. /**
  131215. * Class containing static functions to help procedurally build meshes
  131216. */
  131217. export class ShapeBuilder {
  131218. /**
  131219. * 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.
  131220. * * 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.
  131221. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  131222. * * 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.
  131223. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  131224. * * 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
  131225. * * 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
  131226. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  131227. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  131228. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  131229. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  131230. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  131231. * @param name defines the name of the mesh
  131232. * @param options defines the options used to create the mesh
  131233. * @param scene defines the hosting scene
  131234. * @returns the extruded shape mesh
  131235. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  131236. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  131237. */
  131238. static ExtrudeShape(name: string, options: {
  131239. shape: Vector3[];
  131240. path: Vector3[];
  131241. scale?: number;
  131242. rotation?: number;
  131243. cap?: number;
  131244. updatable?: boolean;
  131245. sideOrientation?: number;
  131246. frontUVs?: Vector4;
  131247. backUVs?: Vector4;
  131248. instance?: Mesh;
  131249. invertUV?: boolean;
  131250. }, scene?: Nullable<Scene>): Mesh;
  131251. /**
  131252. * Creates an custom extruded shape mesh.
  131253. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  131254. * * 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.
  131255. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  131256. * * 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
  131257. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  131258. * * 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
  131259. * * It must returns a float value that will be the scale value applied to the shape on each path point
  131260. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  131261. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  131262. * * 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
  131263. * * 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
  131264. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  131265. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  131266. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  131267. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  131268. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  131269. * @param name defines the name of the mesh
  131270. * @param options defines the options used to create the mesh
  131271. * @param scene defines the hosting scene
  131272. * @returns the custom extruded shape mesh
  131273. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  131274. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  131275. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  131276. */
  131277. static ExtrudeShapeCustom(name: string, options: {
  131278. shape: Vector3[];
  131279. path: Vector3[];
  131280. scaleFunction?: any;
  131281. rotationFunction?: any;
  131282. ribbonCloseArray?: boolean;
  131283. ribbonClosePath?: boolean;
  131284. cap?: number;
  131285. updatable?: boolean;
  131286. sideOrientation?: number;
  131287. frontUVs?: Vector4;
  131288. backUVs?: Vector4;
  131289. instance?: Mesh;
  131290. invertUV?: boolean;
  131291. }, scene?: Nullable<Scene>): Mesh;
  131292. private static _ExtrudeShapeGeneric;
  131293. }
  131294. }
  131295. declare module BABYLON {
  131296. /**
  131297. * AmmoJS Physics plugin
  131298. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  131299. * @see https://github.com/kripken/ammo.js/
  131300. */
  131301. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  131302. private _useDeltaForWorldStep;
  131303. /**
  131304. * Reference to the Ammo library
  131305. */
  131306. bjsAMMO: any;
  131307. /**
  131308. * Created ammoJS world which physics bodies are added to
  131309. */
  131310. world: any;
  131311. /**
  131312. * Name of the plugin
  131313. */
  131314. name: string;
  131315. private _timeStep;
  131316. private _fixedTimeStep;
  131317. private _maxSteps;
  131318. private _tmpQuaternion;
  131319. private _tmpAmmoTransform;
  131320. private _tmpAmmoQuaternion;
  131321. private _tmpAmmoConcreteContactResultCallback;
  131322. private _collisionConfiguration;
  131323. private _dispatcher;
  131324. private _overlappingPairCache;
  131325. private _solver;
  131326. private _softBodySolver;
  131327. private _tmpAmmoVectorA;
  131328. private _tmpAmmoVectorB;
  131329. private _tmpAmmoVectorC;
  131330. private _tmpAmmoVectorD;
  131331. private _tmpContactCallbackResult;
  131332. private _tmpAmmoVectorRCA;
  131333. private _tmpAmmoVectorRCB;
  131334. private _raycastResult;
  131335. private static readonly DISABLE_COLLISION_FLAG;
  131336. private static readonly KINEMATIC_FLAG;
  131337. private static readonly DISABLE_DEACTIVATION_FLAG;
  131338. /**
  131339. * Initializes the ammoJS plugin
  131340. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  131341. * @param ammoInjection can be used to inject your own ammo reference
  131342. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  131343. */
  131344. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  131345. /**
  131346. * Sets the gravity of the physics world (m/(s^2))
  131347. * @param gravity Gravity to set
  131348. */
  131349. setGravity(gravity: Vector3): void;
  131350. /**
  131351. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  131352. * @param timeStep timestep to use in seconds
  131353. */
  131354. setTimeStep(timeStep: number): void;
  131355. /**
  131356. * 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)
  131357. * @param fixedTimeStep fixedTimeStep to use in seconds
  131358. */
  131359. setFixedTimeStep(fixedTimeStep: number): void;
  131360. /**
  131361. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  131362. * @param maxSteps the maximum number of steps by the physics engine per frame
  131363. */
  131364. setMaxSteps(maxSteps: number): void;
  131365. /**
  131366. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  131367. * @returns the current timestep in seconds
  131368. */
  131369. getTimeStep(): number;
  131370. /**
  131371. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  131372. */
  131373. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  131374. private _isImpostorInContact;
  131375. private _isImpostorPairInContact;
  131376. private _stepSimulation;
  131377. /**
  131378. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  131379. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  131380. * After the step the babylon meshes are set to the position of the physics imposters
  131381. * @param delta amount of time to step forward
  131382. * @param impostors array of imposters to update before/after the step
  131383. */
  131384. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  131385. /**
  131386. * Update babylon mesh to match physics world object
  131387. * @param impostor imposter to match
  131388. */
  131389. private _afterSoftStep;
  131390. /**
  131391. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  131392. * @param impostor imposter to match
  131393. */
  131394. private _ropeStep;
  131395. /**
  131396. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  131397. * @param impostor imposter to match
  131398. */
  131399. private _softbodyOrClothStep;
  131400. private _tmpMatrix;
  131401. /**
  131402. * Applies an impulse on the imposter
  131403. * @param impostor imposter to apply impulse to
  131404. * @param force amount of force to be applied to the imposter
  131405. * @param contactPoint the location to apply the impulse on the imposter
  131406. */
  131407. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  131408. /**
  131409. * Applies a force on the imposter
  131410. * @param impostor imposter to apply force
  131411. * @param force amount of force to be applied to the imposter
  131412. * @param contactPoint the location to apply the force on the imposter
  131413. */
  131414. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  131415. /**
  131416. * Creates a physics body using the plugin
  131417. * @param impostor the imposter to create the physics body on
  131418. */
  131419. generatePhysicsBody(impostor: PhysicsImpostor): void;
  131420. /**
  131421. * Removes the physics body from the imposter and disposes of the body's memory
  131422. * @param impostor imposter to remove the physics body from
  131423. */
  131424. removePhysicsBody(impostor: PhysicsImpostor): void;
  131425. /**
  131426. * Generates a joint
  131427. * @param impostorJoint the imposter joint to create the joint with
  131428. */
  131429. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  131430. /**
  131431. * Removes a joint
  131432. * @param impostorJoint the imposter joint to remove the joint from
  131433. */
  131434. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  131435. private _addMeshVerts;
  131436. /**
  131437. * Initialise the soft body vertices to match its object's (mesh) vertices
  131438. * Softbody vertices (nodes) are in world space and to match this
  131439. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  131440. * @param impostor to create the softbody for
  131441. */
  131442. private _softVertexData;
  131443. /**
  131444. * Create an impostor's soft body
  131445. * @param impostor to create the softbody for
  131446. */
  131447. private _createSoftbody;
  131448. /**
  131449. * Create cloth for an impostor
  131450. * @param impostor to create the softbody for
  131451. */
  131452. private _createCloth;
  131453. /**
  131454. * Create rope for an impostor
  131455. * @param impostor to create the softbody for
  131456. */
  131457. private _createRope;
  131458. /**
  131459. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  131460. * @param impostor to create the custom physics shape for
  131461. */
  131462. private _createCustom;
  131463. private _addHullVerts;
  131464. private _createShape;
  131465. /**
  131466. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  131467. * @param impostor imposter containing the physics body and babylon object
  131468. */
  131469. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  131470. /**
  131471. * Sets the babylon object's position/rotation from the physics body's position/rotation
  131472. * @param impostor imposter containing the physics body and babylon object
  131473. * @param newPosition new position
  131474. * @param newRotation new rotation
  131475. */
  131476. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  131477. /**
  131478. * If this plugin is supported
  131479. * @returns true if its supported
  131480. */
  131481. isSupported(): boolean;
  131482. /**
  131483. * Sets the linear velocity of the physics body
  131484. * @param impostor imposter to set the velocity on
  131485. * @param velocity velocity to set
  131486. */
  131487. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  131488. /**
  131489. * Sets the angular velocity of the physics body
  131490. * @param impostor imposter to set the velocity on
  131491. * @param velocity velocity to set
  131492. */
  131493. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  131494. /**
  131495. * gets the linear velocity
  131496. * @param impostor imposter to get linear velocity from
  131497. * @returns linear velocity
  131498. */
  131499. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  131500. /**
  131501. * gets the angular velocity
  131502. * @param impostor imposter to get angular velocity from
  131503. * @returns angular velocity
  131504. */
  131505. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  131506. /**
  131507. * Sets the mass of physics body
  131508. * @param impostor imposter to set the mass on
  131509. * @param mass mass to set
  131510. */
  131511. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  131512. /**
  131513. * Gets the mass of the physics body
  131514. * @param impostor imposter to get the mass from
  131515. * @returns mass
  131516. */
  131517. getBodyMass(impostor: PhysicsImpostor): number;
  131518. /**
  131519. * Gets friction of the impostor
  131520. * @param impostor impostor to get friction from
  131521. * @returns friction value
  131522. */
  131523. getBodyFriction(impostor: PhysicsImpostor): number;
  131524. /**
  131525. * Sets friction of the impostor
  131526. * @param impostor impostor to set friction on
  131527. * @param friction friction value
  131528. */
  131529. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  131530. /**
  131531. * Gets restitution of the impostor
  131532. * @param impostor impostor to get restitution from
  131533. * @returns restitution value
  131534. */
  131535. getBodyRestitution(impostor: PhysicsImpostor): number;
  131536. /**
  131537. * Sets resitution of the impostor
  131538. * @param impostor impostor to set resitution on
  131539. * @param restitution resitution value
  131540. */
  131541. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  131542. /**
  131543. * Gets pressure inside the impostor
  131544. * @param impostor impostor to get pressure from
  131545. * @returns pressure value
  131546. */
  131547. getBodyPressure(impostor: PhysicsImpostor): number;
  131548. /**
  131549. * Sets pressure inside a soft body impostor
  131550. * Cloth and rope must remain 0 pressure
  131551. * @param impostor impostor to set pressure on
  131552. * @param pressure pressure value
  131553. */
  131554. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  131555. /**
  131556. * Gets stiffness of the impostor
  131557. * @param impostor impostor to get stiffness from
  131558. * @returns pressure value
  131559. */
  131560. getBodyStiffness(impostor: PhysicsImpostor): number;
  131561. /**
  131562. * Sets stiffness of the impostor
  131563. * @param impostor impostor to set stiffness on
  131564. * @param stiffness stiffness value from 0 to 1
  131565. */
  131566. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  131567. /**
  131568. * Gets velocityIterations of the impostor
  131569. * @param impostor impostor to get velocity iterations from
  131570. * @returns velocityIterations value
  131571. */
  131572. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  131573. /**
  131574. * Sets velocityIterations of the impostor
  131575. * @param impostor impostor to set velocity iterations on
  131576. * @param velocityIterations velocityIterations value
  131577. */
  131578. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  131579. /**
  131580. * Gets positionIterations of the impostor
  131581. * @param impostor impostor to get position iterations from
  131582. * @returns positionIterations value
  131583. */
  131584. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  131585. /**
  131586. * Sets positionIterations of the impostor
  131587. * @param impostor impostor to set position on
  131588. * @param positionIterations positionIterations value
  131589. */
  131590. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  131591. /**
  131592. * Append an anchor to a cloth object
  131593. * @param impostor is the cloth impostor to add anchor to
  131594. * @param otherImpostor is the rigid impostor to anchor to
  131595. * @param width ratio across width from 0 to 1
  131596. * @param height ratio up height from 0 to 1
  131597. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  131598. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  131599. */
  131600. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  131601. /**
  131602. * Append an hook to a rope object
  131603. * @param impostor is the rope impostor to add hook to
  131604. * @param otherImpostor is the rigid impostor to hook to
  131605. * @param length ratio along the rope from 0 to 1
  131606. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  131607. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  131608. */
  131609. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  131610. /**
  131611. * Sleeps the physics body and stops it from being active
  131612. * @param impostor impostor to sleep
  131613. */
  131614. sleepBody(impostor: PhysicsImpostor): void;
  131615. /**
  131616. * Activates the physics body
  131617. * @param impostor impostor to activate
  131618. */
  131619. wakeUpBody(impostor: PhysicsImpostor): void;
  131620. /**
  131621. * Updates the distance parameters of the joint
  131622. * @param joint joint to update
  131623. * @param maxDistance maximum distance of the joint
  131624. * @param minDistance minimum distance of the joint
  131625. */
  131626. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  131627. /**
  131628. * Sets a motor on the joint
  131629. * @param joint joint to set motor on
  131630. * @param speed speed of the motor
  131631. * @param maxForce maximum force of the motor
  131632. * @param motorIndex index of the motor
  131633. */
  131634. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  131635. /**
  131636. * Sets the motors limit
  131637. * @param joint joint to set limit on
  131638. * @param upperLimit upper limit
  131639. * @param lowerLimit lower limit
  131640. */
  131641. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  131642. /**
  131643. * Syncs the position and rotation of a mesh with the impostor
  131644. * @param mesh mesh to sync
  131645. * @param impostor impostor to update the mesh with
  131646. */
  131647. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  131648. /**
  131649. * Gets the radius of the impostor
  131650. * @param impostor impostor to get radius from
  131651. * @returns the radius
  131652. */
  131653. getRadius(impostor: PhysicsImpostor): number;
  131654. /**
  131655. * Gets the box size of the impostor
  131656. * @param impostor impostor to get box size from
  131657. * @param result the resulting box size
  131658. */
  131659. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  131660. /**
  131661. * Disposes of the impostor
  131662. */
  131663. dispose(): void;
  131664. /**
  131665. * Does a raycast in the physics world
  131666. * @param from when should the ray start?
  131667. * @param to when should the ray end?
  131668. * @returns PhysicsRaycastResult
  131669. */
  131670. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  131671. }
  131672. }
  131673. declare module BABYLON {
  131674. interface AbstractScene {
  131675. /**
  131676. * The list of reflection probes added to the scene
  131677. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  131678. */
  131679. reflectionProbes: Array<ReflectionProbe>;
  131680. /**
  131681. * Removes the given reflection probe from this scene.
  131682. * @param toRemove The reflection probe to remove
  131683. * @returns The index of the removed reflection probe
  131684. */
  131685. removeReflectionProbe(toRemove: ReflectionProbe): number;
  131686. /**
  131687. * Adds the given reflection probe to this scene.
  131688. * @param newReflectionProbe The reflection probe to add
  131689. */
  131690. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  131691. }
  131692. /**
  131693. * Class used to generate realtime reflection / refraction cube textures
  131694. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  131695. */
  131696. export class ReflectionProbe {
  131697. /** defines the name of the probe */
  131698. name: string;
  131699. private _scene;
  131700. private _renderTargetTexture;
  131701. private _projectionMatrix;
  131702. private _viewMatrix;
  131703. private _target;
  131704. private _add;
  131705. private _attachedMesh;
  131706. private _invertYAxis;
  131707. /** Gets or sets probe position (center of the cube map) */
  131708. position: Vector3;
  131709. /**
  131710. * Creates a new reflection probe
  131711. * @param name defines the name of the probe
  131712. * @param size defines the texture resolution (for each face)
  131713. * @param scene defines the hosting scene
  131714. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  131715. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  131716. */
  131717. constructor(
  131718. /** defines the name of the probe */
  131719. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  131720. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  131721. get samples(): number;
  131722. set samples(value: number);
  131723. /** Gets or sets the refresh rate to use (on every frame by default) */
  131724. get refreshRate(): number;
  131725. set refreshRate(value: number);
  131726. /**
  131727. * Gets the hosting scene
  131728. * @returns a Scene
  131729. */
  131730. getScene(): Scene;
  131731. /** Gets the internal CubeTexture used to render to */
  131732. get cubeTexture(): RenderTargetTexture;
  131733. /** Gets the list of meshes to render */
  131734. get renderList(): Nullable<AbstractMesh[]>;
  131735. /**
  131736. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  131737. * @param mesh defines the mesh to attach to
  131738. */
  131739. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  131740. /**
  131741. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  131742. * @param renderingGroupId The rendering group id corresponding to its index
  131743. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  131744. */
  131745. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  131746. /**
  131747. * Clean all associated resources
  131748. */
  131749. dispose(): void;
  131750. /**
  131751. * Converts the reflection probe information to a readable string for debug purpose.
  131752. * @param fullDetails Supports for multiple levels of logging within scene loading
  131753. * @returns the human readable reflection probe info
  131754. */
  131755. toString(fullDetails?: boolean): string;
  131756. /**
  131757. * Get the class name of the relfection probe.
  131758. * @returns "ReflectionProbe"
  131759. */
  131760. getClassName(): string;
  131761. /**
  131762. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  131763. * @returns The JSON representation of the texture
  131764. */
  131765. serialize(): any;
  131766. /**
  131767. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  131768. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  131769. * @param scene Define the scene the parsed reflection probe should be instantiated in
  131770. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  131771. * @returns The parsed reflection probe if successful
  131772. */
  131773. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  131774. }
  131775. }
  131776. declare module BABYLON {
  131777. /** @hidden */
  131778. export var _BabylonLoaderRegistered: boolean;
  131779. /**
  131780. * Helps setting up some configuration for the babylon file loader.
  131781. */
  131782. export class BabylonFileLoaderConfiguration {
  131783. /**
  131784. * The loader does not allow injecting custom physix engine into the plugins.
  131785. * Unfortunately in ES6, we need to manually inject them into the plugin.
  131786. * So you could set this variable to your engine import to make it work.
  131787. */
  131788. static LoaderInjectedPhysicsEngine: any;
  131789. }
  131790. }
  131791. declare module BABYLON {
  131792. /**
  131793. * The Physically based simple base material of BJS.
  131794. *
  131795. * This enables better naming and convention enforcements on top of the pbrMaterial.
  131796. * It is used as the base class for both the specGloss and metalRough conventions.
  131797. */
  131798. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  131799. /**
  131800. * Number of Simultaneous lights allowed on the material.
  131801. */
  131802. maxSimultaneousLights: number;
  131803. /**
  131804. * If sets to true, disables all the lights affecting the material.
  131805. */
  131806. disableLighting: boolean;
  131807. /**
  131808. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  131809. */
  131810. environmentTexture: BaseTexture;
  131811. /**
  131812. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  131813. */
  131814. invertNormalMapX: boolean;
  131815. /**
  131816. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  131817. */
  131818. invertNormalMapY: boolean;
  131819. /**
  131820. * Normal map used in the model.
  131821. */
  131822. normalTexture: BaseTexture;
  131823. /**
  131824. * Emissivie color used to self-illuminate the model.
  131825. */
  131826. emissiveColor: Color3;
  131827. /**
  131828. * Emissivie texture used to self-illuminate the model.
  131829. */
  131830. emissiveTexture: BaseTexture;
  131831. /**
  131832. * Occlusion Channel Strenght.
  131833. */
  131834. occlusionStrength: number;
  131835. /**
  131836. * Occlusion Texture of the material (adding extra occlusion effects).
  131837. */
  131838. occlusionTexture: BaseTexture;
  131839. /**
  131840. * Defines the alpha limits in alpha test mode.
  131841. */
  131842. alphaCutOff: number;
  131843. /**
  131844. * Gets the current double sided mode.
  131845. */
  131846. get doubleSided(): boolean;
  131847. /**
  131848. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  131849. */
  131850. set doubleSided(value: boolean);
  131851. /**
  131852. * Stores the pre-calculated light information of a mesh in a texture.
  131853. */
  131854. lightmapTexture: BaseTexture;
  131855. /**
  131856. * If true, the light map contains occlusion information instead of lighting info.
  131857. */
  131858. useLightmapAsShadowmap: boolean;
  131859. /**
  131860. * Instantiates a new PBRMaterial instance.
  131861. *
  131862. * @param name The material name
  131863. * @param scene The scene the material will be use in.
  131864. */
  131865. constructor(name: string, scene: Scene);
  131866. getClassName(): string;
  131867. }
  131868. }
  131869. declare module BABYLON {
  131870. /**
  131871. * The PBR material of BJS following the metal roughness convention.
  131872. *
  131873. * This fits to the PBR convention in the GLTF definition:
  131874. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  131875. */
  131876. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  131877. /**
  131878. * The base color has two different interpretations depending on the value of metalness.
  131879. * When the material is a metal, the base color is the specific measured reflectance value
  131880. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  131881. * of the material.
  131882. */
  131883. baseColor: Color3;
  131884. /**
  131885. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  131886. * well as opacity information in the alpha channel.
  131887. */
  131888. baseTexture: BaseTexture;
  131889. /**
  131890. * Specifies the metallic scalar value of the material.
  131891. * Can also be used to scale the metalness values of the metallic texture.
  131892. */
  131893. metallic: number;
  131894. /**
  131895. * Specifies the roughness scalar value of the material.
  131896. * Can also be used to scale the roughness values of the metallic texture.
  131897. */
  131898. roughness: number;
  131899. /**
  131900. * Texture containing both the metallic value in the B channel and the
  131901. * roughness value in the G channel to keep better precision.
  131902. */
  131903. metallicRoughnessTexture: BaseTexture;
  131904. /**
  131905. * Instantiates a new PBRMetalRoughnessMaterial instance.
  131906. *
  131907. * @param name The material name
  131908. * @param scene The scene the material will be use in.
  131909. */
  131910. constructor(name: string, scene: Scene);
  131911. /**
  131912. * Return the currrent class name of the material.
  131913. */
  131914. getClassName(): string;
  131915. /**
  131916. * Makes a duplicate of the current material.
  131917. * @param name - name to use for the new material.
  131918. */
  131919. clone(name: string): PBRMetallicRoughnessMaterial;
  131920. /**
  131921. * Serialize the material to a parsable JSON object.
  131922. */
  131923. serialize(): any;
  131924. /**
  131925. * Parses a JSON object correponding to the serialize function.
  131926. */
  131927. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  131928. }
  131929. }
  131930. declare module BABYLON {
  131931. /**
  131932. * The PBR material of BJS following the specular glossiness convention.
  131933. *
  131934. * This fits to the PBR convention in the GLTF definition:
  131935. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  131936. */
  131937. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  131938. /**
  131939. * Specifies the diffuse color of the material.
  131940. */
  131941. diffuseColor: Color3;
  131942. /**
  131943. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  131944. * channel.
  131945. */
  131946. diffuseTexture: BaseTexture;
  131947. /**
  131948. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  131949. */
  131950. specularColor: Color3;
  131951. /**
  131952. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  131953. */
  131954. glossiness: number;
  131955. /**
  131956. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  131957. */
  131958. specularGlossinessTexture: BaseTexture;
  131959. /**
  131960. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  131961. *
  131962. * @param name The material name
  131963. * @param scene The scene the material will be use in.
  131964. */
  131965. constructor(name: string, scene: Scene);
  131966. /**
  131967. * Return the currrent class name of the material.
  131968. */
  131969. getClassName(): string;
  131970. /**
  131971. * Makes a duplicate of the current material.
  131972. * @param name - name to use for the new material.
  131973. */
  131974. clone(name: string): PBRSpecularGlossinessMaterial;
  131975. /**
  131976. * Serialize the material to a parsable JSON object.
  131977. */
  131978. serialize(): any;
  131979. /**
  131980. * Parses a JSON object correponding to the serialize function.
  131981. */
  131982. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  131983. }
  131984. }
  131985. declare module BABYLON {
  131986. /**
  131987. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  131988. * It can help converting any input color in a desired output one. This can then be used to create effects
  131989. * from sepia, black and white to sixties or futuristic rendering...
  131990. *
  131991. * The only supported format is currently 3dl.
  131992. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  131993. */
  131994. export class ColorGradingTexture extends BaseTexture {
  131995. /**
  131996. * The texture URL.
  131997. */
  131998. url: string;
  131999. /**
  132000. * Empty line regex stored for GC.
  132001. */
  132002. private static _noneEmptyLineRegex;
  132003. private _textureMatrix;
  132004. private _engine;
  132005. private _onLoad;
  132006. /**
  132007. * Instantiates a ColorGradingTexture from the following parameters.
  132008. *
  132009. * @param url The location of the color gradind data (currently only supporting 3dl)
  132010. * @param sceneOrEngine The scene or engine the texture will be used in
  132011. * @param onLoad defines a callback triggered when the texture has been loaded
  132012. */
  132013. constructor(url: string, sceneOrEngine: Scene | ThinEngine, onLoad?: Nullable<() => void>);
  132014. /**
  132015. * Fires the onload event from the constructor if requested.
  132016. */
  132017. private _triggerOnLoad;
  132018. /**
  132019. * Returns the texture matrix used in most of the material.
  132020. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  132021. */
  132022. getTextureMatrix(): Matrix;
  132023. /**
  132024. * Occurs when the file being loaded is a .3dl LUT file.
  132025. */
  132026. private load3dlTexture;
  132027. /**
  132028. * Starts the loading process of the texture.
  132029. */
  132030. private loadTexture;
  132031. /**
  132032. * Clones the color gradind texture.
  132033. */
  132034. clone(): ColorGradingTexture;
  132035. /**
  132036. * Called during delayed load for textures.
  132037. */
  132038. delayLoad(): void;
  132039. /**
  132040. * Parses a color grading texture serialized by Babylon.
  132041. * @param parsedTexture The texture information being parsedTexture
  132042. * @param scene The scene to load the texture in
  132043. * @param rootUrl The root url of the data assets to load
  132044. * @return A color gradind texture
  132045. */
  132046. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  132047. /**
  132048. * Serializes the LUT texture to json format.
  132049. */
  132050. serialize(): any;
  132051. /**
  132052. * Returns true if the passed parameter is a scene object (can be use for typings)
  132053. * @param sceneOrEngine The object to test.
  132054. */
  132055. private static _isScene;
  132056. }
  132057. }
  132058. declare module BABYLON {
  132059. /**
  132060. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  132061. */
  132062. export class EquiRectangularCubeTexture extends BaseTexture {
  132063. /** The six faces of the cube. */
  132064. private static _FacesMapping;
  132065. private _noMipmap;
  132066. private _onLoad;
  132067. private _onError;
  132068. /** The size of the cubemap. */
  132069. private _size;
  132070. /** The buffer of the image. */
  132071. private _buffer;
  132072. /** The width of the input image. */
  132073. private _width;
  132074. /** The height of the input image. */
  132075. private _height;
  132076. /** The URL to the image. */
  132077. url: string;
  132078. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  132079. coordinatesMode: number;
  132080. /**
  132081. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  132082. * @param url The location of the image
  132083. * @param scene The scene the texture will be used in
  132084. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  132085. * @param noMipmap Forces to not generate the mipmap if true
  132086. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  132087. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  132088. * @param onLoad — defines a callback called when texture is loaded
  132089. * @param onError — defines a callback called if there is an error
  132090. */
  132091. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  132092. /**
  132093. * Load the image data, by putting the image on a canvas and extracting its buffer.
  132094. */
  132095. private loadImage;
  132096. /**
  132097. * Convert the image buffer into a cubemap and create a CubeTexture.
  132098. */
  132099. private loadTexture;
  132100. /**
  132101. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  132102. * @param buffer The ArrayBuffer that should be converted.
  132103. * @returns The buffer as Float32Array.
  132104. */
  132105. private getFloat32ArrayFromArrayBuffer;
  132106. /**
  132107. * Get the current class name of the texture useful for serialization or dynamic coding.
  132108. * @returns "EquiRectangularCubeTexture"
  132109. */
  132110. getClassName(): string;
  132111. /**
  132112. * Create a clone of the current EquiRectangularCubeTexture and return it.
  132113. * @returns A clone of the current EquiRectangularCubeTexture.
  132114. */
  132115. clone(): EquiRectangularCubeTexture;
  132116. }
  132117. }
  132118. declare module BABYLON {
  132119. /**
  132120. * Based on jsTGALoader - Javascript loader for TGA file
  132121. * By Vincent Thibault
  132122. * @see http://blog.robrowser.com/javascript-tga-loader.html
  132123. */
  132124. export class TGATools {
  132125. private static _TYPE_INDEXED;
  132126. private static _TYPE_RGB;
  132127. private static _TYPE_GREY;
  132128. private static _TYPE_RLE_INDEXED;
  132129. private static _TYPE_RLE_RGB;
  132130. private static _TYPE_RLE_GREY;
  132131. private static _ORIGIN_MASK;
  132132. private static _ORIGIN_SHIFT;
  132133. private static _ORIGIN_BL;
  132134. private static _ORIGIN_BR;
  132135. private static _ORIGIN_UL;
  132136. private static _ORIGIN_UR;
  132137. /**
  132138. * Gets the header of a TGA file
  132139. * @param data defines the TGA data
  132140. * @returns the header
  132141. */
  132142. static GetTGAHeader(data: Uint8Array): any;
  132143. /**
  132144. * Uploads TGA content to a Babylon Texture
  132145. * @hidden
  132146. */
  132147. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  132148. /** @hidden */
  132149. 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;
  132150. /** @hidden */
  132151. 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;
  132152. /** @hidden */
  132153. 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;
  132154. /** @hidden */
  132155. 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;
  132156. /** @hidden */
  132157. 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;
  132158. /** @hidden */
  132159. 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;
  132160. }
  132161. }
  132162. declare module BABYLON {
  132163. /**
  132164. * Implementation of the TGA Texture Loader.
  132165. * @hidden
  132166. */
  132167. export class _TGATextureLoader implements IInternalTextureLoader {
  132168. /**
  132169. * Defines wether the loader supports cascade loading the different faces.
  132170. */
  132171. readonly supportCascades: boolean;
  132172. /**
  132173. * This returns if the loader support the current file information.
  132174. * @param extension defines the file extension of the file being loaded
  132175. * @returns true if the loader can load the specified file
  132176. */
  132177. canLoad(extension: string): boolean;
  132178. /**
  132179. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  132180. * @param data contains the texture data
  132181. * @param texture defines the BabylonJS internal texture
  132182. * @param createPolynomials will be true if polynomials have been requested
  132183. * @param onLoad defines the callback to trigger once the texture is ready
  132184. * @param onError defines the callback to trigger in case of error
  132185. */
  132186. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  132187. /**
  132188. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  132189. * @param data contains the texture data
  132190. * @param texture defines the BabylonJS internal texture
  132191. * @param callback defines the method to call once ready to upload
  132192. */
  132193. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  132194. }
  132195. }
  132196. declare module BABYLON {
  132197. /**
  132198. * Info about the .basis files
  132199. */
  132200. class BasisFileInfo {
  132201. /**
  132202. * If the file has alpha
  132203. */
  132204. hasAlpha: boolean;
  132205. /**
  132206. * Info about each image of the basis file
  132207. */
  132208. images: Array<{
  132209. levels: Array<{
  132210. width: number;
  132211. height: number;
  132212. transcodedPixels: ArrayBufferView;
  132213. }>;
  132214. }>;
  132215. }
  132216. /**
  132217. * Result of transcoding a basis file
  132218. */
  132219. class TranscodeResult {
  132220. /**
  132221. * Info about the .basis file
  132222. */
  132223. fileInfo: BasisFileInfo;
  132224. /**
  132225. * Format to use when loading the file
  132226. */
  132227. format: number;
  132228. }
  132229. /**
  132230. * Configuration options for the Basis transcoder
  132231. */
  132232. export class BasisTranscodeConfiguration {
  132233. /**
  132234. * Supported compression formats used to determine the supported output format of the transcoder
  132235. */
  132236. supportedCompressionFormats?: {
  132237. /**
  132238. * etc1 compression format
  132239. */
  132240. etc1?: boolean;
  132241. /**
  132242. * s3tc compression format
  132243. */
  132244. s3tc?: boolean;
  132245. /**
  132246. * pvrtc compression format
  132247. */
  132248. pvrtc?: boolean;
  132249. /**
  132250. * etc2 compression format
  132251. */
  132252. etc2?: boolean;
  132253. };
  132254. /**
  132255. * If mipmap levels should be loaded for transcoded images (Default: true)
  132256. */
  132257. loadMipmapLevels?: boolean;
  132258. /**
  132259. * Index of a single image to load (Default: all images)
  132260. */
  132261. loadSingleImage?: number;
  132262. }
  132263. /**
  132264. * Used to load .Basis files
  132265. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  132266. */
  132267. export class BasisTools {
  132268. private static _IgnoreSupportedFormats;
  132269. /**
  132270. * URL to use when loading the basis transcoder
  132271. */
  132272. static JSModuleURL: string;
  132273. /**
  132274. * URL to use when loading the wasm module for the transcoder
  132275. */
  132276. static WasmModuleURL: string;
  132277. /**
  132278. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  132279. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  132280. * @returns internal format corresponding to the Basis format
  132281. */
  132282. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  132283. private static _WorkerPromise;
  132284. private static _Worker;
  132285. private static _actionId;
  132286. private static _CreateWorkerAsync;
  132287. /**
  132288. * Transcodes a loaded image file to compressed pixel data
  132289. * @param data image data to transcode
  132290. * @param config configuration options for the transcoding
  132291. * @returns a promise resulting in the transcoded image
  132292. */
  132293. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  132294. /**
  132295. * Loads a texture from the transcode result
  132296. * @param texture texture load to
  132297. * @param transcodeResult the result of transcoding the basis file to load from
  132298. */
  132299. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  132300. }
  132301. }
  132302. declare module BABYLON {
  132303. /**
  132304. * Loader for .basis file format
  132305. */
  132306. export class _BasisTextureLoader implements IInternalTextureLoader {
  132307. /**
  132308. * Defines whether the loader supports cascade loading the different faces.
  132309. */
  132310. readonly supportCascades: boolean;
  132311. /**
  132312. * This returns if the loader support the current file information.
  132313. * @param extension defines the file extension of the file being loaded
  132314. * @returns true if the loader can load the specified file
  132315. */
  132316. canLoad(extension: string): boolean;
  132317. /**
  132318. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  132319. * @param data contains the texture data
  132320. * @param texture defines the BabylonJS internal texture
  132321. * @param createPolynomials will be true if polynomials have been requested
  132322. * @param onLoad defines the callback to trigger once the texture is ready
  132323. * @param onError defines the callback to trigger in case of error
  132324. */
  132325. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  132326. /**
  132327. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  132328. * @param data contains the texture data
  132329. * @param texture defines the BabylonJS internal texture
  132330. * @param callback defines the method to call once ready to upload
  132331. */
  132332. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  132333. }
  132334. }
  132335. declare module BABYLON {
  132336. /**
  132337. * 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.
  132338. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  132339. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  132340. */
  132341. export class CustomProceduralTexture extends ProceduralTexture {
  132342. private _animate;
  132343. private _time;
  132344. private _config;
  132345. private _texturePath;
  132346. /**
  132347. * Instantiates a new Custom Procedural Texture.
  132348. * 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.
  132349. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  132350. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  132351. * @param name Define the name of the texture
  132352. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  132353. * @param size Define the size of the texture to create
  132354. * @param scene Define the scene the texture belongs to
  132355. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  132356. * @param generateMipMaps Define if the texture should creates mip maps or not
  132357. */
  132358. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  132359. private _loadJson;
  132360. /**
  132361. * Is the texture ready to be used ? (rendered at least once)
  132362. * @returns true if ready, otherwise, false.
  132363. */
  132364. isReady(): boolean;
  132365. /**
  132366. * Render the texture to its associated render target.
  132367. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  132368. */
  132369. render(useCameraPostProcess?: boolean): void;
  132370. /**
  132371. * Update the list of dependant textures samplers in the shader.
  132372. */
  132373. updateTextures(): void;
  132374. /**
  132375. * Update the uniform values of the procedural texture in the shader.
  132376. */
  132377. updateShaderUniforms(): void;
  132378. /**
  132379. * Define if the texture animates or not.
  132380. */
  132381. get animate(): boolean;
  132382. set animate(value: boolean);
  132383. }
  132384. }
  132385. declare module BABYLON {
  132386. /** @hidden */
  132387. export var noisePixelShader: {
  132388. name: string;
  132389. shader: string;
  132390. };
  132391. }
  132392. declare module BABYLON {
  132393. /**
  132394. * Class used to generate noise procedural textures
  132395. */
  132396. export class NoiseProceduralTexture extends ProceduralTexture {
  132397. private _time;
  132398. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  132399. brightness: number;
  132400. /** Defines the number of octaves to process */
  132401. octaves: number;
  132402. /** Defines the level of persistence (0.8 by default) */
  132403. persistence: number;
  132404. /** Gets or sets animation speed factor (default is 1) */
  132405. animationSpeedFactor: number;
  132406. /**
  132407. * Creates a new NoiseProceduralTexture
  132408. * @param name defines the name fo the texture
  132409. * @param size defines the size of the texture (default is 256)
  132410. * @param scene defines the hosting scene
  132411. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  132412. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  132413. */
  132414. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  132415. private _updateShaderUniforms;
  132416. protected _getDefines(): string;
  132417. /** Generate the current state of the procedural texture */
  132418. render(useCameraPostProcess?: boolean): void;
  132419. /**
  132420. * Serializes this noise procedural texture
  132421. * @returns a serialized noise procedural texture object
  132422. */
  132423. serialize(): any;
  132424. /**
  132425. * Clone the texture.
  132426. * @returns the cloned texture
  132427. */
  132428. clone(): NoiseProceduralTexture;
  132429. /**
  132430. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  132431. * @param parsedTexture defines parsed texture data
  132432. * @param scene defines the current scene
  132433. * @param rootUrl defines the root URL containing noise procedural texture information
  132434. * @returns a parsed NoiseProceduralTexture
  132435. */
  132436. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  132437. }
  132438. }
  132439. declare module BABYLON {
  132440. /**
  132441. * Raw cube texture where the raw buffers are passed in
  132442. */
  132443. export class RawCubeTexture extends CubeTexture {
  132444. /**
  132445. * Creates a cube texture where the raw buffers are passed in.
  132446. * @param scene defines the scene the texture is attached to
  132447. * @param data defines the array of data to use to create each face
  132448. * @param size defines the size of the textures
  132449. * @param format defines the format of the data
  132450. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  132451. * @param generateMipMaps defines if the engine should generate the mip levels
  132452. * @param invertY defines if data must be stored with Y axis inverted
  132453. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  132454. * @param compression defines the compression used (null by default)
  132455. */
  132456. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  132457. /**
  132458. * Updates the raw cube texture.
  132459. * @param data defines the data to store
  132460. * @param format defines the data format
  132461. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  132462. * @param invertY defines if data must be stored with Y axis inverted
  132463. * @param compression defines the compression used (null by default)
  132464. * @param level defines which level of the texture to update
  132465. */
  132466. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  132467. /**
  132468. * Updates a raw cube texture with RGBD encoded data.
  132469. * @param data defines the array of data [mipmap][face] to use to create each face
  132470. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  132471. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  132472. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  132473. * @returns a promsie that resolves when the operation is complete
  132474. */
  132475. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  132476. /**
  132477. * Clones the raw cube texture.
  132478. * @return a new cube texture
  132479. */
  132480. clone(): CubeTexture;
  132481. /** @hidden */
  132482. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  132483. }
  132484. }
  132485. declare module BABYLON {
  132486. /**
  132487. * Class used to store 3D textures containing user data
  132488. */
  132489. export class RawTexture3D extends Texture {
  132490. /** Gets or sets the texture format to use */
  132491. format: number;
  132492. private _engine;
  132493. /**
  132494. * Create a new RawTexture3D
  132495. * @param data defines the data of the texture
  132496. * @param width defines the width of the texture
  132497. * @param height defines the height of the texture
  132498. * @param depth defines the depth of the texture
  132499. * @param format defines the texture format to use
  132500. * @param scene defines the hosting scene
  132501. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  132502. * @param invertY defines if texture must be stored with Y axis inverted
  132503. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  132504. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  132505. */
  132506. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  132507. /** Gets or sets the texture format to use */
  132508. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  132509. /**
  132510. * Update the texture with new data
  132511. * @param data defines the data to store in the texture
  132512. */
  132513. update(data: ArrayBufferView): void;
  132514. }
  132515. }
  132516. declare module BABYLON {
  132517. /**
  132518. * Class used to store 2D array textures containing user data
  132519. */
  132520. export class RawTexture2DArray extends Texture {
  132521. /** Gets or sets the texture format to use */
  132522. format: number;
  132523. private _engine;
  132524. /**
  132525. * Create a new RawTexture2DArray
  132526. * @param data defines the data of the texture
  132527. * @param width defines the width of the texture
  132528. * @param height defines the height of the texture
  132529. * @param depth defines the number of layers of the texture
  132530. * @param format defines the texture format to use
  132531. * @param scene defines the hosting scene
  132532. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  132533. * @param invertY defines if texture must be stored with Y axis inverted
  132534. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  132535. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  132536. */
  132537. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  132538. /** Gets or sets the texture format to use */
  132539. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  132540. /**
  132541. * Update the texture with new data
  132542. * @param data defines the data to store in the texture
  132543. */
  132544. update(data: ArrayBufferView): void;
  132545. }
  132546. }
  132547. declare module BABYLON {
  132548. /**
  132549. * Creates a refraction texture used by refraction channel of the standard material.
  132550. * It is like a mirror but to see through a material.
  132551. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  132552. */
  132553. export class RefractionTexture extends RenderTargetTexture {
  132554. /**
  132555. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  132556. * 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.
  132557. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  132558. */
  132559. refractionPlane: Plane;
  132560. /**
  132561. * Define how deep under the surface we should see.
  132562. */
  132563. depth: number;
  132564. /**
  132565. * Creates a refraction texture used by refraction channel of the standard material.
  132566. * It is like a mirror but to see through a material.
  132567. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  132568. * @param name Define the texture name
  132569. * @param size Define the size of the underlying texture
  132570. * @param scene Define the scene the refraction belongs to
  132571. * @param generateMipMaps Define if we need to generate mips level for the refraction
  132572. */
  132573. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  132574. /**
  132575. * Clone the refraction texture.
  132576. * @returns the cloned texture
  132577. */
  132578. clone(): RefractionTexture;
  132579. /**
  132580. * Serialize the texture to a JSON representation you could use in Parse later on
  132581. * @returns the serialized JSON representation
  132582. */
  132583. serialize(): any;
  132584. }
  132585. }
  132586. declare module BABYLON {
  132587. /**
  132588. * Defines the options related to the creation of an HtmlElementTexture
  132589. */
  132590. export interface IHtmlElementTextureOptions {
  132591. /**
  132592. * Defines wether mip maps should be created or not.
  132593. */
  132594. generateMipMaps?: boolean;
  132595. /**
  132596. * Defines the sampling mode of the texture.
  132597. */
  132598. samplingMode?: number;
  132599. /**
  132600. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  132601. */
  132602. engine: Nullable<ThinEngine>;
  132603. /**
  132604. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  132605. */
  132606. scene: Nullable<Scene>;
  132607. }
  132608. /**
  132609. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  132610. * To be as efficient as possible depending on your constraints nothing aside the first upload
  132611. * is automatically managed.
  132612. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  132613. * in your application.
  132614. *
  132615. * As the update is not automatic, you need to call them manually.
  132616. */
  132617. export class HtmlElementTexture extends BaseTexture {
  132618. /**
  132619. * The texture URL.
  132620. */
  132621. element: HTMLVideoElement | HTMLCanvasElement;
  132622. private static readonly DefaultOptions;
  132623. private _textureMatrix;
  132624. private _engine;
  132625. private _isVideo;
  132626. private _generateMipMaps;
  132627. private _samplingMode;
  132628. /**
  132629. * Instantiates a HtmlElementTexture from the following parameters.
  132630. *
  132631. * @param name Defines the name of the texture
  132632. * @param element Defines the video or canvas the texture is filled with
  132633. * @param options Defines the other none mandatory texture creation options
  132634. */
  132635. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  132636. private _createInternalTexture;
  132637. /**
  132638. * Returns the texture matrix used in most of the material.
  132639. */
  132640. getTextureMatrix(): Matrix;
  132641. /**
  132642. * Updates the content of the texture.
  132643. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  132644. */
  132645. update(invertY?: Nullable<boolean>): void;
  132646. }
  132647. }
  132648. declare module BABYLON {
  132649. /**
  132650. * Defines the basic options interface of a TexturePacker Frame
  132651. */
  132652. export interface ITexturePackerFrame {
  132653. /**
  132654. * The frame ID
  132655. */
  132656. id: number;
  132657. /**
  132658. * The frames Scale
  132659. */
  132660. scale: Vector2;
  132661. /**
  132662. * The Frames offset
  132663. */
  132664. offset: Vector2;
  132665. }
  132666. /**
  132667. * This is a support class for frame Data on texture packer sets.
  132668. */
  132669. export class TexturePackerFrame implements ITexturePackerFrame {
  132670. /**
  132671. * The frame ID
  132672. */
  132673. id: number;
  132674. /**
  132675. * The frames Scale
  132676. */
  132677. scale: Vector2;
  132678. /**
  132679. * The Frames offset
  132680. */
  132681. offset: Vector2;
  132682. /**
  132683. * Initializes a texture package frame.
  132684. * @param id The numerical frame identifier
  132685. * @param scale Scalar Vector2 for UV frame
  132686. * @param offset Vector2 for the frame position in UV units.
  132687. * @returns TexturePackerFrame
  132688. */
  132689. constructor(id: number, scale: Vector2, offset: Vector2);
  132690. }
  132691. }
  132692. declare module BABYLON {
  132693. /**
  132694. * Defines the basic options interface of a TexturePacker
  132695. */
  132696. export interface ITexturePackerOptions {
  132697. /**
  132698. * Custom targets for the channels of a texture packer. Default is all the channels of the Standard Material
  132699. */
  132700. map?: string[];
  132701. /**
  132702. * the UV input targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  132703. */
  132704. uvsIn?: string;
  132705. /**
  132706. * the UV output targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  132707. */
  132708. uvsOut?: string;
  132709. /**
  132710. * number representing the layout style. Defaults to LAYOUT_STRIP
  132711. */
  132712. layout?: number;
  132713. /**
  132714. * number of columns if using custom column count layout(2). This defaults to 4.
  132715. */
  132716. colnum?: number;
  132717. /**
  132718. * flag to update the input meshes to the new packed texture after compilation. Defaults to true.
  132719. */
  132720. updateInputMeshes?: boolean;
  132721. /**
  132722. * boolean flag to dispose all the source textures. Defaults to true.
  132723. */
  132724. disposeSources?: boolean;
  132725. /**
  132726. * Fills the blank cells in a set to the customFillColor. Defaults to true.
  132727. */
  132728. fillBlanks?: boolean;
  132729. /**
  132730. * string value representing the context fill style color. Defaults to 'black'.
  132731. */
  132732. customFillColor?: string;
  132733. /**
  132734. * Width and Height Value of each Frame in the TexturePacker Sets
  132735. */
  132736. frameSize?: number;
  132737. /**
  132738. * Ratio of the value to add padding wise to each cell. Defaults to 0.0115
  132739. */
  132740. paddingRatio?: number;
  132741. /**
  132742. * Number that declares the fill method for the padding gutter.
  132743. */
  132744. paddingMode?: number;
  132745. /**
  132746. * If in SUBUV_COLOR padding mode what color to use.
  132747. */
  132748. paddingColor?: Color3 | Color4;
  132749. }
  132750. /**
  132751. * Defines the basic interface of a TexturePacker JSON File
  132752. */
  132753. export interface ITexturePackerJSON {
  132754. /**
  132755. * The frame ID
  132756. */
  132757. name: string;
  132758. /**
  132759. * The base64 channel data
  132760. */
  132761. sets: any;
  132762. /**
  132763. * The options of the Packer
  132764. */
  132765. options: ITexturePackerOptions;
  132766. /**
  132767. * The frame data of the Packer
  132768. */
  132769. frames: Array<number>;
  132770. }
  132771. /**
  132772. * This is a support class that generates a series of packed texture sets.
  132773. * @see https://doc.babylonjs.com/babylon101/materials
  132774. */
  132775. export class TexturePacker {
  132776. /** Packer Layout Constant 0 */
  132777. static readonly LAYOUT_STRIP: number;
  132778. /** Packer Layout Constant 1 */
  132779. static readonly LAYOUT_POWER2: number;
  132780. /** Packer Layout Constant 2 */
  132781. static readonly LAYOUT_COLNUM: number;
  132782. /** Packer Layout Constant 0 */
  132783. static readonly SUBUV_WRAP: number;
  132784. /** Packer Layout Constant 1 */
  132785. static readonly SUBUV_EXTEND: number;
  132786. /** Packer Layout Constant 2 */
  132787. static readonly SUBUV_COLOR: number;
  132788. /** The Name of the Texture Package */
  132789. name: string;
  132790. /** The scene scope of the TexturePacker */
  132791. scene: Scene;
  132792. /** The Meshes to target */
  132793. meshes: AbstractMesh[];
  132794. /** Arguments passed with the Constructor */
  132795. options: ITexturePackerOptions;
  132796. /** The promise that is started upon initialization */
  132797. promise: Nullable<Promise<TexturePacker | string>>;
  132798. /** The Container object for the channel sets that are generated */
  132799. sets: object;
  132800. /** The Container array for the frames that are generated */
  132801. frames: TexturePackerFrame[];
  132802. /** The expected number of textures the system is parsing. */
  132803. private _expecting;
  132804. /** The padding value from Math.ceil(frameSize * paddingRatio) */
  132805. private _paddingValue;
  132806. /**
  132807. * Initializes a texture package series from an array of meshes or a single mesh.
  132808. * @param name The name of the package
  132809. * @param meshes The target meshes to compose the package from
  132810. * @param options The arguments that texture packer should follow while building.
  132811. * @param scene The scene which the textures are scoped to.
  132812. * @returns TexturePacker
  132813. */
  132814. constructor(name: string, meshes: AbstractMesh[], options: ITexturePackerOptions, scene: Scene);
  132815. /**
  132816. * Starts the package process
  132817. * @param resolve The promises resolution function
  132818. * @returns TexturePacker
  132819. */
  132820. private _createFrames;
  132821. /**
  132822. * Calculates the Size of the Channel Sets
  132823. * @returns Vector2
  132824. */
  132825. private _calculateSize;
  132826. /**
  132827. * Calculates the UV data for the frames.
  132828. * @param baseSize the base frameSize
  132829. * @param padding the base frame padding
  132830. * @param dtSize size of the Dynamic Texture for that channel
  132831. * @param dtUnits is 1/dtSize
  132832. * @param update flag to update the input meshes
  132833. */
  132834. private _calculateMeshUVFrames;
  132835. /**
  132836. * Calculates the frames Offset.
  132837. * @param index of the frame
  132838. * @returns Vector2
  132839. */
  132840. private _getFrameOffset;
  132841. /**
  132842. * Updates a Mesh to the frame data
  132843. * @param mesh that is the target
  132844. * @param frameID or the frame index
  132845. */
  132846. private _updateMeshUV;
  132847. /**
  132848. * Updates a Meshes materials to use the texture packer channels
  132849. * @param m is the mesh to target
  132850. * @param force all channels on the packer to be set.
  132851. */
  132852. private _updateTextureReferences;
  132853. /**
  132854. * Public method to set a Mesh to a frame
  132855. * @param m that is the target
  132856. * @param frameID or the frame index
  132857. * @param updateMaterial trigger for if the Meshes attached Material be updated?
  132858. */
  132859. setMeshToFrame(m: AbstractMesh, frameID: number, updateMaterial?: boolean): void;
  132860. /**
  132861. * Starts the async promise to compile the texture packer.
  132862. * @returns Promise<void>
  132863. */
  132864. processAsync(): Promise<void>;
  132865. /**
  132866. * Disposes all textures associated with this packer
  132867. */
  132868. dispose(): void;
  132869. /**
  132870. * Starts the download process for all the channels converting them to base64 data and embedding it all in a JSON file.
  132871. * @param imageType is the image type to use.
  132872. * @param quality of the image if downloading as jpeg, Ranges from >0 to 1.
  132873. */
  132874. download(imageType?: string, quality?: number): void;
  132875. /**
  132876. * Public method to load a texturePacker JSON file.
  132877. * @param data of the JSON file in string format.
  132878. */
  132879. updateFromJSON(data: string): void;
  132880. }
  132881. }
  132882. declare module BABYLON {
  132883. /**
  132884. * Enum used to define the target of a block
  132885. */
  132886. export enum NodeMaterialBlockTargets {
  132887. /** Vertex shader */
  132888. Vertex = 1,
  132889. /** Fragment shader */
  132890. Fragment = 2,
  132891. /** Neutral */
  132892. Neutral = 4,
  132893. /** Vertex and Fragment */
  132894. VertexAndFragment = 3
  132895. }
  132896. }
  132897. declare module BABYLON {
  132898. /**
  132899. * Defines the kind of connection point for node based material
  132900. */
  132901. export enum NodeMaterialBlockConnectionPointTypes {
  132902. /** Float */
  132903. Float = 1,
  132904. /** Int */
  132905. Int = 2,
  132906. /** Vector2 */
  132907. Vector2 = 4,
  132908. /** Vector3 */
  132909. Vector3 = 8,
  132910. /** Vector4 */
  132911. Vector4 = 16,
  132912. /** Color3 */
  132913. Color3 = 32,
  132914. /** Color4 */
  132915. Color4 = 64,
  132916. /** Matrix */
  132917. Matrix = 128,
  132918. /** Custom object */
  132919. Object = 256,
  132920. /** Detect type based on connection */
  132921. AutoDetect = 1024,
  132922. /** Output type that will be defined by input type */
  132923. BasedOnInput = 2048
  132924. }
  132925. }
  132926. declare module BABYLON {
  132927. /**
  132928. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  132929. */
  132930. export enum NodeMaterialBlockConnectionPointMode {
  132931. /** Value is an uniform */
  132932. Uniform = 0,
  132933. /** Value is a mesh attribute */
  132934. Attribute = 1,
  132935. /** Value is a varying between vertex and fragment shaders */
  132936. Varying = 2,
  132937. /** Mode is undefined */
  132938. Undefined = 3
  132939. }
  132940. }
  132941. declare module BABYLON {
  132942. /**
  132943. * Enum used to define system values e.g. values automatically provided by the system
  132944. */
  132945. export enum NodeMaterialSystemValues {
  132946. /** World */
  132947. World = 1,
  132948. /** View */
  132949. View = 2,
  132950. /** Projection */
  132951. Projection = 3,
  132952. /** ViewProjection */
  132953. ViewProjection = 4,
  132954. /** WorldView */
  132955. WorldView = 5,
  132956. /** WorldViewProjection */
  132957. WorldViewProjection = 6,
  132958. /** CameraPosition */
  132959. CameraPosition = 7,
  132960. /** Fog Color */
  132961. FogColor = 8,
  132962. /** Delta time */
  132963. DeltaTime = 9
  132964. }
  132965. }
  132966. declare module BABYLON {
  132967. /**
  132968. * Root class for all node material optimizers
  132969. */
  132970. export class NodeMaterialOptimizer {
  132971. /**
  132972. * Function used to optimize a NodeMaterial graph
  132973. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  132974. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  132975. */
  132976. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  132977. }
  132978. }
  132979. declare module BABYLON {
  132980. /**
  132981. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  132982. */
  132983. export class TransformBlock extends NodeMaterialBlock {
  132984. /**
  132985. * Defines the value to use to complement W value to transform it to a Vector4
  132986. */
  132987. complementW: number;
  132988. /**
  132989. * Defines the value to use to complement z value to transform it to a Vector4
  132990. */
  132991. complementZ: number;
  132992. /**
  132993. * Creates a new TransformBlock
  132994. * @param name defines the block name
  132995. */
  132996. constructor(name: string);
  132997. /**
  132998. * Gets the current class name
  132999. * @returns the class name
  133000. */
  133001. getClassName(): string;
  133002. /**
  133003. * Gets the vector input
  133004. */
  133005. get vector(): NodeMaterialConnectionPoint;
  133006. /**
  133007. * Gets the output component
  133008. */
  133009. get output(): NodeMaterialConnectionPoint;
  133010. /**
  133011. * Gets the xyz output component
  133012. */
  133013. get xyz(): NodeMaterialConnectionPoint;
  133014. /**
  133015. * Gets the matrix transform input
  133016. */
  133017. get transform(): NodeMaterialConnectionPoint;
  133018. protected _buildBlock(state: NodeMaterialBuildState): this;
  133019. serialize(): any;
  133020. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  133021. protected _dumpPropertiesCode(): string;
  133022. }
  133023. }
  133024. declare module BABYLON {
  133025. /**
  133026. * Block used to output the vertex position
  133027. */
  133028. export class VertexOutputBlock extends NodeMaterialBlock {
  133029. /**
  133030. * Creates a new VertexOutputBlock
  133031. * @param name defines the block name
  133032. */
  133033. constructor(name: string);
  133034. /**
  133035. * Gets the current class name
  133036. * @returns the class name
  133037. */
  133038. getClassName(): string;
  133039. /**
  133040. * Gets the vector input component
  133041. */
  133042. get vector(): NodeMaterialConnectionPoint;
  133043. protected _buildBlock(state: NodeMaterialBuildState): this;
  133044. }
  133045. }
  133046. declare module BABYLON {
  133047. /**
  133048. * Block used to output the final color
  133049. */
  133050. export class FragmentOutputBlock extends NodeMaterialBlock {
  133051. /**
  133052. * Create a new FragmentOutputBlock
  133053. * @param name defines the block name
  133054. */
  133055. constructor(name: string);
  133056. /**
  133057. * Gets the current class name
  133058. * @returns the class name
  133059. */
  133060. getClassName(): string;
  133061. /**
  133062. * Gets the rgba input component
  133063. */
  133064. get rgba(): NodeMaterialConnectionPoint;
  133065. /**
  133066. * Gets the rgb input component
  133067. */
  133068. get rgb(): NodeMaterialConnectionPoint;
  133069. /**
  133070. * Gets the a input component
  133071. */
  133072. get a(): NodeMaterialConnectionPoint;
  133073. protected _buildBlock(state: NodeMaterialBuildState): this;
  133074. }
  133075. }
  133076. declare module BABYLON {
  133077. /**
  133078. * Base block used to read a reflection texture from a sampler
  133079. */
  133080. export abstract class ReflectionTextureBaseBlock extends NodeMaterialBlock {
  133081. /** @hidden */
  133082. _define3DName: string;
  133083. /** @hidden */
  133084. _defineCubicName: string;
  133085. /** @hidden */
  133086. _defineExplicitName: string;
  133087. /** @hidden */
  133088. _defineProjectionName: string;
  133089. /** @hidden */
  133090. _defineLocalCubicName: string;
  133091. /** @hidden */
  133092. _defineSphericalName: string;
  133093. /** @hidden */
  133094. _definePlanarName: string;
  133095. /** @hidden */
  133096. _defineEquirectangularName: string;
  133097. /** @hidden */
  133098. _defineMirroredEquirectangularFixedName: string;
  133099. /** @hidden */
  133100. _defineEquirectangularFixedName: string;
  133101. /** @hidden */
  133102. _defineSkyboxName: string;
  133103. /** @hidden */
  133104. _defineOppositeZ: string;
  133105. /** @hidden */
  133106. _cubeSamplerName: string;
  133107. /** @hidden */
  133108. _2DSamplerName: string;
  133109. protected _positionUVWName: string;
  133110. protected _directionWName: string;
  133111. protected _reflectionVectorName: string;
  133112. /** @hidden */
  133113. _reflectionCoordsName: string;
  133114. protected _reflectionMatrixName: string;
  133115. protected _reflectionColorName: string;
  133116. /**
  133117. * Gets or sets the texture associated with the node
  133118. */
  133119. texture: Nullable<BaseTexture>;
  133120. /**
  133121. * Create a new ReflectionTextureBaseBlock
  133122. * @param name defines the block name
  133123. */
  133124. constructor(name: string);
  133125. /**
  133126. * Gets the current class name
  133127. * @returns the class name
  133128. */
  133129. getClassName(): string;
  133130. /**
  133131. * Gets the world position input component
  133132. */
  133133. abstract get position(): NodeMaterialConnectionPoint;
  133134. /**
  133135. * Gets the world position input component
  133136. */
  133137. abstract get worldPosition(): NodeMaterialConnectionPoint;
  133138. /**
  133139. * Gets the world normal input component
  133140. */
  133141. abstract get worldNormal(): NodeMaterialConnectionPoint;
  133142. /**
  133143. * Gets the world input component
  133144. */
  133145. abstract get world(): NodeMaterialConnectionPoint;
  133146. /**
  133147. * Gets the camera (or eye) position component
  133148. */
  133149. abstract get cameraPosition(): NodeMaterialConnectionPoint;
  133150. /**
  133151. * Gets the view input component
  133152. */
  133153. abstract get view(): NodeMaterialConnectionPoint;
  133154. protected _getTexture(): Nullable<BaseTexture>;
  133155. autoConfigure(material: NodeMaterial): void;
  133156. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  133157. isReady(): boolean;
  133158. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  133159. /**
  133160. * Gets the code to inject in the vertex shader
  133161. * @param state current state of the node material building
  133162. * @returns the shader code
  133163. */
  133164. handleVertexSide(state: NodeMaterialBuildState): string;
  133165. /**
  133166. * Handles the inits for the fragment code path
  133167. * @param state node material build state
  133168. */
  133169. handleFragmentSideInits(state: NodeMaterialBuildState): void;
  133170. /**
  133171. * Generates the reflection coords code for the fragment code path
  133172. * @param worldNormalVarName name of the world normal variable
  133173. * @param worldPos name of the world position variable. If not provided, will use the world position connected to this block
  133174. * @param onlyReflectionVector if true, generates code only for the reflection vector computation, not for the reflection coordinates
  133175. * @returns the shader code
  133176. */
  133177. handleFragmentSideCodeReflectionCoords(worldNormalVarName: string, worldPos?: string, onlyReflectionVector?: boolean): string;
  133178. /**
  133179. * Generates the reflection color code for the fragment code path
  133180. * @param lodVarName name of the lod variable
  133181. * @param swizzleLookupTexture swizzle to use for the final color variable
  133182. * @returns the shader code
  133183. */
  133184. handleFragmentSideCodeReflectionColor(lodVarName?: string, swizzleLookupTexture?: string): string;
  133185. /**
  133186. * Generates the code corresponding to the connected output points
  133187. * @param state node material build state
  133188. * @param varName name of the variable to output
  133189. * @returns the shader code
  133190. */
  133191. writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  133192. protected _buildBlock(state: NodeMaterialBuildState): this;
  133193. protected _dumpPropertiesCode(): string;
  133194. serialize(): any;
  133195. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  133196. }
  133197. }
  133198. declare module BABYLON {
  133199. /**
  133200. * Interface used to configure the node material editor
  133201. */
  133202. export interface INodeMaterialEditorOptions {
  133203. /** Define the URl to load node editor script */
  133204. editorURL?: string;
  133205. }
  133206. /** @hidden */
  133207. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  133208. NORMAL: boolean;
  133209. TANGENT: boolean;
  133210. UV1: boolean;
  133211. /** BONES */
  133212. NUM_BONE_INFLUENCERS: number;
  133213. BonesPerMesh: number;
  133214. BONETEXTURE: boolean;
  133215. /** MORPH TARGETS */
  133216. MORPHTARGETS: boolean;
  133217. MORPHTARGETS_NORMAL: boolean;
  133218. MORPHTARGETS_TANGENT: boolean;
  133219. MORPHTARGETS_UV: boolean;
  133220. NUM_MORPH_INFLUENCERS: number;
  133221. /** IMAGE PROCESSING */
  133222. IMAGEPROCESSING: boolean;
  133223. VIGNETTE: boolean;
  133224. VIGNETTEBLENDMODEMULTIPLY: boolean;
  133225. VIGNETTEBLENDMODEOPAQUE: boolean;
  133226. TONEMAPPING: boolean;
  133227. TONEMAPPING_ACES: boolean;
  133228. CONTRAST: boolean;
  133229. EXPOSURE: boolean;
  133230. COLORCURVES: boolean;
  133231. COLORGRADING: boolean;
  133232. COLORGRADING3D: boolean;
  133233. SAMPLER3DGREENDEPTH: boolean;
  133234. SAMPLER3DBGRMAP: boolean;
  133235. IMAGEPROCESSINGPOSTPROCESS: boolean;
  133236. /** MISC. */
  133237. BUMPDIRECTUV: number;
  133238. constructor();
  133239. setValue(name: string, value: any): void;
  133240. }
  133241. /**
  133242. * Class used to configure NodeMaterial
  133243. */
  133244. export interface INodeMaterialOptions {
  133245. /**
  133246. * Defines if blocks should emit comments
  133247. */
  133248. emitComments: boolean;
  133249. }
  133250. /**
  133251. * Class used to create a node based material built by assembling shader blocks
  133252. */
  133253. export class NodeMaterial extends PushMaterial {
  133254. private static _BuildIdGenerator;
  133255. private _options;
  133256. private _vertexCompilationState;
  133257. private _fragmentCompilationState;
  133258. private _sharedData;
  133259. private _buildId;
  133260. private _buildWasSuccessful;
  133261. private _cachedWorldViewMatrix;
  133262. private _cachedWorldViewProjectionMatrix;
  133263. private _optimizers;
  133264. private _animationFrame;
  133265. /** Define the Url to load node editor script */
  133266. static EditorURL: string;
  133267. /** Define the Url to load snippets */
  133268. static SnippetUrl: string;
  133269. /** Gets or sets a boolean indicating that node materials should not deserialize textures from json / snippet content */
  133270. static IgnoreTexturesAtLoadTime: boolean;
  133271. private BJSNODEMATERIALEDITOR;
  133272. /** Get the inspector from bundle or global */
  133273. private _getGlobalNodeMaterialEditor;
  133274. /**
  133275. * Snippet ID if the material was created from the snippet server
  133276. */
  133277. snippetId: string;
  133278. /**
  133279. * Gets or sets data used by visual editor
  133280. * @see https://nme.babylonjs.com
  133281. */
  133282. editorData: any;
  133283. /**
  133284. * 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)
  133285. */
  133286. ignoreAlpha: boolean;
  133287. /**
  133288. * Defines the maximum number of lights that can be used in the material
  133289. */
  133290. maxSimultaneousLights: number;
  133291. /**
  133292. * Observable raised when the material is built
  133293. */
  133294. onBuildObservable: Observable<NodeMaterial>;
  133295. /**
  133296. * Gets or sets the root nodes of the material vertex shader
  133297. */
  133298. _vertexOutputNodes: NodeMaterialBlock[];
  133299. /**
  133300. * Gets or sets the root nodes of the material fragment (pixel) shader
  133301. */
  133302. _fragmentOutputNodes: NodeMaterialBlock[];
  133303. /** Gets or sets options to control the node material overall behavior */
  133304. get options(): INodeMaterialOptions;
  133305. set options(options: INodeMaterialOptions);
  133306. /**
  133307. * Default configuration related to image processing available in the standard Material.
  133308. */
  133309. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  133310. /**
  133311. * Gets the image processing configuration used either in this material.
  133312. */
  133313. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  133314. /**
  133315. * Sets the Default image processing configuration used either in the this material.
  133316. *
  133317. * If sets to null, the scene one is in use.
  133318. */
  133319. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  133320. /**
  133321. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  133322. */
  133323. attachedBlocks: NodeMaterialBlock[];
  133324. /**
  133325. * Create a new node based material
  133326. * @param name defines the material name
  133327. * @param scene defines the hosting scene
  133328. * @param options defines creation option
  133329. */
  133330. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  133331. /**
  133332. * Gets the current class name of the material e.g. "NodeMaterial"
  133333. * @returns the class name
  133334. */
  133335. getClassName(): string;
  133336. /**
  133337. * Keep track of the image processing observer to allow dispose and replace.
  133338. */
  133339. private _imageProcessingObserver;
  133340. /**
  133341. * Attaches a new image processing configuration to the Standard Material.
  133342. * @param configuration
  133343. */
  133344. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  133345. /**
  133346. * Get a block by its name
  133347. * @param name defines the name of the block to retrieve
  133348. * @returns the required block or null if not found
  133349. */
  133350. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  133351. /**
  133352. * Get a block by its name
  133353. * @param predicate defines the predicate used to find the good candidate
  133354. * @returns the required block or null if not found
  133355. */
  133356. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  133357. /**
  133358. * Get an input block by its name
  133359. * @param predicate defines the predicate used to find the good candidate
  133360. * @returns the required input block or null if not found
  133361. */
  133362. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  133363. /**
  133364. * Gets the list of input blocks attached to this material
  133365. * @returns an array of InputBlocks
  133366. */
  133367. getInputBlocks(): InputBlock[];
  133368. /**
  133369. * Adds a new optimizer to the list of optimizers
  133370. * @param optimizer defines the optimizers to add
  133371. * @returns the current material
  133372. */
  133373. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  133374. /**
  133375. * Remove an optimizer from the list of optimizers
  133376. * @param optimizer defines the optimizers to remove
  133377. * @returns the current material
  133378. */
  133379. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  133380. /**
  133381. * Add a new block to the list of output nodes
  133382. * @param node defines the node to add
  133383. * @returns the current material
  133384. */
  133385. addOutputNode(node: NodeMaterialBlock): this;
  133386. /**
  133387. * Remove a block from the list of root nodes
  133388. * @param node defines the node to remove
  133389. * @returns the current material
  133390. */
  133391. removeOutputNode(node: NodeMaterialBlock): this;
  133392. private _addVertexOutputNode;
  133393. private _removeVertexOutputNode;
  133394. private _addFragmentOutputNode;
  133395. private _removeFragmentOutputNode;
  133396. /**
  133397. * Specifies if the material will require alpha blending
  133398. * @returns a boolean specifying if alpha blending is needed
  133399. */
  133400. needAlphaBlending(): boolean;
  133401. /**
  133402. * Specifies if this material should be rendered in alpha test mode
  133403. * @returns a boolean specifying if an alpha test is needed.
  133404. */
  133405. needAlphaTesting(): boolean;
  133406. private _initializeBlock;
  133407. private _resetDualBlocks;
  133408. /**
  133409. * Remove a block from the current node material
  133410. * @param block defines the block to remove
  133411. */
  133412. removeBlock(block: NodeMaterialBlock): void;
  133413. /**
  133414. * Build the material and generates the inner effect
  133415. * @param verbose defines if the build should log activity
  133416. */
  133417. build(verbose?: boolean): void;
  133418. /**
  133419. * Runs an otpimization phase to try to improve the shader code
  133420. */
  133421. optimize(): void;
  133422. private _prepareDefinesForAttributes;
  133423. /**
  133424. * Get if the submesh is ready to be used and all its information available.
  133425. * Child classes can use it to update shaders
  133426. * @param mesh defines the mesh to check
  133427. * @param subMesh defines which submesh to check
  133428. * @param useInstances specifies that instances should be used
  133429. * @returns a boolean indicating that the submesh is ready or not
  133430. */
  133431. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  133432. /**
  133433. * Get a string representing the shaders built by the current node graph
  133434. */
  133435. get compiledShaders(): string;
  133436. /**
  133437. * Binds the world matrix to the material
  133438. * @param world defines the world transformation matrix
  133439. */
  133440. bindOnlyWorldMatrix(world: Matrix): void;
  133441. /**
  133442. * Binds the submesh to this material by preparing the effect and shader to draw
  133443. * @param world defines the world transformation matrix
  133444. * @param mesh defines the mesh containing the submesh
  133445. * @param subMesh defines the submesh to bind the material to
  133446. */
  133447. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  133448. /**
  133449. * Gets the active textures from the material
  133450. * @returns an array of textures
  133451. */
  133452. getActiveTextures(): BaseTexture[];
  133453. /**
  133454. * Gets the list of texture blocks
  133455. * @returns an array of texture blocks
  133456. */
  133457. getTextureBlocks(): (TextureBlock | ReflectionTextureBaseBlock)[];
  133458. /**
  133459. * Specifies if the material uses a texture
  133460. * @param texture defines the texture to check against the material
  133461. * @returns a boolean specifying if the material uses the texture
  133462. */
  133463. hasTexture(texture: BaseTexture): boolean;
  133464. /**
  133465. * Disposes the material
  133466. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  133467. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  133468. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  133469. */
  133470. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  133471. /** Creates the node editor window. */
  133472. private _createNodeEditor;
  133473. /**
  133474. * Launch the node material editor
  133475. * @param config Define the configuration of the editor
  133476. * @return a promise fulfilled when the node editor is visible
  133477. */
  133478. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  133479. /**
  133480. * Clear the current material
  133481. */
  133482. clear(): void;
  133483. /**
  133484. * Clear the current material and set it to a default state
  133485. */
  133486. setToDefault(): void;
  133487. /**
  133488. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  133489. * @param url defines the url to load from
  133490. * @returns a promise that will fullfil when the material is fully loaded
  133491. */
  133492. loadAsync(url: string): Promise<void>;
  133493. private _gatherBlocks;
  133494. /**
  133495. * Generate a string containing the code declaration required to create an equivalent of this material
  133496. * @returns a string
  133497. */
  133498. generateCode(): string;
  133499. /**
  133500. * Serializes this material in a JSON representation
  133501. * @returns the serialized material object
  133502. */
  133503. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  133504. private _restoreConnections;
  133505. /**
  133506. * Clear the current graph and load a new one from a serialization object
  133507. * @param source defines the JSON representation of the material
  133508. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  133509. */
  133510. loadFromSerialization(source: any, rootUrl?: string): void;
  133511. /**
  133512. * Makes a duplicate of the current material.
  133513. * @param name - name to use for the new material.
  133514. */
  133515. clone(name: string): NodeMaterial;
  133516. /**
  133517. * Creates a node material from parsed material data
  133518. * @param source defines the JSON representation of the material
  133519. * @param scene defines the hosting scene
  133520. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  133521. * @returns a new node material
  133522. */
  133523. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  133524. /**
  133525. * Creates a node material from a snippet saved in a remote file
  133526. * @param name defines the name of the material to create
  133527. * @param url defines the url to load from
  133528. * @param scene defines the hosting scene
  133529. * @returns a promise that will resolve to the new node material
  133530. */
  133531. static ParseFromFileAsync(name: string, url: string, scene: Scene): Promise<NodeMaterial>;
  133532. /**
  133533. * Creates a node material from a snippet saved by the node material editor
  133534. * @param snippetId defines the snippet to load
  133535. * @param scene defines the hosting scene
  133536. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  133537. * @param nodeMaterial defines a node material to update (instead of creating a new one)
  133538. * @returns a promise that will resolve to the new node material
  133539. */
  133540. static ParseFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string, nodeMaterial?: NodeMaterial): Promise<NodeMaterial>;
  133541. /**
  133542. * Creates a new node material set to default basic configuration
  133543. * @param name defines the name of the material
  133544. * @param scene defines the hosting scene
  133545. * @returns a new NodeMaterial
  133546. */
  133547. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  133548. }
  133549. }
  133550. declare module BABYLON {
  133551. /**
  133552. * Block used to read a texture from a sampler
  133553. */
  133554. export class TextureBlock extends NodeMaterialBlock {
  133555. private _defineName;
  133556. private _linearDefineName;
  133557. private _gammaDefineName;
  133558. private _tempTextureRead;
  133559. private _samplerName;
  133560. private _transformedUVName;
  133561. private _textureTransformName;
  133562. private _textureInfoName;
  133563. private _mainUVName;
  133564. private _mainUVDefineName;
  133565. /**
  133566. * Gets or sets the texture associated with the node
  133567. */
  133568. texture: Nullable<Texture>;
  133569. /**
  133570. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  133571. */
  133572. convertToGammaSpace: boolean;
  133573. /**
  133574. * Gets or sets a boolean indicating if content needs to be converted to linear space
  133575. */
  133576. convertToLinearSpace: boolean;
  133577. /**
  133578. * Create a new TextureBlock
  133579. * @param name defines the block name
  133580. */
  133581. constructor(name: string);
  133582. /**
  133583. * Gets the current class name
  133584. * @returns the class name
  133585. */
  133586. getClassName(): string;
  133587. /**
  133588. * Gets the uv input component
  133589. */
  133590. get uv(): NodeMaterialConnectionPoint;
  133591. /**
  133592. * Gets the rgba output component
  133593. */
  133594. get rgba(): NodeMaterialConnectionPoint;
  133595. /**
  133596. * Gets the rgb output component
  133597. */
  133598. get rgb(): NodeMaterialConnectionPoint;
  133599. /**
  133600. * Gets the r output component
  133601. */
  133602. get r(): NodeMaterialConnectionPoint;
  133603. /**
  133604. * Gets the g output component
  133605. */
  133606. get g(): NodeMaterialConnectionPoint;
  133607. /**
  133608. * Gets the b output component
  133609. */
  133610. get b(): NodeMaterialConnectionPoint;
  133611. /**
  133612. * Gets the a output component
  133613. */
  133614. get a(): NodeMaterialConnectionPoint;
  133615. get target(): NodeMaterialBlockTargets;
  133616. autoConfigure(material: NodeMaterial): void;
  133617. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  133618. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  133619. isReady(): boolean;
  133620. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  133621. private get _isMixed();
  133622. private _injectVertexCode;
  133623. private _writeTextureRead;
  133624. private _writeOutput;
  133625. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  133626. protected _dumpPropertiesCode(): string;
  133627. serialize(): any;
  133628. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  133629. }
  133630. }
  133631. declare module BABYLON {
  133632. /**
  133633. * Class used to store shared data between 2 NodeMaterialBuildState
  133634. */
  133635. export class NodeMaterialBuildStateSharedData {
  133636. /**
  133637. * Gets the list of emitted varyings
  133638. */
  133639. temps: string[];
  133640. /**
  133641. * Gets the list of emitted varyings
  133642. */
  133643. varyings: string[];
  133644. /**
  133645. * Gets the varying declaration string
  133646. */
  133647. varyingDeclaration: string;
  133648. /**
  133649. * Input blocks
  133650. */
  133651. inputBlocks: InputBlock[];
  133652. /**
  133653. * Input blocks
  133654. */
  133655. textureBlocks: (ReflectionTextureBaseBlock | TextureBlock)[];
  133656. /**
  133657. * Bindable blocks (Blocks that need to set data to the effect)
  133658. */
  133659. bindableBlocks: NodeMaterialBlock[];
  133660. /**
  133661. * List of blocks that can provide a compilation fallback
  133662. */
  133663. blocksWithFallbacks: NodeMaterialBlock[];
  133664. /**
  133665. * List of blocks that can provide a define update
  133666. */
  133667. blocksWithDefines: NodeMaterialBlock[];
  133668. /**
  133669. * List of blocks that can provide a repeatable content
  133670. */
  133671. repeatableContentBlocks: NodeMaterialBlock[];
  133672. /**
  133673. * List of blocks that can provide a dynamic list of uniforms
  133674. */
  133675. dynamicUniformBlocks: NodeMaterialBlock[];
  133676. /**
  133677. * List of blocks that can block the isReady function for the material
  133678. */
  133679. blockingBlocks: NodeMaterialBlock[];
  133680. /**
  133681. * Gets the list of animated inputs
  133682. */
  133683. animatedInputs: InputBlock[];
  133684. /**
  133685. * Build Id used to avoid multiple recompilations
  133686. */
  133687. buildId: number;
  133688. /** List of emitted variables */
  133689. variableNames: {
  133690. [key: string]: number;
  133691. };
  133692. /** List of emitted defines */
  133693. defineNames: {
  133694. [key: string]: number;
  133695. };
  133696. /** Should emit comments? */
  133697. emitComments: boolean;
  133698. /** Emit build activity */
  133699. verbose: boolean;
  133700. /** Gets or sets the hosting scene */
  133701. scene: Scene;
  133702. /**
  133703. * Gets the compilation hints emitted at compilation time
  133704. */
  133705. hints: {
  133706. needWorldViewMatrix: boolean;
  133707. needWorldViewProjectionMatrix: boolean;
  133708. needAlphaBlending: boolean;
  133709. needAlphaTesting: boolean;
  133710. };
  133711. /**
  133712. * List of compilation checks
  133713. */
  133714. checks: {
  133715. emitVertex: boolean;
  133716. emitFragment: boolean;
  133717. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  133718. };
  133719. /** Creates a new shared data */
  133720. constructor();
  133721. /**
  133722. * Emits console errors and exceptions if there is a failing check
  133723. */
  133724. emitErrors(): void;
  133725. }
  133726. }
  133727. declare module BABYLON {
  133728. /**
  133729. * Class used to store node based material build state
  133730. */
  133731. export class NodeMaterialBuildState {
  133732. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  133733. supportUniformBuffers: boolean;
  133734. /**
  133735. * Gets the list of emitted attributes
  133736. */
  133737. attributes: string[];
  133738. /**
  133739. * Gets the list of emitted uniforms
  133740. */
  133741. uniforms: string[];
  133742. /**
  133743. * Gets the list of emitted constants
  133744. */
  133745. constants: string[];
  133746. /**
  133747. * Gets the list of emitted samplers
  133748. */
  133749. samplers: string[];
  133750. /**
  133751. * Gets the list of emitted functions
  133752. */
  133753. functions: {
  133754. [key: string]: string;
  133755. };
  133756. /**
  133757. * Gets the list of emitted extensions
  133758. */
  133759. extensions: {
  133760. [key: string]: string;
  133761. };
  133762. /**
  133763. * Gets the target of the compilation state
  133764. */
  133765. target: NodeMaterialBlockTargets;
  133766. /**
  133767. * Gets the list of emitted counters
  133768. */
  133769. counters: {
  133770. [key: string]: number;
  133771. };
  133772. /**
  133773. * Shared data between multiple NodeMaterialBuildState instances
  133774. */
  133775. sharedData: NodeMaterialBuildStateSharedData;
  133776. /** @hidden */
  133777. _vertexState: NodeMaterialBuildState;
  133778. /** @hidden */
  133779. _attributeDeclaration: string;
  133780. /** @hidden */
  133781. _uniformDeclaration: string;
  133782. /** @hidden */
  133783. _constantDeclaration: string;
  133784. /** @hidden */
  133785. _samplerDeclaration: string;
  133786. /** @hidden */
  133787. _varyingTransfer: string;
  133788. /** @hidden */
  133789. _injectAtEnd: string;
  133790. private _repeatableContentAnchorIndex;
  133791. /** @hidden */
  133792. _builtCompilationString: string;
  133793. /**
  133794. * Gets the emitted compilation strings
  133795. */
  133796. compilationString: string;
  133797. /**
  133798. * Finalize the compilation strings
  133799. * @param state defines the current compilation state
  133800. */
  133801. finalize(state: NodeMaterialBuildState): void;
  133802. /** @hidden */
  133803. get _repeatableContentAnchor(): string;
  133804. /** @hidden */
  133805. _getFreeVariableName(prefix: string): string;
  133806. /** @hidden */
  133807. _getFreeDefineName(prefix: string): string;
  133808. /** @hidden */
  133809. _excludeVariableName(name: string): void;
  133810. /** @hidden */
  133811. _emit2DSampler(name: string): void;
  133812. /** @hidden */
  133813. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  133814. /** @hidden */
  133815. _emitExtension(name: string, extension: string): void;
  133816. /** @hidden */
  133817. _emitFunction(name: string, code: string, comments: string): void;
  133818. /** @hidden */
  133819. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  133820. replaceStrings?: {
  133821. search: RegExp;
  133822. replace: string;
  133823. }[];
  133824. repeatKey?: string;
  133825. }): string;
  133826. /** @hidden */
  133827. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  133828. repeatKey?: string;
  133829. removeAttributes?: boolean;
  133830. removeUniforms?: boolean;
  133831. removeVaryings?: boolean;
  133832. removeIfDef?: boolean;
  133833. replaceStrings?: {
  133834. search: RegExp;
  133835. replace: string;
  133836. }[];
  133837. }, storeKey?: string): void;
  133838. /** @hidden */
  133839. _registerTempVariable(name: string): boolean;
  133840. /** @hidden */
  133841. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  133842. /** @hidden */
  133843. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  133844. /** @hidden */
  133845. _emitFloat(value: number): string;
  133846. }
  133847. }
  133848. declare module BABYLON {
  133849. /**
  133850. * Defines a block that can be used inside a node based material
  133851. */
  133852. export class NodeMaterialBlock {
  133853. private _buildId;
  133854. private _buildTarget;
  133855. private _target;
  133856. private _isFinalMerger;
  133857. private _isInput;
  133858. protected _isUnique: boolean;
  133859. /** Gets or sets a boolean indicating that only one input can be connected at a time */
  133860. inputsAreExclusive: boolean;
  133861. /** @hidden */
  133862. _codeVariableName: string;
  133863. /** @hidden */
  133864. _inputs: NodeMaterialConnectionPoint[];
  133865. /** @hidden */
  133866. _outputs: NodeMaterialConnectionPoint[];
  133867. /** @hidden */
  133868. _preparationId: number;
  133869. /**
  133870. * Gets or sets the name of the block
  133871. */
  133872. name: string;
  133873. /**
  133874. * Gets or sets the unique id of the node
  133875. */
  133876. uniqueId: number;
  133877. /**
  133878. * Gets or sets the comments associated with this block
  133879. */
  133880. comments: string;
  133881. /**
  133882. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  133883. */
  133884. get isUnique(): boolean;
  133885. /**
  133886. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  133887. */
  133888. get isFinalMerger(): boolean;
  133889. /**
  133890. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  133891. */
  133892. get isInput(): boolean;
  133893. /**
  133894. * Gets or sets the build Id
  133895. */
  133896. get buildId(): number;
  133897. set buildId(value: number);
  133898. /**
  133899. * Gets or sets the target of the block
  133900. */
  133901. get target(): NodeMaterialBlockTargets;
  133902. set target(value: NodeMaterialBlockTargets);
  133903. /**
  133904. * Gets the list of input points
  133905. */
  133906. get inputs(): NodeMaterialConnectionPoint[];
  133907. /** Gets the list of output points */
  133908. get outputs(): NodeMaterialConnectionPoint[];
  133909. /**
  133910. * Find an input by its name
  133911. * @param name defines the name of the input to look for
  133912. * @returns the input or null if not found
  133913. */
  133914. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  133915. /**
  133916. * Find an output by its name
  133917. * @param name defines the name of the outputto look for
  133918. * @returns the output or null if not found
  133919. */
  133920. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  133921. /**
  133922. * Creates a new NodeMaterialBlock
  133923. * @param name defines the block name
  133924. * @param target defines the target of that block (Vertex by default)
  133925. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  133926. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  133927. */
  133928. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  133929. /**
  133930. * Initialize the block and prepare the context for build
  133931. * @param state defines the state that will be used for the build
  133932. */
  133933. initialize(state: NodeMaterialBuildState): void;
  133934. /**
  133935. * Bind data to effect. Will only be called for blocks with isBindable === true
  133936. * @param effect defines the effect to bind data to
  133937. * @param nodeMaterial defines the hosting NodeMaterial
  133938. * @param mesh defines the mesh that will be rendered
  133939. * @param subMesh defines the submesh that will be rendered
  133940. */
  133941. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  133942. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  133943. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  133944. protected _writeFloat(value: number): string;
  133945. /**
  133946. * Gets the current class name e.g. "NodeMaterialBlock"
  133947. * @returns the class name
  133948. */
  133949. getClassName(): string;
  133950. /**
  133951. * Register a new input. Must be called inside a block constructor
  133952. * @param name defines the connection point name
  133953. * @param type defines the connection point type
  133954. * @param isOptional defines a boolean indicating that this input can be omitted
  133955. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  133956. * @param point an already created connection point. If not provided, create a new one
  133957. * @returns the current block
  133958. */
  133959. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  133960. /**
  133961. * Register a new output. Must be called inside a block constructor
  133962. * @param name defines the connection point name
  133963. * @param type defines the connection point type
  133964. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  133965. * @param point an already created connection point. If not provided, create a new one
  133966. * @returns the current block
  133967. */
  133968. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  133969. /**
  133970. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  133971. * @param forOutput defines an optional connection point to check compatibility with
  133972. * @returns the first available input or null
  133973. */
  133974. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  133975. /**
  133976. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  133977. * @param forBlock defines an optional block to check compatibility with
  133978. * @returns the first available input or null
  133979. */
  133980. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  133981. /**
  133982. * Gets the sibling of the given output
  133983. * @param current defines the current output
  133984. * @returns the next output in the list or null
  133985. */
  133986. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  133987. /**
  133988. * Connect current block with another block
  133989. * @param other defines the block to connect with
  133990. * @param options define the various options to help pick the right connections
  133991. * @returns the current block
  133992. */
  133993. connectTo(other: NodeMaterialBlock, options?: {
  133994. input?: string;
  133995. output?: string;
  133996. outputSwizzle?: string;
  133997. }): this | undefined;
  133998. protected _buildBlock(state: NodeMaterialBuildState): void;
  133999. /**
  134000. * Add uniforms, samplers and uniform buffers at compilation time
  134001. * @param state defines the state to update
  134002. * @param nodeMaterial defines the node material requesting the update
  134003. * @param defines defines the material defines to update
  134004. * @param uniformBuffers defines the list of uniform buffer names
  134005. */
  134006. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  134007. /**
  134008. * Add potential fallbacks if shader compilation fails
  134009. * @param mesh defines the mesh to be rendered
  134010. * @param fallbacks defines the current prioritized list of fallbacks
  134011. */
  134012. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  134013. /**
  134014. * Initialize defines for shader compilation
  134015. * @param mesh defines the mesh to be rendered
  134016. * @param nodeMaterial defines the node material requesting the update
  134017. * @param defines defines the material defines to update
  134018. * @param useInstances specifies that instances should be used
  134019. */
  134020. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  134021. /**
  134022. * Update defines for shader compilation
  134023. * @param mesh defines the mesh to be rendered
  134024. * @param nodeMaterial defines the node material requesting the update
  134025. * @param defines defines the material defines to update
  134026. * @param useInstances specifies that instances should be used
  134027. */
  134028. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  134029. /**
  134030. * Lets the block try to connect some inputs automatically
  134031. * @param material defines the hosting NodeMaterial
  134032. */
  134033. autoConfigure(material: NodeMaterial): void;
  134034. /**
  134035. * Function called when a block is declared as repeatable content generator
  134036. * @param vertexShaderState defines the current compilation state for the vertex shader
  134037. * @param fragmentShaderState defines the current compilation state for the fragment shader
  134038. * @param mesh defines the mesh to be rendered
  134039. * @param defines defines the material defines to update
  134040. */
  134041. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  134042. /**
  134043. * Checks if the block is ready
  134044. * @param mesh defines the mesh to be rendered
  134045. * @param nodeMaterial defines the node material requesting the update
  134046. * @param defines defines the material defines to update
  134047. * @param useInstances specifies that instances should be used
  134048. * @returns true if the block is ready
  134049. */
  134050. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  134051. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  134052. private _processBuild;
  134053. /**
  134054. * Compile the current node and generate the shader code
  134055. * @param state defines the current compilation state (uniforms, samplers, current string)
  134056. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  134057. * @returns true if already built
  134058. */
  134059. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  134060. protected _inputRename(name: string): string;
  134061. protected _outputRename(name: string): string;
  134062. protected _dumpPropertiesCode(): string;
  134063. /** @hidden */
  134064. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  134065. /** @hidden */
  134066. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  134067. /**
  134068. * Clone the current block to a new identical block
  134069. * @param scene defines the hosting scene
  134070. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  134071. * @returns a copy of the current block
  134072. */
  134073. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  134074. /**
  134075. * Serializes this block in a JSON representation
  134076. * @returns the serialized block object
  134077. */
  134078. serialize(): any;
  134079. /** @hidden */
  134080. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  134081. private _deserializePortDisplayNames;
  134082. /**
  134083. * Release resources
  134084. */
  134085. dispose(): void;
  134086. }
  134087. }
  134088. declare module BABYLON {
  134089. /**
  134090. * Enum defining the type of animations supported by InputBlock
  134091. */
  134092. export enum AnimatedInputBlockTypes {
  134093. /** No animation */
  134094. None = 0,
  134095. /** Time based animation. Will only work for floats */
  134096. Time = 1
  134097. }
  134098. }
  134099. declare module BABYLON {
  134100. /**
  134101. * Block used to expose an input value
  134102. */
  134103. export class InputBlock extends NodeMaterialBlock {
  134104. private _mode;
  134105. private _associatedVariableName;
  134106. private _storedValue;
  134107. private _valueCallback;
  134108. private _type;
  134109. private _animationType;
  134110. /** Gets or set a value used to limit the range of float values */
  134111. min: number;
  134112. /** Gets or set a value used to limit the range of float values */
  134113. max: number;
  134114. /** Gets or set a value indicating that this input can only get 0 and 1 values */
  134115. isBoolean: boolean;
  134116. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  134117. matrixMode: number;
  134118. /** @hidden */
  134119. _systemValue: Nullable<NodeMaterialSystemValues>;
  134120. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  134121. visibleInInspector: boolean;
  134122. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  134123. isConstant: boolean;
  134124. /** Gets or sets the group to use to display this block in the Inspector */
  134125. groupInInspector: string;
  134126. /** Gets an observable raised when the value is changed */
  134127. onValueChangedObservable: Observable<InputBlock>;
  134128. /**
  134129. * Gets or sets the connection point type (default is float)
  134130. */
  134131. get type(): NodeMaterialBlockConnectionPointTypes;
  134132. /**
  134133. * Creates a new InputBlock
  134134. * @param name defines the block name
  134135. * @param target defines the target of that block (Vertex by default)
  134136. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  134137. */
  134138. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  134139. /**
  134140. * Gets the output component
  134141. */
  134142. get output(): NodeMaterialConnectionPoint;
  134143. /**
  134144. * Set the source of this connection point to a vertex attribute
  134145. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  134146. * @returns the current connection point
  134147. */
  134148. setAsAttribute(attributeName?: string): InputBlock;
  134149. /**
  134150. * Set the source of this connection point to a system value
  134151. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  134152. * @returns the current connection point
  134153. */
  134154. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  134155. /**
  134156. * Gets or sets the value of that point.
  134157. * Please note that this value will be ignored if valueCallback is defined
  134158. */
  134159. get value(): any;
  134160. set value(value: any);
  134161. /**
  134162. * Gets or sets a callback used to get the value of that point.
  134163. * Please note that setting this value will force the connection point to ignore the value property
  134164. */
  134165. get valueCallback(): () => any;
  134166. set valueCallback(value: () => any);
  134167. /**
  134168. * Gets or sets the associated variable name in the shader
  134169. */
  134170. get associatedVariableName(): string;
  134171. set associatedVariableName(value: string);
  134172. /** Gets or sets the type of animation applied to the input */
  134173. get animationType(): AnimatedInputBlockTypes;
  134174. set animationType(value: AnimatedInputBlockTypes);
  134175. /**
  134176. * Gets a boolean indicating that this connection point not defined yet
  134177. */
  134178. get isUndefined(): boolean;
  134179. /**
  134180. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  134181. * In this case the connection point name must be the name of the uniform to use.
  134182. * Can only be set on inputs
  134183. */
  134184. get isUniform(): boolean;
  134185. set isUniform(value: boolean);
  134186. /**
  134187. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  134188. * In this case the connection point name must be the name of the attribute to use
  134189. * Can only be set on inputs
  134190. */
  134191. get isAttribute(): boolean;
  134192. set isAttribute(value: boolean);
  134193. /**
  134194. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  134195. * Can only be set on exit points
  134196. */
  134197. get isVarying(): boolean;
  134198. set isVarying(value: boolean);
  134199. /**
  134200. * Gets a boolean indicating that the current connection point is a system value
  134201. */
  134202. get isSystemValue(): boolean;
  134203. /**
  134204. * Gets or sets the current well known value or null if not defined as a system value
  134205. */
  134206. get systemValue(): Nullable<NodeMaterialSystemValues>;
  134207. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  134208. /**
  134209. * Gets the current class name
  134210. * @returns the class name
  134211. */
  134212. getClassName(): string;
  134213. /**
  134214. * Animate the input if animationType !== None
  134215. * @param scene defines the rendering scene
  134216. */
  134217. animate(scene: Scene): void;
  134218. private _emitDefine;
  134219. initialize(state: NodeMaterialBuildState): void;
  134220. /**
  134221. * Set the input block to its default value (based on its type)
  134222. */
  134223. setDefaultValue(): void;
  134224. private _emitConstant;
  134225. private _emit;
  134226. /** @hidden */
  134227. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  134228. /** @hidden */
  134229. _transmit(effect: Effect, scene: Scene): void;
  134230. protected _buildBlock(state: NodeMaterialBuildState): void;
  134231. protected _dumpPropertiesCode(): string;
  134232. dispose(): void;
  134233. serialize(): any;
  134234. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  134235. }
  134236. }
  134237. declare module BABYLON {
  134238. /**
  134239. * Enum used to define the compatibility state between two connection points
  134240. */
  134241. export enum NodeMaterialConnectionPointCompatibilityStates {
  134242. /** Points are compatibles */
  134243. Compatible = 0,
  134244. /** Points are incompatible because of their types */
  134245. TypeIncompatible = 1,
  134246. /** Points are incompatible because of their targets (vertex vs fragment) */
  134247. TargetIncompatible = 2
  134248. }
  134249. /**
  134250. * Defines the direction of a connection point
  134251. */
  134252. export enum NodeMaterialConnectionPointDirection {
  134253. /** Input */
  134254. Input = 0,
  134255. /** Output */
  134256. Output = 1
  134257. }
  134258. /**
  134259. * Defines a connection point for a block
  134260. */
  134261. export class NodeMaterialConnectionPoint {
  134262. /** @hidden */
  134263. _ownerBlock: NodeMaterialBlock;
  134264. /** @hidden */
  134265. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  134266. private _endpoints;
  134267. private _associatedVariableName;
  134268. private _direction;
  134269. /** @hidden */
  134270. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  134271. /** @hidden */
  134272. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  134273. private _type;
  134274. /** @hidden */
  134275. _enforceAssociatedVariableName: boolean;
  134276. /** Gets the direction of the point */
  134277. get direction(): NodeMaterialConnectionPointDirection;
  134278. /** Indicates that this connection point needs dual validation before being connected to another point */
  134279. needDualDirectionValidation: boolean;
  134280. /**
  134281. * Gets or sets the additional types supported by this connection point
  134282. */
  134283. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  134284. /**
  134285. * Gets or sets the additional types excluded by this connection point
  134286. */
  134287. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  134288. /**
  134289. * Observable triggered when this point is connected
  134290. */
  134291. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  134292. /**
  134293. * Gets or sets the associated variable name in the shader
  134294. */
  134295. get associatedVariableName(): string;
  134296. set associatedVariableName(value: string);
  134297. /** Get the inner type (ie AutoDetect for instance instead of the inferred one) */
  134298. get innerType(): NodeMaterialBlockConnectionPointTypes;
  134299. /**
  134300. * Gets or sets the connection point type (default is float)
  134301. */
  134302. get type(): NodeMaterialBlockConnectionPointTypes;
  134303. set type(value: NodeMaterialBlockConnectionPointTypes);
  134304. /**
  134305. * Gets or sets the connection point name
  134306. */
  134307. name: string;
  134308. /**
  134309. * Gets or sets the connection point name
  134310. */
  134311. displayName: string;
  134312. /**
  134313. * Gets or sets a boolean indicating that this connection point can be omitted
  134314. */
  134315. isOptional: boolean;
  134316. /**
  134317. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  134318. */
  134319. define: string;
  134320. /** @hidden */
  134321. _prioritizeVertex: boolean;
  134322. private _target;
  134323. /** Gets or sets the target of that connection point */
  134324. get target(): NodeMaterialBlockTargets;
  134325. set target(value: NodeMaterialBlockTargets);
  134326. /**
  134327. * Gets a boolean indicating that the current point is connected
  134328. */
  134329. get isConnected(): boolean;
  134330. /**
  134331. * Gets a boolean indicating that the current point is connected to an input block
  134332. */
  134333. get isConnectedToInputBlock(): boolean;
  134334. /**
  134335. * Gets a the connected input block (if any)
  134336. */
  134337. get connectInputBlock(): Nullable<InputBlock>;
  134338. /** Get the other side of the connection (if any) */
  134339. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  134340. /** Get the block that owns this connection point */
  134341. get ownerBlock(): NodeMaterialBlock;
  134342. /** Get the block connected on the other side of this connection (if any) */
  134343. get sourceBlock(): Nullable<NodeMaterialBlock>;
  134344. /** Get the block connected on the endpoints of this connection (if any) */
  134345. get connectedBlocks(): Array<NodeMaterialBlock>;
  134346. /** Gets the list of connected endpoints */
  134347. get endpoints(): NodeMaterialConnectionPoint[];
  134348. /** Gets a boolean indicating if that output point is connected to at least one input */
  134349. get hasEndpoints(): boolean;
  134350. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  134351. get isConnectedInVertexShader(): boolean;
  134352. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  134353. get isConnectedInFragmentShader(): boolean;
  134354. /**
  134355. * Creates a block suitable to be used as an input for this input point.
  134356. * If null is returned, a block based on the point type will be created.
  134357. * @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
  134358. */
  134359. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  134360. /**
  134361. * Creates a new connection point
  134362. * @param name defines the connection point name
  134363. * @param ownerBlock defines the block hosting this connection point
  134364. * @param direction defines the direction of the connection point
  134365. */
  134366. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  134367. /**
  134368. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  134369. * @returns the class name
  134370. */
  134371. getClassName(): string;
  134372. /**
  134373. * Gets a boolean indicating if the current point can be connected to another point
  134374. * @param connectionPoint defines the other connection point
  134375. * @returns a boolean
  134376. */
  134377. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  134378. /**
  134379. * Gets a number indicating if the current point can be connected to another point
  134380. * @param connectionPoint defines the other connection point
  134381. * @returns a number defining the compatibility state
  134382. */
  134383. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  134384. /**
  134385. * Connect this point to another connection point
  134386. * @param connectionPoint defines the other connection point
  134387. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  134388. * @returns the current connection point
  134389. */
  134390. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  134391. /**
  134392. * Disconnect this point from one of his endpoint
  134393. * @param endpoint defines the other connection point
  134394. * @returns the current connection point
  134395. */
  134396. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  134397. /**
  134398. * Serializes this point in a JSON representation
  134399. * @param isInput defines if the connection point is an input (default is true)
  134400. * @returns the serialized point object
  134401. */
  134402. serialize(isInput?: boolean): any;
  134403. /**
  134404. * Release resources
  134405. */
  134406. dispose(): void;
  134407. }
  134408. }
  134409. declare module BABYLON {
  134410. /**
  134411. * Block used to add support for vertex skinning (bones)
  134412. */
  134413. export class BonesBlock extends NodeMaterialBlock {
  134414. /**
  134415. * Creates a new BonesBlock
  134416. * @param name defines the block name
  134417. */
  134418. constructor(name: string);
  134419. /**
  134420. * Initialize the block and prepare the context for build
  134421. * @param state defines the state that will be used for the build
  134422. */
  134423. initialize(state: NodeMaterialBuildState): void;
  134424. /**
  134425. * Gets the current class name
  134426. * @returns the class name
  134427. */
  134428. getClassName(): string;
  134429. /**
  134430. * Gets the matrix indices input component
  134431. */
  134432. get matricesIndices(): NodeMaterialConnectionPoint;
  134433. /**
  134434. * Gets the matrix weights input component
  134435. */
  134436. get matricesWeights(): NodeMaterialConnectionPoint;
  134437. /**
  134438. * Gets the extra matrix indices input component
  134439. */
  134440. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  134441. /**
  134442. * Gets the extra matrix weights input component
  134443. */
  134444. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  134445. /**
  134446. * Gets the world input component
  134447. */
  134448. get world(): NodeMaterialConnectionPoint;
  134449. /**
  134450. * Gets the output component
  134451. */
  134452. get output(): NodeMaterialConnectionPoint;
  134453. autoConfigure(material: NodeMaterial): void;
  134454. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  134455. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  134456. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  134457. protected _buildBlock(state: NodeMaterialBuildState): this;
  134458. }
  134459. }
  134460. declare module BABYLON {
  134461. /**
  134462. * Block used to add support for instances
  134463. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  134464. */
  134465. export class InstancesBlock extends NodeMaterialBlock {
  134466. /**
  134467. * Creates a new InstancesBlock
  134468. * @param name defines the block name
  134469. */
  134470. constructor(name: string);
  134471. /**
  134472. * Gets the current class name
  134473. * @returns the class name
  134474. */
  134475. getClassName(): string;
  134476. /**
  134477. * Gets the first world row input component
  134478. */
  134479. get world0(): NodeMaterialConnectionPoint;
  134480. /**
  134481. * Gets the second world row input component
  134482. */
  134483. get world1(): NodeMaterialConnectionPoint;
  134484. /**
  134485. * Gets the third world row input component
  134486. */
  134487. get world2(): NodeMaterialConnectionPoint;
  134488. /**
  134489. * Gets the forth world row input component
  134490. */
  134491. get world3(): NodeMaterialConnectionPoint;
  134492. /**
  134493. * Gets the world input component
  134494. */
  134495. get world(): NodeMaterialConnectionPoint;
  134496. /**
  134497. * Gets the output component
  134498. */
  134499. get output(): NodeMaterialConnectionPoint;
  134500. /**
  134501. * Gets the isntanceID component
  134502. */
  134503. get instanceID(): NodeMaterialConnectionPoint;
  134504. autoConfigure(material: NodeMaterial): void;
  134505. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  134506. protected _buildBlock(state: NodeMaterialBuildState): this;
  134507. }
  134508. }
  134509. declare module BABYLON {
  134510. /**
  134511. * Block used to add morph targets support to vertex shader
  134512. */
  134513. export class MorphTargetsBlock extends NodeMaterialBlock {
  134514. private _repeatableContentAnchor;
  134515. /**
  134516. * Create a new MorphTargetsBlock
  134517. * @param name defines the block name
  134518. */
  134519. constructor(name: string);
  134520. /**
  134521. * Gets the current class name
  134522. * @returns the class name
  134523. */
  134524. getClassName(): string;
  134525. /**
  134526. * Gets the position input component
  134527. */
  134528. get position(): NodeMaterialConnectionPoint;
  134529. /**
  134530. * Gets the normal input component
  134531. */
  134532. get normal(): NodeMaterialConnectionPoint;
  134533. /**
  134534. * Gets the tangent input component
  134535. */
  134536. get tangent(): NodeMaterialConnectionPoint;
  134537. /**
  134538. * Gets the tangent input component
  134539. */
  134540. get uv(): NodeMaterialConnectionPoint;
  134541. /**
  134542. * Gets the position output component
  134543. */
  134544. get positionOutput(): NodeMaterialConnectionPoint;
  134545. /**
  134546. * Gets the normal output component
  134547. */
  134548. get normalOutput(): NodeMaterialConnectionPoint;
  134549. /**
  134550. * Gets the tangent output component
  134551. */
  134552. get tangentOutput(): NodeMaterialConnectionPoint;
  134553. /**
  134554. * Gets the tangent output component
  134555. */
  134556. get uvOutput(): NodeMaterialConnectionPoint;
  134557. initialize(state: NodeMaterialBuildState): void;
  134558. autoConfigure(material: NodeMaterial): void;
  134559. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  134560. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  134561. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  134562. protected _buildBlock(state: NodeMaterialBuildState): this;
  134563. }
  134564. }
  134565. declare module BABYLON {
  134566. /**
  134567. * Block used to get data information from a light
  134568. */
  134569. export class LightInformationBlock extends NodeMaterialBlock {
  134570. private _lightDataUniformName;
  134571. private _lightColorUniformName;
  134572. private _lightTypeDefineName;
  134573. /**
  134574. * Gets or sets the light associated with this block
  134575. */
  134576. light: Nullable<Light>;
  134577. /**
  134578. * Creates a new LightInformationBlock
  134579. * @param name defines the block name
  134580. */
  134581. constructor(name: string);
  134582. /**
  134583. * Gets the current class name
  134584. * @returns the class name
  134585. */
  134586. getClassName(): string;
  134587. /**
  134588. * Gets the world position input component
  134589. */
  134590. get worldPosition(): NodeMaterialConnectionPoint;
  134591. /**
  134592. * Gets the direction output component
  134593. */
  134594. get direction(): NodeMaterialConnectionPoint;
  134595. /**
  134596. * Gets the direction output component
  134597. */
  134598. get color(): NodeMaterialConnectionPoint;
  134599. /**
  134600. * Gets the direction output component
  134601. */
  134602. get intensity(): NodeMaterialConnectionPoint;
  134603. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  134604. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  134605. protected _buildBlock(state: NodeMaterialBuildState): this;
  134606. serialize(): any;
  134607. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  134608. }
  134609. }
  134610. declare module BABYLON {
  134611. /**
  134612. * Block used to add image processing support to fragment shader
  134613. */
  134614. export class ImageProcessingBlock extends NodeMaterialBlock {
  134615. /**
  134616. * Create a new ImageProcessingBlock
  134617. * @param name defines the block name
  134618. */
  134619. constructor(name: string);
  134620. /**
  134621. * Gets the current class name
  134622. * @returns the class name
  134623. */
  134624. getClassName(): string;
  134625. /**
  134626. * Gets the color input component
  134627. */
  134628. get color(): NodeMaterialConnectionPoint;
  134629. /**
  134630. * Gets the output component
  134631. */
  134632. get output(): NodeMaterialConnectionPoint;
  134633. /**
  134634. * Initialize the block and prepare the context for build
  134635. * @param state defines the state that will be used for the build
  134636. */
  134637. initialize(state: NodeMaterialBuildState): void;
  134638. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  134639. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  134640. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  134641. protected _buildBlock(state: NodeMaterialBuildState): this;
  134642. }
  134643. }
  134644. declare module BABYLON {
  134645. /**
  134646. * Enum defining the type of properties that can be edited in the property pages in the NME
  134647. */
  134648. export enum PropertyTypeForEdition {
  134649. /** property is a boolean */
  134650. Boolean = 0,
  134651. /** property is a float */
  134652. Float = 1,
  134653. /** property is a Vector2 */
  134654. Vector2 = 2,
  134655. /** property is a list of values */
  134656. List = 3
  134657. }
  134658. /**
  134659. * Interface that defines an option in a variable of type list
  134660. */
  134661. export interface IEditablePropertyListOption {
  134662. /** label of the option */
  134663. "label": string;
  134664. /** value of the option */
  134665. "value": number;
  134666. }
  134667. /**
  134668. * Interface that defines the options available for an editable property
  134669. */
  134670. export interface IEditablePropertyOption {
  134671. /** min value */
  134672. "min"?: number;
  134673. /** max value */
  134674. "max"?: number;
  134675. /** notifiers: indicates which actions to take when the property is changed */
  134676. "notifiers"?: {
  134677. /** the material should be rebuilt */
  134678. "rebuild"?: boolean;
  134679. /** the preview should be updated */
  134680. "update"?: boolean;
  134681. };
  134682. /** list of the options for a variable of type list */
  134683. "options"?: IEditablePropertyListOption[];
  134684. }
  134685. /**
  134686. * Interface that describes an editable property
  134687. */
  134688. export interface IPropertyDescriptionForEdition {
  134689. /** name of the property */
  134690. "propertyName": string;
  134691. /** display name of the property */
  134692. "displayName": string;
  134693. /** type of the property */
  134694. "type": PropertyTypeForEdition;
  134695. /** group of the property - all properties with the same group value will be displayed in a specific section */
  134696. "groupName": string;
  134697. /** options for the property */
  134698. "options": IEditablePropertyOption;
  134699. }
  134700. /**
  134701. * Decorator that flags a property in a node material block as being editable
  134702. */
  134703. export function editableInPropertyPage(displayName: string, propertyType?: PropertyTypeForEdition, groupName?: string, options?: IEditablePropertyOption): (target: any, propertyKey: string) => void;
  134704. }
  134705. declare module BABYLON {
  134706. /**
  134707. * Block used to pertub normals based on a normal map
  134708. */
  134709. export class PerturbNormalBlock extends NodeMaterialBlock {
  134710. private _tangentSpaceParameterName;
  134711. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  134712. invertX: boolean;
  134713. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  134714. invertY: boolean;
  134715. /**
  134716. * Create a new PerturbNormalBlock
  134717. * @param name defines the block name
  134718. */
  134719. constructor(name: string);
  134720. /**
  134721. * Gets the current class name
  134722. * @returns the class name
  134723. */
  134724. getClassName(): string;
  134725. /**
  134726. * Gets the world position input component
  134727. */
  134728. get worldPosition(): NodeMaterialConnectionPoint;
  134729. /**
  134730. * Gets the world normal input component
  134731. */
  134732. get worldNormal(): NodeMaterialConnectionPoint;
  134733. /**
  134734. * Gets the world tangent input component
  134735. */
  134736. get worldTangent(): NodeMaterialConnectionPoint;
  134737. /**
  134738. * Gets the uv input component
  134739. */
  134740. get uv(): NodeMaterialConnectionPoint;
  134741. /**
  134742. * Gets the normal map color input component
  134743. */
  134744. get normalMapColor(): NodeMaterialConnectionPoint;
  134745. /**
  134746. * Gets the strength input component
  134747. */
  134748. get strength(): NodeMaterialConnectionPoint;
  134749. /**
  134750. * Gets the output component
  134751. */
  134752. get output(): NodeMaterialConnectionPoint;
  134753. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  134754. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  134755. autoConfigure(material: NodeMaterial): void;
  134756. protected _buildBlock(state: NodeMaterialBuildState): this;
  134757. protected _dumpPropertiesCode(): string;
  134758. serialize(): any;
  134759. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  134760. }
  134761. }
  134762. declare module BABYLON {
  134763. /**
  134764. * Block used to discard a pixel if a value is smaller than a cutoff
  134765. */
  134766. export class DiscardBlock extends NodeMaterialBlock {
  134767. /**
  134768. * Create a new DiscardBlock
  134769. * @param name defines the block name
  134770. */
  134771. constructor(name: string);
  134772. /**
  134773. * Gets the current class name
  134774. * @returns the class name
  134775. */
  134776. getClassName(): string;
  134777. /**
  134778. * Gets the color input component
  134779. */
  134780. get value(): NodeMaterialConnectionPoint;
  134781. /**
  134782. * Gets the cutoff input component
  134783. */
  134784. get cutoff(): NodeMaterialConnectionPoint;
  134785. protected _buildBlock(state: NodeMaterialBuildState): this;
  134786. }
  134787. }
  134788. declare module BABYLON {
  134789. /**
  134790. * Block used to test if the fragment shader is front facing
  134791. */
  134792. export class FrontFacingBlock extends NodeMaterialBlock {
  134793. /**
  134794. * Creates a new FrontFacingBlock
  134795. * @param name defines the block name
  134796. */
  134797. constructor(name: string);
  134798. /**
  134799. * Gets the current class name
  134800. * @returns the class name
  134801. */
  134802. getClassName(): string;
  134803. /**
  134804. * Gets the output component
  134805. */
  134806. get output(): NodeMaterialConnectionPoint;
  134807. protected _buildBlock(state: NodeMaterialBuildState): this;
  134808. }
  134809. }
  134810. declare module BABYLON {
  134811. /**
  134812. * Block used to get the derivative value on x and y of a given input
  134813. */
  134814. export class DerivativeBlock extends NodeMaterialBlock {
  134815. /**
  134816. * Create a new DerivativeBlock
  134817. * @param name defines the block name
  134818. */
  134819. constructor(name: string);
  134820. /**
  134821. * Gets the current class name
  134822. * @returns the class name
  134823. */
  134824. getClassName(): string;
  134825. /**
  134826. * Gets the input component
  134827. */
  134828. get input(): NodeMaterialConnectionPoint;
  134829. /**
  134830. * Gets the derivative output on x
  134831. */
  134832. get dx(): NodeMaterialConnectionPoint;
  134833. /**
  134834. * Gets the derivative output on y
  134835. */
  134836. get dy(): NodeMaterialConnectionPoint;
  134837. protected _buildBlock(state: NodeMaterialBuildState): this;
  134838. }
  134839. }
  134840. declare module BABYLON {
  134841. /**
  134842. * Block used to add support for scene fog
  134843. */
  134844. export class FogBlock extends NodeMaterialBlock {
  134845. private _fogDistanceName;
  134846. private _fogParameters;
  134847. /**
  134848. * Create a new FogBlock
  134849. * @param name defines the block name
  134850. */
  134851. constructor(name: string);
  134852. /**
  134853. * Gets the current class name
  134854. * @returns the class name
  134855. */
  134856. getClassName(): string;
  134857. /**
  134858. * Gets the world position input component
  134859. */
  134860. get worldPosition(): NodeMaterialConnectionPoint;
  134861. /**
  134862. * Gets the view input component
  134863. */
  134864. get view(): NodeMaterialConnectionPoint;
  134865. /**
  134866. * Gets the color input component
  134867. */
  134868. get input(): NodeMaterialConnectionPoint;
  134869. /**
  134870. * Gets the fog color input component
  134871. */
  134872. get fogColor(): NodeMaterialConnectionPoint;
  134873. /**
  134874. * Gets the output component
  134875. */
  134876. get output(): NodeMaterialConnectionPoint;
  134877. autoConfigure(material: NodeMaterial): void;
  134878. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  134879. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  134880. protected _buildBlock(state: NodeMaterialBuildState): this;
  134881. }
  134882. }
  134883. declare module BABYLON {
  134884. /**
  134885. * Block used to add light in the fragment shader
  134886. */
  134887. export class LightBlock extends NodeMaterialBlock {
  134888. private _lightId;
  134889. /**
  134890. * Gets or sets the light associated with this block
  134891. */
  134892. light: Nullable<Light>;
  134893. /**
  134894. * Create a new LightBlock
  134895. * @param name defines the block name
  134896. */
  134897. constructor(name: string);
  134898. /**
  134899. * Gets the current class name
  134900. * @returns the class name
  134901. */
  134902. getClassName(): string;
  134903. /**
  134904. * Gets the world position input component
  134905. */
  134906. get worldPosition(): NodeMaterialConnectionPoint;
  134907. /**
  134908. * Gets the world normal input component
  134909. */
  134910. get worldNormal(): NodeMaterialConnectionPoint;
  134911. /**
  134912. * Gets the camera (or eye) position component
  134913. */
  134914. get cameraPosition(): NodeMaterialConnectionPoint;
  134915. /**
  134916. * Gets the glossiness component
  134917. */
  134918. get glossiness(): NodeMaterialConnectionPoint;
  134919. /**
  134920. * Gets the glossinness power component
  134921. */
  134922. get glossPower(): NodeMaterialConnectionPoint;
  134923. /**
  134924. * Gets the diffuse color component
  134925. */
  134926. get diffuseColor(): NodeMaterialConnectionPoint;
  134927. /**
  134928. * Gets the specular color component
  134929. */
  134930. get specularColor(): NodeMaterialConnectionPoint;
  134931. /**
  134932. * Gets the diffuse output component
  134933. */
  134934. get diffuseOutput(): NodeMaterialConnectionPoint;
  134935. /**
  134936. * Gets the specular output component
  134937. */
  134938. get specularOutput(): NodeMaterialConnectionPoint;
  134939. /**
  134940. * Gets the shadow output component
  134941. */
  134942. get shadow(): NodeMaterialConnectionPoint;
  134943. autoConfigure(material: NodeMaterial): void;
  134944. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  134945. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  134946. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  134947. private _injectVertexCode;
  134948. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  134949. serialize(): any;
  134950. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  134951. }
  134952. }
  134953. declare module BABYLON {
  134954. /**
  134955. * Block used to read a reflection texture from a sampler
  134956. */
  134957. export class ReflectionTextureBlock extends ReflectionTextureBaseBlock {
  134958. /**
  134959. * Create a new ReflectionTextureBlock
  134960. * @param name defines the block name
  134961. */
  134962. constructor(name: string);
  134963. /**
  134964. * Gets the current class name
  134965. * @returns the class name
  134966. */
  134967. getClassName(): string;
  134968. /**
  134969. * Gets the world position input component
  134970. */
  134971. get position(): NodeMaterialConnectionPoint;
  134972. /**
  134973. * Gets the world position input component
  134974. */
  134975. get worldPosition(): NodeMaterialConnectionPoint;
  134976. /**
  134977. * Gets the world normal input component
  134978. */
  134979. get worldNormal(): NodeMaterialConnectionPoint;
  134980. /**
  134981. * Gets the world input component
  134982. */
  134983. get world(): NodeMaterialConnectionPoint;
  134984. /**
  134985. * Gets the camera (or eye) position component
  134986. */
  134987. get cameraPosition(): NodeMaterialConnectionPoint;
  134988. /**
  134989. * Gets the view input component
  134990. */
  134991. get view(): NodeMaterialConnectionPoint;
  134992. /**
  134993. * Gets the rgb output component
  134994. */
  134995. get rgb(): NodeMaterialConnectionPoint;
  134996. /**
  134997. * Gets the r output component
  134998. */
  134999. get r(): NodeMaterialConnectionPoint;
  135000. /**
  135001. * Gets the g output component
  135002. */
  135003. get g(): NodeMaterialConnectionPoint;
  135004. /**
  135005. * Gets the b output component
  135006. */
  135007. get b(): NodeMaterialConnectionPoint;
  135008. autoConfigure(material: NodeMaterial): void;
  135009. protected _buildBlock(state: NodeMaterialBuildState): this;
  135010. }
  135011. }
  135012. declare module BABYLON {
  135013. /**
  135014. * Block used to multiply 2 values
  135015. */
  135016. export class MultiplyBlock extends NodeMaterialBlock {
  135017. /**
  135018. * Creates a new MultiplyBlock
  135019. * @param name defines the block name
  135020. */
  135021. constructor(name: string);
  135022. /**
  135023. * Gets the current class name
  135024. * @returns the class name
  135025. */
  135026. getClassName(): string;
  135027. /**
  135028. * Gets the left operand input component
  135029. */
  135030. get left(): NodeMaterialConnectionPoint;
  135031. /**
  135032. * Gets the right operand input component
  135033. */
  135034. get right(): NodeMaterialConnectionPoint;
  135035. /**
  135036. * Gets the output component
  135037. */
  135038. get output(): NodeMaterialConnectionPoint;
  135039. protected _buildBlock(state: NodeMaterialBuildState): this;
  135040. }
  135041. }
  135042. declare module BABYLON {
  135043. /**
  135044. * Block used to add 2 vectors
  135045. */
  135046. export class AddBlock extends NodeMaterialBlock {
  135047. /**
  135048. * Creates a new AddBlock
  135049. * @param name defines the block name
  135050. */
  135051. constructor(name: string);
  135052. /**
  135053. * Gets the current class name
  135054. * @returns the class name
  135055. */
  135056. getClassName(): string;
  135057. /**
  135058. * Gets the left operand input component
  135059. */
  135060. get left(): NodeMaterialConnectionPoint;
  135061. /**
  135062. * Gets the right operand input component
  135063. */
  135064. get right(): NodeMaterialConnectionPoint;
  135065. /**
  135066. * Gets the output component
  135067. */
  135068. get output(): NodeMaterialConnectionPoint;
  135069. protected _buildBlock(state: NodeMaterialBuildState): this;
  135070. }
  135071. }
  135072. declare module BABYLON {
  135073. /**
  135074. * Block used to scale a vector by a float
  135075. */
  135076. export class ScaleBlock extends NodeMaterialBlock {
  135077. /**
  135078. * Creates a new ScaleBlock
  135079. * @param name defines the block name
  135080. */
  135081. constructor(name: string);
  135082. /**
  135083. * Gets the current class name
  135084. * @returns the class name
  135085. */
  135086. getClassName(): string;
  135087. /**
  135088. * Gets the input component
  135089. */
  135090. get input(): NodeMaterialConnectionPoint;
  135091. /**
  135092. * Gets the factor input component
  135093. */
  135094. get factor(): NodeMaterialConnectionPoint;
  135095. /**
  135096. * Gets the output component
  135097. */
  135098. get output(): NodeMaterialConnectionPoint;
  135099. protected _buildBlock(state: NodeMaterialBuildState): this;
  135100. }
  135101. }
  135102. declare module BABYLON {
  135103. /**
  135104. * Block used to clamp a float
  135105. */
  135106. export class ClampBlock extends NodeMaterialBlock {
  135107. /** Gets or sets the minimum range */
  135108. minimum: number;
  135109. /** Gets or sets the maximum range */
  135110. maximum: number;
  135111. /**
  135112. * Creates a new ClampBlock
  135113. * @param name defines the block name
  135114. */
  135115. constructor(name: string);
  135116. /**
  135117. * Gets the current class name
  135118. * @returns the class name
  135119. */
  135120. getClassName(): string;
  135121. /**
  135122. * Gets the value input component
  135123. */
  135124. get value(): NodeMaterialConnectionPoint;
  135125. /**
  135126. * Gets the output component
  135127. */
  135128. get output(): NodeMaterialConnectionPoint;
  135129. protected _buildBlock(state: NodeMaterialBuildState): this;
  135130. protected _dumpPropertiesCode(): string;
  135131. serialize(): any;
  135132. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  135133. }
  135134. }
  135135. declare module BABYLON {
  135136. /**
  135137. * Block used to apply a cross product between 2 vectors
  135138. */
  135139. export class CrossBlock extends NodeMaterialBlock {
  135140. /**
  135141. * Creates a new CrossBlock
  135142. * @param name defines the block name
  135143. */
  135144. constructor(name: string);
  135145. /**
  135146. * Gets the current class name
  135147. * @returns the class name
  135148. */
  135149. getClassName(): string;
  135150. /**
  135151. * Gets the left operand input component
  135152. */
  135153. get left(): NodeMaterialConnectionPoint;
  135154. /**
  135155. * Gets the right operand input component
  135156. */
  135157. get right(): NodeMaterialConnectionPoint;
  135158. /**
  135159. * Gets the output component
  135160. */
  135161. get output(): NodeMaterialConnectionPoint;
  135162. protected _buildBlock(state: NodeMaterialBuildState): this;
  135163. }
  135164. }
  135165. declare module BABYLON {
  135166. /**
  135167. * Block used to apply a dot product between 2 vectors
  135168. */
  135169. export class DotBlock extends NodeMaterialBlock {
  135170. /**
  135171. * Creates a new DotBlock
  135172. * @param name defines the block name
  135173. */
  135174. constructor(name: string);
  135175. /**
  135176. * Gets the current class name
  135177. * @returns the class name
  135178. */
  135179. getClassName(): string;
  135180. /**
  135181. * Gets the left operand input component
  135182. */
  135183. get left(): NodeMaterialConnectionPoint;
  135184. /**
  135185. * Gets the right operand input component
  135186. */
  135187. get right(): NodeMaterialConnectionPoint;
  135188. /**
  135189. * Gets the output component
  135190. */
  135191. get output(): NodeMaterialConnectionPoint;
  135192. protected _buildBlock(state: NodeMaterialBuildState): this;
  135193. }
  135194. }
  135195. declare module BABYLON {
  135196. /**
  135197. * Block used to remap a float from a range to a new one
  135198. */
  135199. export class RemapBlock extends NodeMaterialBlock {
  135200. /**
  135201. * Gets or sets the source range
  135202. */
  135203. sourceRange: Vector2;
  135204. /**
  135205. * Gets or sets the target range
  135206. */
  135207. targetRange: Vector2;
  135208. /**
  135209. * Creates a new RemapBlock
  135210. * @param name defines the block name
  135211. */
  135212. constructor(name: string);
  135213. /**
  135214. * Gets the current class name
  135215. * @returns the class name
  135216. */
  135217. getClassName(): string;
  135218. /**
  135219. * Gets the input component
  135220. */
  135221. get input(): NodeMaterialConnectionPoint;
  135222. /**
  135223. * Gets the source min input component
  135224. */
  135225. get sourceMin(): NodeMaterialConnectionPoint;
  135226. /**
  135227. * Gets the source max input component
  135228. */
  135229. get sourceMax(): NodeMaterialConnectionPoint;
  135230. /**
  135231. * Gets the target min input component
  135232. */
  135233. get targetMin(): NodeMaterialConnectionPoint;
  135234. /**
  135235. * Gets the target max input component
  135236. */
  135237. get targetMax(): NodeMaterialConnectionPoint;
  135238. /**
  135239. * Gets the output component
  135240. */
  135241. get output(): NodeMaterialConnectionPoint;
  135242. protected _buildBlock(state: NodeMaterialBuildState): this;
  135243. protected _dumpPropertiesCode(): string;
  135244. serialize(): any;
  135245. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  135246. }
  135247. }
  135248. declare module BABYLON {
  135249. /**
  135250. * Block used to normalize a vector
  135251. */
  135252. export class NormalizeBlock extends NodeMaterialBlock {
  135253. /**
  135254. * Creates a new NormalizeBlock
  135255. * @param name defines the block name
  135256. */
  135257. constructor(name: string);
  135258. /**
  135259. * Gets the current class name
  135260. * @returns the class name
  135261. */
  135262. getClassName(): string;
  135263. /**
  135264. * Gets the input component
  135265. */
  135266. get input(): NodeMaterialConnectionPoint;
  135267. /**
  135268. * Gets the output component
  135269. */
  135270. get output(): NodeMaterialConnectionPoint;
  135271. protected _buildBlock(state: NodeMaterialBuildState): this;
  135272. }
  135273. }
  135274. declare module BABYLON {
  135275. /**
  135276. * Operations supported by the Trigonometry block
  135277. */
  135278. export enum TrigonometryBlockOperations {
  135279. /** Cos */
  135280. Cos = 0,
  135281. /** Sin */
  135282. Sin = 1,
  135283. /** Abs */
  135284. Abs = 2,
  135285. /** Exp */
  135286. Exp = 3,
  135287. /** Exp2 */
  135288. Exp2 = 4,
  135289. /** Round */
  135290. Round = 5,
  135291. /** Floor */
  135292. Floor = 6,
  135293. /** Ceiling */
  135294. Ceiling = 7,
  135295. /** Square root */
  135296. Sqrt = 8,
  135297. /** Log */
  135298. Log = 9,
  135299. /** Tangent */
  135300. Tan = 10,
  135301. /** Arc tangent */
  135302. ArcTan = 11,
  135303. /** Arc cosinus */
  135304. ArcCos = 12,
  135305. /** Arc sinus */
  135306. ArcSin = 13,
  135307. /** Fraction */
  135308. Fract = 14,
  135309. /** Sign */
  135310. Sign = 15,
  135311. /** To radians (from degrees) */
  135312. Radians = 16,
  135313. /** To degrees (from radians) */
  135314. Degrees = 17
  135315. }
  135316. /**
  135317. * Block used to apply trigonometry operation to floats
  135318. */
  135319. export class TrigonometryBlock extends NodeMaterialBlock {
  135320. /**
  135321. * Gets or sets the operation applied by the block
  135322. */
  135323. operation: TrigonometryBlockOperations;
  135324. /**
  135325. * Creates a new TrigonometryBlock
  135326. * @param name defines the block name
  135327. */
  135328. constructor(name: string);
  135329. /**
  135330. * Gets the current class name
  135331. * @returns the class name
  135332. */
  135333. getClassName(): string;
  135334. /**
  135335. * Gets the input component
  135336. */
  135337. get input(): NodeMaterialConnectionPoint;
  135338. /**
  135339. * Gets the output component
  135340. */
  135341. get output(): NodeMaterialConnectionPoint;
  135342. protected _buildBlock(state: NodeMaterialBuildState): this;
  135343. serialize(): any;
  135344. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  135345. protected _dumpPropertiesCode(): string;
  135346. }
  135347. }
  135348. declare module BABYLON {
  135349. /**
  135350. * Block used to create a Color3/4 out of individual inputs (one for each component)
  135351. */
  135352. export class ColorMergerBlock extends NodeMaterialBlock {
  135353. /**
  135354. * Create a new ColorMergerBlock
  135355. * @param name defines the block name
  135356. */
  135357. constructor(name: string);
  135358. /**
  135359. * Gets the current class name
  135360. * @returns the class name
  135361. */
  135362. getClassName(): string;
  135363. /**
  135364. * Gets the rgb component (input)
  135365. */
  135366. get rgbIn(): NodeMaterialConnectionPoint;
  135367. /**
  135368. * Gets the r component (input)
  135369. */
  135370. get r(): NodeMaterialConnectionPoint;
  135371. /**
  135372. * Gets the g component (input)
  135373. */
  135374. get g(): NodeMaterialConnectionPoint;
  135375. /**
  135376. * Gets the b component (input)
  135377. */
  135378. get b(): NodeMaterialConnectionPoint;
  135379. /**
  135380. * Gets the a component (input)
  135381. */
  135382. get a(): NodeMaterialConnectionPoint;
  135383. /**
  135384. * Gets the rgba component (output)
  135385. */
  135386. get rgba(): NodeMaterialConnectionPoint;
  135387. /**
  135388. * Gets the rgb component (output)
  135389. */
  135390. get rgbOut(): NodeMaterialConnectionPoint;
  135391. /**
  135392. * Gets the rgb component (output)
  135393. * @deprecated Please use rgbOut instead.
  135394. */
  135395. get rgb(): NodeMaterialConnectionPoint;
  135396. protected _buildBlock(state: NodeMaterialBuildState): this;
  135397. }
  135398. }
  135399. declare module BABYLON {
  135400. /**
  135401. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  135402. */
  135403. export class VectorMergerBlock extends NodeMaterialBlock {
  135404. /**
  135405. * Create a new VectorMergerBlock
  135406. * @param name defines the block name
  135407. */
  135408. constructor(name: string);
  135409. /**
  135410. * Gets the current class name
  135411. * @returns the class name
  135412. */
  135413. getClassName(): string;
  135414. /**
  135415. * Gets the xyz component (input)
  135416. */
  135417. get xyzIn(): NodeMaterialConnectionPoint;
  135418. /**
  135419. * Gets the xy component (input)
  135420. */
  135421. get xyIn(): NodeMaterialConnectionPoint;
  135422. /**
  135423. * Gets the x component (input)
  135424. */
  135425. get x(): NodeMaterialConnectionPoint;
  135426. /**
  135427. * Gets the y component (input)
  135428. */
  135429. get y(): NodeMaterialConnectionPoint;
  135430. /**
  135431. * Gets the z component (input)
  135432. */
  135433. get z(): NodeMaterialConnectionPoint;
  135434. /**
  135435. * Gets the w component (input)
  135436. */
  135437. get w(): NodeMaterialConnectionPoint;
  135438. /**
  135439. * Gets the xyzw component (output)
  135440. */
  135441. get xyzw(): NodeMaterialConnectionPoint;
  135442. /**
  135443. * Gets the xyz component (output)
  135444. */
  135445. get xyzOut(): NodeMaterialConnectionPoint;
  135446. /**
  135447. * Gets the xy component (output)
  135448. */
  135449. get xyOut(): NodeMaterialConnectionPoint;
  135450. /**
  135451. * Gets the xy component (output)
  135452. * @deprecated Please use xyOut instead.
  135453. */
  135454. get xy(): NodeMaterialConnectionPoint;
  135455. /**
  135456. * Gets the xyz component (output)
  135457. * @deprecated Please use xyzOut instead.
  135458. */
  135459. get xyz(): NodeMaterialConnectionPoint;
  135460. protected _buildBlock(state: NodeMaterialBuildState): this;
  135461. }
  135462. }
  135463. declare module BABYLON {
  135464. /**
  135465. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  135466. */
  135467. export class ColorSplitterBlock extends NodeMaterialBlock {
  135468. /**
  135469. * Create a new ColorSplitterBlock
  135470. * @param name defines the block name
  135471. */
  135472. constructor(name: string);
  135473. /**
  135474. * Gets the current class name
  135475. * @returns the class name
  135476. */
  135477. getClassName(): string;
  135478. /**
  135479. * Gets the rgba component (input)
  135480. */
  135481. get rgba(): NodeMaterialConnectionPoint;
  135482. /**
  135483. * Gets the rgb component (input)
  135484. */
  135485. get rgbIn(): NodeMaterialConnectionPoint;
  135486. /**
  135487. * Gets the rgb component (output)
  135488. */
  135489. get rgbOut(): NodeMaterialConnectionPoint;
  135490. /**
  135491. * Gets the r component (output)
  135492. */
  135493. get r(): NodeMaterialConnectionPoint;
  135494. /**
  135495. * Gets the g component (output)
  135496. */
  135497. get g(): NodeMaterialConnectionPoint;
  135498. /**
  135499. * Gets the b component (output)
  135500. */
  135501. get b(): NodeMaterialConnectionPoint;
  135502. /**
  135503. * Gets the a component (output)
  135504. */
  135505. get a(): NodeMaterialConnectionPoint;
  135506. protected _inputRename(name: string): string;
  135507. protected _outputRename(name: string): string;
  135508. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  135509. }
  135510. }
  135511. declare module BABYLON {
  135512. /**
  135513. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  135514. */
  135515. export class VectorSplitterBlock extends NodeMaterialBlock {
  135516. /**
  135517. * Create a new VectorSplitterBlock
  135518. * @param name defines the block name
  135519. */
  135520. constructor(name: string);
  135521. /**
  135522. * Gets the current class name
  135523. * @returns the class name
  135524. */
  135525. getClassName(): string;
  135526. /**
  135527. * Gets the xyzw component (input)
  135528. */
  135529. get xyzw(): NodeMaterialConnectionPoint;
  135530. /**
  135531. * Gets the xyz component (input)
  135532. */
  135533. get xyzIn(): NodeMaterialConnectionPoint;
  135534. /**
  135535. * Gets the xy component (input)
  135536. */
  135537. get xyIn(): NodeMaterialConnectionPoint;
  135538. /**
  135539. * Gets the xyz component (output)
  135540. */
  135541. get xyzOut(): NodeMaterialConnectionPoint;
  135542. /**
  135543. * Gets the xy component (output)
  135544. */
  135545. get xyOut(): NodeMaterialConnectionPoint;
  135546. /**
  135547. * Gets the x component (output)
  135548. */
  135549. get x(): NodeMaterialConnectionPoint;
  135550. /**
  135551. * Gets the y component (output)
  135552. */
  135553. get y(): NodeMaterialConnectionPoint;
  135554. /**
  135555. * Gets the z component (output)
  135556. */
  135557. get z(): NodeMaterialConnectionPoint;
  135558. /**
  135559. * Gets the w component (output)
  135560. */
  135561. get w(): NodeMaterialConnectionPoint;
  135562. protected _inputRename(name: string): string;
  135563. protected _outputRename(name: string): string;
  135564. protected _buildBlock(state: NodeMaterialBuildState): this;
  135565. }
  135566. }
  135567. declare module BABYLON {
  135568. /**
  135569. * Block used to lerp between 2 values
  135570. */
  135571. export class LerpBlock extends NodeMaterialBlock {
  135572. /**
  135573. * Creates a new LerpBlock
  135574. * @param name defines the block name
  135575. */
  135576. constructor(name: string);
  135577. /**
  135578. * Gets the current class name
  135579. * @returns the class name
  135580. */
  135581. getClassName(): string;
  135582. /**
  135583. * Gets the left operand input component
  135584. */
  135585. get left(): NodeMaterialConnectionPoint;
  135586. /**
  135587. * Gets the right operand input component
  135588. */
  135589. get right(): NodeMaterialConnectionPoint;
  135590. /**
  135591. * Gets the gradient operand input component
  135592. */
  135593. get gradient(): NodeMaterialConnectionPoint;
  135594. /**
  135595. * Gets the output component
  135596. */
  135597. get output(): NodeMaterialConnectionPoint;
  135598. protected _buildBlock(state: NodeMaterialBuildState): this;
  135599. }
  135600. }
  135601. declare module BABYLON {
  135602. /**
  135603. * Block used to divide 2 vectors
  135604. */
  135605. export class DivideBlock extends NodeMaterialBlock {
  135606. /**
  135607. * Creates a new DivideBlock
  135608. * @param name defines the block name
  135609. */
  135610. constructor(name: string);
  135611. /**
  135612. * Gets the current class name
  135613. * @returns the class name
  135614. */
  135615. getClassName(): string;
  135616. /**
  135617. * Gets the left operand input component
  135618. */
  135619. get left(): NodeMaterialConnectionPoint;
  135620. /**
  135621. * Gets the right operand input component
  135622. */
  135623. get right(): NodeMaterialConnectionPoint;
  135624. /**
  135625. * Gets the output component
  135626. */
  135627. get output(): NodeMaterialConnectionPoint;
  135628. protected _buildBlock(state: NodeMaterialBuildState): this;
  135629. }
  135630. }
  135631. declare module BABYLON {
  135632. /**
  135633. * Block used to subtract 2 vectors
  135634. */
  135635. export class SubtractBlock extends NodeMaterialBlock {
  135636. /**
  135637. * Creates a new SubtractBlock
  135638. * @param name defines the block name
  135639. */
  135640. constructor(name: string);
  135641. /**
  135642. * Gets the current class name
  135643. * @returns the class name
  135644. */
  135645. getClassName(): string;
  135646. /**
  135647. * Gets the left operand input component
  135648. */
  135649. get left(): NodeMaterialConnectionPoint;
  135650. /**
  135651. * Gets the right operand input component
  135652. */
  135653. get right(): NodeMaterialConnectionPoint;
  135654. /**
  135655. * Gets the output component
  135656. */
  135657. get output(): NodeMaterialConnectionPoint;
  135658. protected _buildBlock(state: NodeMaterialBuildState): this;
  135659. }
  135660. }
  135661. declare module BABYLON {
  135662. /**
  135663. * Block used to step a value
  135664. */
  135665. export class StepBlock extends NodeMaterialBlock {
  135666. /**
  135667. * Creates a new StepBlock
  135668. * @param name defines the block name
  135669. */
  135670. constructor(name: string);
  135671. /**
  135672. * Gets the current class name
  135673. * @returns the class name
  135674. */
  135675. getClassName(): string;
  135676. /**
  135677. * Gets the value operand input component
  135678. */
  135679. get value(): NodeMaterialConnectionPoint;
  135680. /**
  135681. * Gets the edge operand input component
  135682. */
  135683. get edge(): NodeMaterialConnectionPoint;
  135684. /**
  135685. * Gets the output component
  135686. */
  135687. get output(): NodeMaterialConnectionPoint;
  135688. protected _buildBlock(state: NodeMaterialBuildState): this;
  135689. }
  135690. }
  135691. declare module BABYLON {
  135692. /**
  135693. * Block used to get the opposite (1 - x) of a value
  135694. */
  135695. export class OneMinusBlock extends NodeMaterialBlock {
  135696. /**
  135697. * Creates a new OneMinusBlock
  135698. * @param name defines the block name
  135699. */
  135700. constructor(name: string);
  135701. /**
  135702. * Gets the current class name
  135703. * @returns the class name
  135704. */
  135705. getClassName(): string;
  135706. /**
  135707. * Gets the input component
  135708. */
  135709. get input(): NodeMaterialConnectionPoint;
  135710. /**
  135711. * Gets the output component
  135712. */
  135713. get output(): NodeMaterialConnectionPoint;
  135714. protected _buildBlock(state: NodeMaterialBuildState): this;
  135715. }
  135716. }
  135717. declare module BABYLON {
  135718. /**
  135719. * Block used to get the view direction
  135720. */
  135721. export class ViewDirectionBlock extends NodeMaterialBlock {
  135722. /**
  135723. * Creates a new ViewDirectionBlock
  135724. * @param name defines the block name
  135725. */
  135726. constructor(name: string);
  135727. /**
  135728. * Gets the current class name
  135729. * @returns the class name
  135730. */
  135731. getClassName(): string;
  135732. /**
  135733. * Gets the world position component
  135734. */
  135735. get worldPosition(): NodeMaterialConnectionPoint;
  135736. /**
  135737. * Gets the camera position component
  135738. */
  135739. get cameraPosition(): NodeMaterialConnectionPoint;
  135740. /**
  135741. * Gets the output component
  135742. */
  135743. get output(): NodeMaterialConnectionPoint;
  135744. autoConfigure(material: NodeMaterial): void;
  135745. protected _buildBlock(state: NodeMaterialBuildState): this;
  135746. }
  135747. }
  135748. declare module BABYLON {
  135749. /**
  135750. * Block used to compute fresnel value
  135751. */
  135752. export class FresnelBlock extends NodeMaterialBlock {
  135753. /**
  135754. * Create a new FresnelBlock
  135755. * @param name defines the block name
  135756. */
  135757. constructor(name: string);
  135758. /**
  135759. * Gets the current class name
  135760. * @returns the class name
  135761. */
  135762. getClassName(): string;
  135763. /**
  135764. * Gets the world normal input component
  135765. */
  135766. get worldNormal(): NodeMaterialConnectionPoint;
  135767. /**
  135768. * Gets the view direction input component
  135769. */
  135770. get viewDirection(): NodeMaterialConnectionPoint;
  135771. /**
  135772. * Gets the bias input component
  135773. */
  135774. get bias(): NodeMaterialConnectionPoint;
  135775. /**
  135776. * Gets the camera (or eye) position component
  135777. */
  135778. get power(): NodeMaterialConnectionPoint;
  135779. /**
  135780. * Gets the fresnel output component
  135781. */
  135782. get fresnel(): NodeMaterialConnectionPoint;
  135783. autoConfigure(material: NodeMaterial): void;
  135784. protected _buildBlock(state: NodeMaterialBuildState): this;
  135785. }
  135786. }
  135787. declare module BABYLON {
  135788. /**
  135789. * Block used to get the max of 2 values
  135790. */
  135791. export class MaxBlock extends NodeMaterialBlock {
  135792. /**
  135793. * Creates a new MaxBlock
  135794. * @param name defines the block name
  135795. */
  135796. constructor(name: string);
  135797. /**
  135798. * Gets the current class name
  135799. * @returns the class name
  135800. */
  135801. getClassName(): string;
  135802. /**
  135803. * Gets the left operand input component
  135804. */
  135805. get left(): NodeMaterialConnectionPoint;
  135806. /**
  135807. * Gets the right operand input component
  135808. */
  135809. get right(): NodeMaterialConnectionPoint;
  135810. /**
  135811. * Gets the output component
  135812. */
  135813. get output(): NodeMaterialConnectionPoint;
  135814. protected _buildBlock(state: NodeMaterialBuildState): this;
  135815. }
  135816. }
  135817. declare module BABYLON {
  135818. /**
  135819. * Block used to get the min of 2 values
  135820. */
  135821. export class MinBlock extends NodeMaterialBlock {
  135822. /**
  135823. * Creates a new MinBlock
  135824. * @param name defines the block name
  135825. */
  135826. constructor(name: string);
  135827. /**
  135828. * Gets the current class name
  135829. * @returns the class name
  135830. */
  135831. getClassName(): string;
  135832. /**
  135833. * Gets the left operand input component
  135834. */
  135835. get left(): NodeMaterialConnectionPoint;
  135836. /**
  135837. * Gets the right operand input component
  135838. */
  135839. get right(): NodeMaterialConnectionPoint;
  135840. /**
  135841. * Gets the output component
  135842. */
  135843. get output(): NodeMaterialConnectionPoint;
  135844. protected _buildBlock(state: NodeMaterialBuildState): this;
  135845. }
  135846. }
  135847. declare module BABYLON {
  135848. /**
  135849. * Block used to get the distance between 2 values
  135850. */
  135851. export class DistanceBlock extends NodeMaterialBlock {
  135852. /**
  135853. * Creates a new DistanceBlock
  135854. * @param name defines the block name
  135855. */
  135856. constructor(name: string);
  135857. /**
  135858. * Gets the current class name
  135859. * @returns the class name
  135860. */
  135861. getClassName(): string;
  135862. /**
  135863. * Gets the left operand input component
  135864. */
  135865. get left(): NodeMaterialConnectionPoint;
  135866. /**
  135867. * Gets the right operand input component
  135868. */
  135869. get right(): NodeMaterialConnectionPoint;
  135870. /**
  135871. * Gets the output component
  135872. */
  135873. get output(): NodeMaterialConnectionPoint;
  135874. protected _buildBlock(state: NodeMaterialBuildState): this;
  135875. }
  135876. }
  135877. declare module BABYLON {
  135878. /**
  135879. * Block used to get the length of a vector
  135880. */
  135881. export class LengthBlock extends NodeMaterialBlock {
  135882. /**
  135883. * Creates a new LengthBlock
  135884. * @param name defines the block name
  135885. */
  135886. constructor(name: string);
  135887. /**
  135888. * Gets the current class name
  135889. * @returns the class name
  135890. */
  135891. getClassName(): string;
  135892. /**
  135893. * Gets the value input component
  135894. */
  135895. get value(): NodeMaterialConnectionPoint;
  135896. /**
  135897. * Gets the output component
  135898. */
  135899. get output(): NodeMaterialConnectionPoint;
  135900. protected _buildBlock(state: NodeMaterialBuildState): this;
  135901. }
  135902. }
  135903. declare module BABYLON {
  135904. /**
  135905. * Block used to get negative version of a value (i.e. x * -1)
  135906. */
  135907. export class NegateBlock extends NodeMaterialBlock {
  135908. /**
  135909. * Creates a new NegateBlock
  135910. * @param name defines the block name
  135911. */
  135912. constructor(name: string);
  135913. /**
  135914. * Gets the current class name
  135915. * @returns the class name
  135916. */
  135917. getClassName(): string;
  135918. /**
  135919. * Gets the value input component
  135920. */
  135921. get value(): NodeMaterialConnectionPoint;
  135922. /**
  135923. * Gets the output component
  135924. */
  135925. get output(): NodeMaterialConnectionPoint;
  135926. protected _buildBlock(state: NodeMaterialBuildState): this;
  135927. }
  135928. }
  135929. declare module BABYLON {
  135930. /**
  135931. * Block used to get the value of the first parameter raised to the power of the second
  135932. */
  135933. export class PowBlock extends NodeMaterialBlock {
  135934. /**
  135935. * Creates a new PowBlock
  135936. * @param name defines the block name
  135937. */
  135938. constructor(name: string);
  135939. /**
  135940. * Gets the current class name
  135941. * @returns the class name
  135942. */
  135943. getClassName(): string;
  135944. /**
  135945. * Gets the value operand input component
  135946. */
  135947. get value(): NodeMaterialConnectionPoint;
  135948. /**
  135949. * Gets the power operand input component
  135950. */
  135951. get power(): NodeMaterialConnectionPoint;
  135952. /**
  135953. * Gets the output component
  135954. */
  135955. get output(): NodeMaterialConnectionPoint;
  135956. protected _buildBlock(state: NodeMaterialBuildState): this;
  135957. }
  135958. }
  135959. declare module BABYLON {
  135960. /**
  135961. * Block used to get a random number
  135962. */
  135963. export class RandomNumberBlock extends NodeMaterialBlock {
  135964. /**
  135965. * Creates a new RandomNumberBlock
  135966. * @param name defines the block name
  135967. */
  135968. constructor(name: string);
  135969. /**
  135970. * Gets the current class name
  135971. * @returns the class name
  135972. */
  135973. getClassName(): string;
  135974. /**
  135975. * Gets the seed input component
  135976. */
  135977. get seed(): NodeMaterialConnectionPoint;
  135978. /**
  135979. * Gets the output component
  135980. */
  135981. get output(): NodeMaterialConnectionPoint;
  135982. protected _buildBlock(state: NodeMaterialBuildState): this;
  135983. }
  135984. }
  135985. declare module BABYLON {
  135986. /**
  135987. * Block used to compute arc tangent of 2 values
  135988. */
  135989. export class ArcTan2Block extends NodeMaterialBlock {
  135990. /**
  135991. * Creates a new ArcTan2Block
  135992. * @param name defines the block name
  135993. */
  135994. constructor(name: string);
  135995. /**
  135996. * Gets the current class name
  135997. * @returns the class name
  135998. */
  135999. getClassName(): string;
  136000. /**
  136001. * Gets the x operand input component
  136002. */
  136003. get x(): NodeMaterialConnectionPoint;
  136004. /**
  136005. * Gets the y operand input component
  136006. */
  136007. get y(): NodeMaterialConnectionPoint;
  136008. /**
  136009. * Gets the output component
  136010. */
  136011. get output(): NodeMaterialConnectionPoint;
  136012. protected _buildBlock(state: NodeMaterialBuildState): this;
  136013. }
  136014. }
  136015. declare module BABYLON {
  136016. /**
  136017. * Block used to smooth step a value
  136018. */
  136019. export class SmoothStepBlock extends NodeMaterialBlock {
  136020. /**
  136021. * Creates a new SmoothStepBlock
  136022. * @param name defines the block name
  136023. */
  136024. constructor(name: string);
  136025. /**
  136026. * Gets the current class name
  136027. * @returns the class name
  136028. */
  136029. getClassName(): string;
  136030. /**
  136031. * Gets the value operand input component
  136032. */
  136033. get value(): NodeMaterialConnectionPoint;
  136034. /**
  136035. * Gets the first edge operand input component
  136036. */
  136037. get edge0(): NodeMaterialConnectionPoint;
  136038. /**
  136039. * Gets the second edge operand input component
  136040. */
  136041. get edge1(): NodeMaterialConnectionPoint;
  136042. /**
  136043. * Gets the output component
  136044. */
  136045. get output(): NodeMaterialConnectionPoint;
  136046. protected _buildBlock(state: NodeMaterialBuildState): this;
  136047. }
  136048. }
  136049. declare module BABYLON {
  136050. /**
  136051. * Block used to get the reciprocal (1 / x) of a value
  136052. */
  136053. export class ReciprocalBlock extends NodeMaterialBlock {
  136054. /**
  136055. * Creates a new ReciprocalBlock
  136056. * @param name defines the block name
  136057. */
  136058. constructor(name: string);
  136059. /**
  136060. * Gets the current class name
  136061. * @returns the class name
  136062. */
  136063. getClassName(): string;
  136064. /**
  136065. * Gets the input component
  136066. */
  136067. get input(): NodeMaterialConnectionPoint;
  136068. /**
  136069. * Gets the output component
  136070. */
  136071. get output(): NodeMaterialConnectionPoint;
  136072. protected _buildBlock(state: NodeMaterialBuildState): this;
  136073. }
  136074. }
  136075. declare module BABYLON {
  136076. /**
  136077. * Block used to replace a color by another one
  136078. */
  136079. export class ReplaceColorBlock extends NodeMaterialBlock {
  136080. /**
  136081. * Creates a new ReplaceColorBlock
  136082. * @param name defines the block name
  136083. */
  136084. constructor(name: string);
  136085. /**
  136086. * Gets the current class name
  136087. * @returns the class name
  136088. */
  136089. getClassName(): string;
  136090. /**
  136091. * Gets the value input component
  136092. */
  136093. get value(): NodeMaterialConnectionPoint;
  136094. /**
  136095. * Gets the reference input component
  136096. */
  136097. get reference(): NodeMaterialConnectionPoint;
  136098. /**
  136099. * Gets the distance input component
  136100. */
  136101. get distance(): NodeMaterialConnectionPoint;
  136102. /**
  136103. * Gets the replacement input component
  136104. */
  136105. get replacement(): NodeMaterialConnectionPoint;
  136106. /**
  136107. * Gets the output component
  136108. */
  136109. get output(): NodeMaterialConnectionPoint;
  136110. protected _buildBlock(state: NodeMaterialBuildState): this;
  136111. }
  136112. }
  136113. declare module BABYLON {
  136114. /**
  136115. * Block used to posterize a value
  136116. * @see https://en.wikipedia.org/wiki/Posterization
  136117. */
  136118. export class PosterizeBlock extends NodeMaterialBlock {
  136119. /**
  136120. * Creates a new PosterizeBlock
  136121. * @param name defines the block name
  136122. */
  136123. constructor(name: string);
  136124. /**
  136125. * Gets the current class name
  136126. * @returns the class name
  136127. */
  136128. getClassName(): string;
  136129. /**
  136130. * Gets the value input component
  136131. */
  136132. get value(): NodeMaterialConnectionPoint;
  136133. /**
  136134. * Gets the steps input component
  136135. */
  136136. get steps(): NodeMaterialConnectionPoint;
  136137. /**
  136138. * Gets the output component
  136139. */
  136140. get output(): NodeMaterialConnectionPoint;
  136141. protected _buildBlock(state: NodeMaterialBuildState): this;
  136142. }
  136143. }
  136144. declare module BABYLON {
  136145. /**
  136146. * Operations supported by the Wave block
  136147. */
  136148. export enum WaveBlockKind {
  136149. /** SawTooth */
  136150. SawTooth = 0,
  136151. /** Square */
  136152. Square = 1,
  136153. /** Triangle */
  136154. Triangle = 2
  136155. }
  136156. /**
  136157. * Block used to apply wave operation to floats
  136158. */
  136159. export class WaveBlock extends NodeMaterialBlock {
  136160. /**
  136161. * Gets or sets the kibnd of wave to be applied by the block
  136162. */
  136163. kind: WaveBlockKind;
  136164. /**
  136165. * Creates a new WaveBlock
  136166. * @param name defines the block name
  136167. */
  136168. constructor(name: string);
  136169. /**
  136170. * Gets the current class name
  136171. * @returns the class name
  136172. */
  136173. getClassName(): string;
  136174. /**
  136175. * Gets the input component
  136176. */
  136177. get input(): NodeMaterialConnectionPoint;
  136178. /**
  136179. * Gets the output component
  136180. */
  136181. get output(): NodeMaterialConnectionPoint;
  136182. protected _buildBlock(state: NodeMaterialBuildState): this;
  136183. serialize(): any;
  136184. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  136185. }
  136186. }
  136187. declare module BABYLON {
  136188. /**
  136189. * Class used to store a color step for the GradientBlock
  136190. */
  136191. export class GradientBlockColorStep {
  136192. /**
  136193. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  136194. */
  136195. step: number;
  136196. /**
  136197. * Gets or sets the color associated with this step
  136198. */
  136199. color: Color3;
  136200. /**
  136201. * Creates a new GradientBlockColorStep
  136202. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  136203. * @param color defines the color associated with this step
  136204. */
  136205. constructor(
  136206. /**
  136207. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  136208. */
  136209. step: number,
  136210. /**
  136211. * Gets or sets the color associated with this step
  136212. */
  136213. color: Color3);
  136214. }
  136215. /**
  136216. * Block used to return a color from a gradient based on an input value between 0 and 1
  136217. */
  136218. export class GradientBlock extends NodeMaterialBlock {
  136219. /**
  136220. * Gets or sets the list of color steps
  136221. */
  136222. colorSteps: GradientBlockColorStep[];
  136223. /**
  136224. * Creates a new GradientBlock
  136225. * @param name defines the block name
  136226. */
  136227. constructor(name: string);
  136228. /**
  136229. * Gets the current class name
  136230. * @returns the class name
  136231. */
  136232. getClassName(): string;
  136233. /**
  136234. * Gets the gradient input component
  136235. */
  136236. get gradient(): NodeMaterialConnectionPoint;
  136237. /**
  136238. * Gets the output component
  136239. */
  136240. get output(): NodeMaterialConnectionPoint;
  136241. private _writeColorConstant;
  136242. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  136243. serialize(): any;
  136244. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  136245. protected _dumpPropertiesCode(): string;
  136246. }
  136247. }
  136248. declare module BABYLON {
  136249. /**
  136250. * Block used to normalize lerp between 2 values
  136251. */
  136252. export class NLerpBlock extends NodeMaterialBlock {
  136253. /**
  136254. * Creates a new NLerpBlock
  136255. * @param name defines the block name
  136256. */
  136257. constructor(name: string);
  136258. /**
  136259. * Gets the current class name
  136260. * @returns the class name
  136261. */
  136262. getClassName(): string;
  136263. /**
  136264. * Gets the left operand input component
  136265. */
  136266. get left(): NodeMaterialConnectionPoint;
  136267. /**
  136268. * Gets the right operand input component
  136269. */
  136270. get right(): NodeMaterialConnectionPoint;
  136271. /**
  136272. * Gets the gradient operand input component
  136273. */
  136274. get gradient(): NodeMaterialConnectionPoint;
  136275. /**
  136276. * Gets the output component
  136277. */
  136278. get output(): NodeMaterialConnectionPoint;
  136279. protected _buildBlock(state: NodeMaterialBuildState): this;
  136280. }
  136281. }
  136282. declare module BABYLON {
  136283. /**
  136284. * block used to Generate a Worley Noise 3D Noise Pattern
  136285. */
  136286. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  136287. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  136288. manhattanDistance: boolean;
  136289. /**
  136290. * Creates a new WorleyNoise3DBlock
  136291. * @param name defines the block name
  136292. */
  136293. constructor(name: string);
  136294. /**
  136295. * Gets the current class name
  136296. * @returns the class name
  136297. */
  136298. getClassName(): string;
  136299. /**
  136300. * Gets the seed input component
  136301. */
  136302. get seed(): NodeMaterialConnectionPoint;
  136303. /**
  136304. * Gets the jitter input component
  136305. */
  136306. get jitter(): NodeMaterialConnectionPoint;
  136307. /**
  136308. * Gets the output component
  136309. */
  136310. get output(): NodeMaterialConnectionPoint;
  136311. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  136312. /**
  136313. * Exposes the properties to the UI?
  136314. */
  136315. protected _dumpPropertiesCode(): string;
  136316. /**
  136317. * Exposes the properties to the Seralize?
  136318. */
  136319. serialize(): any;
  136320. /**
  136321. * Exposes the properties to the deseralize?
  136322. */
  136323. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  136324. }
  136325. }
  136326. declare module BABYLON {
  136327. /**
  136328. * block used to Generate a Simplex Perlin 3d Noise Pattern
  136329. */
  136330. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  136331. /**
  136332. * Creates a new SimplexPerlin3DBlock
  136333. * @param name defines the block name
  136334. */
  136335. constructor(name: string);
  136336. /**
  136337. * Gets the current class name
  136338. * @returns the class name
  136339. */
  136340. getClassName(): string;
  136341. /**
  136342. * Gets the seed operand input component
  136343. */
  136344. get seed(): NodeMaterialConnectionPoint;
  136345. /**
  136346. * Gets the output component
  136347. */
  136348. get output(): NodeMaterialConnectionPoint;
  136349. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  136350. }
  136351. }
  136352. declare module BABYLON {
  136353. /**
  136354. * Block used to blend normals
  136355. */
  136356. export class NormalBlendBlock extends NodeMaterialBlock {
  136357. /**
  136358. * Creates a new NormalBlendBlock
  136359. * @param name defines the block name
  136360. */
  136361. constructor(name: string);
  136362. /**
  136363. * Gets the current class name
  136364. * @returns the class name
  136365. */
  136366. getClassName(): string;
  136367. /**
  136368. * Gets the first input component
  136369. */
  136370. get normalMap0(): NodeMaterialConnectionPoint;
  136371. /**
  136372. * Gets the second input component
  136373. */
  136374. get normalMap1(): NodeMaterialConnectionPoint;
  136375. /**
  136376. * Gets the output component
  136377. */
  136378. get output(): NodeMaterialConnectionPoint;
  136379. protected _buildBlock(state: NodeMaterialBuildState): this;
  136380. }
  136381. }
  136382. declare module BABYLON {
  136383. /**
  136384. * Block used to rotate a 2d vector by a given angle
  136385. */
  136386. export class Rotate2dBlock extends NodeMaterialBlock {
  136387. /**
  136388. * Creates a new Rotate2dBlock
  136389. * @param name defines the block name
  136390. */
  136391. constructor(name: string);
  136392. /**
  136393. * Gets the current class name
  136394. * @returns the class name
  136395. */
  136396. getClassName(): string;
  136397. /**
  136398. * Gets the input vector
  136399. */
  136400. get input(): NodeMaterialConnectionPoint;
  136401. /**
  136402. * Gets the input angle
  136403. */
  136404. get angle(): NodeMaterialConnectionPoint;
  136405. /**
  136406. * Gets the output component
  136407. */
  136408. get output(): NodeMaterialConnectionPoint;
  136409. autoConfigure(material: NodeMaterial): void;
  136410. protected _buildBlock(state: NodeMaterialBuildState): this;
  136411. }
  136412. }
  136413. declare module BABYLON {
  136414. /**
  136415. * Block used to get the reflected vector from a direction and a normal
  136416. */
  136417. export class ReflectBlock extends NodeMaterialBlock {
  136418. /**
  136419. * Creates a new ReflectBlock
  136420. * @param name defines the block name
  136421. */
  136422. constructor(name: string);
  136423. /**
  136424. * Gets the current class name
  136425. * @returns the class name
  136426. */
  136427. getClassName(): string;
  136428. /**
  136429. * Gets the incident component
  136430. */
  136431. get incident(): NodeMaterialConnectionPoint;
  136432. /**
  136433. * Gets the normal component
  136434. */
  136435. get normal(): NodeMaterialConnectionPoint;
  136436. /**
  136437. * Gets the output component
  136438. */
  136439. get output(): NodeMaterialConnectionPoint;
  136440. protected _buildBlock(state: NodeMaterialBuildState): this;
  136441. }
  136442. }
  136443. declare module BABYLON {
  136444. /**
  136445. * Block used to get the refracted vector from a direction and a normal
  136446. */
  136447. export class RefractBlock extends NodeMaterialBlock {
  136448. /**
  136449. * Creates a new RefractBlock
  136450. * @param name defines the block name
  136451. */
  136452. constructor(name: string);
  136453. /**
  136454. * Gets the current class name
  136455. * @returns the class name
  136456. */
  136457. getClassName(): string;
  136458. /**
  136459. * Gets the incident component
  136460. */
  136461. get incident(): NodeMaterialConnectionPoint;
  136462. /**
  136463. * Gets the normal component
  136464. */
  136465. get normal(): NodeMaterialConnectionPoint;
  136466. /**
  136467. * Gets the index of refraction component
  136468. */
  136469. get ior(): NodeMaterialConnectionPoint;
  136470. /**
  136471. * Gets the output component
  136472. */
  136473. get output(): NodeMaterialConnectionPoint;
  136474. protected _buildBlock(state: NodeMaterialBuildState): this;
  136475. }
  136476. }
  136477. declare module BABYLON {
  136478. /**
  136479. * Block used to desaturate a color
  136480. */
  136481. export class DesaturateBlock extends NodeMaterialBlock {
  136482. /**
  136483. * Creates a new DesaturateBlock
  136484. * @param name defines the block name
  136485. */
  136486. constructor(name: string);
  136487. /**
  136488. * Gets the current class name
  136489. * @returns the class name
  136490. */
  136491. getClassName(): string;
  136492. /**
  136493. * Gets the color operand input component
  136494. */
  136495. get color(): NodeMaterialConnectionPoint;
  136496. /**
  136497. * Gets the level operand input component
  136498. */
  136499. get level(): NodeMaterialConnectionPoint;
  136500. /**
  136501. * Gets the output component
  136502. */
  136503. get output(): NodeMaterialConnectionPoint;
  136504. protected _buildBlock(state: NodeMaterialBuildState): this;
  136505. }
  136506. }
  136507. declare module BABYLON {
  136508. /**
  136509. * Defines a connection point to be used for points with a custom object type
  136510. */
  136511. export class NodeMaterialConnectionPointCustomObject<T extends NodeMaterialBlock> extends NodeMaterialConnectionPoint {
  136512. private _blockType;
  136513. private _blockName;
  136514. private _nameForCheking?;
  136515. /**
  136516. * Creates a new connection point
  136517. * @param name defines the connection point name
  136518. * @param ownerBlock defines the block hosting this connection point
  136519. * @param direction defines the direction of the connection point
  136520. */
  136521. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection, _blockType: new (...args: any[]) => T, _blockName: string, _nameForCheking?: string | undefined);
  136522. /**
  136523. * Gets a number indicating if the current point can be connected to another point
  136524. * @param connectionPoint defines the other connection point
  136525. * @returns a number defining the compatibility state
  136526. */
  136527. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  136528. /**
  136529. * Creates a block suitable to be used as an input for this input point.
  136530. * If null is returned, a block based on the point type will be created.
  136531. * @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
  136532. */
  136533. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  136534. }
  136535. }
  136536. declare module BABYLON {
  136537. /**
  136538. * Block used to implement the ambient occlusion module of the PBR material
  136539. */
  136540. export class AmbientOcclusionBlock extends NodeMaterialBlock {
  136541. /**
  136542. * Create a new AmbientOcclusionBlock
  136543. * @param name defines the block name
  136544. */
  136545. constructor(name: string);
  136546. /**
  136547. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  136548. */
  136549. useAmbientInGrayScale: boolean;
  136550. /**
  136551. * Initialize the block and prepare the context for build
  136552. * @param state defines the state that will be used for the build
  136553. */
  136554. initialize(state: NodeMaterialBuildState): void;
  136555. /**
  136556. * Gets the current class name
  136557. * @returns the class name
  136558. */
  136559. getClassName(): string;
  136560. /**
  136561. * Gets the texture input component
  136562. */
  136563. get texture(): NodeMaterialConnectionPoint;
  136564. /**
  136565. * Gets the texture intensity component
  136566. */
  136567. get intensity(): NodeMaterialConnectionPoint;
  136568. /**
  136569. * Gets the direct light intensity input component
  136570. */
  136571. get directLightIntensity(): NodeMaterialConnectionPoint;
  136572. /**
  136573. * Gets the ambient occlusion object output component
  136574. */
  136575. get ambientOcclusion(): NodeMaterialConnectionPoint;
  136576. /**
  136577. * Gets the main code of the block (fragment side)
  136578. * @param block instance of an AmbientOcclusionBlock or null if the code must be generated without an active ambient occlusion module
  136579. * @returns the shader code
  136580. */
  136581. static GetCode(block: Nullable<AmbientOcclusionBlock>): string;
  136582. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  136583. protected _buildBlock(state: NodeMaterialBuildState): this;
  136584. protected _dumpPropertiesCode(): string;
  136585. serialize(): any;
  136586. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  136587. }
  136588. }
  136589. declare module BABYLON {
  136590. /**
  136591. * Block used to implement the reflection module of the PBR material
  136592. */
  136593. export class ReflectionBlock extends ReflectionTextureBaseBlock {
  136594. /** @hidden */
  136595. _defineLODReflectionAlpha: string;
  136596. /** @hidden */
  136597. _defineLinearSpecularReflection: string;
  136598. private _vEnvironmentIrradianceName;
  136599. /** @hidden */
  136600. _vReflectionMicrosurfaceInfosName: string;
  136601. /** @hidden */
  136602. _vReflectionInfosName: string;
  136603. private _scene;
  136604. /**
  136605. * The three properties below are set by the main PBR block prior to calling methods of this class.
  136606. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  136607. * It's less burden on the user side in the editor part.
  136608. */
  136609. /** @hidden */
  136610. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  136611. /** @hidden */
  136612. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  136613. /** @hidden */
  136614. cameraPositionConnectionPoint: NodeMaterialConnectionPoint;
  136615. /**
  136616. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  136617. * diffuse part of the IBL.
  136618. */
  136619. useSphericalHarmonics: boolean;
  136620. /**
  136621. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  136622. */
  136623. forceIrradianceInFragment: boolean;
  136624. /**
  136625. * Create a new ReflectionBlock
  136626. * @param name defines the block name
  136627. */
  136628. constructor(name: string);
  136629. /**
  136630. * Gets the current class name
  136631. * @returns the class name
  136632. */
  136633. getClassName(): string;
  136634. /**
  136635. * Gets the position input component
  136636. */
  136637. get position(): NodeMaterialConnectionPoint;
  136638. /**
  136639. * Gets the world position input component
  136640. */
  136641. get worldPosition(): NodeMaterialConnectionPoint;
  136642. /**
  136643. * Gets the world normal input component
  136644. */
  136645. get worldNormal(): NodeMaterialConnectionPoint;
  136646. /**
  136647. * Gets the world input component
  136648. */
  136649. get world(): NodeMaterialConnectionPoint;
  136650. /**
  136651. * Gets the camera (or eye) position component
  136652. */
  136653. get cameraPosition(): NodeMaterialConnectionPoint;
  136654. /**
  136655. * Gets the view input component
  136656. */
  136657. get view(): NodeMaterialConnectionPoint;
  136658. /**
  136659. * Gets the color input component
  136660. */
  136661. get color(): NodeMaterialConnectionPoint;
  136662. /**
  136663. * Gets the reflection object output component
  136664. */
  136665. get reflection(): NodeMaterialConnectionPoint;
  136666. /**
  136667. * Returns true if the block has a texture (either its own texture or the environment texture from the scene, if set)
  136668. */
  136669. get hasTexture(): boolean;
  136670. /**
  136671. * Gets the reflection color (either the name of the variable if the color input is connected, else a default value)
  136672. */
  136673. get reflectionColor(): string;
  136674. protected _getTexture(): Nullable<BaseTexture>;
  136675. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  136676. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  136677. /**
  136678. * Gets the code to inject in the vertex shader
  136679. * @param state current state of the node material building
  136680. * @returns the shader code
  136681. */
  136682. handleVertexSide(state: NodeMaterialBuildState): string;
  136683. /**
  136684. * Gets the main code of the block (fragment side)
  136685. * @param state current state of the node material building
  136686. * @param normalVarName name of the existing variable corresponding to the normal
  136687. * @returns the shader code
  136688. */
  136689. getCode(state: NodeMaterialBuildState, normalVarName: string): string;
  136690. protected _buildBlock(state: NodeMaterialBuildState): this;
  136691. protected _dumpPropertiesCode(): string;
  136692. serialize(): any;
  136693. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  136694. }
  136695. }
  136696. declare module BABYLON {
  136697. /**
  136698. * Block used to implement the sheen module of the PBR material
  136699. */
  136700. export class SheenBlock extends NodeMaterialBlock {
  136701. /**
  136702. * Create a new SheenBlock
  136703. * @param name defines the block name
  136704. */
  136705. constructor(name: string);
  136706. /**
  136707. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  136708. * It allows the strength of the sheen effect to not depend on the base color of the material,
  136709. * making it easier to setup and tweak the effect
  136710. */
  136711. albedoScaling: boolean;
  136712. /**
  136713. * Defines if the sheen is linked to the sheen color.
  136714. */
  136715. linkSheenWithAlbedo: boolean;
  136716. /**
  136717. * Initialize the block and prepare the context for build
  136718. * @param state defines the state that will be used for the build
  136719. */
  136720. initialize(state: NodeMaterialBuildState): void;
  136721. /**
  136722. * Gets the current class name
  136723. * @returns the class name
  136724. */
  136725. getClassName(): string;
  136726. /**
  136727. * Gets the intensity input component
  136728. */
  136729. get intensity(): NodeMaterialConnectionPoint;
  136730. /**
  136731. * Gets the color input component
  136732. */
  136733. get color(): NodeMaterialConnectionPoint;
  136734. /**
  136735. * Gets the roughness input component
  136736. */
  136737. get roughness(): NodeMaterialConnectionPoint;
  136738. /**
  136739. * Gets the texture input component
  136740. */
  136741. get texture(): NodeMaterialConnectionPoint;
  136742. /**
  136743. * Gets the sheen object output component
  136744. */
  136745. get sheen(): NodeMaterialConnectionPoint;
  136746. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  136747. /**
  136748. * Gets the main code of the block (fragment side)
  136749. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  136750. * @returns the shader code
  136751. */
  136752. getCode(reflectionBlock: Nullable<ReflectionBlock>): string;
  136753. protected _buildBlock(state: NodeMaterialBuildState): this;
  136754. protected _dumpPropertiesCode(): string;
  136755. serialize(): any;
  136756. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  136757. }
  136758. }
  136759. declare module BABYLON {
  136760. /**
  136761. * Block used to implement the reflectivity module of the PBR material
  136762. */
  136763. export class ReflectivityBlock extends NodeMaterialBlock {
  136764. /**
  136765. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  136766. */
  136767. useAmbientOcclusionFromMetallicTextureRed: boolean;
  136768. /**
  136769. * Specifies if the metallic texture contains the metallness information in its blue channel.
  136770. */
  136771. useMetallnessFromMetallicTextureBlue: boolean;
  136772. /**
  136773. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  136774. */
  136775. useRoughnessFromMetallicTextureAlpha: boolean;
  136776. /**
  136777. * Specifies if the metallic texture contains the roughness information in its green channel.
  136778. */
  136779. useRoughnessFromMetallicTextureGreen: boolean;
  136780. /**
  136781. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  136782. */
  136783. useMetallicF0FactorFromMetallicTexture: boolean;
  136784. /**
  136785. * Create a new ReflectivityBlock
  136786. * @param name defines the block name
  136787. */
  136788. constructor(name: string);
  136789. /**
  136790. * Initialize the block and prepare the context for build
  136791. * @param state defines the state that will be used for the build
  136792. */
  136793. initialize(state: NodeMaterialBuildState): void;
  136794. /**
  136795. * Gets the current class name
  136796. * @returns the class name
  136797. */
  136798. getClassName(): string;
  136799. /**
  136800. * Gets the metallic input component
  136801. */
  136802. get metallic(): NodeMaterialConnectionPoint;
  136803. /**
  136804. * Gets the roughness input component
  136805. */
  136806. get roughness(): NodeMaterialConnectionPoint;
  136807. /**
  136808. * Gets the texture input component
  136809. */
  136810. get texture(): NodeMaterialConnectionPoint;
  136811. /**
  136812. * Gets the reflectivity object output component
  136813. */
  136814. get reflectivity(): NodeMaterialConnectionPoint;
  136815. /**
  136816. * Gets the main code of the block (fragment side)
  136817. * @param aoIntensityVarName name of the variable with the ambient occlusion intensity
  136818. * @returns the shader code
  136819. */
  136820. getCode(aoIntensityVarName: string): string;
  136821. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  136822. protected _buildBlock(state: NodeMaterialBuildState): this;
  136823. protected _dumpPropertiesCode(): string;
  136824. serialize(): any;
  136825. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  136826. }
  136827. }
  136828. declare module BABYLON {
  136829. /**
  136830. * Block used to implement the anisotropy module of the PBR material
  136831. */
  136832. export class AnisotropyBlock extends NodeMaterialBlock {
  136833. /**
  136834. * The two properties below are set by the main PBR block prior to calling methods of this class.
  136835. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  136836. * It's less burden on the user side in the editor part.
  136837. */
  136838. /** @hidden */
  136839. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  136840. /** @hidden */
  136841. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  136842. /**
  136843. * Create a new AnisotropyBlock
  136844. * @param name defines the block name
  136845. */
  136846. constructor(name: string);
  136847. /**
  136848. * Initialize the block and prepare the context for build
  136849. * @param state defines the state that will be used for the build
  136850. */
  136851. initialize(state: NodeMaterialBuildState): void;
  136852. /**
  136853. * Gets the current class name
  136854. * @returns the class name
  136855. */
  136856. getClassName(): string;
  136857. /**
  136858. * Gets the intensity input component
  136859. */
  136860. get intensity(): NodeMaterialConnectionPoint;
  136861. /**
  136862. * Gets the direction input component
  136863. */
  136864. get direction(): NodeMaterialConnectionPoint;
  136865. /**
  136866. * Gets the texture input component
  136867. */
  136868. get texture(): NodeMaterialConnectionPoint;
  136869. /**
  136870. * Gets the uv input component
  136871. */
  136872. get uv(): NodeMaterialConnectionPoint;
  136873. /**
  136874. * Gets the worldTangent input component
  136875. */
  136876. get worldTangent(): NodeMaterialConnectionPoint;
  136877. /**
  136878. * Gets the anisotropy object output component
  136879. */
  136880. get anisotropy(): NodeMaterialConnectionPoint;
  136881. private _generateTBNSpace;
  136882. /**
  136883. * Gets the main code of the block (fragment side)
  136884. * @param state current state of the node material building
  136885. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  136886. * @returns the shader code
  136887. */
  136888. getCode(state: NodeMaterialBuildState, generateTBNSpace?: boolean): string;
  136889. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  136890. protected _buildBlock(state: NodeMaterialBuildState): this;
  136891. }
  136892. }
  136893. declare module BABYLON {
  136894. /**
  136895. * Block used to implement the PBR metallic/roughness model
  136896. */
  136897. export class PBRMetallicRoughnessBlock extends NodeMaterialBlock {
  136898. /**
  136899. * Gets or sets the light associated with this block
  136900. */
  136901. light: Nullable<Light>;
  136902. private _lightId;
  136903. private _scene;
  136904. private _environmentBRDFTexture;
  136905. private _environmentBrdfSamplerName;
  136906. private _vNormalWName;
  136907. /**
  136908. * Create a new ReflectionBlock
  136909. * @param name defines the block name
  136910. */
  136911. constructor(name: string);
  136912. /**
  136913. * Defines the falloff type used in this material.
  136914. * It by default is Physical.
  136915. */
  136916. lightFalloff: number;
  136917. /**
  136918. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  136919. */
  136920. useAlphaFromAlbedoTexture: boolean;
  136921. /**
  136922. * Specifies that alpha test should be used
  136923. */
  136924. useAlphaTest: boolean;
  136925. /**
  136926. * Defines the alpha limits in alpha test mode.
  136927. */
  136928. alphaTestCutoff: number;
  136929. /**
  136930. * Specifies that alpha blending should be used
  136931. */
  136932. useAlphaBlending: boolean;
  136933. /**
  136934. * Defines if the alpha value should be determined via the rgb values.
  136935. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  136936. */
  136937. opacityRGB: boolean;
  136938. /**
  136939. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most luminous ones).
  136940. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  136941. */
  136942. useRadianceOverAlpha: boolean;
  136943. /**
  136944. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most luminous ones).
  136945. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  136946. */
  136947. useSpecularOverAlpha: boolean;
  136948. /**
  136949. * Enables specular anti aliasing in the PBR shader.
  136950. * It will both interacts on the Geometry for analytical and IBL lighting.
  136951. * It also prefilter the roughness map based on the bump values.
  136952. */
  136953. enableSpecularAntiAliasing: boolean;
  136954. /**
  136955. * Defines if the material uses energy conservation.
  136956. */
  136957. useEnergyConservation: boolean;
  136958. /**
  136959. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  136960. * too much the area relying on ambient texture to define their ambient occlusion.
  136961. */
  136962. useRadianceOcclusion: boolean;
  136963. /**
  136964. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  136965. * makes the reflect vector face the model (under horizon).
  136966. */
  136967. useHorizonOcclusion: boolean;
  136968. /**
  136969. * If set to true, no lighting calculations will be applied.
  136970. */
  136971. unlit: boolean;
  136972. /**
  136973. * Defines the material debug mode.
  136974. * It helps seeing only some components of the material while troubleshooting.
  136975. */
  136976. debugMode: number;
  136977. /**
  136978. * Specify from where on screen the debug mode should start.
  136979. * The value goes from -1 (full screen) to 1 (not visible)
  136980. * It helps with side by side comparison against the final render
  136981. * This defaults to 0
  136982. */
  136983. debugLimit: number;
  136984. /**
  136985. * As the default viewing range might not be enough (if the ambient is really small for instance)
  136986. * You can use the factor to better multiply the final value.
  136987. */
  136988. debugFactor: number;
  136989. /**
  136990. * Initialize the block and prepare the context for build
  136991. * @param state defines the state that will be used for the build
  136992. */
  136993. initialize(state: NodeMaterialBuildState): void;
  136994. /**
  136995. * Gets the current class name
  136996. * @returns the class name
  136997. */
  136998. getClassName(): string;
  136999. /**
  137000. * Gets the world position input component
  137001. */
  137002. get worldPosition(): NodeMaterialConnectionPoint;
  137003. /**
  137004. * Gets the world normal input component
  137005. */
  137006. get worldNormal(): NodeMaterialConnectionPoint;
  137007. /**
  137008. * Gets the perturbed normal input component
  137009. */
  137010. get perturbedNormal(): NodeMaterialConnectionPoint;
  137011. /**
  137012. * Gets the camera position input component
  137013. */
  137014. get cameraPosition(): NodeMaterialConnectionPoint;
  137015. /**
  137016. * Gets the base color input component
  137017. */
  137018. get baseColor(): NodeMaterialConnectionPoint;
  137019. /**
  137020. * Gets the base texture input component
  137021. */
  137022. get baseTexture(): NodeMaterialConnectionPoint;
  137023. /**
  137024. * Gets the opacity texture input component
  137025. */
  137026. get opacityTexture(): NodeMaterialConnectionPoint;
  137027. /**
  137028. * Gets the ambient color input component
  137029. */
  137030. get ambientColor(): NodeMaterialConnectionPoint;
  137031. /**
  137032. * Gets the reflectivity object parameters
  137033. */
  137034. get reflectivity(): NodeMaterialConnectionPoint;
  137035. /**
  137036. * Gets the ambient occlusion object parameters
  137037. */
  137038. get ambientOcclusion(): NodeMaterialConnectionPoint;
  137039. /**
  137040. * Gets the reflection object parameters
  137041. */
  137042. get reflection(): NodeMaterialConnectionPoint;
  137043. /**
  137044. * Gets the sheen object parameters
  137045. */
  137046. get sheen(): NodeMaterialConnectionPoint;
  137047. /**
  137048. * Gets the clear coat object parameters
  137049. */
  137050. get clearcoat(): NodeMaterialConnectionPoint;
  137051. /**
  137052. * Gets the sub surface object parameters
  137053. */
  137054. get subSurface(): NodeMaterialConnectionPoint;
  137055. /**
  137056. * Gets the anisotropy object parameters
  137057. */
  137058. get anisotropy(): NodeMaterialConnectionPoint;
  137059. /**
  137060. * Gets the ambient output component
  137061. */
  137062. get ambient(): NodeMaterialConnectionPoint;
  137063. /**
  137064. * Gets the diffuse output component
  137065. */
  137066. get diffuse(): NodeMaterialConnectionPoint;
  137067. /**
  137068. * Gets the specular output component
  137069. */
  137070. get specular(): NodeMaterialConnectionPoint;
  137071. /**
  137072. * Gets the sheen output component
  137073. */
  137074. get sheenDir(): NodeMaterialConnectionPoint;
  137075. /**
  137076. * Gets the clear coat output component
  137077. */
  137078. get clearcoatDir(): NodeMaterialConnectionPoint;
  137079. /**
  137080. * Gets the indirect diffuse output component
  137081. */
  137082. get diffuseIndirect(): NodeMaterialConnectionPoint;
  137083. /**
  137084. * Gets the indirect specular output component
  137085. */
  137086. get specularIndirect(): NodeMaterialConnectionPoint;
  137087. /**
  137088. * Gets the indirect sheen output component
  137089. */
  137090. get sheenIndirect(): NodeMaterialConnectionPoint;
  137091. /**
  137092. * Gets the indirect clear coat output component
  137093. */
  137094. get clearcoatIndirect(): NodeMaterialConnectionPoint;
  137095. /**
  137096. * Gets the refraction output component
  137097. */
  137098. get refraction(): NodeMaterialConnectionPoint;
  137099. /**
  137100. * Gets the global lighting output component
  137101. */
  137102. get lighting(): NodeMaterialConnectionPoint;
  137103. /**
  137104. * Gets the shadow output component
  137105. */
  137106. get shadow(): NodeMaterialConnectionPoint;
  137107. /**
  137108. * Gets the alpha output component
  137109. */
  137110. get alpha(): NodeMaterialConnectionPoint;
  137111. autoConfigure(material: NodeMaterial): void;
  137112. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  137113. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  137114. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  137115. private _injectVertexCode;
  137116. /**
  137117. * Gets the code corresponding to the albedo/opacity module
  137118. * @returns the shader code
  137119. */
  137120. getAlbedoOpacityCode(): string;
  137121. protected _buildBlock(state: NodeMaterialBuildState): this;
  137122. protected _dumpPropertiesCode(): string;
  137123. serialize(): any;
  137124. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  137125. }
  137126. }
  137127. declare module BABYLON {
  137128. /**
  137129. * Effect Render Options
  137130. */
  137131. export interface IEffectRendererOptions {
  137132. /**
  137133. * Defines the vertices positions.
  137134. */
  137135. positions?: number[];
  137136. /**
  137137. * Defines the indices.
  137138. */
  137139. indices?: number[];
  137140. }
  137141. /**
  137142. * Helper class to render one or more effects.
  137143. * You can access the previous rendering in your shader by declaring a sampler named textureSampler
  137144. */
  137145. export class EffectRenderer {
  137146. private engine;
  137147. private static _DefaultOptions;
  137148. private _vertexBuffers;
  137149. private _indexBuffer;
  137150. private _fullscreenViewport;
  137151. /**
  137152. * Creates an effect renderer
  137153. * @param engine the engine to use for rendering
  137154. * @param options defines the options of the effect renderer
  137155. */
  137156. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  137157. /**
  137158. * Sets the current viewport in normalized coordinates 0-1
  137159. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  137160. */
  137161. setViewport(viewport?: Viewport): void;
  137162. /**
  137163. * Binds the embedded attributes buffer to the effect.
  137164. * @param effect Defines the effect to bind the attributes for
  137165. */
  137166. bindBuffers(effect: Effect): void;
  137167. /**
  137168. * Sets the current effect wrapper to use during draw.
  137169. * The effect needs to be ready before calling this api.
  137170. * This also sets the default full screen position attribute.
  137171. * @param effectWrapper Defines the effect to draw with
  137172. */
  137173. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  137174. /**
  137175. * Draws a full screen quad.
  137176. */
  137177. draw(): void;
  137178. private isRenderTargetTexture;
  137179. /**
  137180. * renders one or more effects to a specified texture
  137181. * @param effectWrapper the effect to renderer
  137182. * @param outputTexture texture to draw to, if null it will render to the screen.
  137183. */
  137184. render(effectWrapper: EffectWrapper, outputTexture?: Nullable<InternalTexture | RenderTargetTexture>): void;
  137185. /**
  137186. * Disposes of the effect renderer
  137187. */
  137188. dispose(): void;
  137189. }
  137190. /**
  137191. * Options to create an EffectWrapper
  137192. */
  137193. interface EffectWrapperCreationOptions {
  137194. /**
  137195. * Engine to use to create the effect
  137196. */
  137197. engine: ThinEngine;
  137198. /**
  137199. * Fragment shader for the effect
  137200. */
  137201. fragmentShader: string;
  137202. /**
  137203. * Vertex shader for the effect
  137204. */
  137205. vertexShader?: string;
  137206. /**
  137207. * Attributes to use in the shader
  137208. */
  137209. attributeNames?: Array<string>;
  137210. /**
  137211. * Uniforms to use in the shader
  137212. */
  137213. uniformNames?: Array<string>;
  137214. /**
  137215. * Texture sampler names to use in the shader
  137216. */
  137217. samplerNames?: Array<string>;
  137218. /**
  137219. * The friendly name of the effect displayed in Spector.
  137220. */
  137221. name?: string;
  137222. }
  137223. /**
  137224. * Wraps an effect to be used for rendering
  137225. */
  137226. export class EffectWrapper {
  137227. /**
  137228. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  137229. */
  137230. onApplyObservable: Observable<{}>;
  137231. /**
  137232. * The underlying effect
  137233. */
  137234. effect: Effect;
  137235. /**
  137236. * Creates an effect to be renderer
  137237. * @param creationOptions options to create the effect
  137238. */
  137239. constructor(creationOptions: EffectWrapperCreationOptions);
  137240. /**
  137241. * Disposes of the effect wrapper
  137242. */
  137243. dispose(): void;
  137244. }
  137245. }
  137246. declare module BABYLON {
  137247. /**
  137248. * Helper class to push actions to a pool of workers.
  137249. */
  137250. export class WorkerPool implements IDisposable {
  137251. private _workerInfos;
  137252. private _pendingActions;
  137253. /**
  137254. * Constructor
  137255. * @param workers Array of workers to use for actions
  137256. */
  137257. constructor(workers: Array<Worker>);
  137258. /**
  137259. * Terminates all workers and clears any pending actions.
  137260. */
  137261. dispose(): void;
  137262. /**
  137263. * Pushes an action to the worker pool. If all the workers are active, the action will be
  137264. * pended until a worker has completed its action.
  137265. * @param action The action to perform. Call onComplete when the action is complete.
  137266. */
  137267. push(action: (worker: Worker, onComplete: () => void) => void): void;
  137268. private _execute;
  137269. }
  137270. }
  137271. declare module BABYLON {
  137272. /**
  137273. * Configuration for Draco compression
  137274. */
  137275. export interface IDracoCompressionConfiguration {
  137276. /**
  137277. * Configuration for the decoder.
  137278. */
  137279. decoder: {
  137280. /**
  137281. * The url to the WebAssembly module.
  137282. */
  137283. wasmUrl?: string;
  137284. /**
  137285. * The url to the WebAssembly binary.
  137286. */
  137287. wasmBinaryUrl?: string;
  137288. /**
  137289. * The url to the fallback JavaScript module.
  137290. */
  137291. fallbackUrl?: string;
  137292. };
  137293. }
  137294. /**
  137295. * Draco compression (https://google.github.io/draco/)
  137296. *
  137297. * This class wraps the Draco module.
  137298. *
  137299. * **Encoder**
  137300. *
  137301. * The encoder is not currently implemented.
  137302. *
  137303. * **Decoder**
  137304. *
  137305. * 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.
  137306. *
  137307. * To update the configuration, use the following code:
  137308. * ```javascript
  137309. * DracoCompression.Configuration = {
  137310. * decoder: {
  137311. * wasmUrl: "<url to the WebAssembly library>",
  137312. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  137313. * fallbackUrl: "<url to the fallback JavaScript library>",
  137314. * }
  137315. * };
  137316. * ```
  137317. *
  137318. * 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.
  137319. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  137320. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  137321. *
  137322. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  137323. * ```javascript
  137324. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  137325. * ```
  137326. *
  137327. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  137328. */
  137329. export class DracoCompression implements IDisposable {
  137330. private _workerPoolPromise?;
  137331. private _decoderModulePromise?;
  137332. /**
  137333. * The configuration. Defaults to the following urls:
  137334. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  137335. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  137336. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  137337. */
  137338. static Configuration: IDracoCompressionConfiguration;
  137339. /**
  137340. * Returns true if the decoder configuration is available.
  137341. */
  137342. static get DecoderAvailable(): boolean;
  137343. /**
  137344. * Default number of workers to create when creating the draco compression object.
  137345. */
  137346. static DefaultNumWorkers: number;
  137347. private static GetDefaultNumWorkers;
  137348. private static _Default;
  137349. /**
  137350. * Default instance for the draco compression object.
  137351. */
  137352. static get Default(): DracoCompression;
  137353. /**
  137354. * Constructor
  137355. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  137356. */
  137357. constructor(numWorkers?: number);
  137358. /**
  137359. * Stop all async operations and release resources.
  137360. */
  137361. dispose(): void;
  137362. /**
  137363. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  137364. * @returns a promise that resolves when ready
  137365. */
  137366. whenReadyAsync(): Promise<void>;
  137367. /**
  137368. * Decode Draco compressed mesh data to vertex data.
  137369. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  137370. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  137371. * @returns A promise that resolves with the decoded vertex data
  137372. */
  137373. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  137374. [kind: string]: number;
  137375. }): Promise<VertexData>;
  137376. }
  137377. }
  137378. declare module BABYLON {
  137379. /**
  137380. * Class for building Constructive Solid Geometry
  137381. */
  137382. export class CSG {
  137383. private polygons;
  137384. /**
  137385. * The world matrix
  137386. */
  137387. matrix: Matrix;
  137388. /**
  137389. * Stores the position
  137390. */
  137391. position: Vector3;
  137392. /**
  137393. * Stores the rotation
  137394. */
  137395. rotation: Vector3;
  137396. /**
  137397. * Stores the rotation quaternion
  137398. */
  137399. rotationQuaternion: Nullable<Quaternion>;
  137400. /**
  137401. * Stores the scaling vector
  137402. */
  137403. scaling: Vector3;
  137404. /**
  137405. * Convert the Mesh to CSG
  137406. * @param mesh The Mesh to convert to CSG
  137407. * @returns A new CSG from the Mesh
  137408. */
  137409. static FromMesh(mesh: Mesh): CSG;
  137410. /**
  137411. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  137412. * @param polygons Polygons used to construct a CSG solid
  137413. */
  137414. private static FromPolygons;
  137415. /**
  137416. * Clones, or makes a deep copy, of the CSG
  137417. * @returns A new CSG
  137418. */
  137419. clone(): CSG;
  137420. /**
  137421. * Unions this CSG with another CSG
  137422. * @param csg The CSG to union against this CSG
  137423. * @returns The unioned CSG
  137424. */
  137425. union(csg: CSG): CSG;
  137426. /**
  137427. * Unions this CSG with another CSG in place
  137428. * @param csg The CSG to union against this CSG
  137429. */
  137430. unionInPlace(csg: CSG): void;
  137431. /**
  137432. * Subtracts this CSG with another CSG
  137433. * @param csg The CSG to subtract against this CSG
  137434. * @returns A new CSG
  137435. */
  137436. subtract(csg: CSG): CSG;
  137437. /**
  137438. * Subtracts this CSG with another CSG in place
  137439. * @param csg The CSG to subtact against this CSG
  137440. */
  137441. subtractInPlace(csg: CSG): void;
  137442. /**
  137443. * Intersect this CSG with another CSG
  137444. * @param csg The CSG to intersect against this CSG
  137445. * @returns A new CSG
  137446. */
  137447. intersect(csg: CSG): CSG;
  137448. /**
  137449. * Intersects this CSG with another CSG in place
  137450. * @param csg The CSG to intersect against this CSG
  137451. */
  137452. intersectInPlace(csg: CSG): void;
  137453. /**
  137454. * Return a new CSG solid with solid and empty space switched. This solid is
  137455. * not modified.
  137456. * @returns A new CSG solid with solid and empty space switched
  137457. */
  137458. inverse(): CSG;
  137459. /**
  137460. * Inverses the CSG in place
  137461. */
  137462. inverseInPlace(): void;
  137463. /**
  137464. * This is used to keep meshes transformations so they can be restored
  137465. * when we build back a Babylon Mesh
  137466. * NB : All CSG operations are performed in world coordinates
  137467. * @param csg The CSG to copy the transform attributes from
  137468. * @returns This CSG
  137469. */
  137470. copyTransformAttributes(csg: CSG): CSG;
  137471. /**
  137472. * Build Raw mesh from CSG
  137473. * Coordinates here are in world space
  137474. * @param name The name of the mesh geometry
  137475. * @param scene The Scene
  137476. * @param keepSubMeshes Specifies if the submeshes should be kept
  137477. * @returns A new Mesh
  137478. */
  137479. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  137480. /**
  137481. * Build Mesh from CSG taking material and transforms into account
  137482. * @param name The name of the Mesh
  137483. * @param material The material of the Mesh
  137484. * @param scene The Scene
  137485. * @param keepSubMeshes Specifies if submeshes should be kept
  137486. * @returns The new Mesh
  137487. */
  137488. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  137489. }
  137490. }
  137491. declare module BABYLON {
  137492. /**
  137493. * Class used to create a trail following a mesh
  137494. */
  137495. export class TrailMesh extends Mesh {
  137496. private _generator;
  137497. private _autoStart;
  137498. private _running;
  137499. private _diameter;
  137500. private _length;
  137501. private _sectionPolygonPointsCount;
  137502. private _sectionVectors;
  137503. private _sectionNormalVectors;
  137504. private _beforeRenderObserver;
  137505. /**
  137506. * @constructor
  137507. * @param name The value used by scene.getMeshByName() to do a lookup.
  137508. * @param generator The mesh or transform node to generate a trail.
  137509. * @param scene The scene to add this mesh to.
  137510. * @param diameter Diameter of trailing mesh. Default is 1.
  137511. * @param length Length of trailing mesh. Default is 60.
  137512. * @param autoStart Automatically start trailing mesh. Default true.
  137513. */
  137514. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  137515. /**
  137516. * "TrailMesh"
  137517. * @returns "TrailMesh"
  137518. */
  137519. getClassName(): string;
  137520. private _createMesh;
  137521. /**
  137522. * Start trailing mesh.
  137523. */
  137524. start(): void;
  137525. /**
  137526. * Stop trailing mesh.
  137527. */
  137528. stop(): void;
  137529. /**
  137530. * Update trailing mesh geometry.
  137531. */
  137532. update(): void;
  137533. /**
  137534. * Returns a new TrailMesh object.
  137535. * @param name is a string, the name given to the new mesh
  137536. * @param newGenerator use new generator object for cloned trail mesh
  137537. * @returns a new mesh
  137538. */
  137539. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  137540. /**
  137541. * Serializes this trail mesh
  137542. * @param serializationObject object to write serialization to
  137543. */
  137544. serialize(serializationObject: any): void;
  137545. /**
  137546. * Parses a serialized trail mesh
  137547. * @param parsedMesh the serialized mesh
  137548. * @param scene the scene to create the trail mesh in
  137549. * @returns the created trail mesh
  137550. */
  137551. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  137552. }
  137553. }
  137554. declare module BABYLON {
  137555. /**
  137556. * Class containing static functions to help procedurally build meshes
  137557. */
  137558. export class TiledBoxBuilder {
  137559. /**
  137560. * Creates a box mesh
  137561. * 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)
  137562. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  137563. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  137564. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  137565. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  137566. * @param name defines the name of the mesh
  137567. * @param options defines the options used to create the mesh
  137568. * @param scene defines the hosting scene
  137569. * @returns the box mesh
  137570. */
  137571. static CreateTiledBox(name: string, options: {
  137572. pattern?: number;
  137573. width?: number;
  137574. height?: number;
  137575. depth?: number;
  137576. tileSize?: number;
  137577. tileWidth?: number;
  137578. tileHeight?: number;
  137579. alignHorizontal?: number;
  137580. alignVertical?: number;
  137581. faceUV?: Vector4[];
  137582. faceColors?: Color4[];
  137583. sideOrientation?: number;
  137584. updatable?: boolean;
  137585. }, scene?: Nullable<Scene>): Mesh;
  137586. }
  137587. }
  137588. declare module BABYLON {
  137589. /**
  137590. * Class containing static functions to help procedurally build meshes
  137591. */
  137592. export class TorusKnotBuilder {
  137593. /**
  137594. * Creates a torus knot mesh
  137595. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  137596. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  137597. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  137598. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  137599. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  137600. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  137601. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  137602. * @param name defines the name of the mesh
  137603. * @param options defines the options used to create the mesh
  137604. * @param scene defines the hosting scene
  137605. * @returns the torus knot mesh
  137606. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  137607. */
  137608. static CreateTorusKnot(name: string, options: {
  137609. radius?: number;
  137610. tube?: number;
  137611. radialSegments?: number;
  137612. tubularSegments?: number;
  137613. p?: number;
  137614. q?: number;
  137615. updatable?: boolean;
  137616. sideOrientation?: number;
  137617. frontUVs?: Vector4;
  137618. backUVs?: Vector4;
  137619. }, scene: any): Mesh;
  137620. }
  137621. }
  137622. declare module BABYLON {
  137623. /**
  137624. * Polygon
  137625. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  137626. */
  137627. export class Polygon {
  137628. /**
  137629. * Creates a rectangle
  137630. * @param xmin bottom X coord
  137631. * @param ymin bottom Y coord
  137632. * @param xmax top X coord
  137633. * @param ymax top Y coord
  137634. * @returns points that make the resulting rectation
  137635. */
  137636. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  137637. /**
  137638. * Creates a circle
  137639. * @param radius radius of circle
  137640. * @param cx scale in x
  137641. * @param cy scale in y
  137642. * @param numberOfSides number of sides that make up the circle
  137643. * @returns points that make the resulting circle
  137644. */
  137645. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  137646. /**
  137647. * Creates a polygon from input string
  137648. * @param input Input polygon data
  137649. * @returns the parsed points
  137650. */
  137651. static Parse(input: string): Vector2[];
  137652. /**
  137653. * Starts building a polygon from x and y coordinates
  137654. * @param x x coordinate
  137655. * @param y y coordinate
  137656. * @returns the started path2
  137657. */
  137658. static StartingAt(x: number, y: number): Path2;
  137659. }
  137660. /**
  137661. * Builds a polygon
  137662. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  137663. */
  137664. export class PolygonMeshBuilder {
  137665. private _points;
  137666. private _outlinepoints;
  137667. private _holes;
  137668. private _name;
  137669. private _scene;
  137670. private _epoints;
  137671. private _eholes;
  137672. private _addToepoint;
  137673. /**
  137674. * Babylon reference to the earcut plugin.
  137675. */
  137676. bjsEarcut: any;
  137677. /**
  137678. * Creates a PolygonMeshBuilder
  137679. * @param name name of the builder
  137680. * @param contours Path of the polygon
  137681. * @param scene scene to add to when creating the mesh
  137682. * @param earcutInjection can be used to inject your own earcut reference
  137683. */
  137684. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  137685. /**
  137686. * Adds a whole within the polygon
  137687. * @param hole Array of points defining the hole
  137688. * @returns this
  137689. */
  137690. addHole(hole: Vector2[]): PolygonMeshBuilder;
  137691. /**
  137692. * Creates the polygon
  137693. * @param updatable If the mesh should be updatable
  137694. * @param depth The depth of the mesh created
  137695. * @returns the created mesh
  137696. */
  137697. build(updatable?: boolean, depth?: number): Mesh;
  137698. /**
  137699. * Creates the polygon
  137700. * @param depth The depth of the mesh created
  137701. * @returns the created VertexData
  137702. */
  137703. buildVertexData(depth?: number): VertexData;
  137704. /**
  137705. * Adds a side to the polygon
  137706. * @param positions points that make the polygon
  137707. * @param normals normals of the polygon
  137708. * @param uvs uvs of the polygon
  137709. * @param indices indices of the polygon
  137710. * @param bounds bounds of the polygon
  137711. * @param points points of the polygon
  137712. * @param depth depth of the polygon
  137713. * @param flip flip of the polygon
  137714. */
  137715. private addSide;
  137716. }
  137717. }
  137718. declare module BABYLON {
  137719. /**
  137720. * Class containing static functions to help procedurally build meshes
  137721. */
  137722. export class PolygonBuilder {
  137723. /**
  137724. * Creates a polygon mesh
  137725. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  137726. * * 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
  137727. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  137728. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  137729. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  137730. * * Remember you can only change the shape positions, not their number when updating a polygon
  137731. * @param name defines the name of the mesh
  137732. * @param options defines the options used to create the mesh
  137733. * @param scene defines the hosting scene
  137734. * @param earcutInjection can be used to inject your own earcut reference
  137735. * @returns the polygon mesh
  137736. */
  137737. static CreatePolygon(name: string, options: {
  137738. shape: Vector3[];
  137739. holes?: Vector3[][];
  137740. depth?: number;
  137741. faceUV?: Vector4[];
  137742. faceColors?: Color4[];
  137743. updatable?: boolean;
  137744. sideOrientation?: number;
  137745. frontUVs?: Vector4;
  137746. backUVs?: Vector4;
  137747. wrap?: boolean;
  137748. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  137749. /**
  137750. * Creates an extruded polygon mesh, with depth in the Y direction.
  137751. * * 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)
  137752. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  137753. * @param name defines the name of the mesh
  137754. * @param options defines the options used to create the mesh
  137755. * @param scene defines the hosting scene
  137756. * @param earcutInjection can be used to inject your own earcut reference
  137757. * @returns the polygon mesh
  137758. */
  137759. static ExtrudePolygon(name: string, options: {
  137760. shape: Vector3[];
  137761. holes?: Vector3[][];
  137762. depth?: number;
  137763. faceUV?: Vector4[];
  137764. faceColors?: Color4[];
  137765. updatable?: boolean;
  137766. sideOrientation?: number;
  137767. frontUVs?: Vector4;
  137768. backUVs?: Vector4;
  137769. wrap?: boolean;
  137770. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  137771. }
  137772. }
  137773. declare module BABYLON {
  137774. /**
  137775. * Class containing static functions to help procedurally build meshes
  137776. */
  137777. export class LatheBuilder {
  137778. /**
  137779. * Creates lathe mesh.
  137780. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  137781. * * 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
  137782. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  137783. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  137784. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  137785. * * 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
  137786. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  137787. * * 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
  137788. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  137789. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  137790. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  137791. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  137792. * @param name defines the name of the mesh
  137793. * @param options defines the options used to create the mesh
  137794. * @param scene defines the hosting scene
  137795. * @returns the lathe mesh
  137796. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  137797. */
  137798. static CreateLathe(name: string, options: {
  137799. shape: Vector3[];
  137800. radius?: number;
  137801. tessellation?: number;
  137802. clip?: number;
  137803. arc?: number;
  137804. closed?: boolean;
  137805. updatable?: boolean;
  137806. sideOrientation?: number;
  137807. frontUVs?: Vector4;
  137808. backUVs?: Vector4;
  137809. cap?: number;
  137810. invertUV?: boolean;
  137811. }, scene?: Nullable<Scene>): Mesh;
  137812. }
  137813. }
  137814. declare module BABYLON {
  137815. /**
  137816. * Class containing static functions to help procedurally build meshes
  137817. */
  137818. export class TiledPlaneBuilder {
  137819. /**
  137820. * Creates a tiled plane mesh
  137821. * * The parameter `pattern` will, depending on value, do nothing or
  137822. * * * flip (reflect about central vertical) alternate tiles across and up
  137823. * * * flip every tile on alternate rows
  137824. * * * rotate (180 degs) alternate tiles across and up
  137825. * * * rotate every tile on alternate rows
  137826. * * * flip and rotate alternate tiles across and up
  137827. * * * flip and rotate every tile on alternate rows
  137828. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  137829. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  137830. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  137831. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  137832. * * 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)
  137833. * * 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)
  137834. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  137835. * @param name defines the name of the mesh
  137836. * @param options defines the options used to create the mesh
  137837. * @param scene defines the hosting scene
  137838. * @returns the box mesh
  137839. */
  137840. static CreateTiledPlane(name: string, options: {
  137841. pattern?: number;
  137842. tileSize?: number;
  137843. tileWidth?: number;
  137844. tileHeight?: number;
  137845. size?: number;
  137846. width?: number;
  137847. height?: number;
  137848. alignHorizontal?: number;
  137849. alignVertical?: number;
  137850. sideOrientation?: number;
  137851. frontUVs?: Vector4;
  137852. backUVs?: Vector4;
  137853. updatable?: boolean;
  137854. }, scene?: Nullable<Scene>): Mesh;
  137855. }
  137856. }
  137857. declare module BABYLON {
  137858. /**
  137859. * Class containing static functions to help procedurally build meshes
  137860. */
  137861. export class TubeBuilder {
  137862. /**
  137863. * Creates a tube mesh.
  137864. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  137865. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  137866. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  137867. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  137868. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  137869. * * 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)
  137870. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  137871. * * 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
  137872. * * 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
  137873. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  137874. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  137875. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  137876. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  137877. * @param name defines the name of the mesh
  137878. * @param options defines the options used to create the mesh
  137879. * @param scene defines the hosting scene
  137880. * @returns the tube mesh
  137881. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  137882. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  137883. */
  137884. static CreateTube(name: string, options: {
  137885. path: Vector3[];
  137886. radius?: number;
  137887. tessellation?: number;
  137888. radiusFunction?: {
  137889. (i: number, distance: number): number;
  137890. };
  137891. cap?: number;
  137892. arc?: number;
  137893. updatable?: boolean;
  137894. sideOrientation?: number;
  137895. frontUVs?: Vector4;
  137896. backUVs?: Vector4;
  137897. instance?: Mesh;
  137898. invertUV?: boolean;
  137899. }, scene?: Nullable<Scene>): Mesh;
  137900. }
  137901. }
  137902. declare module BABYLON {
  137903. /**
  137904. * Class containing static functions to help procedurally build meshes
  137905. */
  137906. export class IcoSphereBuilder {
  137907. /**
  137908. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  137909. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  137910. * * 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`)
  137911. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  137912. * * 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
  137913. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  137914. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  137915. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  137916. * @param name defines the name of the mesh
  137917. * @param options defines the options used to create the mesh
  137918. * @param scene defines the hosting scene
  137919. * @returns the icosahedron mesh
  137920. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  137921. */
  137922. static CreateIcoSphere(name: string, options: {
  137923. radius?: number;
  137924. radiusX?: number;
  137925. radiusY?: number;
  137926. radiusZ?: number;
  137927. flat?: boolean;
  137928. subdivisions?: number;
  137929. sideOrientation?: number;
  137930. frontUVs?: Vector4;
  137931. backUVs?: Vector4;
  137932. updatable?: boolean;
  137933. }, scene?: Nullable<Scene>): Mesh;
  137934. }
  137935. }
  137936. declare module BABYLON {
  137937. /**
  137938. * Class containing static functions to help procedurally build meshes
  137939. */
  137940. export class DecalBuilder {
  137941. /**
  137942. * Creates a decal mesh.
  137943. * 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
  137944. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  137945. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  137946. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  137947. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  137948. * @param name defines the name of the mesh
  137949. * @param sourceMesh defines the mesh where the decal must be applied
  137950. * @param options defines the options used to create the mesh
  137951. * @param scene defines the hosting scene
  137952. * @returns the decal mesh
  137953. * @see https://doc.babylonjs.com/how_to/decals
  137954. */
  137955. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  137956. position?: Vector3;
  137957. normal?: Vector3;
  137958. size?: Vector3;
  137959. angle?: number;
  137960. }): Mesh;
  137961. }
  137962. }
  137963. declare module BABYLON {
  137964. /**
  137965. * Class containing static functions to help procedurally build meshes
  137966. */
  137967. export class MeshBuilder {
  137968. /**
  137969. * Creates a box mesh
  137970. * * The parameter `size` sets the size (float) of each box side (default 1)
  137971. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  137972. * * 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)
  137973. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  137974. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  137975. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  137976. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  137977. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  137978. * @param name defines the name of the mesh
  137979. * @param options defines the options used to create the mesh
  137980. * @param scene defines the hosting scene
  137981. * @returns the box mesh
  137982. */
  137983. static CreateBox(name: string, options: {
  137984. size?: number;
  137985. width?: number;
  137986. height?: number;
  137987. depth?: number;
  137988. faceUV?: Vector4[];
  137989. faceColors?: Color4[];
  137990. sideOrientation?: number;
  137991. frontUVs?: Vector4;
  137992. backUVs?: Vector4;
  137993. wrap?: boolean;
  137994. topBaseAt?: number;
  137995. bottomBaseAt?: number;
  137996. updatable?: boolean;
  137997. }, scene?: Nullable<Scene>): Mesh;
  137998. /**
  137999. * Creates a tiled box mesh
  138000. * * faceTiles sets the pattern, tile size and number of tiles for a face
  138001. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  138002. * @param name defines the name of the mesh
  138003. * @param options defines the options used to create the mesh
  138004. * @param scene defines the hosting scene
  138005. * @returns the tiled box mesh
  138006. */
  138007. static CreateTiledBox(name: string, options: {
  138008. pattern?: number;
  138009. size?: number;
  138010. width?: number;
  138011. height?: number;
  138012. depth: number;
  138013. tileSize?: number;
  138014. tileWidth?: number;
  138015. tileHeight?: number;
  138016. faceUV?: Vector4[];
  138017. faceColors?: Color4[];
  138018. alignHorizontal?: number;
  138019. alignVertical?: number;
  138020. sideOrientation?: number;
  138021. updatable?: boolean;
  138022. }, scene?: Nullable<Scene>): Mesh;
  138023. /**
  138024. * Creates a sphere mesh
  138025. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  138026. * * 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`)
  138027. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  138028. * * 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
  138029. * * 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)
  138030. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  138031. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  138032. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  138033. * @param name defines the name of the mesh
  138034. * @param options defines the options used to create the mesh
  138035. * @param scene defines the hosting scene
  138036. * @returns the sphere mesh
  138037. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  138038. */
  138039. static CreateSphere(name: string, options: {
  138040. segments?: number;
  138041. diameter?: number;
  138042. diameterX?: number;
  138043. diameterY?: number;
  138044. diameterZ?: number;
  138045. arc?: number;
  138046. slice?: number;
  138047. sideOrientation?: number;
  138048. frontUVs?: Vector4;
  138049. backUVs?: Vector4;
  138050. updatable?: boolean;
  138051. }, scene?: Nullable<Scene>): Mesh;
  138052. /**
  138053. * Creates a plane polygonal mesh. By default, this is a disc
  138054. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  138055. * * 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
  138056. * * 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
  138057. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  138058. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  138059. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  138060. * @param name defines the name of the mesh
  138061. * @param options defines the options used to create the mesh
  138062. * @param scene defines the hosting scene
  138063. * @returns the plane polygonal mesh
  138064. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  138065. */
  138066. static CreateDisc(name: string, options: {
  138067. radius?: number;
  138068. tessellation?: number;
  138069. arc?: number;
  138070. updatable?: boolean;
  138071. sideOrientation?: number;
  138072. frontUVs?: Vector4;
  138073. backUVs?: Vector4;
  138074. }, scene?: Nullable<Scene>): Mesh;
  138075. /**
  138076. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  138077. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  138078. * * 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`)
  138079. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  138080. * * 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
  138081. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  138082. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  138083. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  138084. * @param name defines the name of the mesh
  138085. * @param options defines the options used to create the mesh
  138086. * @param scene defines the hosting scene
  138087. * @returns the icosahedron mesh
  138088. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  138089. */
  138090. static CreateIcoSphere(name: string, options: {
  138091. radius?: number;
  138092. radiusX?: number;
  138093. radiusY?: number;
  138094. radiusZ?: number;
  138095. flat?: boolean;
  138096. subdivisions?: number;
  138097. sideOrientation?: number;
  138098. frontUVs?: Vector4;
  138099. backUVs?: Vector4;
  138100. updatable?: boolean;
  138101. }, scene?: Nullable<Scene>): Mesh;
  138102. /**
  138103. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  138104. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  138105. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  138106. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  138107. * * 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
  138108. * * 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
  138109. * * 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
  138110. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  138111. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  138112. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  138113. * * 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
  138114. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  138115. * * 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
  138116. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  138117. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  138118. * @param name defines the name of the mesh
  138119. * @param options defines the options used to create the mesh
  138120. * @param scene defines the hosting scene
  138121. * @returns the ribbon mesh
  138122. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  138123. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  138124. */
  138125. static CreateRibbon(name: string, options: {
  138126. pathArray: Vector3[][];
  138127. closeArray?: boolean;
  138128. closePath?: boolean;
  138129. offset?: number;
  138130. updatable?: boolean;
  138131. sideOrientation?: number;
  138132. frontUVs?: Vector4;
  138133. backUVs?: Vector4;
  138134. instance?: Mesh;
  138135. invertUV?: boolean;
  138136. uvs?: Vector2[];
  138137. colors?: Color4[];
  138138. }, scene?: Nullable<Scene>): Mesh;
  138139. /**
  138140. * Creates a cylinder or a cone mesh
  138141. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  138142. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  138143. * * 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.
  138144. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  138145. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  138146. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  138147. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  138148. * * 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).
  138149. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  138150. * * 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).
  138151. * * 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
  138152. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  138153. * * 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
  138154. * * 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.
  138155. * * If `enclose` is false, a ring surface is one element.
  138156. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  138157. * * 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
  138158. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  138159. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  138160. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  138161. * @param name defines the name of the mesh
  138162. * @param options defines the options used to create the mesh
  138163. * @param scene defines the hosting scene
  138164. * @returns the cylinder mesh
  138165. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  138166. */
  138167. static CreateCylinder(name: string, options: {
  138168. height?: number;
  138169. diameterTop?: number;
  138170. diameterBottom?: number;
  138171. diameter?: number;
  138172. tessellation?: number;
  138173. subdivisions?: number;
  138174. arc?: number;
  138175. faceColors?: Color4[];
  138176. faceUV?: Vector4[];
  138177. updatable?: boolean;
  138178. hasRings?: boolean;
  138179. enclose?: boolean;
  138180. cap?: number;
  138181. sideOrientation?: number;
  138182. frontUVs?: Vector4;
  138183. backUVs?: Vector4;
  138184. }, scene?: Nullable<Scene>): Mesh;
  138185. /**
  138186. * Creates a torus mesh
  138187. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  138188. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  138189. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  138190. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  138191. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  138192. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  138193. * @param name defines the name of the mesh
  138194. * @param options defines the options used to create the mesh
  138195. * @param scene defines the hosting scene
  138196. * @returns the torus mesh
  138197. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  138198. */
  138199. static CreateTorus(name: string, options: {
  138200. diameter?: number;
  138201. thickness?: number;
  138202. tessellation?: number;
  138203. updatable?: boolean;
  138204. sideOrientation?: number;
  138205. frontUVs?: Vector4;
  138206. backUVs?: Vector4;
  138207. }, scene?: Nullable<Scene>): Mesh;
  138208. /**
  138209. * Creates a torus knot mesh
  138210. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  138211. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  138212. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  138213. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  138214. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  138215. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  138216. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  138217. * @param name defines the name of the mesh
  138218. * @param options defines the options used to create the mesh
  138219. * @param scene defines the hosting scene
  138220. * @returns the torus knot mesh
  138221. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  138222. */
  138223. static CreateTorusKnot(name: string, options: {
  138224. radius?: number;
  138225. tube?: number;
  138226. radialSegments?: number;
  138227. tubularSegments?: number;
  138228. p?: number;
  138229. q?: number;
  138230. updatable?: boolean;
  138231. sideOrientation?: number;
  138232. frontUVs?: Vector4;
  138233. backUVs?: Vector4;
  138234. }, scene?: Nullable<Scene>): Mesh;
  138235. /**
  138236. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  138237. * * 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
  138238. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  138239. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  138240. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  138241. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  138242. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  138243. * * 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
  138244. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  138245. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  138246. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  138247. * @param name defines the name of the new line system
  138248. * @param options defines the options used to create the line system
  138249. * @param scene defines the hosting scene
  138250. * @returns a new line system mesh
  138251. */
  138252. static CreateLineSystem(name: string, options: {
  138253. lines: Vector3[][];
  138254. updatable?: boolean;
  138255. instance?: Nullable<LinesMesh>;
  138256. colors?: Nullable<Color4[][]>;
  138257. useVertexAlpha?: boolean;
  138258. }, scene: Nullable<Scene>): LinesMesh;
  138259. /**
  138260. * Creates a line mesh
  138261. * 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
  138262. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  138263. * * The parameter `points` is an array successive Vector3
  138264. * * 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
  138265. * * The optional parameter `colors` is an array of successive Color4, one per line point
  138266. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  138267. * * When updating an instance, remember that only point positions can change, not the number of points
  138268. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  138269. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  138270. * @param name defines the name of the new line system
  138271. * @param options defines the options used to create the line system
  138272. * @param scene defines the hosting scene
  138273. * @returns a new line mesh
  138274. */
  138275. static CreateLines(name: string, options: {
  138276. points: Vector3[];
  138277. updatable?: boolean;
  138278. instance?: Nullable<LinesMesh>;
  138279. colors?: Color4[];
  138280. useVertexAlpha?: boolean;
  138281. }, scene?: Nullable<Scene>): LinesMesh;
  138282. /**
  138283. * Creates a dashed line mesh
  138284. * * 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
  138285. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  138286. * * The parameter `points` is an array successive Vector3
  138287. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  138288. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  138289. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  138290. * * 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
  138291. * * When updating an instance, remember that only point positions can change, not the number of points
  138292. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  138293. * @param name defines the name of the mesh
  138294. * @param options defines the options used to create the mesh
  138295. * @param scene defines the hosting scene
  138296. * @returns the dashed line mesh
  138297. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  138298. */
  138299. static CreateDashedLines(name: string, options: {
  138300. points: Vector3[];
  138301. dashSize?: number;
  138302. gapSize?: number;
  138303. dashNb?: number;
  138304. updatable?: boolean;
  138305. instance?: LinesMesh;
  138306. }, scene?: Nullable<Scene>): LinesMesh;
  138307. /**
  138308. * 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.
  138309. * * 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.
  138310. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  138311. * * 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.
  138312. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  138313. * * 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
  138314. * * 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
  138315. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  138316. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  138317. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  138318. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  138319. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  138320. * @param name defines the name of the mesh
  138321. * @param options defines the options used to create the mesh
  138322. * @param scene defines the hosting scene
  138323. * @returns the extruded shape mesh
  138324. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  138325. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  138326. */
  138327. static ExtrudeShape(name: string, options: {
  138328. shape: Vector3[];
  138329. path: Vector3[];
  138330. scale?: number;
  138331. rotation?: number;
  138332. cap?: number;
  138333. updatable?: boolean;
  138334. sideOrientation?: number;
  138335. frontUVs?: Vector4;
  138336. backUVs?: Vector4;
  138337. instance?: Mesh;
  138338. invertUV?: boolean;
  138339. }, scene?: Nullable<Scene>): Mesh;
  138340. /**
  138341. * Creates an custom extruded shape mesh.
  138342. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  138343. * * 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.
  138344. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  138345. * * 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
  138346. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  138347. * * 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
  138348. * * It must returns a float value that will be the scale value applied to the shape on each path point
  138349. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  138350. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  138351. * * 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
  138352. * * 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
  138353. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  138354. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  138355. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  138356. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  138357. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  138358. * @param name defines the name of the mesh
  138359. * @param options defines the options used to create the mesh
  138360. * @param scene defines the hosting scene
  138361. * @returns the custom extruded shape mesh
  138362. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  138363. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  138364. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  138365. */
  138366. static ExtrudeShapeCustom(name: string, options: {
  138367. shape: Vector3[];
  138368. path: Vector3[];
  138369. scaleFunction?: any;
  138370. rotationFunction?: any;
  138371. ribbonCloseArray?: boolean;
  138372. ribbonClosePath?: boolean;
  138373. cap?: number;
  138374. updatable?: boolean;
  138375. sideOrientation?: number;
  138376. frontUVs?: Vector4;
  138377. backUVs?: Vector4;
  138378. instance?: Mesh;
  138379. invertUV?: boolean;
  138380. }, scene?: Nullable<Scene>): Mesh;
  138381. /**
  138382. * Creates lathe mesh.
  138383. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  138384. * * 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
  138385. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  138386. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  138387. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  138388. * * 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
  138389. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  138390. * * 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
  138391. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  138392. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  138393. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  138394. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  138395. * @param name defines the name of the mesh
  138396. * @param options defines the options used to create the mesh
  138397. * @param scene defines the hosting scene
  138398. * @returns the lathe mesh
  138399. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  138400. */
  138401. static CreateLathe(name: string, options: {
  138402. shape: Vector3[];
  138403. radius?: number;
  138404. tessellation?: number;
  138405. clip?: number;
  138406. arc?: number;
  138407. closed?: boolean;
  138408. updatable?: boolean;
  138409. sideOrientation?: number;
  138410. frontUVs?: Vector4;
  138411. backUVs?: Vector4;
  138412. cap?: number;
  138413. invertUV?: boolean;
  138414. }, scene?: Nullable<Scene>): Mesh;
  138415. /**
  138416. * Creates a tiled plane mesh
  138417. * * You can set a limited pattern arrangement with the tiles
  138418. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  138419. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  138420. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  138421. * @param name defines the name of the mesh
  138422. * @param options defines the options used to create the mesh
  138423. * @param scene defines the hosting scene
  138424. * @returns the plane mesh
  138425. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  138426. */
  138427. static CreateTiledPlane(name: string, options: {
  138428. pattern?: number;
  138429. tileSize?: number;
  138430. tileWidth?: number;
  138431. tileHeight?: number;
  138432. size?: number;
  138433. width?: number;
  138434. height?: number;
  138435. alignHorizontal?: number;
  138436. alignVertical?: number;
  138437. sideOrientation?: number;
  138438. frontUVs?: Vector4;
  138439. backUVs?: Vector4;
  138440. updatable?: boolean;
  138441. }, scene?: Nullable<Scene>): Mesh;
  138442. /**
  138443. * Creates a plane mesh
  138444. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  138445. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  138446. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  138447. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  138448. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  138449. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  138450. * @param name defines the name of the mesh
  138451. * @param options defines the options used to create the mesh
  138452. * @param scene defines the hosting scene
  138453. * @returns the plane mesh
  138454. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  138455. */
  138456. static CreatePlane(name: string, options: {
  138457. size?: number;
  138458. width?: number;
  138459. height?: number;
  138460. sideOrientation?: number;
  138461. frontUVs?: Vector4;
  138462. backUVs?: Vector4;
  138463. updatable?: boolean;
  138464. sourcePlane?: Plane;
  138465. }, scene?: Nullable<Scene>): Mesh;
  138466. /**
  138467. * Creates a ground mesh
  138468. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  138469. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  138470. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  138471. * @param name defines the name of the mesh
  138472. * @param options defines the options used to create the mesh
  138473. * @param scene defines the hosting scene
  138474. * @returns the ground mesh
  138475. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  138476. */
  138477. static CreateGround(name: string, options: {
  138478. width?: number;
  138479. height?: number;
  138480. subdivisions?: number;
  138481. subdivisionsX?: number;
  138482. subdivisionsY?: number;
  138483. updatable?: boolean;
  138484. }, scene?: Nullable<Scene>): Mesh;
  138485. /**
  138486. * Creates a tiled ground mesh
  138487. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  138488. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  138489. * * 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
  138490. * * 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
  138491. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  138492. * @param name defines the name of the mesh
  138493. * @param options defines the options used to create the mesh
  138494. * @param scene defines the hosting scene
  138495. * @returns the tiled ground mesh
  138496. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  138497. */
  138498. static CreateTiledGround(name: string, options: {
  138499. xmin: number;
  138500. zmin: number;
  138501. xmax: number;
  138502. zmax: number;
  138503. subdivisions?: {
  138504. w: number;
  138505. h: number;
  138506. };
  138507. precision?: {
  138508. w: number;
  138509. h: number;
  138510. };
  138511. updatable?: boolean;
  138512. }, scene?: Nullable<Scene>): Mesh;
  138513. /**
  138514. * Creates a ground mesh from a height map
  138515. * * The parameter `url` sets the URL of the height map image resource.
  138516. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  138517. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  138518. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  138519. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  138520. * * 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.
  138521. * * 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).
  138522. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  138523. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  138524. * @param name defines the name of the mesh
  138525. * @param url defines the url to the height map
  138526. * @param options defines the options used to create the mesh
  138527. * @param scene defines the hosting scene
  138528. * @returns the ground mesh
  138529. * @see https://doc.babylonjs.com/babylon101/height_map
  138530. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  138531. */
  138532. static CreateGroundFromHeightMap(name: string, url: string, options: {
  138533. width?: number;
  138534. height?: number;
  138535. subdivisions?: number;
  138536. minHeight?: number;
  138537. maxHeight?: number;
  138538. colorFilter?: Color3;
  138539. alphaFilter?: number;
  138540. updatable?: boolean;
  138541. onReady?: (mesh: GroundMesh) => void;
  138542. }, scene?: Nullable<Scene>): GroundMesh;
  138543. /**
  138544. * Creates a polygon mesh
  138545. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  138546. * * 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
  138547. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  138548. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  138549. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  138550. * * Remember you can only change the shape positions, not their number when updating a polygon
  138551. * @param name defines the name of the mesh
  138552. * @param options defines the options used to create the mesh
  138553. * @param scene defines the hosting scene
  138554. * @param earcutInjection can be used to inject your own earcut reference
  138555. * @returns the polygon mesh
  138556. */
  138557. static CreatePolygon(name: string, options: {
  138558. shape: Vector3[];
  138559. holes?: Vector3[][];
  138560. depth?: number;
  138561. faceUV?: Vector4[];
  138562. faceColors?: Color4[];
  138563. updatable?: boolean;
  138564. sideOrientation?: number;
  138565. frontUVs?: Vector4;
  138566. backUVs?: Vector4;
  138567. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  138568. /**
  138569. * Creates an extruded polygon mesh, with depth in the Y direction.
  138570. * * 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)
  138571. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  138572. * @param name defines the name of the mesh
  138573. * @param options defines the options used to create the mesh
  138574. * @param scene defines the hosting scene
  138575. * @param earcutInjection can be used to inject your own earcut reference
  138576. * @returns the polygon mesh
  138577. */
  138578. static ExtrudePolygon(name: string, options: {
  138579. shape: Vector3[];
  138580. holes?: Vector3[][];
  138581. depth?: number;
  138582. faceUV?: Vector4[];
  138583. faceColors?: Color4[];
  138584. updatable?: boolean;
  138585. sideOrientation?: number;
  138586. frontUVs?: Vector4;
  138587. backUVs?: Vector4;
  138588. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  138589. /**
  138590. * Creates a tube mesh.
  138591. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  138592. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  138593. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  138594. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  138595. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  138596. * * 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)
  138597. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  138598. * * 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
  138599. * * 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
  138600. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  138601. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  138602. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  138603. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  138604. * @param name defines the name of the mesh
  138605. * @param options defines the options used to create the mesh
  138606. * @param scene defines the hosting scene
  138607. * @returns the tube mesh
  138608. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  138609. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  138610. */
  138611. static CreateTube(name: string, options: {
  138612. path: Vector3[];
  138613. radius?: number;
  138614. tessellation?: number;
  138615. radiusFunction?: {
  138616. (i: number, distance: number): number;
  138617. };
  138618. cap?: number;
  138619. arc?: number;
  138620. updatable?: boolean;
  138621. sideOrientation?: number;
  138622. frontUVs?: Vector4;
  138623. backUVs?: Vector4;
  138624. instance?: Mesh;
  138625. invertUV?: boolean;
  138626. }, scene?: Nullable<Scene>): Mesh;
  138627. /**
  138628. * Creates a polyhedron mesh
  138629. * * 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
  138630. * * The parameter `size` (positive float, default 1) sets the polygon size
  138631. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  138632. * * 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`
  138633. * * 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
  138634. * * 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)`)
  138635. * * 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
  138636. * * 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
  138637. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  138638. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  138639. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  138640. * @param name defines the name of the mesh
  138641. * @param options defines the options used to create the mesh
  138642. * @param scene defines the hosting scene
  138643. * @returns the polyhedron mesh
  138644. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  138645. */
  138646. static CreatePolyhedron(name: string, options: {
  138647. type?: number;
  138648. size?: number;
  138649. sizeX?: number;
  138650. sizeY?: number;
  138651. sizeZ?: number;
  138652. custom?: any;
  138653. faceUV?: Vector4[];
  138654. faceColors?: Color4[];
  138655. flat?: boolean;
  138656. updatable?: boolean;
  138657. sideOrientation?: number;
  138658. frontUVs?: Vector4;
  138659. backUVs?: Vector4;
  138660. }, scene?: Nullable<Scene>): Mesh;
  138661. /**
  138662. * Creates a decal mesh.
  138663. * 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
  138664. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  138665. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  138666. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  138667. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  138668. * @param name defines the name of the mesh
  138669. * @param sourceMesh defines the mesh where the decal must be applied
  138670. * @param options defines the options used to create the mesh
  138671. * @param scene defines the hosting scene
  138672. * @returns the decal mesh
  138673. * @see https://doc.babylonjs.com/how_to/decals
  138674. */
  138675. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  138676. position?: Vector3;
  138677. normal?: Vector3;
  138678. size?: Vector3;
  138679. angle?: number;
  138680. }): Mesh;
  138681. }
  138682. }
  138683. declare module BABYLON {
  138684. /**
  138685. * A simplifier interface for future simplification implementations
  138686. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  138687. */
  138688. export interface ISimplifier {
  138689. /**
  138690. * Simplification of a given mesh according to the given settings.
  138691. * Since this requires computation, it is assumed that the function runs async.
  138692. * @param settings The settings of the simplification, including quality and distance
  138693. * @param successCallback A callback that will be called after the mesh was simplified.
  138694. * @param errorCallback in case of an error, this callback will be called. optional.
  138695. */
  138696. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  138697. }
  138698. /**
  138699. * Expected simplification settings.
  138700. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  138701. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  138702. */
  138703. export interface ISimplificationSettings {
  138704. /**
  138705. * Gets or sets the expected quality
  138706. */
  138707. quality: number;
  138708. /**
  138709. * Gets or sets the distance when this optimized version should be used
  138710. */
  138711. distance: number;
  138712. /**
  138713. * Gets an already optimized mesh
  138714. */
  138715. optimizeMesh?: boolean;
  138716. }
  138717. /**
  138718. * Class used to specify simplification options
  138719. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  138720. */
  138721. export class SimplificationSettings implements ISimplificationSettings {
  138722. /** expected quality */
  138723. quality: number;
  138724. /** distance when this optimized version should be used */
  138725. distance: number;
  138726. /** already optimized mesh */
  138727. optimizeMesh?: boolean | undefined;
  138728. /**
  138729. * Creates a SimplificationSettings
  138730. * @param quality expected quality
  138731. * @param distance distance when this optimized version should be used
  138732. * @param optimizeMesh already optimized mesh
  138733. */
  138734. constructor(
  138735. /** expected quality */
  138736. quality: number,
  138737. /** distance when this optimized version should be used */
  138738. distance: number,
  138739. /** already optimized mesh */
  138740. optimizeMesh?: boolean | undefined);
  138741. }
  138742. /**
  138743. * Interface used to define a simplification task
  138744. */
  138745. export interface ISimplificationTask {
  138746. /**
  138747. * Array of settings
  138748. */
  138749. settings: Array<ISimplificationSettings>;
  138750. /**
  138751. * Simplification type
  138752. */
  138753. simplificationType: SimplificationType;
  138754. /**
  138755. * Mesh to simplify
  138756. */
  138757. mesh: Mesh;
  138758. /**
  138759. * Callback called on success
  138760. */
  138761. successCallback?: () => void;
  138762. /**
  138763. * Defines if parallel processing can be used
  138764. */
  138765. parallelProcessing: boolean;
  138766. }
  138767. /**
  138768. * Queue used to order the simplification tasks
  138769. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  138770. */
  138771. export class SimplificationQueue {
  138772. private _simplificationArray;
  138773. /**
  138774. * Gets a boolean indicating that the process is still running
  138775. */
  138776. running: boolean;
  138777. /**
  138778. * Creates a new queue
  138779. */
  138780. constructor();
  138781. /**
  138782. * Adds a new simplification task
  138783. * @param task defines a task to add
  138784. */
  138785. addTask(task: ISimplificationTask): void;
  138786. /**
  138787. * Execute next task
  138788. */
  138789. executeNext(): void;
  138790. /**
  138791. * Execute a simplification task
  138792. * @param task defines the task to run
  138793. */
  138794. runSimplification(task: ISimplificationTask): void;
  138795. private getSimplifier;
  138796. }
  138797. /**
  138798. * The implemented types of simplification
  138799. * At the moment only Quadratic Error Decimation is implemented
  138800. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  138801. */
  138802. export enum SimplificationType {
  138803. /** Quadratic error decimation */
  138804. QUADRATIC = 0
  138805. }
  138806. /**
  138807. * An implementation of the Quadratic Error simplification algorithm.
  138808. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  138809. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  138810. * @author RaananW
  138811. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  138812. */
  138813. export class QuadraticErrorSimplification implements ISimplifier {
  138814. private _mesh;
  138815. private triangles;
  138816. private vertices;
  138817. private references;
  138818. private _reconstructedMesh;
  138819. /** Gets or sets the number pf sync interations */
  138820. syncIterations: number;
  138821. /** Gets or sets the aggressiveness of the simplifier */
  138822. aggressiveness: number;
  138823. /** Gets or sets the number of allowed iterations for decimation */
  138824. decimationIterations: number;
  138825. /** Gets or sets the espilon to use for bounding box computation */
  138826. boundingBoxEpsilon: number;
  138827. /**
  138828. * Creates a new QuadraticErrorSimplification
  138829. * @param _mesh defines the target mesh
  138830. */
  138831. constructor(_mesh: Mesh);
  138832. /**
  138833. * Simplification of a given mesh according to the given settings.
  138834. * Since this requires computation, it is assumed that the function runs async.
  138835. * @param settings The settings of the simplification, including quality and distance
  138836. * @param successCallback A callback that will be called after the mesh was simplified.
  138837. */
  138838. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  138839. private runDecimation;
  138840. private initWithMesh;
  138841. private init;
  138842. private reconstructMesh;
  138843. private initDecimatedMesh;
  138844. private isFlipped;
  138845. private updateTriangles;
  138846. private identifyBorder;
  138847. private updateMesh;
  138848. private vertexError;
  138849. private calculateError;
  138850. }
  138851. }
  138852. declare module BABYLON {
  138853. interface Scene {
  138854. /** @hidden (Backing field) */
  138855. _simplificationQueue: SimplificationQueue;
  138856. /**
  138857. * Gets or sets the simplification queue attached to the scene
  138858. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  138859. */
  138860. simplificationQueue: SimplificationQueue;
  138861. }
  138862. interface Mesh {
  138863. /**
  138864. * Simplify the mesh according to the given array of settings.
  138865. * Function will return immediately and will simplify async
  138866. * @param settings a collection of simplification settings
  138867. * @param parallelProcessing should all levels calculate parallel or one after the other
  138868. * @param simplificationType the type of simplification to run
  138869. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  138870. * @returns the current mesh
  138871. */
  138872. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  138873. }
  138874. /**
  138875. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  138876. * created in a scene
  138877. */
  138878. export class SimplicationQueueSceneComponent implements ISceneComponent {
  138879. /**
  138880. * The component name helpfull to identify the component in the list of scene components.
  138881. */
  138882. readonly name: string;
  138883. /**
  138884. * The scene the component belongs to.
  138885. */
  138886. scene: Scene;
  138887. /**
  138888. * Creates a new instance of the component for the given scene
  138889. * @param scene Defines the scene to register the component in
  138890. */
  138891. constructor(scene: Scene);
  138892. /**
  138893. * Registers the component in a given scene
  138894. */
  138895. register(): void;
  138896. /**
  138897. * Rebuilds the elements related to this component in case of
  138898. * context lost for instance.
  138899. */
  138900. rebuild(): void;
  138901. /**
  138902. * Disposes the component and the associated ressources
  138903. */
  138904. dispose(): void;
  138905. private _beforeCameraUpdate;
  138906. }
  138907. }
  138908. declare module BABYLON {
  138909. /**
  138910. * Navigation plugin interface to add navigation constrained by a navigation mesh
  138911. */
  138912. export interface INavigationEnginePlugin {
  138913. /**
  138914. * plugin name
  138915. */
  138916. name: string;
  138917. /**
  138918. * Creates a navigation mesh
  138919. * @param meshes array of all the geometry used to compute the navigatio mesh
  138920. * @param parameters bunch of parameters used to filter geometry
  138921. */
  138922. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  138923. /**
  138924. * Create a navigation mesh debug mesh
  138925. * @param scene is where the mesh will be added
  138926. * @returns debug display mesh
  138927. */
  138928. createDebugNavMesh(scene: Scene): Mesh;
  138929. /**
  138930. * Get a navigation mesh constrained position, closest to the parameter position
  138931. * @param position world position
  138932. * @returns the closest point to position constrained by the navigation mesh
  138933. */
  138934. getClosestPoint(position: Vector3): Vector3;
  138935. /**
  138936. * Get a navigation mesh constrained position, closest to the parameter position
  138937. * @param position world position
  138938. * @param result output the closest point to position constrained by the navigation mesh
  138939. */
  138940. getClosestPointToRef(position: Vector3, result: Vector3): void;
  138941. /**
  138942. * Get a navigation mesh constrained position, within a particular radius
  138943. * @param position world position
  138944. * @param maxRadius the maximum distance to the constrained world position
  138945. * @returns the closest point to position constrained by the navigation mesh
  138946. */
  138947. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  138948. /**
  138949. * Get a navigation mesh constrained position, within a particular radius
  138950. * @param position world position
  138951. * @param maxRadius the maximum distance to the constrained world position
  138952. * @param result output the closest point to position constrained by the navigation mesh
  138953. */
  138954. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  138955. /**
  138956. * Compute the final position from a segment made of destination-position
  138957. * @param position world position
  138958. * @param destination world position
  138959. * @returns the resulting point along the navmesh
  138960. */
  138961. moveAlong(position: Vector3, destination: Vector3): Vector3;
  138962. /**
  138963. * Compute the final position from a segment made of destination-position
  138964. * @param position world position
  138965. * @param destination world position
  138966. * @param result output the resulting point along the navmesh
  138967. */
  138968. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  138969. /**
  138970. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  138971. * @param start world position
  138972. * @param end world position
  138973. * @returns array containing world position composing the path
  138974. */
  138975. computePath(start: Vector3, end: Vector3): Vector3[];
  138976. /**
  138977. * If this plugin is supported
  138978. * @returns true if plugin is supported
  138979. */
  138980. isSupported(): boolean;
  138981. /**
  138982. * Create a new Crowd so you can add agents
  138983. * @param maxAgents the maximum agent count in the crowd
  138984. * @param maxAgentRadius the maximum radius an agent can have
  138985. * @param scene to attach the crowd to
  138986. * @returns the crowd you can add agents to
  138987. */
  138988. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  138989. /**
  138990. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  138991. * The queries will try to find a solution within those bounds
  138992. * default is (1,1,1)
  138993. * @param extent x,y,z value that define the extent around the queries point of reference
  138994. */
  138995. setDefaultQueryExtent(extent: Vector3): void;
  138996. /**
  138997. * Get the Bounding box extent specified by setDefaultQueryExtent
  138998. * @returns the box extent values
  138999. */
  139000. getDefaultQueryExtent(): Vector3;
  139001. /**
  139002. * build the navmesh from a previously saved state using getNavmeshData
  139003. * @param data the Uint8Array returned by getNavmeshData
  139004. */
  139005. buildFromNavmeshData(data: Uint8Array): void;
  139006. /**
  139007. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  139008. * @returns data the Uint8Array that can be saved and reused
  139009. */
  139010. getNavmeshData(): Uint8Array;
  139011. /**
  139012. * Get the Bounding box extent result specified by setDefaultQueryExtent
  139013. * @param result output the box extent values
  139014. */
  139015. getDefaultQueryExtentToRef(result: Vector3): void;
  139016. /**
  139017. * Release all resources
  139018. */
  139019. dispose(): void;
  139020. }
  139021. /**
  139022. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  139023. */
  139024. export interface ICrowd {
  139025. /**
  139026. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  139027. * You can attach anything to that node. The node position is updated in the scene update tick.
  139028. * @param pos world position that will be constrained by the navigation mesh
  139029. * @param parameters agent parameters
  139030. * @param transform hooked to the agent that will be update by the scene
  139031. * @returns agent index
  139032. */
  139033. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  139034. /**
  139035. * Returns the agent position in world space
  139036. * @param index agent index returned by addAgent
  139037. * @returns world space position
  139038. */
  139039. getAgentPosition(index: number): Vector3;
  139040. /**
  139041. * Gets the agent position result in world space
  139042. * @param index agent index returned by addAgent
  139043. * @param result output world space position
  139044. */
  139045. getAgentPositionToRef(index: number, result: Vector3): void;
  139046. /**
  139047. * Gets the agent velocity in world space
  139048. * @param index agent index returned by addAgent
  139049. * @returns world space velocity
  139050. */
  139051. getAgentVelocity(index: number): Vector3;
  139052. /**
  139053. * Gets the agent velocity result in world space
  139054. * @param index agent index returned by addAgent
  139055. * @param result output world space velocity
  139056. */
  139057. getAgentVelocityToRef(index: number, result: Vector3): void;
  139058. /**
  139059. * remove a particular agent previously created
  139060. * @param index agent index returned by addAgent
  139061. */
  139062. removeAgent(index: number): void;
  139063. /**
  139064. * get the list of all agents attached to this crowd
  139065. * @returns list of agent indices
  139066. */
  139067. getAgents(): number[];
  139068. /**
  139069. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  139070. * @param deltaTime in seconds
  139071. */
  139072. update(deltaTime: number): void;
  139073. /**
  139074. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  139075. * @param index agent index returned by addAgent
  139076. * @param destination targeted world position
  139077. */
  139078. agentGoto(index: number, destination: Vector3): void;
  139079. /**
  139080. * Teleport the agent to a new position
  139081. * @param index agent index returned by addAgent
  139082. * @param destination targeted world position
  139083. */
  139084. agentTeleport(index: number, destination: Vector3): void;
  139085. /**
  139086. * Update agent parameters
  139087. * @param index agent index returned by addAgent
  139088. * @param parameters agent parameters
  139089. */
  139090. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  139091. /**
  139092. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  139093. * The queries will try to find a solution within those bounds
  139094. * default is (1,1,1)
  139095. * @param extent x,y,z value that define the extent around the queries point of reference
  139096. */
  139097. setDefaultQueryExtent(extent: Vector3): void;
  139098. /**
  139099. * Get the Bounding box extent specified by setDefaultQueryExtent
  139100. * @returns the box extent values
  139101. */
  139102. getDefaultQueryExtent(): Vector3;
  139103. /**
  139104. * Get the Bounding box extent result specified by setDefaultQueryExtent
  139105. * @param result output the box extent values
  139106. */
  139107. getDefaultQueryExtentToRef(result: Vector3): void;
  139108. /**
  139109. * Release all resources
  139110. */
  139111. dispose(): void;
  139112. }
  139113. /**
  139114. * Configures an agent
  139115. */
  139116. export interface IAgentParameters {
  139117. /**
  139118. * Agent radius. [Limit: >= 0]
  139119. */
  139120. radius: number;
  139121. /**
  139122. * Agent height. [Limit: > 0]
  139123. */
  139124. height: number;
  139125. /**
  139126. * Maximum allowed acceleration. [Limit: >= 0]
  139127. */
  139128. maxAcceleration: number;
  139129. /**
  139130. * Maximum allowed speed. [Limit: >= 0]
  139131. */
  139132. maxSpeed: number;
  139133. /**
  139134. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  139135. */
  139136. collisionQueryRange: number;
  139137. /**
  139138. * The path visibility optimization range. [Limit: > 0]
  139139. */
  139140. pathOptimizationRange: number;
  139141. /**
  139142. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  139143. */
  139144. separationWeight: number;
  139145. }
  139146. /**
  139147. * Configures the navigation mesh creation
  139148. */
  139149. export interface INavMeshParameters {
  139150. /**
  139151. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  139152. */
  139153. cs: number;
  139154. /**
  139155. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  139156. */
  139157. ch: number;
  139158. /**
  139159. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  139160. */
  139161. walkableSlopeAngle: number;
  139162. /**
  139163. * Minimum floor to 'ceiling' height that will still allow the floor area to
  139164. * be considered walkable. [Limit: >= 3] [Units: vx]
  139165. */
  139166. walkableHeight: number;
  139167. /**
  139168. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  139169. */
  139170. walkableClimb: number;
  139171. /**
  139172. * The distance to erode/shrink the walkable area of the heightfield away from
  139173. * obstructions. [Limit: >=0] [Units: vx]
  139174. */
  139175. walkableRadius: number;
  139176. /**
  139177. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  139178. */
  139179. maxEdgeLen: number;
  139180. /**
  139181. * The maximum distance a simplfied contour's border edges should deviate
  139182. * the original raw contour. [Limit: >=0] [Units: vx]
  139183. */
  139184. maxSimplificationError: number;
  139185. /**
  139186. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  139187. */
  139188. minRegionArea: number;
  139189. /**
  139190. * Any regions with a span count smaller than this value will, if possible,
  139191. * be merged with larger regions. [Limit: >=0] [Units: vx]
  139192. */
  139193. mergeRegionArea: number;
  139194. /**
  139195. * The maximum number of vertices allowed for polygons generated during the
  139196. * contour to polygon conversion process. [Limit: >= 3]
  139197. */
  139198. maxVertsPerPoly: number;
  139199. /**
  139200. * Sets the sampling distance to use when generating the detail mesh.
  139201. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  139202. */
  139203. detailSampleDist: number;
  139204. /**
  139205. * The maximum distance the detail mesh surface should deviate from heightfield
  139206. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  139207. */
  139208. detailSampleMaxError: number;
  139209. }
  139210. }
  139211. declare module BABYLON {
  139212. /**
  139213. * RecastJS navigation plugin
  139214. */
  139215. export class RecastJSPlugin implements INavigationEnginePlugin {
  139216. /**
  139217. * Reference to the Recast library
  139218. */
  139219. bjsRECAST: any;
  139220. /**
  139221. * plugin name
  139222. */
  139223. name: string;
  139224. /**
  139225. * the first navmesh created. We might extend this to support multiple navmeshes
  139226. */
  139227. navMesh: any;
  139228. /**
  139229. * Initializes the recastJS plugin
  139230. * @param recastInjection can be used to inject your own recast reference
  139231. */
  139232. constructor(recastInjection?: any);
  139233. /**
  139234. * Creates a navigation mesh
  139235. * @param meshes array of all the geometry used to compute the navigatio mesh
  139236. * @param parameters bunch of parameters used to filter geometry
  139237. */
  139238. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  139239. /**
  139240. * Create a navigation mesh debug mesh
  139241. * @param scene is where the mesh will be added
  139242. * @returns debug display mesh
  139243. */
  139244. createDebugNavMesh(scene: Scene): Mesh;
  139245. /**
  139246. * Get a navigation mesh constrained position, closest to the parameter position
  139247. * @param position world position
  139248. * @returns the closest point to position constrained by the navigation mesh
  139249. */
  139250. getClosestPoint(position: Vector3): Vector3;
  139251. /**
  139252. * Get a navigation mesh constrained position, closest to the parameter position
  139253. * @param position world position
  139254. * @param result output the closest point to position constrained by the navigation mesh
  139255. */
  139256. getClosestPointToRef(position: Vector3, result: Vector3): void;
  139257. /**
  139258. * Get a navigation mesh constrained position, within a particular radius
  139259. * @param position world position
  139260. * @param maxRadius the maximum distance to the constrained world position
  139261. * @returns the closest point to position constrained by the navigation mesh
  139262. */
  139263. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  139264. /**
  139265. * Get a navigation mesh constrained position, within a particular radius
  139266. * @param position world position
  139267. * @param maxRadius the maximum distance to the constrained world position
  139268. * @param result output the closest point to position constrained by the navigation mesh
  139269. */
  139270. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  139271. /**
  139272. * Compute the final position from a segment made of destination-position
  139273. * @param position world position
  139274. * @param destination world position
  139275. * @returns the resulting point along the navmesh
  139276. */
  139277. moveAlong(position: Vector3, destination: Vector3): Vector3;
  139278. /**
  139279. * Compute the final position from a segment made of destination-position
  139280. * @param position world position
  139281. * @param destination world position
  139282. * @param result output the resulting point along the navmesh
  139283. */
  139284. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  139285. /**
  139286. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  139287. * @param start world position
  139288. * @param end world position
  139289. * @returns array containing world position composing the path
  139290. */
  139291. computePath(start: Vector3, end: Vector3): Vector3[];
  139292. /**
  139293. * Create a new Crowd so you can add agents
  139294. * @param maxAgents the maximum agent count in the crowd
  139295. * @param maxAgentRadius the maximum radius an agent can have
  139296. * @param scene to attach the crowd to
  139297. * @returns the crowd you can add agents to
  139298. */
  139299. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  139300. /**
  139301. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  139302. * The queries will try to find a solution within those bounds
  139303. * default is (1,1,1)
  139304. * @param extent x,y,z value that define the extent around the queries point of reference
  139305. */
  139306. setDefaultQueryExtent(extent: Vector3): void;
  139307. /**
  139308. * Get the Bounding box extent specified by setDefaultQueryExtent
  139309. * @returns the box extent values
  139310. */
  139311. getDefaultQueryExtent(): Vector3;
  139312. /**
  139313. * build the navmesh from a previously saved state using getNavmeshData
  139314. * @param data the Uint8Array returned by getNavmeshData
  139315. */
  139316. buildFromNavmeshData(data: Uint8Array): void;
  139317. /**
  139318. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  139319. * @returns data the Uint8Array that can be saved and reused
  139320. */
  139321. getNavmeshData(): Uint8Array;
  139322. /**
  139323. * Get the Bounding box extent result specified by setDefaultQueryExtent
  139324. * @param result output the box extent values
  139325. */
  139326. getDefaultQueryExtentToRef(result: Vector3): void;
  139327. /**
  139328. * Disposes
  139329. */
  139330. dispose(): void;
  139331. /**
  139332. * If this plugin is supported
  139333. * @returns true if plugin is supported
  139334. */
  139335. isSupported(): boolean;
  139336. }
  139337. /**
  139338. * Recast detour crowd implementation
  139339. */
  139340. export class RecastJSCrowd implements ICrowd {
  139341. /**
  139342. * Recast/detour plugin
  139343. */
  139344. bjsRECASTPlugin: RecastJSPlugin;
  139345. /**
  139346. * Link to the detour crowd
  139347. */
  139348. recastCrowd: any;
  139349. /**
  139350. * One transform per agent
  139351. */
  139352. transforms: TransformNode[];
  139353. /**
  139354. * All agents created
  139355. */
  139356. agents: number[];
  139357. /**
  139358. * Link to the scene is kept to unregister the crowd from the scene
  139359. */
  139360. private _scene;
  139361. /**
  139362. * Observer for crowd updates
  139363. */
  139364. private _onBeforeAnimationsObserver;
  139365. /**
  139366. * Constructor
  139367. * @param plugin recastJS plugin
  139368. * @param maxAgents the maximum agent count in the crowd
  139369. * @param maxAgentRadius the maximum radius an agent can have
  139370. * @param scene to attach the crowd to
  139371. * @returns the crowd you can add agents to
  139372. */
  139373. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  139374. /**
  139375. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  139376. * You can attach anything to that node. The node position is updated in the scene update tick.
  139377. * @param pos world position that will be constrained by the navigation mesh
  139378. * @param parameters agent parameters
  139379. * @param transform hooked to the agent that will be update by the scene
  139380. * @returns agent index
  139381. */
  139382. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  139383. /**
  139384. * Returns the agent position in world space
  139385. * @param index agent index returned by addAgent
  139386. * @returns world space position
  139387. */
  139388. getAgentPosition(index: number): Vector3;
  139389. /**
  139390. * Returns the agent position result in world space
  139391. * @param index agent index returned by addAgent
  139392. * @param result output world space position
  139393. */
  139394. getAgentPositionToRef(index: number, result: Vector3): void;
  139395. /**
  139396. * Returns the agent velocity in world space
  139397. * @param index agent index returned by addAgent
  139398. * @returns world space velocity
  139399. */
  139400. getAgentVelocity(index: number): Vector3;
  139401. /**
  139402. * Returns the agent velocity result in world space
  139403. * @param index agent index returned by addAgent
  139404. * @param result output world space velocity
  139405. */
  139406. getAgentVelocityToRef(index: number, result: Vector3): void;
  139407. /**
  139408. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  139409. * @param index agent index returned by addAgent
  139410. * @param destination targeted world position
  139411. */
  139412. agentGoto(index: number, destination: Vector3): void;
  139413. /**
  139414. * Teleport the agent to a new position
  139415. * @param index agent index returned by addAgent
  139416. * @param destination targeted world position
  139417. */
  139418. agentTeleport(index: number, destination: Vector3): void;
  139419. /**
  139420. * Update agent parameters
  139421. * @param index agent index returned by addAgent
  139422. * @param parameters agent parameters
  139423. */
  139424. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  139425. /**
  139426. * remove a particular agent previously created
  139427. * @param index agent index returned by addAgent
  139428. */
  139429. removeAgent(index: number): void;
  139430. /**
  139431. * get the list of all agents attached to this crowd
  139432. * @returns list of agent indices
  139433. */
  139434. getAgents(): number[];
  139435. /**
  139436. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  139437. * @param deltaTime in seconds
  139438. */
  139439. update(deltaTime: number): void;
  139440. /**
  139441. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  139442. * The queries will try to find a solution within those bounds
  139443. * default is (1,1,1)
  139444. * @param extent x,y,z value that define the extent around the queries point of reference
  139445. */
  139446. setDefaultQueryExtent(extent: Vector3): void;
  139447. /**
  139448. * Get the Bounding box extent specified by setDefaultQueryExtent
  139449. * @returns the box extent values
  139450. */
  139451. getDefaultQueryExtent(): Vector3;
  139452. /**
  139453. * Get the Bounding box extent result specified by setDefaultQueryExtent
  139454. * @param result output the box extent values
  139455. */
  139456. getDefaultQueryExtentToRef(result: Vector3): void;
  139457. /**
  139458. * Release all resources
  139459. */
  139460. dispose(): void;
  139461. }
  139462. }
  139463. declare module BABYLON {
  139464. /**
  139465. * Class used to enable access to IndexedDB
  139466. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  139467. */
  139468. export class Database implements IOfflineProvider {
  139469. private _callbackManifestChecked;
  139470. private _currentSceneUrl;
  139471. private _db;
  139472. private _enableSceneOffline;
  139473. private _enableTexturesOffline;
  139474. private _manifestVersionFound;
  139475. private _mustUpdateRessources;
  139476. private _hasReachedQuota;
  139477. private _isSupported;
  139478. private _idbFactory;
  139479. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  139480. private static IsUASupportingBlobStorage;
  139481. /**
  139482. * Gets a boolean indicating if Database storate is enabled (off by default)
  139483. */
  139484. static IDBStorageEnabled: boolean;
  139485. /**
  139486. * Gets a boolean indicating if scene must be saved in the database
  139487. */
  139488. get enableSceneOffline(): boolean;
  139489. /**
  139490. * Gets a boolean indicating if textures must be saved in the database
  139491. */
  139492. get enableTexturesOffline(): boolean;
  139493. /**
  139494. * Creates a new Database
  139495. * @param urlToScene defines the url to load the scene
  139496. * @param callbackManifestChecked defines the callback to use when manifest is checked
  139497. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  139498. */
  139499. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  139500. private static _ParseURL;
  139501. private static _ReturnFullUrlLocation;
  139502. private _checkManifestFile;
  139503. /**
  139504. * Open the database and make it available
  139505. * @param successCallback defines the callback to call on success
  139506. * @param errorCallback defines the callback to call on error
  139507. */
  139508. open(successCallback: () => void, errorCallback: () => void): void;
  139509. /**
  139510. * Loads an image from the database
  139511. * @param url defines the url to load from
  139512. * @param image defines the target DOM image
  139513. */
  139514. loadImage(url: string, image: HTMLImageElement): void;
  139515. private _loadImageFromDBAsync;
  139516. private _saveImageIntoDBAsync;
  139517. private _checkVersionFromDB;
  139518. private _loadVersionFromDBAsync;
  139519. private _saveVersionIntoDBAsync;
  139520. /**
  139521. * Loads a file from database
  139522. * @param url defines the URL to load from
  139523. * @param sceneLoaded defines a callback to call on success
  139524. * @param progressCallBack defines a callback to call when progress changed
  139525. * @param errorCallback defines a callback to call on error
  139526. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  139527. */
  139528. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  139529. private _loadFileAsync;
  139530. private _saveFileAsync;
  139531. /**
  139532. * Validates if xhr data is correct
  139533. * @param xhr defines the request to validate
  139534. * @param dataType defines the expected data type
  139535. * @returns true if data is correct
  139536. */
  139537. private static _ValidateXHRData;
  139538. }
  139539. }
  139540. declare module BABYLON {
  139541. /** @hidden */
  139542. export var gpuUpdateParticlesPixelShader: {
  139543. name: string;
  139544. shader: string;
  139545. };
  139546. }
  139547. declare module BABYLON {
  139548. /** @hidden */
  139549. export var gpuUpdateParticlesVertexShader: {
  139550. name: string;
  139551. shader: string;
  139552. };
  139553. }
  139554. declare module BABYLON {
  139555. /** @hidden */
  139556. export var clipPlaneFragmentDeclaration2: {
  139557. name: string;
  139558. shader: string;
  139559. };
  139560. }
  139561. declare module BABYLON {
  139562. /** @hidden */
  139563. export var gpuRenderParticlesPixelShader: {
  139564. name: string;
  139565. shader: string;
  139566. };
  139567. }
  139568. declare module BABYLON {
  139569. /** @hidden */
  139570. export var clipPlaneVertexDeclaration2: {
  139571. name: string;
  139572. shader: string;
  139573. };
  139574. }
  139575. declare module BABYLON {
  139576. /** @hidden */
  139577. export var gpuRenderParticlesVertexShader: {
  139578. name: string;
  139579. shader: string;
  139580. };
  139581. }
  139582. declare module BABYLON {
  139583. /**
  139584. * This represents a GPU particle system in Babylon
  139585. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  139586. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  139587. */
  139588. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  139589. /**
  139590. * The layer mask we are rendering the particles through.
  139591. */
  139592. layerMask: number;
  139593. private _capacity;
  139594. private _activeCount;
  139595. private _currentActiveCount;
  139596. private _accumulatedCount;
  139597. private _renderEffect;
  139598. private _updateEffect;
  139599. private _buffer0;
  139600. private _buffer1;
  139601. private _spriteBuffer;
  139602. private _updateVAO;
  139603. private _renderVAO;
  139604. private _targetIndex;
  139605. private _sourceBuffer;
  139606. private _targetBuffer;
  139607. private _engine;
  139608. private _currentRenderId;
  139609. private _started;
  139610. private _stopped;
  139611. private _timeDelta;
  139612. private _randomTexture;
  139613. private _randomTexture2;
  139614. private _attributesStrideSize;
  139615. private _updateEffectOptions;
  139616. private _randomTextureSize;
  139617. private _actualFrame;
  139618. private readonly _rawTextureWidth;
  139619. /**
  139620. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  139621. */
  139622. static get IsSupported(): boolean;
  139623. /**
  139624. * An event triggered when the system is disposed.
  139625. */
  139626. onDisposeObservable: Observable<GPUParticleSystem>;
  139627. /**
  139628. * Gets the maximum number of particles active at the same time.
  139629. * @returns The max number of active particles.
  139630. */
  139631. getCapacity(): number;
  139632. /**
  139633. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  139634. * to override the particles.
  139635. */
  139636. forceDepthWrite: boolean;
  139637. /**
  139638. * Gets or set the number of active particles
  139639. */
  139640. get activeParticleCount(): number;
  139641. set activeParticleCount(value: number);
  139642. private _preWarmDone;
  139643. /**
  139644. * Specifies if the particles are updated in emitter local space or world space.
  139645. */
  139646. isLocal: boolean;
  139647. /**
  139648. * Is this system ready to be used/rendered
  139649. * @return true if the system is ready
  139650. */
  139651. isReady(): boolean;
  139652. /**
  139653. * Gets if the system has been started. (Note: this will still be true after stop is called)
  139654. * @returns True if it has been started, otherwise false.
  139655. */
  139656. isStarted(): boolean;
  139657. /**
  139658. * Gets if the system has been stopped. (Note: rendering is still happening but the system is frozen)
  139659. * @returns True if it has been stopped, otherwise false.
  139660. */
  139661. isStopped(): boolean;
  139662. /**
  139663. * Gets a boolean indicating that the system is stopping
  139664. * @returns true if the system is currently stopping
  139665. */
  139666. isStopping(): boolean;
  139667. /**
  139668. * Gets the number of particles active at the same time.
  139669. * @returns The number of active particles.
  139670. */
  139671. getActiveCount(): number;
  139672. /**
  139673. * Starts the particle system and begins to emit
  139674. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  139675. */
  139676. start(delay?: number): void;
  139677. /**
  139678. * Stops the particle system.
  139679. */
  139680. stop(): void;
  139681. /**
  139682. * Remove all active particles
  139683. */
  139684. reset(): void;
  139685. /**
  139686. * Returns the string "GPUParticleSystem"
  139687. * @returns a string containing the class name
  139688. */
  139689. getClassName(): string;
  139690. private _colorGradientsTexture;
  139691. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  139692. /**
  139693. * Adds a new color gradient
  139694. * @param gradient defines the gradient to use (between 0 and 1)
  139695. * @param color1 defines the color to affect to the specified gradient
  139696. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  139697. * @returns the current particle system
  139698. */
  139699. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  139700. private _refreshColorGradient;
  139701. /** Force the system to rebuild all gradients that need to be resync */
  139702. forceRefreshGradients(): void;
  139703. /**
  139704. * Remove a specific color gradient
  139705. * @param gradient defines the gradient to remove
  139706. * @returns the current particle system
  139707. */
  139708. removeColorGradient(gradient: number): GPUParticleSystem;
  139709. private _angularSpeedGradientsTexture;
  139710. private _sizeGradientsTexture;
  139711. private _velocityGradientsTexture;
  139712. private _limitVelocityGradientsTexture;
  139713. private _dragGradientsTexture;
  139714. private _addFactorGradient;
  139715. /**
  139716. * Adds a new size gradient
  139717. * @param gradient defines the gradient to use (between 0 and 1)
  139718. * @param factor defines the size factor to affect to the specified gradient
  139719. * @returns the current particle system
  139720. */
  139721. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  139722. /**
  139723. * Remove a specific size gradient
  139724. * @param gradient defines the gradient to remove
  139725. * @returns the current particle system
  139726. */
  139727. removeSizeGradient(gradient: number): GPUParticleSystem;
  139728. private _refreshFactorGradient;
  139729. /**
  139730. * Adds a new angular speed gradient
  139731. * @param gradient defines the gradient to use (between 0 and 1)
  139732. * @param factor defines the angular speed to affect to the specified gradient
  139733. * @returns the current particle system
  139734. */
  139735. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  139736. /**
  139737. * Remove a specific angular speed gradient
  139738. * @param gradient defines the gradient to remove
  139739. * @returns the current particle system
  139740. */
  139741. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  139742. /**
  139743. * Adds a new velocity gradient
  139744. * @param gradient defines the gradient to use (between 0 and 1)
  139745. * @param factor defines the velocity to affect to the specified gradient
  139746. * @returns the current particle system
  139747. */
  139748. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  139749. /**
  139750. * Remove a specific velocity gradient
  139751. * @param gradient defines the gradient to remove
  139752. * @returns the current particle system
  139753. */
  139754. removeVelocityGradient(gradient: number): GPUParticleSystem;
  139755. /**
  139756. * Adds a new limit velocity gradient
  139757. * @param gradient defines the gradient to use (between 0 and 1)
  139758. * @param factor defines the limit velocity value to affect to the specified gradient
  139759. * @returns the current particle system
  139760. */
  139761. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  139762. /**
  139763. * Remove a specific limit velocity gradient
  139764. * @param gradient defines the gradient to remove
  139765. * @returns the current particle system
  139766. */
  139767. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  139768. /**
  139769. * Adds a new drag gradient
  139770. * @param gradient defines the gradient to use (between 0 and 1)
  139771. * @param factor defines the drag value to affect to the specified gradient
  139772. * @returns the current particle system
  139773. */
  139774. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  139775. /**
  139776. * Remove a specific drag gradient
  139777. * @param gradient defines the gradient to remove
  139778. * @returns the current particle system
  139779. */
  139780. removeDragGradient(gradient: number): GPUParticleSystem;
  139781. /**
  139782. * Not supported by GPUParticleSystem
  139783. * @param gradient defines the gradient to use (between 0 and 1)
  139784. * @param factor defines the emit rate value to affect to the specified gradient
  139785. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  139786. * @returns the current particle system
  139787. */
  139788. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  139789. /**
  139790. * Not supported by GPUParticleSystem
  139791. * @param gradient defines the gradient to remove
  139792. * @returns the current particle system
  139793. */
  139794. removeEmitRateGradient(gradient: number): IParticleSystem;
  139795. /**
  139796. * Not supported by GPUParticleSystem
  139797. * @param gradient defines the gradient to use (between 0 and 1)
  139798. * @param factor defines the start size value to affect to the specified gradient
  139799. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  139800. * @returns the current particle system
  139801. */
  139802. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  139803. /**
  139804. * Not supported by GPUParticleSystem
  139805. * @param gradient defines the gradient to remove
  139806. * @returns the current particle system
  139807. */
  139808. removeStartSizeGradient(gradient: number): IParticleSystem;
  139809. /**
  139810. * Not supported by GPUParticleSystem
  139811. * @param gradient defines the gradient to use (between 0 and 1)
  139812. * @param min defines the color remap minimal range
  139813. * @param max defines the color remap maximal range
  139814. * @returns the current particle system
  139815. */
  139816. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  139817. /**
  139818. * Not supported by GPUParticleSystem
  139819. * @param gradient defines the gradient to remove
  139820. * @returns the current particle system
  139821. */
  139822. removeColorRemapGradient(): IParticleSystem;
  139823. /**
  139824. * Not supported by GPUParticleSystem
  139825. * @param gradient defines the gradient to use (between 0 and 1)
  139826. * @param min defines the alpha remap minimal range
  139827. * @param max defines the alpha remap maximal range
  139828. * @returns the current particle system
  139829. */
  139830. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  139831. /**
  139832. * Not supported by GPUParticleSystem
  139833. * @param gradient defines the gradient to remove
  139834. * @returns the current particle system
  139835. */
  139836. removeAlphaRemapGradient(): IParticleSystem;
  139837. /**
  139838. * Not supported by GPUParticleSystem
  139839. * @param gradient defines the gradient to use (between 0 and 1)
  139840. * @param color defines the color to affect to the specified gradient
  139841. * @returns the current particle system
  139842. */
  139843. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  139844. /**
  139845. * Not supported by GPUParticleSystem
  139846. * @param gradient defines the gradient to remove
  139847. * @returns the current particle system
  139848. */
  139849. removeRampGradient(): IParticleSystem;
  139850. /**
  139851. * Not supported by GPUParticleSystem
  139852. * @returns the list of ramp gradients
  139853. */
  139854. getRampGradients(): Nullable<Array<Color3Gradient>>;
  139855. /**
  139856. * Not supported by GPUParticleSystem
  139857. * Gets or sets a boolean indicating that ramp gradients must be used
  139858. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  139859. */
  139860. get useRampGradients(): boolean;
  139861. set useRampGradients(value: boolean);
  139862. /**
  139863. * Not supported by GPUParticleSystem
  139864. * @param gradient defines the gradient to use (between 0 and 1)
  139865. * @param factor defines the life time factor to affect to the specified gradient
  139866. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  139867. * @returns the current particle system
  139868. */
  139869. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  139870. /**
  139871. * Not supported by GPUParticleSystem
  139872. * @param gradient defines the gradient to remove
  139873. * @returns the current particle system
  139874. */
  139875. removeLifeTimeGradient(gradient: number): IParticleSystem;
  139876. /**
  139877. * Instantiates a GPU particle system.
  139878. * 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.
  139879. * @param name The name of the particle system
  139880. * @param options The options used to create the system
  139881. * @param scene The scene the particle system belongs to
  139882. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  139883. */
  139884. constructor(name: string, options: Partial<{
  139885. capacity: number;
  139886. randomTextureSize: number;
  139887. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  139888. protected _reset(): void;
  139889. private _createUpdateVAO;
  139890. private _createRenderVAO;
  139891. private _initialize;
  139892. /** @hidden */
  139893. _recreateUpdateEffect(): void;
  139894. /** @hidden */
  139895. _recreateRenderEffect(): void;
  139896. /**
  139897. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  139898. * @param preWarm defines if we are in the pre-warmimg phase
  139899. */
  139900. animate(preWarm?: boolean): void;
  139901. private _createFactorGradientTexture;
  139902. private _createSizeGradientTexture;
  139903. private _createAngularSpeedGradientTexture;
  139904. private _createVelocityGradientTexture;
  139905. private _createLimitVelocityGradientTexture;
  139906. private _createDragGradientTexture;
  139907. private _createColorGradientTexture;
  139908. /**
  139909. * Renders the particle system in its current state
  139910. * @param preWarm defines if the system should only update the particles but not render them
  139911. * @returns the current number of particles
  139912. */
  139913. render(preWarm?: boolean): number;
  139914. /**
  139915. * Rebuilds the particle system
  139916. */
  139917. rebuild(): void;
  139918. private _releaseBuffers;
  139919. private _releaseVAOs;
  139920. /**
  139921. * Disposes the particle system and free the associated resources
  139922. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  139923. */
  139924. dispose(disposeTexture?: boolean): void;
  139925. /**
  139926. * Clones the particle system.
  139927. * @param name The name of the cloned object
  139928. * @param newEmitter The new emitter to use
  139929. * @returns the cloned particle system
  139930. */
  139931. clone(name: string, newEmitter: any): GPUParticleSystem;
  139932. /**
  139933. * Serializes the particle system to a JSON object
  139934. * @param serializeTexture defines if the texture must be serialized as well
  139935. * @returns the JSON object
  139936. */
  139937. serialize(serializeTexture?: boolean): any;
  139938. /**
  139939. * Parses a JSON object to create a GPU particle system.
  139940. * @param parsedParticleSystem The JSON object to parse
  139941. * @param scene The scene to create the particle system in
  139942. * @param rootUrl The root url to use to load external dependencies like texture
  139943. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  139944. * @returns the parsed GPU particle system
  139945. */
  139946. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  139947. }
  139948. }
  139949. declare module BABYLON {
  139950. /**
  139951. * Represents a set of particle systems working together to create a specific effect
  139952. */
  139953. export class ParticleSystemSet implements IDisposable {
  139954. /**
  139955. * Gets or sets base Assets URL
  139956. */
  139957. static BaseAssetsUrl: string;
  139958. private _emitterCreationOptions;
  139959. private _emitterNode;
  139960. /**
  139961. * Gets the particle system list
  139962. */
  139963. systems: IParticleSystem[];
  139964. /**
  139965. * Gets the emitter node used with this set
  139966. */
  139967. get emitterNode(): Nullable<TransformNode>;
  139968. /**
  139969. * Creates a new emitter mesh as a sphere
  139970. * @param options defines the options used to create the sphere
  139971. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  139972. * @param scene defines the hosting scene
  139973. */
  139974. setEmitterAsSphere(options: {
  139975. diameter: number;
  139976. segments: number;
  139977. color: Color3;
  139978. }, renderingGroupId: number, scene: Scene): void;
  139979. /**
  139980. * Starts all particle systems of the set
  139981. * @param emitter defines an optional mesh to use as emitter for the particle systems
  139982. */
  139983. start(emitter?: AbstractMesh): void;
  139984. /**
  139985. * Release all associated resources
  139986. */
  139987. dispose(): void;
  139988. /**
  139989. * Serialize the set into a JSON compatible object
  139990. * @param serializeTexture defines if the texture must be serialized as well
  139991. * @returns a JSON compatible representation of the set
  139992. */
  139993. serialize(serializeTexture?: boolean): any;
  139994. /**
  139995. * Parse a new ParticleSystemSet from a serialized source
  139996. * @param data defines a JSON compatible representation of the set
  139997. * @param scene defines the hosting scene
  139998. * @param gpu defines if we want GPU particles or CPU particles
  139999. * @returns a new ParticleSystemSet
  140000. */
  140001. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  140002. }
  140003. }
  140004. declare module BABYLON {
  140005. /**
  140006. * This class is made for on one-liner static method to help creating particle system set.
  140007. */
  140008. export class ParticleHelper {
  140009. /**
  140010. * Gets or sets base Assets URL
  140011. */
  140012. static BaseAssetsUrl: string;
  140013. /** Define the Url to load snippets */
  140014. static SnippetUrl: string;
  140015. /**
  140016. * Create a default particle system that you can tweak
  140017. * @param emitter defines the emitter to use
  140018. * @param capacity defines the system capacity (default is 500 particles)
  140019. * @param scene defines the hosting scene
  140020. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  140021. * @returns the new Particle system
  140022. */
  140023. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  140024. /**
  140025. * This is the main static method (one-liner) of this helper to create different particle systems
  140026. * @param type This string represents the type to the particle system to create
  140027. * @param scene The scene where the particle system should live
  140028. * @param gpu If the system will use gpu
  140029. * @returns the ParticleSystemSet created
  140030. */
  140031. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  140032. /**
  140033. * Static function used to export a particle system to a ParticleSystemSet variable.
  140034. * Please note that the emitter shape is not exported
  140035. * @param systems defines the particle systems to export
  140036. * @returns the created particle system set
  140037. */
  140038. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  140039. /**
  140040. * Creates a particle system from a snippet saved in a remote file
  140041. * @param name defines the name of the particle system to create
  140042. * @param url defines the url to load from
  140043. * @param scene defines the hosting scene
  140044. * @param gpu If the system will use gpu
  140045. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  140046. * @returns a promise that will resolve to the new particle system
  140047. */
  140048. static ParseFromFileAsync(name: string, url: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  140049. /**
  140050. * Creates a particle system from a snippet saved by the particle system editor
  140051. * @param snippetId defines the snippet to load
  140052. * @param scene defines the hosting scene
  140053. * @param gpu If the system will use gpu
  140054. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  140055. * @returns a promise that will resolve to the new particle system
  140056. */
  140057. static CreateFromSnippetAsync(snippetId: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  140058. }
  140059. }
  140060. declare module BABYLON {
  140061. interface Engine {
  140062. /**
  140063. * Create an effect to use with particle systems.
  140064. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  140065. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  140066. * @param uniformsNames defines a list of attribute names
  140067. * @param samplers defines an array of string used to represent textures
  140068. * @param defines defines the string containing the defines to use to compile the shaders
  140069. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  140070. * @param onCompiled defines a function to call when the effect creation is successful
  140071. * @param onError defines a function to call when the effect creation has failed
  140072. * @returns the new Effect
  140073. */
  140074. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  140075. }
  140076. interface Mesh {
  140077. /**
  140078. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  140079. * @returns an array of IParticleSystem
  140080. */
  140081. getEmittedParticleSystems(): IParticleSystem[];
  140082. /**
  140083. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  140084. * @returns an array of IParticleSystem
  140085. */
  140086. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  140087. }
  140088. /**
  140089. * @hidden
  140090. */
  140091. export var _IDoNeedToBeInTheBuild: number;
  140092. }
  140093. declare module BABYLON {
  140094. /** Defines the 4 color options */
  140095. export enum PointColor {
  140096. /** color value */
  140097. Color = 2,
  140098. /** uv value */
  140099. UV = 1,
  140100. /** random value */
  140101. Random = 0,
  140102. /** stated value */
  140103. Stated = 3
  140104. }
  140105. /**
  140106. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  140107. * 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.
  140108. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  140109. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  140110. *
  140111. * Full documentation here : TO BE ENTERED
  140112. */
  140113. export class PointsCloudSystem implements IDisposable {
  140114. /**
  140115. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  140116. * Example : var p = SPS.particles[i];
  140117. */
  140118. particles: CloudPoint[];
  140119. /**
  140120. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  140121. */
  140122. nbParticles: number;
  140123. /**
  140124. * This a counter for your own usage. It's not set by any SPS functions.
  140125. */
  140126. counter: number;
  140127. /**
  140128. * The PCS name. This name is also given to the underlying mesh.
  140129. */
  140130. name: string;
  140131. /**
  140132. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  140133. */
  140134. mesh: Mesh;
  140135. /**
  140136. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  140137. * Please read :
  140138. */
  140139. vars: any;
  140140. /**
  140141. * @hidden
  140142. */
  140143. _size: number;
  140144. private _scene;
  140145. private _promises;
  140146. private _positions;
  140147. private _indices;
  140148. private _normals;
  140149. private _colors;
  140150. private _uvs;
  140151. private _indices32;
  140152. private _positions32;
  140153. private _colors32;
  140154. private _uvs32;
  140155. private _updatable;
  140156. private _isVisibilityBoxLocked;
  140157. private _alwaysVisible;
  140158. private _groups;
  140159. private _groupCounter;
  140160. private _computeParticleColor;
  140161. private _computeParticleTexture;
  140162. private _computeParticleRotation;
  140163. private _computeBoundingBox;
  140164. private _isReady;
  140165. /**
  140166. * Creates a PCS (Points Cloud System) object
  140167. * @param name (String) is the PCS name, this will be the underlying mesh name
  140168. * @param pointSize (number) is the size for each point
  140169. * @param scene (Scene) is the scene in which the PCS is added
  140170. * @param options defines the options of the PCS e.g.
  140171. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  140172. */
  140173. constructor(name: string, pointSize: number, scene: Scene, options?: {
  140174. updatable?: boolean;
  140175. });
  140176. /**
  140177. * Builds the PCS underlying mesh. Returns a standard Mesh.
  140178. * If no points were added to the PCS, the returned mesh is just a single point.
  140179. * @returns a promise for the created mesh
  140180. */
  140181. buildMeshAsync(): Promise<Mesh>;
  140182. /**
  140183. * @hidden
  140184. */
  140185. private _buildMesh;
  140186. private _addParticle;
  140187. private _randomUnitVector;
  140188. private _getColorIndicesForCoord;
  140189. private _setPointsColorOrUV;
  140190. private _colorFromTexture;
  140191. private _calculateDensity;
  140192. /**
  140193. * Adds points to the PCS in random positions within a unit sphere
  140194. * @param nb (positive integer) the number of particles to be created from this model
  140195. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  140196. * @returns the number of groups in the system
  140197. */
  140198. addPoints(nb: number, pointFunction?: any): number;
  140199. /**
  140200. * Adds points to the PCS from the surface of the model shape
  140201. * @param mesh is any Mesh object that will be used as a surface model for the points
  140202. * @param nb (positive integer) the number of particles to be created from this model
  140203. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  140204. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  140205. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  140206. * @returns the number of groups in the system
  140207. */
  140208. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  140209. /**
  140210. * Adds points to the PCS inside the model shape
  140211. * @param mesh is any Mesh object that will be used as a surface model for the points
  140212. * @param nb (positive integer) the number of particles to be created from this model
  140213. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  140214. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  140215. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  140216. * @returns the number of groups in the system
  140217. */
  140218. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  140219. /**
  140220. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  140221. * This method calls `updateParticle()` for each particle of the SPS.
  140222. * For an animated SPS, it is usually called within the render loop.
  140223. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  140224. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  140225. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  140226. * @returns the PCS.
  140227. */
  140228. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  140229. /**
  140230. * Disposes the PCS.
  140231. */
  140232. dispose(): void;
  140233. /**
  140234. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  140235. * doc :
  140236. * @returns the PCS.
  140237. */
  140238. refreshVisibleSize(): PointsCloudSystem;
  140239. /**
  140240. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  140241. * @param size the size (float) of the visibility box
  140242. * note : this doesn't lock the PCS mesh bounding box.
  140243. * doc :
  140244. */
  140245. setVisibilityBox(size: number): void;
  140246. /**
  140247. * Gets whether the PCS is always visible or not
  140248. * doc :
  140249. */
  140250. get isAlwaysVisible(): boolean;
  140251. /**
  140252. * Sets the PCS as always visible or not
  140253. * doc :
  140254. */
  140255. set isAlwaysVisible(val: boolean);
  140256. /**
  140257. * Tells to `setParticles()` to compute the particle rotations or not
  140258. * Default value : false. The PCS is faster when it's set to false
  140259. * Note : particle rotations are only applied to parent particles
  140260. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  140261. */
  140262. set computeParticleRotation(val: boolean);
  140263. /**
  140264. * Tells to `setParticles()` to compute the particle colors or not.
  140265. * Default value : true. The PCS is faster when it's set to false.
  140266. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  140267. */
  140268. set computeParticleColor(val: boolean);
  140269. set computeParticleTexture(val: boolean);
  140270. /**
  140271. * Gets if `setParticles()` computes the particle colors or not.
  140272. * Default value : false. The PCS is faster when it's set to false.
  140273. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  140274. */
  140275. get computeParticleColor(): boolean;
  140276. /**
  140277. * Gets if `setParticles()` computes the particle textures or not.
  140278. * Default value : false. The PCS is faster when it's set to false.
  140279. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  140280. */
  140281. get computeParticleTexture(): boolean;
  140282. /**
  140283. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  140284. */
  140285. set computeBoundingBox(val: boolean);
  140286. /**
  140287. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  140288. */
  140289. get computeBoundingBox(): boolean;
  140290. /**
  140291. * This function does nothing. It may be overwritten to set all the particle first values.
  140292. * The PCS doesn't call this function, you may have to call it by your own.
  140293. * doc :
  140294. */
  140295. initParticles(): void;
  140296. /**
  140297. * This function does nothing. It may be overwritten to recycle a particle
  140298. * The PCS doesn't call this function, you can to call it
  140299. * doc :
  140300. * @param particle The particle to recycle
  140301. * @returns the recycled particle
  140302. */
  140303. recycleParticle(particle: CloudPoint): CloudPoint;
  140304. /**
  140305. * Updates a particle : this function should be overwritten by the user.
  140306. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  140307. * doc :
  140308. * @example : just set a particle position or velocity and recycle conditions
  140309. * @param particle The particle to update
  140310. * @returns the updated particle
  140311. */
  140312. updateParticle(particle: CloudPoint): CloudPoint;
  140313. /**
  140314. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  140315. * This does nothing and may be overwritten by the user.
  140316. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  140317. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  140318. * @param update the boolean update value actually passed to setParticles()
  140319. */
  140320. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  140321. /**
  140322. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  140323. * This will be passed three parameters.
  140324. * This does nothing and may be overwritten by the user.
  140325. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  140326. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  140327. * @param update the boolean update value actually passed to setParticles()
  140328. */
  140329. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  140330. }
  140331. }
  140332. declare module BABYLON {
  140333. /**
  140334. * Represents one particle of a points cloud system.
  140335. */
  140336. export class CloudPoint {
  140337. /**
  140338. * particle global index
  140339. */
  140340. idx: number;
  140341. /**
  140342. * The color of the particle
  140343. */
  140344. color: Nullable<Color4>;
  140345. /**
  140346. * The world space position of the particle.
  140347. */
  140348. position: Vector3;
  140349. /**
  140350. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  140351. */
  140352. rotation: Vector3;
  140353. /**
  140354. * The world space rotation quaternion of the particle.
  140355. */
  140356. rotationQuaternion: Nullable<Quaternion>;
  140357. /**
  140358. * The uv of the particle.
  140359. */
  140360. uv: Nullable<Vector2>;
  140361. /**
  140362. * The current speed of the particle.
  140363. */
  140364. velocity: Vector3;
  140365. /**
  140366. * The pivot point in the particle local space.
  140367. */
  140368. pivot: Vector3;
  140369. /**
  140370. * Must the particle be translated from its pivot point in its local space ?
  140371. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  140372. * Default : false
  140373. */
  140374. translateFromPivot: boolean;
  140375. /**
  140376. * Index of this particle in the global "positions" array (Internal use)
  140377. * @hidden
  140378. */
  140379. _pos: number;
  140380. /**
  140381. * @hidden Index of this particle in the global "indices" array (Internal use)
  140382. */
  140383. _ind: number;
  140384. /**
  140385. * Group this particle belongs to
  140386. */
  140387. _group: PointsGroup;
  140388. /**
  140389. * Group id of this particle
  140390. */
  140391. groupId: number;
  140392. /**
  140393. * Index of the particle in its group id (Internal use)
  140394. */
  140395. idxInGroup: number;
  140396. /**
  140397. * @hidden Particle BoundingInfo object (Internal use)
  140398. */
  140399. _boundingInfo: BoundingInfo;
  140400. /**
  140401. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  140402. */
  140403. _pcs: PointsCloudSystem;
  140404. /**
  140405. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  140406. */
  140407. _stillInvisible: boolean;
  140408. /**
  140409. * @hidden Last computed particle rotation matrix
  140410. */
  140411. _rotationMatrix: number[];
  140412. /**
  140413. * Parent particle Id, if any.
  140414. * Default null.
  140415. */
  140416. parentId: Nullable<number>;
  140417. /**
  140418. * @hidden Internal global position in the PCS.
  140419. */
  140420. _globalPosition: Vector3;
  140421. /**
  140422. * Creates a Point Cloud object.
  140423. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  140424. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  140425. * @param group (PointsGroup) is the group the particle belongs to
  140426. * @param groupId (integer) is the group identifier in the PCS.
  140427. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  140428. * @param pcs defines the PCS it is associated to
  140429. */
  140430. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  140431. /**
  140432. * get point size
  140433. */
  140434. get size(): Vector3;
  140435. /**
  140436. * Set point size
  140437. */
  140438. set size(scale: Vector3);
  140439. /**
  140440. * Legacy support, changed quaternion to rotationQuaternion
  140441. */
  140442. get quaternion(): Nullable<Quaternion>;
  140443. /**
  140444. * Legacy support, changed quaternion to rotationQuaternion
  140445. */
  140446. set quaternion(q: Nullable<Quaternion>);
  140447. /**
  140448. * Returns a boolean. True if the particle intersects a mesh, else false
  140449. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  140450. * @param target is the object (point or mesh) what the intersection is computed against
  140451. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  140452. * @returns true if it intersects
  140453. */
  140454. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  140455. /**
  140456. * get the rotation matrix of the particle
  140457. * @hidden
  140458. */
  140459. getRotationMatrix(m: Matrix): void;
  140460. }
  140461. /**
  140462. * Represents a group of points in a points cloud system
  140463. * * PCS internal tool, don't use it manually.
  140464. */
  140465. export class PointsGroup {
  140466. /**
  140467. * The group id
  140468. * @hidden
  140469. */
  140470. groupID: number;
  140471. /**
  140472. * image data for group (internal use)
  140473. * @hidden
  140474. */
  140475. _groupImageData: Nullable<ArrayBufferView>;
  140476. /**
  140477. * Image Width (internal use)
  140478. * @hidden
  140479. */
  140480. _groupImgWidth: number;
  140481. /**
  140482. * Image Height (internal use)
  140483. * @hidden
  140484. */
  140485. _groupImgHeight: number;
  140486. /**
  140487. * Custom position function (internal use)
  140488. * @hidden
  140489. */
  140490. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  140491. /**
  140492. * density per facet for surface points
  140493. * @hidden
  140494. */
  140495. _groupDensity: number[];
  140496. /**
  140497. * Only when points are colored by texture carries pointer to texture list array
  140498. * @hidden
  140499. */
  140500. _textureNb: number;
  140501. /**
  140502. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  140503. * PCS internal tool, don't use it manually.
  140504. * @hidden
  140505. */
  140506. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  140507. }
  140508. }
  140509. declare module BABYLON {
  140510. interface Scene {
  140511. /** @hidden (Backing field) */
  140512. _physicsEngine: Nullable<IPhysicsEngine>;
  140513. /** @hidden */
  140514. _physicsTimeAccumulator: number;
  140515. /**
  140516. * Gets the current physics engine
  140517. * @returns a IPhysicsEngine or null if none attached
  140518. */
  140519. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  140520. /**
  140521. * Enables physics to the current scene
  140522. * @param gravity defines the scene's gravity for the physics engine
  140523. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  140524. * @return a boolean indicating if the physics engine was initialized
  140525. */
  140526. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  140527. /**
  140528. * Disables and disposes the physics engine associated with the scene
  140529. */
  140530. disablePhysicsEngine(): void;
  140531. /**
  140532. * Gets a boolean indicating if there is an active physics engine
  140533. * @returns a boolean indicating if there is an active physics engine
  140534. */
  140535. isPhysicsEnabled(): boolean;
  140536. /**
  140537. * Deletes a physics compound impostor
  140538. * @param compound defines the compound to delete
  140539. */
  140540. deleteCompoundImpostor(compound: any): void;
  140541. /**
  140542. * An event triggered when physic simulation is about to be run
  140543. */
  140544. onBeforePhysicsObservable: Observable<Scene>;
  140545. /**
  140546. * An event triggered when physic simulation has been done
  140547. */
  140548. onAfterPhysicsObservable: Observable<Scene>;
  140549. }
  140550. interface AbstractMesh {
  140551. /** @hidden */
  140552. _physicsImpostor: Nullable<PhysicsImpostor>;
  140553. /**
  140554. * Gets or sets impostor used for physic simulation
  140555. * @see http://doc.babylonjs.com/features/physics_engine
  140556. */
  140557. physicsImpostor: Nullable<PhysicsImpostor>;
  140558. /**
  140559. * Gets the current physics impostor
  140560. * @see http://doc.babylonjs.com/features/physics_engine
  140561. * @returns a physics impostor or null
  140562. */
  140563. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  140564. /** Apply a physic impulse to the mesh
  140565. * @param force defines the force to apply
  140566. * @param contactPoint defines where to apply the force
  140567. * @returns the current mesh
  140568. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  140569. */
  140570. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  140571. /**
  140572. * Creates a physic joint between two meshes
  140573. * @param otherMesh defines the other mesh to use
  140574. * @param pivot1 defines the pivot to use on this mesh
  140575. * @param pivot2 defines the pivot to use on the other mesh
  140576. * @param options defines additional options (can be plugin dependent)
  140577. * @returns the current mesh
  140578. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  140579. */
  140580. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  140581. /** @hidden */
  140582. _disposePhysicsObserver: Nullable<Observer<Node>>;
  140583. }
  140584. /**
  140585. * Defines the physics engine scene component responsible to manage a physics engine
  140586. */
  140587. export class PhysicsEngineSceneComponent implements ISceneComponent {
  140588. /**
  140589. * The component name helpful to identify the component in the list of scene components.
  140590. */
  140591. readonly name: string;
  140592. /**
  140593. * The scene the component belongs to.
  140594. */
  140595. scene: Scene;
  140596. /**
  140597. * Creates a new instance of the component for the given scene
  140598. * @param scene Defines the scene to register the component in
  140599. */
  140600. constructor(scene: Scene);
  140601. /**
  140602. * Registers the component in a given scene
  140603. */
  140604. register(): void;
  140605. /**
  140606. * Rebuilds the elements related to this component in case of
  140607. * context lost for instance.
  140608. */
  140609. rebuild(): void;
  140610. /**
  140611. * Disposes the component and the associated ressources
  140612. */
  140613. dispose(): void;
  140614. }
  140615. }
  140616. declare module BABYLON {
  140617. /**
  140618. * A helper for physics simulations
  140619. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  140620. */
  140621. export class PhysicsHelper {
  140622. private _scene;
  140623. private _physicsEngine;
  140624. /**
  140625. * Initializes the Physics helper
  140626. * @param scene Babylon.js scene
  140627. */
  140628. constructor(scene: Scene);
  140629. /**
  140630. * Applies a radial explosion impulse
  140631. * @param origin the origin of the explosion
  140632. * @param radiusOrEventOptions the radius or the options of radial explosion
  140633. * @param strength the explosion strength
  140634. * @param falloff possible options: Constant & Linear. Defaults to Constant
  140635. * @returns A physics radial explosion event, or null
  140636. */
  140637. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  140638. /**
  140639. * Applies a radial explosion force
  140640. * @param origin the origin of the explosion
  140641. * @param radiusOrEventOptions the radius or the options of radial explosion
  140642. * @param strength the explosion strength
  140643. * @param falloff possible options: Constant & Linear. Defaults to Constant
  140644. * @returns A physics radial explosion event, or null
  140645. */
  140646. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  140647. /**
  140648. * Creates a gravitational field
  140649. * @param origin the origin of the explosion
  140650. * @param radiusOrEventOptions the radius or the options of radial explosion
  140651. * @param strength the explosion strength
  140652. * @param falloff possible options: Constant & Linear. Defaults to Constant
  140653. * @returns A physics gravitational field event, or null
  140654. */
  140655. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  140656. /**
  140657. * Creates a physics updraft event
  140658. * @param origin the origin of the updraft
  140659. * @param radiusOrEventOptions the radius or the options of the updraft
  140660. * @param strength the strength of the updraft
  140661. * @param height the height of the updraft
  140662. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  140663. * @returns A physics updraft event, or null
  140664. */
  140665. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  140666. /**
  140667. * Creates a physics vortex event
  140668. * @param origin the of the vortex
  140669. * @param radiusOrEventOptions the radius or the options of the vortex
  140670. * @param strength the strength of the vortex
  140671. * @param height the height of the vortex
  140672. * @returns a Physics vortex event, or null
  140673. * A physics vortex event or null
  140674. */
  140675. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  140676. }
  140677. /**
  140678. * Represents a physics radial explosion event
  140679. */
  140680. class PhysicsRadialExplosionEvent {
  140681. private _scene;
  140682. private _options;
  140683. private _sphere;
  140684. private _dataFetched;
  140685. /**
  140686. * Initializes a radial explosioin event
  140687. * @param _scene BabylonJS scene
  140688. * @param _options The options for the vortex event
  140689. */
  140690. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  140691. /**
  140692. * Returns the data related to the radial explosion event (sphere).
  140693. * @returns The radial explosion event data
  140694. */
  140695. getData(): PhysicsRadialExplosionEventData;
  140696. /**
  140697. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  140698. * @param impostor A physics imposter
  140699. * @param origin the origin of the explosion
  140700. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  140701. */
  140702. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  140703. /**
  140704. * Triggers affecterd impostors callbacks
  140705. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  140706. */
  140707. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  140708. /**
  140709. * Disposes the sphere.
  140710. * @param force Specifies if the sphere should be disposed by force
  140711. */
  140712. dispose(force?: boolean): void;
  140713. /*** Helpers ***/
  140714. private _prepareSphere;
  140715. private _intersectsWithSphere;
  140716. }
  140717. /**
  140718. * Represents a gravitational field event
  140719. */
  140720. class PhysicsGravitationalFieldEvent {
  140721. private _physicsHelper;
  140722. private _scene;
  140723. private _origin;
  140724. private _options;
  140725. private _tickCallback;
  140726. private _sphere;
  140727. private _dataFetched;
  140728. /**
  140729. * Initializes the physics gravitational field event
  140730. * @param _physicsHelper A physics helper
  140731. * @param _scene BabylonJS scene
  140732. * @param _origin The origin position of the gravitational field event
  140733. * @param _options The options for the vortex event
  140734. */
  140735. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  140736. /**
  140737. * Returns the data related to the gravitational field event (sphere).
  140738. * @returns A gravitational field event
  140739. */
  140740. getData(): PhysicsGravitationalFieldEventData;
  140741. /**
  140742. * Enables the gravitational field.
  140743. */
  140744. enable(): void;
  140745. /**
  140746. * Disables the gravitational field.
  140747. */
  140748. disable(): void;
  140749. /**
  140750. * Disposes the sphere.
  140751. * @param force The force to dispose from the gravitational field event
  140752. */
  140753. dispose(force?: boolean): void;
  140754. private _tick;
  140755. }
  140756. /**
  140757. * Represents a physics updraft event
  140758. */
  140759. class PhysicsUpdraftEvent {
  140760. private _scene;
  140761. private _origin;
  140762. private _options;
  140763. private _physicsEngine;
  140764. private _originTop;
  140765. private _originDirection;
  140766. private _tickCallback;
  140767. private _cylinder;
  140768. private _cylinderPosition;
  140769. private _dataFetched;
  140770. /**
  140771. * Initializes the physics updraft event
  140772. * @param _scene BabylonJS scene
  140773. * @param _origin The origin position of the updraft
  140774. * @param _options The options for the updraft event
  140775. */
  140776. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  140777. /**
  140778. * Returns the data related to the updraft event (cylinder).
  140779. * @returns A physics updraft event
  140780. */
  140781. getData(): PhysicsUpdraftEventData;
  140782. /**
  140783. * Enables the updraft.
  140784. */
  140785. enable(): void;
  140786. /**
  140787. * Disables the updraft.
  140788. */
  140789. disable(): void;
  140790. /**
  140791. * Disposes the cylinder.
  140792. * @param force Specifies if the updraft should be disposed by force
  140793. */
  140794. dispose(force?: boolean): void;
  140795. private getImpostorHitData;
  140796. private _tick;
  140797. /*** Helpers ***/
  140798. private _prepareCylinder;
  140799. private _intersectsWithCylinder;
  140800. }
  140801. /**
  140802. * Represents a physics vortex event
  140803. */
  140804. class PhysicsVortexEvent {
  140805. private _scene;
  140806. private _origin;
  140807. private _options;
  140808. private _physicsEngine;
  140809. private _originTop;
  140810. private _tickCallback;
  140811. private _cylinder;
  140812. private _cylinderPosition;
  140813. private _dataFetched;
  140814. /**
  140815. * Initializes the physics vortex event
  140816. * @param _scene The BabylonJS scene
  140817. * @param _origin The origin position of the vortex
  140818. * @param _options The options for the vortex event
  140819. */
  140820. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  140821. /**
  140822. * Returns the data related to the vortex event (cylinder).
  140823. * @returns The physics vortex event data
  140824. */
  140825. getData(): PhysicsVortexEventData;
  140826. /**
  140827. * Enables the vortex.
  140828. */
  140829. enable(): void;
  140830. /**
  140831. * Disables the cortex.
  140832. */
  140833. disable(): void;
  140834. /**
  140835. * Disposes the sphere.
  140836. * @param force
  140837. */
  140838. dispose(force?: boolean): void;
  140839. private getImpostorHitData;
  140840. private _tick;
  140841. /*** Helpers ***/
  140842. private _prepareCylinder;
  140843. private _intersectsWithCylinder;
  140844. }
  140845. /**
  140846. * Options fot the radial explosion event
  140847. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  140848. */
  140849. export class PhysicsRadialExplosionEventOptions {
  140850. /**
  140851. * The radius of the sphere for the radial explosion.
  140852. */
  140853. radius: number;
  140854. /**
  140855. * The strenth of the explosion.
  140856. */
  140857. strength: number;
  140858. /**
  140859. * The strenght of the force in correspondence to the distance of the affected object
  140860. */
  140861. falloff: PhysicsRadialImpulseFalloff;
  140862. /**
  140863. * Sphere options for the radial explosion.
  140864. */
  140865. sphere: {
  140866. segments: number;
  140867. diameter: number;
  140868. };
  140869. /**
  140870. * Sphere options for the radial explosion.
  140871. */
  140872. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  140873. }
  140874. /**
  140875. * Options fot the updraft event
  140876. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  140877. */
  140878. export class PhysicsUpdraftEventOptions {
  140879. /**
  140880. * The radius of the cylinder for the vortex
  140881. */
  140882. radius: number;
  140883. /**
  140884. * The strenth of the updraft.
  140885. */
  140886. strength: number;
  140887. /**
  140888. * The height of the cylinder for the updraft.
  140889. */
  140890. height: number;
  140891. /**
  140892. * The mode for the the updraft.
  140893. */
  140894. updraftMode: PhysicsUpdraftMode;
  140895. }
  140896. /**
  140897. * Options fot the vortex event
  140898. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  140899. */
  140900. export class PhysicsVortexEventOptions {
  140901. /**
  140902. * The radius of the cylinder for the vortex
  140903. */
  140904. radius: number;
  140905. /**
  140906. * The strenth of the vortex.
  140907. */
  140908. strength: number;
  140909. /**
  140910. * The height of the cylinder for the vortex.
  140911. */
  140912. height: number;
  140913. /**
  140914. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  140915. */
  140916. centripetalForceThreshold: number;
  140917. /**
  140918. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  140919. */
  140920. centripetalForceMultiplier: number;
  140921. /**
  140922. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  140923. */
  140924. centrifugalForceMultiplier: number;
  140925. /**
  140926. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  140927. */
  140928. updraftForceMultiplier: number;
  140929. }
  140930. /**
  140931. * The strenght of the force in correspondence to the distance of the affected object
  140932. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  140933. */
  140934. export enum PhysicsRadialImpulseFalloff {
  140935. /** Defines that impulse is constant in strength across it's whole radius */
  140936. Constant = 0,
  140937. /** Defines that impulse gets weaker if it's further from the origin */
  140938. Linear = 1
  140939. }
  140940. /**
  140941. * The strength of the force in correspondence to the distance of the affected object
  140942. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  140943. */
  140944. export enum PhysicsUpdraftMode {
  140945. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  140946. Center = 0,
  140947. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  140948. Perpendicular = 1
  140949. }
  140950. /**
  140951. * Interface for a physics hit data
  140952. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  140953. */
  140954. export interface PhysicsHitData {
  140955. /**
  140956. * The force applied at the contact point
  140957. */
  140958. force: Vector3;
  140959. /**
  140960. * The contact point
  140961. */
  140962. contactPoint: Vector3;
  140963. /**
  140964. * The distance from the origin to the contact point
  140965. */
  140966. distanceFromOrigin: number;
  140967. }
  140968. /**
  140969. * Interface for radial explosion event data
  140970. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  140971. */
  140972. export interface PhysicsRadialExplosionEventData {
  140973. /**
  140974. * A sphere used for the radial explosion event
  140975. */
  140976. sphere: Mesh;
  140977. }
  140978. /**
  140979. * Interface for gravitational field event data
  140980. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  140981. */
  140982. export interface PhysicsGravitationalFieldEventData {
  140983. /**
  140984. * A sphere mesh used for the gravitational field event
  140985. */
  140986. sphere: Mesh;
  140987. }
  140988. /**
  140989. * Interface for updraft event data
  140990. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  140991. */
  140992. export interface PhysicsUpdraftEventData {
  140993. /**
  140994. * A cylinder used for the updraft event
  140995. */
  140996. cylinder: Mesh;
  140997. }
  140998. /**
  140999. * Interface for vortex event data
  141000. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  141001. */
  141002. export interface PhysicsVortexEventData {
  141003. /**
  141004. * A cylinder used for the vortex event
  141005. */
  141006. cylinder: Mesh;
  141007. }
  141008. /**
  141009. * Interface for an affected physics impostor
  141010. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  141011. */
  141012. export interface PhysicsAffectedImpostorWithData {
  141013. /**
  141014. * The impostor affected by the effect
  141015. */
  141016. impostor: PhysicsImpostor;
  141017. /**
  141018. * The data about the hit/horce from the explosion
  141019. */
  141020. hitData: PhysicsHitData;
  141021. }
  141022. }
  141023. declare module BABYLON {
  141024. /** @hidden */
  141025. export var blackAndWhitePixelShader: {
  141026. name: string;
  141027. shader: string;
  141028. };
  141029. }
  141030. declare module BABYLON {
  141031. /**
  141032. * Post process used to render in black and white
  141033. */
  141034. export class BlackAndWhitePostProcess extends PostProcess {
  141035. /**
  141036. * Linear about to convert he result to black and white (default: 1)
  141037. */
  141038. degree: number;
  141039. /**
  141040. * Creates a black and white post process
  141041. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  141042. * @param name The name of the effect.
  141043. * @param options The required width/height ratio to downsize to before computing the render pass.
  141044. * @param camera The camera to apply the render pass to.
  141045. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  141046. * @param engine The engine which the post process will be applied. (default: current engine)
  141047. * @param reusable If the post process can be reused on the same frame. (default: false)
  141048. */
  141049. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  141050. }
  141051. }
  141052. declare module BABYLON {
  141053. /**
  141054. * This represents a set of one or more post processes in Babylon.
  141055. * A post process can be used to apply a shader to a texture after it is rendered.
  141056. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  141057. */
  141058. export class PostProcessRenderEffect {
  141059. private _postProcesses;
  141060. private _getPostProcesses;
  141061. private _singleInstance;
  141062. private _cameras;
  141063. private _indicesForCamera;
  141064. /**
  141065. * Name of the effect
  141066. * @hidden
  141067. */
  141068. _name: string;
  141069. /**
  141070. * Instantiates a post process render effect.
  141071. * A post process can be used to apply a shader to a texture after it is rendered.
  141072. * @param engine The engine the effect is tied to
  141073. * @param name The name of the effect
  141074. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  141075. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  141076. */
  141077. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  141078. /**
  141079. * Checks if all the post processes in the effect are supported.
  141080. */
  141081. get isSupported(): boolean;
  141082. /**
  141083. * Updates the current state of the effect
  141084. * @hidden
  141085. */
  141086. _update(): void;
  141087. /**
  141088. * Attaches the effect on cameras
  141089. * @param cameras The camera to attach to.
  141090. * @hidden
  141091. */
  141092. _attachCameras(cameras: Camera): void;
  141093. /**
  141094. * Attaches the effect on cameras
  141095. * @param cameras The camera to attach to.
  141096. * @hidden
  141097. */
  141098. _attachCameras(cameras: Camera[]): void;
  141099. /**
  141100. * Detaches the effect on cameras
  141101. * @param cameras The camera to detatch from.
  141102. * @hidden
  141103. */
  141104. _detachCameras(cameras: Camera): void;
  141105. /**
  141106. * Detatches the effect on cameras
  141107. * @param cameras The camera to detatch from.
  141108. * @hidden
  141109. */
  141110. _detachCameras(cameras: Camera[]): void;
  141111. /**
  141112. * Enables the effect on given cameras
  141113. * @param cameras The camera to enable.
  141114. * @hidden
  141115. */
  141116. _enable(cameras: Camera): void;
  141117. /**
  141118. * Enables the effect on given cameras
  141119. * @param cameras The camera to enable.
  141120. * @hidden
  141121. */
  141122. _enable(cameras: Nullable<Camera[]>): void;
  141123. /**
  141124. * Disables the effect on the given cameras
  141125. * @param cameras The camera to disable.
  141126. * @hidden
  141127. */
  141128. _disable(cameras: Camera): void;
  141129. /**
  141130. * Disables the effect on the given cameras
  141131. * @param cameras The camera to disable.
  141132. * @hidden
  141133. */
  141134. _disable(cameras: Nullable<Camera[]>): void;
  141135. /**
  141136. * Gets a list of the post processes contained in the effect.
  141137. * @param camera The camera to get the post processes on.
  141138. * @returns The list of the post processes in the effect.
  141139. */
  141140. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  141141. }
  141142. }
  141143. declare module BABYLON {
  141144. /** @hidden */
  141145. export var extractHighlightsPixelShader: {
  141146. name: string;
  141147. shader: string;
  141148. };
  141149. }
  141150. declare module BABYLON {
  141151. /**
  141152. * 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.
  141153. */
  141154. export class ExtractHighlightsPostProcess extends PostProcess {
  141155. /**
  141156. * The luminance threshold, pixels below this value will be set to black.
  141157. */
  141158. threshold: number;
  141159. /** @hidden */
  141160. _exposure: number;
  141161. /**
  141162. * Post process which has the input texture to be used when performing highlight extraction
  141163. * @hidden
  141164. */
  141165. _inputPostProcess: Nullable<PostProcess>;
  141166. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  141167. }
  141168. }
  141169. declare module BABYLON {
  141170. /** @hidden */
  141171. export var bloomMergePixelShader: {
  141172. name: string;
  141173. shader: string;
  141174. };
  141175. }
  141176. declare module BABYLON {
  141177. /**
  141178. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  141179. */
  141180. export class BloomMergePostProcess extends PostProcess {
  141181. /** Weight of the bloom to be added to the original input. */
  141182. weight: number;
  141183. /**
  141184. * Creates a new instance of @see BloomMergePostProcess
  141185. * @param name The name of the effect.
  141186. * @param originalFromInput Post process which's input will be used for the merge.
  141187. * @param blurred Blurred highlights post process which's output will be used.
  141188. * @param weight Weight of the bloom to be added to the original input.
  141189. * @param options The required width/height ratio to downsize to before computing the render pass.
  141190. * @param camera The camera to apply the render pass to.
  141191. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  141192. * @param engine The engine which the post process will be applied. (default: current engine)
  141193. * @param reusable If the post process can be reused on the same frame. (default: false)
  141194. * @param textureType Type of textures used when performing the post process. (default: 0)
  141195. * @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)
  141196. */
  141197. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  141198. /** Weight of the bloom to be added to the original input. */
  141199. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  141200. }
  141201. }
  141202. declare module BABYLON {
  141203. /**
  141204. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  141205. */
  141206. export class BloomEffect extends PostProcessRenderEffect {
  141207. private bloomScale;
  141208. /**
  141209. * @hidden Internal
  141210. */
  141211. _effects: Array<PostProcess>;
  141212. /**
  141213. * @hidden Internal
  141214. */
  141215. _downscale: ExtractHighlightsPostProcess;
  141216. private _blurX;
  141217. private _blurY;
  141218. private _merge;
  141219. /**
  141220. * The luminance threshold to find bright areas of the image to bloom.
  141221. */
  141222. get threshold(): number;
  141223. set threshold(value: number);
  141224. /**
  141225. * The strength of the bloom.
  141226. */
  141227. get weight(): number;
  141228. set weight(value: number);
  141229. /**
  141230. * Specifies the size of the bloom blur kernel, relative to the final output size
  141231. */
  141232. get kernel(): number;
  141233. set kernel(value: number);
  141234. /**
  141235. * Creates a new instance of @see BloomEffect
  141236. * @param scene The scene the effect belongs to.
  141237. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  141238. * @param bloomKernel The size of the kernel to be used when applying the blur.
  141239. * @param bloomWeight The the strength of bloom.
  141240. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  141241. * @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)
  141242. */
  141243. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  141244. /**
  141245. * Disposes each of the internal effects for a given camera.
  141246. * @param camera The camera to dispose the effect on.
  141247. */
  141248. disposeEffects(camera: Camera): void;
  141249. /**
  141250. * @hidden Internal
  141251. */
  141252. _updateEffects(): void;
  141253. /**
  141254. * Internal
  141255. * @returns if all the contained post processes are ready.
  141256. * @hidden
  141257. */
  141258. _isReady(): boolean;
  141259. }
  141260. }
  141261. declare module BABYLON {
  141262. /** @hidden */
  141263. export var chromaticAberrationPixelShader: {
  141264. name: string;
  141265. shader: string;
  141266. };
  141267. }
  141268. declare module BABYLON {
  141269. /**
  141270. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  141271. */
  141272. export class ChromaticAberrationPostProcess extends PostProcess {
  141273. /**
  141274. * The amount of seperation of rgb channels (default: 30)
  141275. */
  141276. aberrationAmount: number;
  141277. /**
  141278. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  141279. */
  141280. radialIntensity: number;
  141281. /**
  141282. * 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))
  141283. */
  141284. direction: Vector2;
  141285. /**
  141286. * 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))
  141287. */
  141288. centerPosition: Vector2;
  141289. /**
  141290. * Creates a new instance ChromaticAberrationPostProcess
  141291. * @param name The name of the effect.
  141292. * @param screenWidth The width of the screen to apply the effect on.
  141293. * @param screenHeight The height of the screen to apply the effect on.
  141294. * @param options The required width/height ratio to downsize to before computing the render pass.
  141295. * @param camera The camera to apply the render pass to.
  141296. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  141297. * @param engine The engine which the post process will be applied. (default: current engine)
  141298. * @param reusable If the post process can be reused on the same frame. (default: false)
  141299. * @param textureType Type of textures used when performing the post process. (default: 0)
  141300. * @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)
  141301. */
  141302. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  141303. }
  141304. }
  141305. declare module BABYLON {
  141306. /** @hidden */
  141307. export var circleOfConfusionPixelShader: {
  141308. name: string;
  141309. shader: string;
  141310. };
  141311. }
  141312. declare module BABYLON {
  141313. /**
  141314. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  141315. */
  141316. export class CircleOfConfusionPostProcess extends PostProcess {
  141317. /**
  141318. * 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.
  141319. */
  141320. lensSize: number;
  141321. /**
  141322. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  141323. */
  141324. fStop: number;
  141325. /**
  141326. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  141327. */
  141328. focusDistance: number;
  141329. /**
  141330. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  141331. */
  141332. focalLength: number;
  141333. private _depthTexture;
  141334. /**
  141335. * Creates a new instance CircleOfConfusionPostProcess
  141336. * @param name The name of the effect.
  141337. * @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.
  141338. * @param options The required width/height ratio to downsize to before computing the render pass.
  141339. * @param camera The camera to apply the render pass to.
  141340. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  141341. * @param engine The engine which the post process will be applied. (default: current engine)
  141342. * @param reusable If the post process can be reused on the same frame. (default: false)
  141343. * @param textureType Type of textures used when performing the post process. (default: 0)
  141344. * @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)
  141345. */
  141346. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  141347. /**
  141348. * 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.
  141349. */
  141350. set depthTexture(value: RenderTargetTexture);
  141351. }
  141352. }
  141353. declare module BABYLON {
  141354. /** @hidden */
  141355. export var colorCorrectionPixelShader: {
  141356. name: string;
  141357. shader: string;
  141358. };
  141359. }
  141360. declare module BABYLON {
  141361. /**
  141362. *
  141363. * This post-process allows the modification of rendered colors by using
  141364. * a 'look-up table' (LUT). This effect is also called Color Grading.
  141365. *
  141366. * The object needs to be provided an url to a texture containing the color
  141367. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  141368. * Use an image editing software to tweak the LUT to match your needs.
  141369. *
  141370. * For an example of a color LUT, see here:
  141371. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  141372. * For explanations on color grading, see here:
  141373. * @see http://udn.epicgames.com/Three/ColorGrading.html
  141374. *
  141375. */
  141376. export class ColorCorrectionPostProcess extends PostProcess {
  141377. private _colorTableTexture;
  141378. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  141379. }
  141380. }
  141381. declare module BABYLON {
  141382. /** @hidden */
  141383. export var convolutionPixelShader: {
  141384. name: string;
  141385. shader: string;
  141386. };
  141387. }
  141388. declare module BABYLON {
  141389. /**
  141390. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  141391. * input texture to perform effects such as edge detection or sharpening
  141392. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  141393. */
  141394. export class ConvolutionPostProcess extends PostProcess {
  141395. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  141396. kernel: number[];
  141397. /**
  141398. * Creates a new instance ConvolutionPostProcess
  141399. * @param name The name of the effect.
  141400. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  141401. * @param options The required width/height ratio to downsize to before computing the render pass.
  141402. * @param camera The camera to apply the render pass to.
  141403. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  141404. * @param engine The engine which the post process will be applied. (default: current engine)
  141405. * @param reusable If the post process can be reused on the same frame. (default: false)
  141406. * @param textureType Type of textures used when performing the post process. (default: 0)
  141407. */
  141408. constructor(name: string,
  141409. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  141410. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  141411. /**
  141412. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  141413. */
  141414. static EdgeDetect0Kernel: number[];
  141415. /**
  141416. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  141417. */
  141418. static EdgeDetect1Kernel: number[];
  141419. /**
  141420. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  141421. */
  141422. static EdgeDetect2Kernel: number[];
  141423. /**
  141424. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  141425. */
  141426. static SharpenKernel: number[];
  141427. /**
  141428. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  141429. */
  141430. static EmbossKernel: number[];
  141431. /**
  141432. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  141433. */
  141434. static GaussianKernel: number[];
  141435. }
  141436. }
  141437. declare module BABYLON {
  141438. /**
  141439. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  141440. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  141441. * based on samples that have a large difference in distance than the center pixel.
  141442. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  141443. */
  141444. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  141445. direction: Vector2;
  141446. /**
  141447. * Creates a new instance CircleOfConfusionPostProcess
  141448. * @param name The name of the effect.
  141449. * @param scene The scene the effect belongs to.
  141450. * @param direction The direction the blur should be applied.
  141451. * @param kernel The size of the kernel used to blur.
  141452. * @param options The required width/height ratio to downsize to before computing the render pass.
  141453. * @param camera The camera to apply the render pass to.
  141454. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  141455. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  141456. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  141457. * @param engine The engine which the post process will be applied. (default: current engine)
  141458. * @param reusable If the post process can be reused on the same frame. (default: false)
  141459. * @param textureType Type of textures used when performing the post process. (default: 0)
  141460. * @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)
  141461. */
  141462. 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);
  141463. }
  141464. }
  141465. declare module BABYLON {
  141466. /** @hidden */
  141467. export var depthOfFieldMergePixelShader: {
  141468. name: string;
  141469. shader: string;
  141470. };
  141471. }
  141472. declare module BABYLON {
  141473. /**
  141474. * Options to be set when merging outputs from the default pipeline.
  141475. */
  141476. export class DepthOfFieldMergePostProcessOptions {
  141477. /**
  141478. * The original image to merge on top of
  141479. */
  141480. originalFromInput: PostProcess;
  141481. /**
  141482. * Parameters to perform the merge of the depth of field effect
  141483. */
  141484. depthOfField?: {
  141485. circleOfConfusion: PostProcess;
  141486. blurSteps: Array<PostProcess>;
  141487. };
  141488. /**
  141489. * Parameters to perform the merge of bloom effect
  141490. */
  141491. bloom?: {
  141492. blurred: PostProcess;
  141493. weight: number;
  141494. };
  141495. }
  141496. /**
  141497. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  141498. */
  141499. export class DepthOfFieldMergePostProcess extends PostProcess {
  141500. private blurSteps;
  141501. /**
  141502. * Creates a new instance of DepthOfFieldMergePostProcess
  141503. * @param name The name of the effect.
  141504. * @param originalFromInput Post process which's input will be used for the merge.
  141505. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  141506. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  141507. * @param options The required width/height ratio to downsize to before computing the render pass.
  141508. * @param camera The camera to apply the render pass to.
  141509. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  141510. * @param engine The engine which the post process will be applied. (default: current engine)
  141511. * @param reusable If the post process can be reused on the same frame. (default: false)
  141512. * @param textureType Type of textures used when performing the post process. (default: 0)
  141513. * @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)
  141514. */
  141515. 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);
  141516. /**
  141517. * Updates the effect with the current post process compile time values and recompiles the shader.
  141518. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  141519. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  141520. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  141521. * @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
  141522. * @param onCompiled Called when the shader has been compiled.
  141523. * @param onError Called if there is an error when compiling a shader.
  141524. */
  141525. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  141526. }
  141527. }
  141528. declare module BABYLON {
  141529. /**
  141530. * Specifies the level of max blur that should be applied when using the depth of field effect
  141531. */
  141532. export enum DepthOfFieldEffectBlurLevel {
  141533. /**
  141534. * Subtle blur
  141535. */
  141536. Low = 0,
  141537. /**
  141538. * Medium blur
  141539. */
  141540. Medium = 1,
  141541. /**
  141542. * Large blur
  141543. */
  141544. High = 2
  141545. }
  141546. /**
  141547. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  141548. */
  141549. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  141550. private _circleOfConfusion;
  141551. /**
  141552. * @hidden Internal, blurs from high to low
  141553. */
  141554. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  141555. private _depthOfFieldBlurY;
  141556. private _dofMerge;
  141557. /**
  141558. * @hidden Internal post processes in depth of field effect
  141559. */
  141560. _effects: Array<PostProcess>;
  141561. /**
  141562. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  141563. */
  141564. set focalLength(value: number);
  141565. get focalLength(): number;
  141566. /**
  141567. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  141568. */
  141569. set fStop(value: number);
  141570. get fStop(): number;
  141571. /**
  141572. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  141573. */
  141574. set focusDistance(value: number);
  141575. get focusDistance(): number;
  141576. /**
  141577. * 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.
  141578. */
  141579. set lensSize(value: number);
  141580. get lensSize(): number;
  141581. /**
  141582. * Creates a new instance DepthOfFieldEffect
  141583. * @param scene The scene the effect belongs to.
  141584. * @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.
  141585. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  141586. * @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)
  141587. */
  141588. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  141589. /**
  141590. * Get the current class name of the current effet
  141591. * @returns "DepthOfFieldEffect"
  141592. */
  141593. getClassName(): string;
  141594. /**
  141595. * 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.
  141596. */
  141597. set depthTexture(value: RenderTargetTexture);
  141598. /**
  141599. * Disposes each of the internal effects for a given camera.
  141600. * @param camera The camera to dispose the effect on.
  141601. */
  141602. disposeEffects(camera: Camera): void;
  141603. /**
  141604. * @hidden Internal
  141605. */
  141606. _updateEffects(): void;
  141607. /**
  141608. * Internal
  141609. * @returns if all the contained post processes are ready.
  141610. * @hidden
  141611. */
  141612. _isReady(): boolean;
  141613. }
  141614. }
  141615. declare module BABYLON {
  141616. /** @hidden */
  141617. export var displayPassPixelShader: {
  141618. name: string;
  141619. shader: string;
  141620. };
  141621. }
  141622. declare module BABYLON {
  141623. /**
  141624. * DisplayPassPostProcess which produces an output the same as it's input
  141625. */
  141626. export class DisplayPassPostProcess extends PostProcess {
  141627. /**
  141628. * Creates the DisplayPassPostProcess
  141629. * @param name The name of the effect.
  141630. * @param options The required width/height ratio to downsize to before computing the render pass.
  141631. * @param camera The camera to apply the render pass to.
  141632. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  141633. * @param engine The engine which the post process will be applied. (default: current engine)
  141634. * @param reusable If the post process can be reused on the same frame. (default: false)
  141635. */
  141636. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  141637. }
  141638. }
  141639. declare module BABYLON {
  141640. /** @hidden */
  141641. export var filterPixelShader: {
  141642. name: string;
  141643. shader: string;
  141644. };
  141645. }
  141646. declare module BABYLON {
  141647. /**
  141648. * Applies a kernel filter to the image
  141649. */
  141650. export class FilterPostProcess extends PostProcess {
  141651. /** The matrix to be applied to the image */
  141652. kernelMatrix: Matrix;
  141653. /**
  141654. *
  141655. * @param name The name of the effect.
  141656. * @param kernelMatrix The matrix to be applied to the image
  141657. * @param options The required width/height ratio to downsize to before computing the render pass.
  141658. * @param camera The camera to apply the render pass to.
  141659. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  141660. * @param engine The engine which the post process will be applied. (default: current engine)
  141661. * @param reusable If the post process can be reused on the same frame. (default: false)
  141662. */
  141663. constructor(name: string,
  141664. /** The matrix to be applied to the image */
  141665. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  141666. }
  141667. }
  141668. declare module BABYLON {
  141669. /** @hidden */
  141670. export var fxaaPixelShader: {
  141671. name: string;
  141672. shader: string;
  141673. };
  141674. }
  141675. declare module BABYLON {
  141676. /** @hidden */
  141677. export var fxaaVertexShader: {
  141678. name: string;
  141679. shader: string;
  141680. };
  141681. }
  141682. declare module BABYLON {
  141683. /**
  141684. * Fxaa post process
  141685. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  141686. */
  141687. export class FxaaPostProcess extends PostProcess {
  141688. /** @hidden */
  141689. texelWidth: number;
  141690. /** @hidden */
  141691. texelHeight: number;
  141692. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  141693. private _getDefines;
  141694. }
  141695. }
  141696. declare module BABYLON {
  141697. /** @hidden */
  141698. export var grainPixelShader: {
  141699. name: string;
  141700. shader: string;
  141701. };
  141702. }
  141703. declare module BABYLON {
  141704. /**
  141705. * The GrainPostProcess adds noise to the image at mid luminance levels
  141706. */
  141707. export class GrainPostProcess extends PostProcess {
  141708. /**
  141709. * The intensity of the grain added (default: 30)
  141710. */
  141711. intensity: number;
  141712. /**
  141713. * If the grain should be randomized on every frame
  141714. */
  141715. animated: boolean;
  141716. /**
  141717. * Creates a new instance of @see GrainPostProcess
  141718. * @param name The name of the effect.
  141719. * @param options The required width/height ratio to downsize to before computing the render pass.
  141720. * @param camera The camera to apply the render pass to.
  141721. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  141722. * @param engine The engine which the post process will be applied. (default: current engine)
  141723. * @param reusable If the post process can be reused on the same frame. (default: false)
  141724. * @param textureType Type of textures used when performing the post process. (default: 0)
  141725. * @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)
  141726. */
  141727. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  141728. }
  141729. }
  141730. declare module BABYLON {
  141731. /** @hidden */
  141732. export var highlightsPixelShader: {
  141733. name: string;
  141734. shader: string;
  141735. };
  141736. }
  141737. declare module BABYLON {
  141738. /**
  141739. * Extracts highlights from the image
  141740. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  141741. */
  141742. export class HighlightsPostProcess extends PostProcess {
  141743. /**
  141744. * Extracts highlights from the image
  141745. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  141746. * @param name The name of the effect.
  141747. * @param options The required width/height ratio to downsize to before computing the render pass.
  141748. * @param camera The camera to apply the render pass to.
  141749. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  141750. * @param engine The engine which the post process will be applied. (default: current engine)
  141751. * @param reusable If the post process can be reused on the same frame. (default: false)
  141752. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  141753. */
  141754. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  141755. }
  141756. }
  141757. declare module BABYLON {
  141758. /** @hidden */
  141759. export var mrtFragmentDeclaration: {
  141760. name: string;
  141761. shader: string;
  141762. };
  141763. }
  141764. declare module BABYLON {
  141765. /** @hidden */
  141766. export var geometryPixelShader: {
  141767. name: string;
  141768. shader: string;
  141769. };
  141770. }
  141771. declare module BABYLON {
  141772. /** @hidden */
  141773. export var geometryVertexShader: {
  141774. name: string;
  141775. shader: string;
  141776. };
  141777. }
  141778. declare module BABYLON {
  141779. /** @hidden */
  141780. interface ISavedTransformationMatrix {
  141781. world: Matrix;
  141782. viewProjection: Matrix;
  141783. }
  141784. /**
  141785. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  141786. */
  141787. export class GeometryBufferRenderer {
  141788. /**
  141789. * Constant used to retrieve the position texture index in the G-Buffer textures array
  141790. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  141791. */
  141792. static readonly POSITION_TEXTURE_TYPE: number;
  141793. /**
  141794. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  141795. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  141796. */
  141797. static readonly VELOCITY_TEXTURE_TYPE: number;
  141798. /**
  141799. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  141800. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  141801. */
  141802. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  141803. /**
  141804. * Dictionary used to store the previous transformation matrices of each rendered mesh
  141805. * in order to compute objects velocities when enableVelocity is set to "true"
  141806. * @hidden
  141807. */
  141808. _previousTransformationMatrices: {
  141809. [index: number]: ISavedTransformationMatrix;
  141810. };
  141811. /**
  141812. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  141813. * in order to compute objects velocities when enableVelocity is set to "true"
  141814. * @hidden
  141815. */
  141816. _previousBonesTransformationMatrices: {
  141817. [index: number]: Float32Array;
  141818. };
  141819. /**
  141820. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  141821. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  141822. */
  141823. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  141824. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  141825. renderTransparentMeshes: boolean;
  141826. private _scene;
  141827. private _multiRenderTarget;
  141828. private _ratio;
  141829. private _enablePosition;
  141830. private _enableVelocity;
  141831. private _enableReflectivity;
  141832. private _positionIndex;
  141833. private _velocityIndex;
  141834. private _reflectivityIndex;
  141835. protected _effect: Effect;
  141836. protected _cachedDefines: string;
  141837. /**
  141838. * Set the render list (meshes to be rendered) used in the G buffer.
  141839. */
  141840. set renderList(meshes: Mesh[]);
  141841. /**
  141842. * Gets wether or not G buffer are supported by the running hardware.
  141843. * This requires draw buffer supports
  141844. */
  141845. get isSupported(): boolean;
  141846. /**
  141847. * Returns the index of the given texture type in the G-Buffer textures array
  141848. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  141849. * @returns the index of the given texture type in the G-Buffer textures array
  141850. */
  141851. getTextureIndex(textureType: number): number;
  141852. /**
  141853. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  141854. */
  141855. get enablePosition(): boolean;
  141856. /**
  141857. * Sets whether or not objects positions are enabled for the G buffer.
  141858. */
  141859. set enablePosition(enable: boolean);
  141860. /**
  141861. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  141862. */
  141863. get enableVelocity(): boolean;
  141864. /**
  141865. * Sets wether or not objects velocities are enabled for the G buffer.
  141866. */
  141867. set enableVelocity(enable: boolean);
  141868. /**
  141869. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  141870. */
  141871. get enableReflectivity(): boolean;
  141872. /**
  141873. * Sets wether or not objects roughness are enabled for the G buffer.
  141874. */
  141875. set enableReflectivity(enable: boolean);
  141876. /**
  141877. * Gets the scene associated with the buffer.
  141878. */
  141879. get scene(): Scene;
  141880. /**
  141881. * Gets the ratio used by the buffer during its creation.
  141882. * How big is the buffer related to the main canvas.
  141883. */
  141884. get ratio(): number;
  141885. /** @hidden */
  141886. static _SceneComponentInitialization: (scene: Scene) => void;
  141887. /**
  141888. * Creates a new G Buffer for the scene
  141889. * @param scene The scene the buffer belongs to
  141890. * @param ratio How big is the buffer related to the main canvas.
  141891. */
  141892. constructor(scene: Scene, ratio?: number);
  141893. /**
  141894. * Checks wether everything is ready to render a submesh to the G buffer.
  141895. * @param subMesh the submesh to check readiness for
  141896. * @param useInstances is the mesh drawn using instance or not
  141897. * @returns true if ready otherwise false
  141898. */
  141899. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  141900. /**
  141901. * Gets the current underlying G Buffer.
  141902. * @returns the buffer
  141903. */
  141904. getGBuffer(): MultiRenderTarget;
  141905. /**
  141906. * Gets the number of samples used to render the buffer (anti aliasing).
  141907. */
  141908. get samples(): number;
  141909. /**
  141910. * Sets the number of samples used to render the buffer (anti aliasing).
  141911. */
  141912. set samples(value: number);
  141913. /**
  141914. * Disposes the renderer and frees up associated resources.
  141915. */
  141916. dispose(): void;
  141917. protected _createRenderTargets(): void;
  141918. private _copyBonesTransformationMatrices;
  141919. }
  141920. }
  141921. declare module BABYLON {
  141922. interface Scene {
  141923. /** @hidden (Backing field) */
  141924. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  141925. /**
  141926. * Gets or Sets the current geometry buffer associated to the scene.
  141927. */
  141928. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  141929. /**
  141930. * Enables a GeometryBufferRender and associates it with the scene
  141931. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  141932. * @returns the GeometryBufferRenderer
  141933. */
  141934. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  141935. /**
  141936. * Disables the GeometryBufferRender associated with the scene
  141937. */
  141938. disableGeometryBufferRenderer(): void;
  141939. }
  141940. /**
  141941. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  141942. * in several rendering techniques.
  141943. */
  141944. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  141945. /**
  141946. * The component name helpful to identify the component in the list of scene components.
  141947. */
  141948. readonly name: string;
  141949. /**
  141950. * The scene the component belongs to.
  141951. */
  141952. scene: Scene;
  141953. /**
  141954. * Creates a new instance of the component for the given scene
  141955. * @param scene Defines the scene to register the component in
  141956. */
  141957. constructor(scene: Scene);
  141958. /**
  141959. * Registers the component in a given scene
  141960. */
  141961. register(): void;
  141962. /**
  141963. * Rebuilds the elements related to this component in case of
  141964. * context lost for instance.
  141965. */
  141966. rebuild(): void;
  141967. /**
  141968. * Disposes the component and the associated ressources
  141969. */
  141970. dispose(): void;
  141971. private _gatherRenderTargets;
  141972. }
  141973. }
  141974. declare module BABYLON {
  141975. /** @hidden */
  141976. export var motionBlurPixelShader: {
  141977. name: string;
  141978. shader: string;
  141979. };
  141980. }
  141981. declare module BABYLON {
  141982. /**
  141983. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  141984. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  141985. * As an example, all you have to do is to create the post-process:
  141986. * var mb = new BABYLON.MotionBlurPostProcess(
  141987. * 'mb', // The name of the effect.
  141988. * scene, // The scene containing the objects to blur according to their velocity.
  141989. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  141990. * camera // The camera to apply the render pass to.
  141991. * );
  141992. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  141993. */
  141994. export class MotionBlurPostProcess extends PostProcess {
  141995. /**
  141996. * Defines how much the image is blurred by the movement. Default value is equal to 1
  141997. */
  141998. motionStrength: number;
  141999. /**
  142000. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  142001. */
  142002. get motionBlurSamples(): number;
  142003. /**
  142004. * Sets the number of iterations to be used for motion blur quality
  142005. */
  142006. set motionBlurSamples(samples: number);
  142007. private _motionBlurSamples;
  142008. private _geometryBufferRenderer;
  142009. /**
  142010. * Creates a new instance MotionBlurPostProcess
  142011. * @param name The name of the effect.
  142012. * @param scene The scene containing the objects to blur according to their velocity.
  142013. * @param options The required width/height ratio to downsize to before computing the render pass.
  142014. * @param camera The camera to apply the render pass to.
  142015. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  142016. * @param engine The engine which the post process will be applied. (default: current engine)
  142017. * @param reusable If the post process can be reused on the same frame. (default: false)
  142018. * @param textureType Type of textures used when performing the post process. (default: 0)
  142019. * @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)
  142020. */
  142021. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  142022. /**
  142023. * Excludes the given skinned mesh from computing bones velocities.
  142024. * 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.
  142025. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  142026. */
  142027. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  142028. /**
  142029. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  142030. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  142031. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  142032. */
  142033. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  142034. /**
  142035. * Disposes the post process.
  142036. * @param camera The camera to dispose the post process on.
  142037. */
  142038. dispose(camera?: Camera): void;
  142039. }
  142040. }
  142041. declare module BABYLON {
  142042. /** @hidden */
  142043. export var refractionPixelShader: {
  142044. name: string;
  142045. shader: string;
  142046. };
  142047. }
  142048. declare module BABYLON {
  142049. /**
  142050. * Post process which applies a refractin texture
  142051. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  142052. */
  142053. export class RefractionPostProcess extends PostProcess {
  142054. /** the base color of the refraction (used to taint the rendering) */
  142055. color: Color3;
  142056. /** simulated refraction depth */
  142057. depth: number;
  142058. /** the coefficient of the base color (0 to remove base color tainting) */
  142059. colorLevel: number;
  142060. private _refTexture;
  142061. private _ownRefractionTexture;
  142062. /**
  142063. * Gets or sets the refraction texture
  142064. * Please note that you are responsible for disposing the texture if you set it manually
  142065. */
  142066. get refractionTexture(): Texture;
  142067. set refractionTexture(value: Texture);
  142068. /**
  142069. * Initializes the RefractionPostProcess
  142070. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  142071. * @param name The name of the effect.
  142072. * @param refractionTextureUrl Url of the refraction texture to use
  142073. * @param color the base color of the refraction (used to taint the rendering)
  142074. * @param depth simulated refraction depth
  142075. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  142076. * @param camera The camera to apply the render pass to.
  142077. * @param options The required width/height ratio to downsize to before computing the render pass.
  142078. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  142079. * @param engine The engine which the post process will be applied. (default: current engine)
  142080. * @param reusable If the post process can be reused on the same frame. (default: false)
  142081. */
  142082. constructor(name: string, refractionTextureUrl: string,
  142083. /** the base color of the refraction (used to taint the rendering) */
  142084. color: Color3,
  142085. /** simulated refraction depth */
  142086. depth: number,
  142087. /** the coefficient of the base color (0 to remove base color tainting) */
  142088. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  142089. /**
  142090. * Disposes of the post process
  142091. * @param camera Camera to dispose post process on
  142092. */
  142093. dispose(camera: Camera): void;
  142094. }
  142095. }
  142096. declare module BABYLON {
  142097. /** @hidden */
  142098. export var sharpenPixelShader: {
  142099. name: string;
  142100. shader: string;
  142101. };
  142102. }
  142103. declare module BABYLON {
  142104. /**
  142105. * The SharpenPostProcess applies a sharpen kernel to every pixel
  142106. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  142107. */
  142108. export class SharpenPostProcess extends PostProcess {
  142109. /**
  142110. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  142111. */
  142112. colorAmount: number;
  142113. /**
  142114. * How much sharpness should be applied (default: 0.3)
  142115. */
  142116. edgeAmount: number;
  142117. /**
  142118. * Creates a new instance ConvolutionPostProcess
  142119. * @param name The name of the effect.
  142120. * @param options The required width/height ratio to downsize to before computing the render pass.
  142121. * @param camera The camera to apply the render pass to.
  142122. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  142123. * @param engine The engine which the post process will be applied. (default: current engine)
  142124. * @param reusable If the post process can be reused on the same frame. (default: false)
  142125. * @param textureType Type of textures used when performing the post process. (default: 0)
  142126. * @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)
  142127. */
  142128. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  142129. }
  142130. }
  142131. declare module BABYLON {
  142132. /**
  142133. * PostProcessRenderPipeline
  142134. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  142135. */
  142136. export class PostProcessRenderPipeline {
  142137. private engine;
  142138. private _renderEffects;
  142139. private _renderEffectsForIsolatedPass;
  142140. /**
  142141. * List of inspectable custom properties (used by the Inspector)
  142142. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  142143. */
  142144. inspectableCustomProperties: IInspectable[];
  142145. /**
  142146. * @hidden
  142147. */
  142148. protected _cameras: Camera[];
  142149. /** @hidden */
  142150. _name: string;
  142151. /**
  142152. * Gets pipeline name
  142153. */
  142154. get name(): string;
  142155. /** Gets the list of attached cameras */
  142156. get cameras(): Camera[];
  142157. /**
  142158. * Initializes a PostProcessRenderPipeline
  142159. * @param engine engine to add the pipeline to
  142160. * @param name name of the pipeline
  142161. */
  142162. constructor(engine: Engine, name: string);
  142163. /**
  142164. * Gets the class name
  142165. * @returns "PostProcessRenderPipeline"
  142166. */
  142167. getClassName(): string;
  142168. /**
  142169. * If all the render effects in the pipeline are supported
  142170. */
  142171. get isSupported(): boolean;
  142172. /**
  142173. * Adds an effect to the pipeline
  142174. * @param renderEffect the effect to add
  142175. */
  142176. addEffect(renderEffect: PostProcessRenderEffect): void;
  142177. /** @hidden */
  142178. _rebuild(): void;
  142179. /** @hidden */
  142180. _enableEffect(renderEffectName: string, cameras: Camera): void;
  142181. /** @hidden */
  142182. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  142183. /** @hidden */
  142184. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  142185. /** @hidden */
  142186. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  142187. /** @hidden */
  142188. _attachCameras(cameras: Camera, unique: boolean): void;
  142189. /** @hidden */
  142190. _attachCameras(cameras: Camera[], unique: boolean): void;
  142191. /** @hidden */
  142192. _detachCameras(cameras: Camera): void;
  142193. /** @hidden */
  142194. _detachCameras(cameras: Nullable<Camera[]>): void;
  142195. /** @hidden */
  142196. _update(): void;
  142197. /** @hidden */
  142198. _reset(): void;
  142199. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  142200. /**
  142201. * Disposes of the pipeline
  142202. */
  142203. dispose(): void;
  142204. }
  142205. }
  142206. declare module BABYLON {
  142207. /**
  142208. * PostProcessRenderPipelineManager class
  142209. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  142210. */
  142211. export class PostProcessRenderPipelineManager {
  142212. private _renderPipelines;
  142213. /**
  142214. * Initializes a PostProcessRenderPipelineManager
  142215. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  142216. */
  142217. constructor();
  142218. /**
  142219. * Gets the list of supported render pipelines
  142220. */
  142221. get supportedPipelines(): PostProcessRenderPipeline[];
  142222. /**
  142223. * Adds a pipeline to the manager
  142224. * @param renderPipeline The pipeline to add
  142225. */
  142226. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  142227. /**
  142228. * Attaches a camera to the pipeline
  142229. * @param renderPipelineName The name of the pipeline to attach to
  142230. * @param cameras the camera to attach
  142231. * @param unique if the camera can be attached multiple times to the pipeline
  142232. */
  142233. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  142234. /**
  142235. * Detaches a camera from the pipeline
  142236. * @param renderPipelineName The name of the pipeline to detach from
  142237. * @param cameras the camera to detach
  142238. */
  142239. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  142240. /**
  142241. * Enables an effect by name on a pipeline
  142242. * @param renderPipelineName the name of the pipeline to enable the effect in
  142243. * @param renderEffectName the name of the effect to enable
  142244. * @param cameras the cameras that the effect should be enabled on
  142245. */
  142246. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  142247. /**
  142248. * Disables an effect by name on a pipeline
  142249. * @param renderPipelineName the name of the pipeline to disable the effect in
  142250. * @param renderEffectName the name of the effect to disable
  142251. * @param cameras the cameras that the effect should be disabled on
  142252. */
  142253. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  142254. /**
  142255. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  142256. */
  142257. update(): void;
  142258. /** @hidden */
  142259. _rebuild(): void;
  142260. /**
  142261. * Disposes of the manager and pipelines
  142262. */
  142263. dispose(): void;
  142264. }
  142265. }
  142266. declare module BABYLON {
  142267. interface Scene {
  142268. /** @hidden (Backing field) */
  142269. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  142270. /**
  142271. * Gets the postprocess render pipeline manager
  142272. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  142273. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  142274. */
  142275. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  142276. }
  142277. /**
  142278. * Defines the Render Pipeline scene component responsible to rendering pipelines
  142279. */
  142280. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  142281. /**
  142282. * The component name helpfull to identify the component in the list of scene components.
  142283. */
  142284. readonly name: string;
  142285. /**
  142286. * The scene the component belongs to.
  142287. */
  142288. scene: Scene;
  142289. /**
  142290. * Creates a new instance of the component for the given scene
  142291. * @param scene Defines the scene to register the component in
  142292. */
  142293. constructor(scene: Scene);
  142294. /**
  142295. * Registers the component in a given scene
  142296. */
  142297. register(): void;
  142298. /**
  142299. * Rebuilds the elements related to this component in case of
  142300. * context lost for instance.
  142301. */
  142302. rebuild(): void;
  142303. /**
  142304. * Disposes the component and the associated ressources
  142305. */
  142306. dispose(): void;
  142307. private _gatherRenderTargets;
  142308. }
  142309. }
  142310. declare module BABYLON {
  142311. /**
  142312. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  142313. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  142314. */
  142315. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  142316. private _scene;
  142317. private _camerasToBeAttached;
  142318. /**
  142319. * ID of the sharpen post process,
  142320. */
  142321. private readonly SharpenPostProcessId;
  142322. /**
  142323. * @ignore
  142324. * ID of the image processing post process;
  142325. */
  142326. readonly ImageProcessingPostProcessId: string;
  142327. /**
  142328. * @ignore
  142329. * ID of the Fast Approximate Anti-Aliasing post process;
  142330. */
  142331. readonly FxaaPostProcessId: string;
  142332. /**
  142333. * ID of the chromatic aberration post process,
  142334. */
  142335. private readonly ChromaticAberrationPostProcessId;
  142336. /**
  142337. * ID of the grain post process
  142338. */
  142339. private readonly GrainPostProcessId;
  142340. /**
  142341. * Sharpen post process which will apply a sharpen convolution to enhance edges
  142342. */
  142343. sharpen: SharpenPostProcess;
  142344. private _sharpenEffect;
  142345. private bloom;
  142346. /**
  142347. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  142348. */
  142349. depthOfField: DepthOfFieldEffect;
  142350. /**
  142351. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  142352. */
  142353. fxaa: FxaaPostProcess;
  142354. /**
  142355. * Image post processing pass used to perform operations such as tone mapping or color grading.
  142356. */
  142357. imageProcessing: ImageProcessingPostProcess;
  142358. /**
  142359. * Chromatic aberration post process which will shift rgb colors in the image
  142360. */
  142361. chromaticAberration: ChromaticAberrationPostProcess;
  142362. private _chromaticAberrationEffect;
  142363. /**
  142364. * Grain post process which add noise to the image
  142365. */
  142366. grain: GrainPostProcess;
  142367. private _grainEffect;
  142368. /**
  142369. * Glow post process which adds a glow to emissive areas of the image
  142370. */
  142371. private _glowLayer;
  142372. /**
  142373. * Animations which can be used to tweak settings over a period of time
  142374. */
  142375. animations: Animation[];
  142376. private _imageProcessingConfigurationObserver;
  142377. private _sharpenEnabled;
  142378. private _bloomEnabled;
  142379. private _depthOfFieldEnabled;
  142380. private _depthOfFieldBlurLevel;
  142381. private _fxaaEnabled;
  142382. private _imageProcessingEnabled;
  142383. private _defaultPipelineTextureType;
  142384. private _bloomScale;
  142385. private _chromaticAberrationEnabled;
  142386. private _grainEnabled;
  142387. private _buildAllowed;
  142388. /**
  142389. * Gets active scene
  142390. */
  142391. get scene(): Scene;
  142392. /**
  142393. * Enable or disable the sharpen process from the pipeline
  142394. */
  142395. set sharpenEnabled(enabled: boolean);
  142396. get sharpenEnabled(): boolean;
  142397. private _resizeObserver;
  142398. private _hardwareScaleLevel;
  142399. private _bloomKernel;
  142400. /**
  142401. * Specifies the size of the bloom blur kernel, relative to the final output size
  142402. */
  142403. get bloomKernel(): number;
  142404. set bloomKernel(value: number);
  142405. /**
  142406. * Specifies the weight of the bloom in the final rendering
  142407. */
  142408. private _bloomWeight;
  142409. /**
  142410. * Specifies the luma threshold for the area that will be blurred by the bloom
  142411. */
  142412. private _bloomThreshold;
  142413. private _hdr;
  142414. /**
  142415. * The strength of the bloom.
  142416. */
  142417. set bloomWeight(value: number);
  142418. get bloomWeight(): number;
  142419. /**
  142420. * The strength of the bloom.
  142421. */
  142422. set bloomThreshold(value: number);
  142423. get bloomThreshold(): number;
  142424. /**
  142425. * The scale of the bloom, lower value will provide better performance.
  142426. */
  142427. set bloomScale(value: number);
  142428. get bloomScale(): number;
  142429. /**
  142430. * Enable or disable the bloom from the pipeline
  142431. */
  142432. set bloomEnabled(enabled: boolean);
  142433. get bloomEnabled(): boolean;
  142434. private _rebuildBloom;
  142435. /**
  142436. * If the depth of field is enabled.
  142437. */
  142438. get depthOfFieldEnabled(): boolean;
  142439. set depthOfFieldEnabled(enabled: boolean);
  142440. /**
  142441. * Blur level of the depth of field effect. (Higher blur will effect performance)
  142442. */
  142443. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  142444. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  142445. /**
  142446. * If the anti aliasing is enabled.
  142447. */
  142448. set fxaaEnabled(enabled: boolean);
  142449. get fxaaEnabled(): boolean;
  142450. private _samples;
  142451. /**
  142452. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  142453. */
  142454. set samples(sampleCount: number);
  142455. get samples(): number;
  142456. /**
  142457. * If image processing is enabled.
  142458. */
  142459. set imageProcessingEnabled(enabled: boolean);
  142460. get imageProcessingEnabled(): boolean;
  142461. /**
  142462. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  142463. */
  142464. set glowLayerEnabled(enabled: boolean);
  142465. get glowLayerEnabled(): boolean;
  142466. /**
  142467. * Gets the glow layer (or null if not defined)
  142468. */
  142469. get glowLayer(): Nullable<GlowLayer>;
  142470. /**
  142471. * Enable or disable the chromaticAberration process from the pipeline
  142472. */
  142473. set chromaticAberrationEnabled(enabled: boolean);
  142474. get chromaticAberrationEnabled(): boolean;
  142475. /**
  142476. * Enable or disable the grain process from the pipeline
  142477. */
  142478. set grainEnabled(enabled: boolean);
  142479. get grainEnabled(): boolean;
  142480. /**
  142481. * @constructor
  142482. * @param name - The rendering pipeline name (default: "")
  142483. * @param hdr - If high dynamic range textures should be used (default: true)
  142484. * @param scene - The scene linked to this pipeline (default: the last created scene)
  142485. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  142486. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  142487. */
  142488. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  142489. /**
  142490. * Get the class name
  142491. * @returns "DefaultRenderingPipeline"
  142492. */
  142493. getClassName(): string;
  142494. /**
  142495. * Force the compilation of the entire pipeline.
  142496. */
  142497. prepare(): void;
  142498. private _hasCleared;
  142499. private _prevPostProcess;
  142500. private _prevPrevPostProcess;
  142501. private _setAutoClearAndTextureSharing;
  142502. private _depthOfFieldSceneObserver;
  142503. private _buildPipeline;
  142504. private _disposePostProcesses;
  142505. /**
  142506. * Adds a camera to the pipeline
  142507. * @param camera the camera to be added
  142508. */
  142509. addCamera(camera: Camera): void;
  142510. /**
  142511. * Removes a camera from the pipeline
  142512. * @param camera the camera to remove
  142513. */
  142514. removeCamera(camera: Camera): void;
  142515. /**
  142516. * Dispose of the pipeline and stop all post processes
  142517. */
  142518. dispose(): void;
  142519. /**
  142520. * Serialize the rendering pipeline (Used when exporting)
  142521. * @returns the serialized object
  142522. */
  142523. serialize(): any;
  142524. /**
  142525. * Parse the serialized pipeline
  142526. * @param source Source pipeline.
  142527. * @param scene The scene to load the pipeline to.
  142528. * @param rootUrl The URL of the serialized pipeline.
  142529. * @returns An instantiated pipeline from the serialized object.
  142530. */
  142531. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  142532. }
  142533. }
  142534. declare module BABYLON {
  142535. /** @hidden */
  142536. export var lensHighlightsPixelShader: {
  142537. name: string;
  142538. shader: string;
  142539. };
  142540. }
  142541. declare module BABYLON {
  142542. /** @hidden */
  142543. export var depthOfFieldPixelShader: {
  142544. name: string;
  142545. shader: string;
  142546. };
  142547. }
  142548. declare module BABYLON {
  142549. /**
  142550. * BABYLON.JS Chromatic Aberration GLSL Shader
  142551. * Author: Olivier Guyot
  142552. * Separates very slightly R, G and B colors on the edges of the screen
  142553. * Inspired by Francois Tarlier & Martins Upitis
  142554. */
  142555. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  142556. /**
  142557. * @ignore
  142558. * The chromatic aberration PostProcess id in the pipeline
  142559. */
  142560. LensChromaticAberrationEffect: string;
  142561. /**
  142562. * @ignore
  142563. * The highlights enhancing PostProcess id in the pipeline
  142564. */
  142565. HighlightsEnhancingEffect: string;
  142566. /**
  142567. * @ignore
  142568. * The depth-of-field PostProcess id in the pipeline
  142569. */
  142570. LensDepthOfFieldEffect: string;
  142571. private _scene;
  142572. private _depthTexture;
  142573. private _grainTexture;
  142574. private _chromaticAberrationPostProcess;
  142575. private _highlightsPostProcess;
  142576. private _depthOfFieldPostProcess;
  142577. private _edgeBlur;
  142578. private _grainAmount;
  142579. private _chromaticAberration;
  142580. private _distortion;
  142581. private _highlightsGain;
  142582. private _highlightsThreshold;
  142583. private _dofDistance;
  142584. private _dofAperture;
  142585. private _dofDarken;
  142586. private _dofPentagon;
  142587. private _blurNoise;
  142588. /**
  142589. * @constructor
  142590. *
  142591. * Effect parameters are as follow:
  142592. * {
  142593. * chromatic_aberration: number; // from 0 to x (1 for realism)
  142594. * edge_blur: number; // from 0 to x (1 for realism)
  142595. * distortion: number; // from 0 to x (1 for realism)
  142596. * grain_amount: number; // from 0 to 1
  142597. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  142598. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  142599. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  142600. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  142601. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  142602. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  142603. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  142604. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  142605. * }
  142606. * Note: if an effect parameter is unset, effect is disabled
  142607. *
  142608. * @param name The rendering pipeline name
  142609. * @param parameters - An object containing all parameters (see above)
  142610. * @param scene The scene linked to this pipeline
  142611. * @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)
  142612. * @param cameras The array of cameras that the rendering pipeline will be attached to
  142613. */
  142614. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  142615. /**
  142616. * Get the class name
  142617. * @returns "LensRenderingPipeline"
  142618. */
  142619. getClassName(): string;
  142620. /**
  142621. * Gets associated scene
  142622. */
  142623. get scene(): Scene;
  142624. /**
  142625. * Gets or sets the edge blur
  142626. */
  142627. get edgeBlur(): number;
  142628. set edgeBlur(value: number);
  142629. /**
  142630. * Gets or sets the grain amount
  142631. */
  142632. get grainAmount(): number;
  142633. set grainAmount(value: number);
  142634. /**
  142635. * Gets or sets the chromatic aberration amount
  142636. */
  142637. get chromaticAberration(): number;
  142638. set chromaticAberration(value: number);
  142639. /**
  142640. * Gets or sets the depth of field aperture
  142641. */
  142642. get dofAperture(): number;
  142643. set dofAperture(value: number);
  142644. /**
  142645. * Gets or sets the edge distortion
  142646. */
  142647. get edgeDistortion(): number;
  142648. set edgeDistortion(value: number);
  142649. /**
  142650. * Gets or sets the depth of field distortion
  142651. */
  142652. get dofDistortion(): number;
  142653. set dofDistortion(value: number);
  142654. /**
  142655. * Gets or sets the darken out of focus amount
  142656. */
  142657. get darkenOutOfFocus(): number;
  142658. set darkenOutOfFocus(value: number);
  142659. /**
  142660. * Gets or sets a boolean indicating if blur noise is enabled
  142661. */
  142662. get blurNoise(): boolean;
  142663. set blurNoise(value: boolean);
  142664. /**
  142665. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  142666. */
  142667. get pentagonBokeh(): boolean;
  142668. set pentagonBokeh(value: boolean);
  142669. /**
  142670. * Gets or sets the highlight grain amount
  142671. */
  142672. get highlightsGain(): number;
  142673. set highlightsGain(value: number);
  142674. /**
  142675. * Gets or sets the highlight threshold
  142676. */
  142677. get highlightsThreshold(): number;
  142678. set highlightsThreshold(value: number);
  142679. /**
  142680. * Sets the amount of blur at the edges
  142681. * @param amount blur amount
  142682. */
  142683. setEdgeBlur(amount: number): void;
  142684. /**
  142685. * Sets edge blur to 0
  142686. */
  142687. disableEdgeBlur(): void;
  142688. /**
  142689. * Sets the amout of grain
  142690. * @param amount Amount of grain
  142691. */
  142692. setGrainAmount(amount: number): void;
  142693. /**
  142694. * Set grain amount to 0
  142695. */
  142696. disableGrain(): void;
  142697. /**
  142698. * Sets the chromatic aberration amount
  142699. * @param amount amount of chromatic aberration
  142700. */
  142701. setChromaticAberration(amount: number): void;
  142702. /**
  142703. * Sets chromatic aberration amount to 0
  142704. */
  142705. disableChromaticAberration(): void;
  142706. /**
  142707. * Sets the EdgeDistortion amount
  142708. * @param amount amount of EdgeDistortion
  142709. */
  142710. setEdgeDistortion(amount: number): void;
  142711. /**
  142712. * Sets edge distortion to 0
  142713. */
  142714. disableEdgeDistortion(): void;
  142715. /**
  142716. * Sets the FocusDistance amount
  142717. * @param amount amount of FocusDistance
  142718. */
  142719. setFocusDistance(amount: number): void;
  142720. /**
  142721. * Disables depth of field
  142722. */
  142723. disableDepthOfField(): void;
  142724. /**
  142725. * Sets the Aperture amount
  142726. * @param amount amount of Aperture
  142727. */
  142728. setAperture(amount: number): void;
  142729. /**
  142730. * Sets the DarkenOutOfFocus amount
  142731. * @param amount amount of DarkenOutOfFocus
  142732. */
  142733. setDarkenOutOfFocus(amount: number): void;
  142734. private _pentagonBokehIsEnabled;
  142735. /**
  142736. * Creates a pentagon bokeh effect
  142737. */
  142738. enablePentagonBokeh(): void;
  142739. /**
  142740. * Disables the pentagon bokeh effect
  142741. */
  142742. disablePentagonBokeh(): void;
  142743. /**
  142744. * Enables noise blur
  142745. */
  142746. enableNoiseBlur(): void;
  142747. /**
  142748. * Disables noise blur
  142749. */
  142750. disableNoiseBlur(): void;
  142751. /**
  142752. * Sets the HighlightsGain amount
  142753. * @param amount amount of HighlightsGain
  142754. */
  142755. setHighlightsGain(amount: number): void;
  142756. /**
  142757. * Sets the HighlightsThreshold amount
  142758. * @param amount amount of HighlightsThreshold
  142759. */
  142760. setHighlightsThreshold(amount: number): void;
  142761. /**
  142762. * Disables highlights
  142763. */
  142764. disableHighlights(): void;
  142765. /**
  142766. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  142767. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  142768. */
  142769. dispose(disableDepthRender?: boolean): void;
  142770. private _createChromaticAberrationPostProcess;
  142771. private _createHighlightsPostProcess;
  142772. private _createDepthOfFieldPostProcess;
  142773. private _createGrainTexture;
  142774. }
  142775. }
  142776. declare module BABYLON {
  142777. /** @hidden */
  142778. export var ssao2PixelShader: {
  142779. name: string;
  142780. shader: string;
  142781. };
  142782. }
  142783. declare module BABYLON {
  142784. /** @hidden */
  142785. export var ssaoCombinePixelShader: {
  142786. name: string;
  142787. shader: string;
  142788. };
  142789. }
  142790. declare module BABYLON {
  142791. /**
  142792. * Render pipeline to produce ssao effect
  142793. */
  142794. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  142795. /**
  142796. * @ignore
  142797. * The PassPostProcess id in the pipeline that contains the original scene color
  142798. */
  142799. SSAOOriginalSceneColorEffect: string;
  142800. /**
  142801. * @ignore
  142802. * The SSAO PostProcess id in the pipeline
  142803. */
  142804. SSAORenderEffect: string;
  142805. /**
  142806. * @ignore
  142807. * The horizontal blur PostProcess id in the pipeline
  142808. */
  142809. SSAOBlurHRenderEffect: string;
  142810. /**
  142811. * @ignore
  142812. * The vertical blur PostProcess id in the pipeline
  142813. */
  142814. SSAOBlurVRenderEffect: string;
  142815. /**
  142816. * @ignore
  142817. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  142818. */
  142819. SSAOCombineRenderEffect: string;
  142820. /**
  142821. * The output strength of the SSAO post-process. Default value is 1.0.
  142822. */
  142823. totalStrength: number;
  142824. /**
  142825. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  142826. */
  142827. maxZ: number;
  142828. /**
  142829. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  142830. */
  142831. minZAspect: number;
  142832. private _samples;
  142833. /**
  142834. * Number of samples used for the SSAO calculations. Default value is 8
  142835. */
  142836. set samples(n: number);
  142837. get samples(): number;
  142838. private _textureSamples;
  142839. /**
  142840. * Number of samples to use for antialiasing
  142841. */
  142842. set textureSamples(n: number);
  142843. get textureSamples(): number;
  142844. /**
  142845. * Ratio object used for SSAO ratio and blur ratio
  142846. */
  142847. private _ratio;
  142848. /**
  142849. * Dynamically generated sphere sampler.
  142850. */
  142851. private _sampleSphere;
  142852. /**
  142853. * Blur filter offsets
  142854. */
  142855. private _samplerOffsets;
  142856. private _expensiveBlur;
  142857. /**
  142858. * If bilateral blur should be used
  142859. */
  142860. set expensiveBlur(b: boolean);
  142861. get expensiveBlur(): boolean;
  142862. /**
  142863. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  142864. */
  142865. radius: number;
  142866. /**
  142867. * The base color of the SSAO post-process
  142868. * The final result is "base + ssao" between [0, 1]
  142869. */
  142870. base: number;
  142871. /**
  142872. * Support test.
  142873. */
  142874. static get IsSupported(): boolean;
  142875. private _scene;
  142876. private _depthTexture;
  142877. private _normalTexture;
  142878. private _randomTexture;
  142879. private _originalColorPostProcess;
  142880. private _ssaoPostProcess;
  142881. private _blurHPostProcess;
  142882. private _blurVPostProcess;
  142883. private _ssaoCombinePostProcess;
  142884. /**
  142885. * Gets active scene
  142886. */
  142887. get scene(): Scene;
  142888. /**
  142889. * @constructor
  142890. * @param name The rendering pipeline name
  142891. * @param scene The scene linked to this pipeline
  142892. * @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 }
  142893. * @param cameras The array of cameras that the rendering pipeline will be attached to
  142894. */
  142895. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  142896. /**
  142897. * Get the class name
  142898. * @returns "SSAO2RenderingPipeline"
  142899. */
  142900. getClassName(): string;
  142901. /**
  142902. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  142903. */
  142904. dispose(disableGeometryBufferRenderer?: boolean): void;
  142905. private _createBlurPostProcess;
  142906. /** @hidden */
  142907. _rebuild(): void;
  142908. private _bits;
  142909. private _radicalInverse_VdC;
  142910. private _hammersley;
  142911. private _hemisphereSample_uniform;
  142912. private _generateHemisphere;
  142913. private _createSSAOPostProcess;
  142914. private _createSSAOCombinePostProcess;
  142915. private _createRandomTexture;
  142916. /**
  142917. * Serialize the rendering pipeline (Used when exporting)
  142918. * @returns the serialized object
  142919. */
  142920. serialize(): any;
  142921. /**
  142922. * Parse the serialized pipeline
  142923. * @param source Source pipeline.
  142924. * @param scene The scene to load the pipeline to.
  142925. * @param rootUrl The URL of the serialized pipeline.
  142926. * @returns An instantiated pipeline from the serialized object.
  142927. */
  142928. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  142929. }
  142930. }
  142931. declare module BABYLON {
  142932. /** @hidden */
  142933. export var ssaoPixelShader: {
  142934. name: string;
  142935. shader: string;
  142936. };
  142937. }
  142938. declare module BABYLON {
  142939. /**
  142940. * Render pipeline to produce ssao effect
  142941. */
  142942. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  142943. /**
  142944. * @ignore
  142945. * The PassPostProcess id in the pipeline that contains the original scene color
  142946. */
  142947. SSAOOriginalSceneColorEffect: string;
  142948. /**
  142949. * @ignore
  142950. * The SSAO PostProcess id in the pipeline
  142951. */
  142952. SSAORenderEffect: string;
  142953. /**
  142954. * @ignore
  142955. * The horizontal blur PostProcess id in the pipeline
  142956. */
  142957. SSAOBlurHRenderEffect: string;
  142958. /**
  142959. * @ignore
  142960. * The vertical blur PostProcess id in the pipeline
  142961. */
  142962. SSAOBlurVRenderEffect: string;
  142963. /**
  142964. * @ignore
  142965. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  142966. */
  142967. SSAOCombineRenderEffect: string;
  142968. /**
  142969. * The output strength of the SSAO post-process. Default value is 1.0.
  142970. */
  142971. totalStrength: number;
  142972. /**
  142973. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  142974. */
  142975. radius: number;
  142976. /**
  142977. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  142978. * Must not be equal to fallOff and superior to fallOff.
  142979. * Default value is 0.0075
  142980. */
  142981. area: number;
  142982. /**
  142983. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  142984. * Must not be equal to area and inferior to area.
  142985. * Default value is 0.000001
  142986. */
  142987. fallOff: number;
  142988. /**
  142989. * The base color of the SSAO post-process
  142990. * The final result is "base + ssao" between [0, 1]
  142991. */
  142992. base: number;
  142993. private _scene;
  142994. private _depthTexture;
  142995. private _randomTexture;
  142996. private _originalColorPostProcess;
  142997. private _ssaoPostProcess;
  142998. private _blurHPostProcess;
  142999. private _blurVPostProcess;
  143000. private _ssaoCombinePostProcess;
  143001. private _firstUpdate;
  143002. /**
  143003. * Gets active scene
  143004. */
  143005. get scene(): Scene;
  143006. /**
  143007. * @constructor
  143008. * @param name - The rendering pipeline name
  143009. * @param scene - The scene linked to this pipeline
  143010. * @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 }
  143011. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  143012. */
  143013. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  143014. /**
  143015. * Get the class name
  143016. * @returns "SSAORenderingPipeline"
  143017. */
  143018. getClassName(): string;
  143019. /**
  143020. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  143021. */
  143022. dispose(disableDepthRender?: boolean): void;
  143023. private _createBlurPostProcess;
  143024. /** @hidden */
  143025. _rebuild(): void;
  143026. private _createSSAOPostProcess;
  143027. private _createSSAOCombinePostProcess;
  143028. private _createRandomTexture;
  143029. }
  143030. }
  143031. declare module BABYLON {
  143032. /** @hidden */
  143033. export var screenSpaceReflectionPixelShader: {
  143034. name: string;
  143035. shader: string;
  143036. };
  143037. }
  143038. declare module BABYLON {
  143039. /**
  143040. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  143041. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  143042. */
  143043. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  143044. /**
  143045. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  143046. */
  143047. threshold: number;
  143048. /**
  143049. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  143050. */
  143051. strength: number;
  143052. /**
  143053. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  143054. */
  143055. reflectionSpecularFalloffExponent: number;
  143056. /**
  143057. * 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]
  143058. */
  143059. step: number;
  143060. /**
  143061. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  143062. */
  143063. roughnessFactor: number;
  143064. private _geometryBufferRenderer;
  143065. private _enableSmoothReflections;
  143066. private _reflectionSamples;
  143067. private _smoothSteps;
  143068. /**
  143069. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  143070. * @param name The name of the effect.
  143071. * @param scene The scene containing the objects to calculate reflections.
  143072. * @param options The required width/height ratio to downsize to before computing the render pass.
  143073. * @param camera The camera to apply the render pass to.
  143074. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  143075. * @param engine The engine which the post process will be applied. (default: current engine)
  143076. * @param reusable If the post process can be reused on the same frame. (default: false)
  143077. * @param textureType Type of textures used when performing the post process. (default: 0)
  143078. * @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)
  143079. */
  143080. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  143081. /**
  143082. * Gets wether or not smoothing reflections is enabled.
  143083. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  143084. */
  143085. get enableSmoothReflections(): boolean;
  143086. /**
  143087. * Sets wether or not smoothing reflections is enabled.
  143088. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  143089. */
  143090. set enableSmoothReflections(enabled: boolean);
  143091. /**
  143092. * Gets the number of samples taken while computing reflections. More samples count is high,
  143093. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  143094. */
  143095. get reflectionSamples(): number;
  143096. /**
  143097. * Sets the number of samples taken while computing reflections. More samples count is high,
  143098. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  143099. */
  143100. set reflectionSamples(samples: number);
  143101. /**
  143102. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  143103. * more the post-process will require GPU power and can generate a drop in FPS.
  143104. * Default value (5.0) work pretty well in all cases but can be adjusted.
  143105. */
  143106. get smoothSteps(): number;
  143107. set smoothSteps(steps: number);
  143108. private _updateEffectDefines;
  143109. }
  143110. }
  143111. declare module BABYLON {
  143112. /** @hidden */
  143113. export var standardPixelShader: {
  143114. name: string;
  143115. shader: string;
  143116. };
  143117. }
  143118. declare module BABYLON {
  143119. /**
  143120. * Standard rendering pipeline
  143121. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  143122. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  143123. */
  143124. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  143125. /**
  143126. * Public members
  143127. */
  143128. /**
  143129. * Post-process which contains the original scene color before the pipeline applies all the effects
  143130. */
  143131. originalPostProcess: Nullable<PostProcess>;
  143132. /**
  143133. * Post-process used to down scale an image x4
  143134. */
  143135. downSampleX4PostProcess: Nullable<PostProcess>;
  143136. /**
  143137. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  143138. */
  143139. brightPassPostProcess: Nullable<PostProcess>;
  143140. /**
  143141. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  143142. */
  143143. blurHPostProcesses: PostProcess[];
  143144. /**
  143145. * Post-process array storing all the vertical blur post-processes used by the pipeline
  143146. */
  143147. blurVPostProcesses: PostProcess[];
  143148. /**
  143149. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  143150. */
  143151. textureAdderPostProcess: Nullable<PostProcess>;
  143152. /**
  143153. * Post-process used to create volumetric lighting effect
  143154. */
  143155. volumetricLightPostProcess: Nullable<PostProcess>;
  143156. /**
  143157. * Post-process used to smooth the previous volumetric light post-process on the X axis
  143158. */
  143159. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  143160. /**
  143161. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  143162. */
  143163. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  143164. /**
  143165. * Post-process used to merge the volumetric light effect and the real scene color
  143166. */
  143167. volumetricLightMergePostProces: Nullable<PostProcess>;
  143168. /**
  143169. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  143170. */
  143171. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  143172. /**
  143173. * Base post-process used to calculate the average luminance of the final image for HDR
  143174. */
  143175. luminancePostProcess: Nullable<PostProcess>;
  143176. /**
  143177. * Post-processes used to create down sample post-processes in order to get
  143178. * the average luminance of the final image for HDR
  143179. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  143180. */
  143181. luminanceDownSamplePostProcesses: PostProcess[];
  143182. /**
  143183. * Post-process used to create a HDR effect (light adaptation)
  143184. */
  143185. hdrPostProcess: Nullable<PostProcess>;
  143186. /**
  143187. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  143188. */
  143189. textureAdderFinalPostProcess: Nullable<PostProcess>;
  143190. /**
  143191. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  143192. */
  143193. lensFlareFinalPostProcess: Nullable<PostProcess>;
  143194. /**
  143195. * Post-process used to merge the final HDR post-process and the real scene color
  143196. */
  143197. hdrFinalPostProcess: Nullable<PostProcess>;
  143198. /**
  143199. * Post-process used to create a lens flare effect
  143200. */
  143201. lensFlarePostProcess: Nullable<PostProcess>;
  143202. /**
  143203. * Post-process that merges the result of the lens flare post-process and the real scene color
  143204. */
  143205. lensFlareComposePostProcess: Nullable<PostProcess>;
  143206. /**
  143207. * Post-process used to create a motion blur effect
  143208. */
  143209. motionBlurPostProcess: Nullable<PostProcess>;
  143210. /**
  143211. * Post-process used to create a depth of field effect
  143212. */
  143213. depthOfFieldPostProcess: Nullable<PostProcess>;
  143214. /**
  143215. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  143216. */
  143217. fxaaPostProcess: Nullable<FxaaPostProcess>;
  143218. /**
  143219. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  143220. */
  143221. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  143222. /**
  143223. * Represents the brightness threshold in order to configure the illuminated surfaces
  143224. */
  143225. brightThreshold: number;
  143226. /**
  143227. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  143228. */
  143229. blurWidth: number;
  143230. /**
  143231. * Sets if the blur for highlighted surfaces must be only horizontal
  143232. */
  143233. horizontalBlur: boolean;
  143234. /**
  143235. * Gets the overall exposure used by the pipeline
  143236. */
  143237. get exposure(): number;
  143238. /**
  143239. * Sets the overall exposure used by the pipeline
  143240. */
  143241. set exposure(value: number);
  143242. /**
  143243. * Texture used typically to simulate "dirty" on camera lens
  143244. */
  143245. lensTexture: Nullable<Texture>;
  143246. /**
  143247. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  143248. */
  143249. volumetricLightCoefficient: number;
  143250. /**
  143251. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  143252. */
  143253. volumetricLightPower: number;
  143254. /**
  143255. * Used the set the blur intensity to smooth the volumetric lights
  143256. */
  143257. volumetricLightBlurScale: number;
  143258. /**
  143259. * Light (spot or directional) used to generate the volumetric lights rays
  143260. * The source light must have a shadow generate so the pipeline can get its
  143261. * depth map
  143262. */
  143263. sourceLight: Nullable<SpotLight | DirectionalLight>;
  143264. /**
  143265. * For eye adaptation, represents the minimum luminance the eye can see
  143266. */
  143267. hdrMinimumLuminance: number;
  143268. /**
  143269. * For eye adaptation, represents the decrease luminance speed
  143270. */
  143271. hdrDecreaseRate: number;
  143272. /**
  143273. * For eye adaptation, represents the increase luminance speed
  143274. */
  143275. hdrIncreaseRate: number;
  143276. /**
  143277. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  143278. */
  143279. get hdrAutoExposure(): boolean;
  143280. /**
  143281. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  143282. */
  143283. set hdrAutoExposure(value: boolean);
  143284. /**
  143285. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  143286. */
  143287. lensColorTexture: Nullable<Texture>;
  143288. /**
  143289. * The overall strengh for the lens flare effect
  143290. */
  143291. lensFlareStrength: number;
  143292. /**
  143293. * Dispersion coefficient for lens flare ghosts
  143294. */
  143295. lensFlareGhostDispersal: number;
  143296. /**
  143297. * Main lens flare halo width
  143298. */
  143299. lensFlareHaloWidth: number;
  143300. /**
  143301. * Based on the lens distortion effect, defines how much the lens flare result
  143302. * is distorted
  143303. */
  143304. lensFlareDistortionStrength: number;
  143305. /**
  143306. * Configures the blur intensity used for for lens flare (halo)
  143307. */
  143308. lensFlareBlurWidth: number;
  143309. /**
  143310. * Lens star texture must be used to simulate rays on the flares and is available
  143311. * in the documentation
  143312. */
  143313. lensStarTexture: Nullable<Texture>;
  143314. /**
  143315. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  143316. * flare effect by taking account of the dirt texture
  143317. */
  143318. lensFlareDirtTexture: Nullable<Texture>;
  143319. /**
  143320. * Represents the focal length for the depth of field effect
  143321. */
  143322. depthOfFieldDistance: number;
  143323. /**
  143324. * Represents the blur intensity for the blurred part of the depth of field effect
  143325. */
  143326. depthOfFieldBlurWidth: number;
  143327. /**
  143328. * Gets how much the image is blurred by the movement while using the motion blur post-process
  143329. */
  143330. get motionStrength(): number;
  143331. /**
  143332. * Sets how much the image is blurred by the movement while using the motion blur post-process
  143333. */
  143334. set motionStrength(strength: number);
  143335. /**
  143336. * Gets wether or not the motion blur post-process is object based or screen based.
  143337. */
  143338. get objectBasedMotionBlur(): boolean;
  143339. /**
  143340. * Sets wether or not the motion blur post-process should be object based or screen based
  143341. */
  143342. set objectBasedMotionBlur(value: boolean);
  143343. /**
  143344. * List of animations for the pipeline (IAnimatable implementation)
  143345. */
  143346. animations: Animation[];
  143347. /**
  143348. * Private members
  143349. */
  143350. private _scene;
  143351. private _currentDepthOfFieldSource;
  143352. private _basePostProcess;
  143353. private _fixedExposure;
  143354. private _currentExposure;
  143355. private _hdrAutoExposure;
  143356. private _hdrCurrentLuminance;
  143357. private _motionStrength;
  143358. private _isObjectBasedMotionBlur;
  143359. private _floatTextureType;
  143360. private _camerasToBeAttached;
  143361. private _ratio;
  143362. private _bloomEnabled;
  143363. private _depthOfFieldEnabled;
  143364. private _vlsEnabled;
  143365. private _lensFlareEnabled;
  143366. private _hdrEnabled;
  143367. private _motionBlurEnabled;
  143368. private _fxaaEnabled;
  143369. private _screenSpaceReflectionsEnabled;
  143370. private _motionBlurSamples;
  143371. private _volumetricLightStepsCount;
  143372. private _samples;
  143373. /**
  143374. * @ignore
  143375. * Specifies if the bloom pipeline is enabled
  143376. */
  143377. get BloomEnabled(): boolean;
  143378. set BloomEnabled(enabled: boolean);
  143379. /**
  143380. * @ignore
  143381. * Specifies if the depth of field pipeline is enabed
  143382. */
  143383. get DepthOfFieldEnabled(): boolean;
  143384. set DepthOfFieldEnabled(enabled: boolean);
  143385. /**
  143386. * @ignore
  143387. * Specifies if the lens flare pipeline is enabed
  143388. */
  143389. get LensFlareEnabled(): boolean;
  143390. set LensFlareEnabled(enabled: boolean);
  143391. /**
  143392. * @ignore
  143393. * Specifies if the HDR pipeline is enabled
  143394. */
  143395. get HDREnabled(): boolean;
  143396. set HDREnabled(enabled: boolean);
  143397. /**
  143398. * @ignore
  143399. * Specifies if the volumetric lights scattering effect is enabled
  143400. */
  143401. get VLSEnabled(): boolean;
  143402. set VLSEnabled(enabled: boolean);
  143403. /**
  143404. * @ignore
  143405. * Specifies if the motion blur effect is enabled
  143406. */
  143407. get MotionBlurEnabled(): boolean;
  143408. set MotionBlurEnabled(enabled: boolean);
  143409. /**
  143410. * Specifies if anti-aliasing is enabled
  143411. */
  143412. get fxaaEnabled(): boolean;
  143413. set fxaaEnabled(enabled: boolean);
  143414. /**
  143415. * Specifies if screen space reflections are enabled.
  143416. */
  143417. get screenSpaceReflectionsEnabled(): boolean;
  143418. set screenSpaceReflectionsEnabled(enabled: boolean);
  143419. /**
  143420. * Specifies the number of steps used to calculate the volumetric lights
  143421. * Typically in interval [50, 200]
  143422. */
  143423. get volumetricLightStepsCount(): number;
  143424. set volumetricLightStepsCount(count: number);
  143425. /**
  143426. * Specifies the number of samples used for the motion blur effect
  143427. * Typically in interval [16, 64]
  143428. */
  143429. get motionBlurSamples(): number;
  143430. set motionBlurSamples(samples: number);
  143431. /**
  143432. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  143433. */
  143434. get samples(): number;
  143435. set samples(sampleCount: number);
  143436. /**
  143437. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  143438. * @constructor
  143439. * @param name The rendering pipeline name
  143440. * @param scene The scene linked to this pipeline
  143441. * @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)
  143442. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  143443. * @param cameras The array of cameras that the rendering pipeline will be attached to
  143444. */
  143445. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  143446. private _buildPipeline;
  143447. private _createDownSampleX4PostProcess;
  143448. private _createBrightPassPostProcess;
  143449. private _createBlurPostProcesses;
  143450. private _createTextureAdderPostProcess;
  143451. private _createVolumetricLightPostProcess;
  143452. private _createLuminancePostProcesses;
  143453. private _createHdrPostProcess;
  143454. private _createLensFlarePostProcess;
  143455. private _createDepthOfFieldPostProcess;
  143456. private _createMotionBlurPostProcess;
  143457. private _getDepthTexture;
  143458. private _disposePostProcesses;
  143459. /**
  143460. * Dispose of the pipeline and stop all post processes
  143461. */
  143462. dispose(): void;
  143463. /**
  143464. * Serialize the rendering pipeline (Used when exporting)
  143465. * @returns the serialized object
  143466. */
  143467. serialize(): any;
  143468. /**
  143469. * Parse the serialized pipeline
  143470. * @param source Source pipeline.
  143471. * @param scene The scene to load the pipeline to.
  143472. * @param rootUrl The URL of the serialized pipeline.
  143473. * @returns An instantiated pipeline from the serialized object.
  143474. */
  143475. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  143476. /**
  143477. * Luminance steps
  143478. */
  143479. static LuminanceSteps: number;
  143480. }
  143481. }
  143482. declare module BABYLON {
  143483. /** @hidden */
  143484. export var stereoscopicInterlacePixelShader: {
  143485. name: string;
  143486. shader: string;
  143487. };
  143488. }
  143489. declare module BABYLON {
  143490. /**
  143491. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  143492. */
  143493. export class StereoscopicInterlacePostProcessI extends PostProcess {
  143494. private _stepSize;
  143495. private _passedProcess;
  143496. /**
  143497. * Initializes a StereoscopicInterlacePostProcessI
  143498. * @param name The name of the effect.
  143499. * @param rigCameras The rig cameras to be appled to the post process
  143500. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  143501. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  143502. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  143503. * @param engine The engine which the post process will be applied. (default: current engine)
  143504. * @param reusable If the post process can be reused on the same frame. (default: false)
  143505. */
  143506. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  143507. }
  143508. /**
  143509. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  143510. */
  143511. export class StereoscopicInterlacePostProcess extends PostProcess {
  143512. private _stepSize;
  143513. private _passedProcess;
  143514. /**
  143515. * Initializes a StereoscopicInterlacePostProcess
  143516. * @param name The name of the effect.
  143517. * @param rigCameras The rig cameras to be appled to the post process
  143518. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  143519. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  143520. * @param engine The engine which the post process will be applied. (default: current engine)
  143521. * @param reusable If the post process can be reused on the same frame. (default: false)
  143522. */
  143523. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  143524. }
  143525. }
  143526. declare module BABYLON {
  143527. /** @hidden */
  143528. export var tonemapPixelShader: {
  143529. name: string;
  143530. shader: string;
  143531. };
  143532. }
  143533. declare module BABYLON {
  143534. /** Defines operator used for tonemapping */
  143535. export enum TonemappingOperator {
  143536. /** Hable */
  143537. Hable = 0,
  143538. /** Reinhard */
  143539. Reinhard = 1,
  143540. /** HejiDawson */
  143541. HejiDawson = 2,
  143542. /** Photographic */
  143543. Photographic = 3
  143544. }
  143545. /**
  143546. * Defines a post process to apply tone mapping
  143547. */
  143548. export class TonemapPostProcess extends PostProcess {
  143549. private _operator;
  143550. /** Defines the required exposure adjustement */
  143551. exposureAdjustment: number;
  143552. /**
  143553. * Creates a new TonemapPostProcess
  143554. * @param name defines the name of the postprocess
  143555. * @param _operator defines the operator to use
  143556. * @param exposureAdjustment defines the required exposure adjustement
  143557. * @param camera defines the camera to use (can be null)
  143558. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  143559. * @param engine defines the hosting engine (can be ignore if camera is set)
  143560. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  143561. */
  143562. constructor(name: string, _operator: TonemappingOperator,
  143563. /** Defines the required exposure adjustement */
  143564. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  143565. }
  143566. }
  143567. declare module BABYLON {
  143568. /** @hidden */
  143569. export var volumetricLightScatteringPixelShader: {
  143570. name: string;
  143571. shader: string;
  143572. };
  143573. }
  143574. declare module BABYLON {
  143575. /** @hidden */
  143576. export var volumetricLightScatteringPassVertexShader: {
  143577. name: string;
  143578. shader: string;
  143579. };
  143580. }
  143581. declare module BABYLON {
  143582. /** @hidden */
  143583. export var volumetricLightScatteringPassPixelShader: {
  143584. name: string;
  143585. shader: string;
  143586. };
  143587. }
  143588. declare module BABYLON {
  143589. /**
  143590. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  143591. */
  143592. export class VolumetricLightScatteringPostProcess extends PostProcess {
  143593. private _volumetricLightScatteringPass;
  143594. private _volumetricLightScatteringRTT;
  143595. private _viewPort;
  143596. private _screenCoordinates;
  143597. private _cachedDefines;
  143598. /**
  143599. * If not undefined, the mesh position is computed from the attached node position
  143600. */
  143601. attachedNode: {
  143602. position: Vector3;
  143603. };
  143604. /**
  143605. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  143606. */
  143607. customMeshPosition: Vector3;
  143608. /**
  143609. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  143610. */
  143611. useCustomMeshPosition: boolean;
  143612. /**
  143613. * If the post-process should inverse the light scattering direction
  143614. */
  143615. invert: boolean;
  143616. /**
  143617. * The internal mesh used by the post-process
  143618. */
  143619. mesh: Mesh;
  143620. /**
  143621. * @hidden
  143622. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  143623. */
  143624. get useDiffuseColor(): boolean;
  143625. set useDiffuseColor(useDiffuseColor: boolean);
  143626. /**
  143627. * Array containing the excluded meshes not rendered in the internal pass
  143628. */
  143629. excludedMeshes: AbstractMesh[];
  143630. /**
  143631. * Controls the overall intensity of the post-process
  143632. */
  143633. exposure: number;
  143634. /**
  143635. * Dissipates each sample's contribution in range [0, 1]
  143636. */
  143637. decay: number;
  143638. /**
  143639. * Controls the overall intensity of each sample
  143640. */
  143641. weight: number;
  143642. /**
  143643. * Controls the density of each sample
  143644. */
  143645. density: number;
  143646. /**
  143647. * @constructor
  143648. * @param name The post-process name
  143649. * @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)
  143650. * @param camera The camera that the post-process will be attached to
  143651. * @param mesh The mesh used to create the light scattering
  143652. * @param samples The post-process quality, default 100
  143653. * @param samplingModeThe post-process filtering mode
  143654. * @param engine The babylon engine
  143655. * @param reusable If the post-process is reusable
  143656. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  143657. */
  143658. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  143659. /**
  143660. * Returns the string "VolumetricLightScatteringPostProcess"
  143661. * @returns "VolumetricLightScatteringPostProcess"
  143662. */
  143663. getClassName(): string;
  143664. private _isReady;
  143665. /**
  143666. * Sets the new light position for light scattering effect
  143667. * @param position The new custom light position
  143668. */
  143669. setCustomMeshPosition(position: Vector3): void;
  143670. /**
  143671. * Returns the light position for light scattering effect
  143672. * @return Vector3 The custom light position
  143673. */
  143674. getCustomMeshPosition(): Vector3;
  143675. /**
  143676. * Disposes the internal assets and detaches the post-process from the camera
  143677. */
  143678. dispose(camera: Camera): void;
  143679. /**
  143680. * Returns the render target texture used by the post-process
  143681. * @return the render target texture used by the post-process
  143682. */
  143683. getPass(): RenderTargetTexture;
  143684. private _meshExcluded;
  143685. private _createPass;
  143686. private _updateMeshScreenCoordinates;
  143687. /**
  143688. * Creates a default mesh for the Volumeric Light Scattering post-process
  143689. * @param name The mesh name
  143690. * @param scene The scene where to create the mesh
  143691. * @return the default mesh
  143692. */
  143693. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  143694. }
  143695. }
  143696. declare module BABYLON {
  143697. interface Scene {
  143698. /** @hidden (Backing field) */
  143699. _boundingBoxRenderer: BoundingBoxRenderer;
  143700. /** @hidden (Backing field) */
  143701. _forceShowBoundingBoxes: boolean;
  143702. /**
  143703. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  143704. */
  143705. forceShowBoundingBoxes: boolean;
  143706. /**
  143707. * Gets the bounding box renderer associated with the scene
  143708. * @returns a BoundingBoxRenderer
  143709. */
  143710. getBoundingBoxRenderer(): BoundingBoxRenderer;
  143711. }
  143712. interface AbstractMesh {
  143713. /** @hidden (Backing field) */
  143714. _showBoundingBox: boolean;
  143715. /**
  143716. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  143717. */
  143718. showBoundingBox: boolean;
  143719. }
  143720. /**
  143721. * Component responsible of rendering the bounding box of the meshes in a scene.
  143722. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  143723. */
  143724. export class BoundingBoxRenderer implements ISceneComponent {
  143725. /**
  143726. * The component name helpfull to identify the component in the list of scene components.
  143727. */
  143728. readonly name: string;
  143729. /**
  143730. * The scene the component belongs to.
  143731. */
  143732. scene: Scene;
  143733. /**
  143734. * Color of the bounding box lines placed in front of an object
  143735. */
  143736. frontColor: Color3;
  143737. /**
  143738. * Color of the bounding box lines placed behind an object
  143739. */
  143740. backColor: Color3;
  143741. /**
  143742. * Defines if the renderer should show the back lines or not
  143743. */
  143744. showBackLines: boolean;
  143745. /**
  143746. * @hidden
  143747. */
  143748. renderList: SmartArray<BoundingBox>;
  143749. private _colorShader;
  143750. private _vertexBuffers;
  143751. private _indexBuffer;
  143752. private _fillIndexBuffer;
  143753. private _fillIndexData;
  143754. /**
  143755. * Instantiates a new bounding box renderer in a scene.
  143756. * @param scene the scene the renderer renders in
  143757. */
  143758. constructor(scene: Scene);
  143759. /**
  143760. * Registers the component in a given scene
  143761. */
  143762. register(): void;
  143763. private _evaluateSubMesh;
  143764. private _activeMesh;
  143765. private _prepareRessources;
  143766. private _createIndexBuffer;
  143767. /**
  143768. * Rebuilds the elements related to this component in case of
  143769. * context lost for instance.
  143770. */
  143771. rebuild(): void;
  143772. /**
  143773. * @hidden
  143774. */
  143775. reset(): void;
  143776. /**
  143777. * Render the bounding boxes of a specific rendering group
  143778. * @param renderingGroupId defines the rendering group to render
  143779. */
  143780. render(renderingGroupId: number): void;
  143781. /**
  143782. * In case of occlusion queries, we can render the occlusion bounding box through this method
  143783. * @param mesh Define the mesh to render the occlusion bounding box for
  143784. */
  143785. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  143786. /**
  143787. * Dispose and release the resources attached to this renderer.
  143788. */
  143789. dispose(): void;
  143790. }
  143791. }
  143792. declare module BABYLON {
  143793. interface Scene {
  143794. /** @hidden (Backing field) */
  143795. _depthRenderer: {
  143796. [id: string]: DepthRenderer;
  143797. };
  143798. /**
  143799. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  143800. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  143801. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  143802. * @returns the created depth renderer
  143803. */
  143804. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  143805. /**
  143806. * Disables a depth renderer for a given camera
  143807. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  143808. */
  143809. disableDepthRenderer(camera?: Nullable<Camera>): void;
  143810. }
  143811. /**
  143812. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  143813. * in several rendering techniques.
  143814. */
  143815. export class DepthRendererSceneComponent implements ISceneComponent {
  143816. /**
  143817. * The component name helpfull to identify the component in the list of scene components.
  143818. */
  143819. readonly name: string;
  143820. /**
  143821. * The scene the component belongs to.
  143822. */
  143823. scene: Scene;
  143824. /**
  143825. * Creates a new instance of the component for the given scene
  143826. * @param scene Defines the scene to register the component in
  143827. */
  143828. constructor(scene: Scene);
  143829. /**
  143830. * Registers the component in a given scene
  143831. */
  143832. register(): void;
  143833. /**
  143834. * Rebuilds the elements related to this component in case of
  143835. * context lost for instance.
  143836. */
  143837. rebuild(): void;
  143838. /**
  143839. * Disposes the component and the associated ressources
  143840. */
  143841. dispose(): void;
  143842. private _gatherRenderTargets;
  143843. private _gatherActiveCameraRenderTargets;
  143844. }
  143845. }
  143846. declare module BABYLON {
  143847. /** @hidden */
  143848. export var outlinePixelShader: {
  143849. name: string;
  143850. shader: string;
  143851. };
  143852. }
  143853. declare module BABYLON {
  143854. /** @hidden */
  143855. export var outlineVertexShader: {
  143856. name: string;
  143857. shader: string;
  143858. };
  143859. }
  143860. declare module BABYLON {
  143861. interface Scene {
  143862. /** @hidden */
  143863. _outlineRenderer: OutlineRenderer;
  143864. /**
  143865. * Gets the outline renderer associated with the scene
  143866. * @returns a OutlineRenderer
  143867. */
  143868. getOutlineRenderer(): OutlineRenderer;
  143869. }
  143870. interface AbstractMesh {
  143871. /** @hidden (Backing field) */
  143872. _renderOutline: boolean;
  143873. /**
  143874. * Gets or sets a boolean indicating if the outline must be rendered as well
  143875. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  143876. */
  143877. renderOutline: boolean;
  143878. /** @hidden (Backing field) */
  143879. _renderOverlay: boolean;
  143880. /**
  143881. * Gets or sets a boolean indicating if the overlay must be rendered as well
  143882. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  143883. */
  143884. renderOverlay: boolean;
  143885. }
  143886. /**
  143887. * This class is responsible to draw bothe outline/overlay of meshes.
  143888. * It should not be used directly but through the available method on mesh.
  143889. */
  143890. export class OutlineRenderer implements ISceneComponent {
  143891. /**
  143892. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  143893. */
  143894. private static _StencilReference;
  143895. /**
  143896. * The name of the component. Each component must have a unique name.
  143897. */
  143898. name: string;
  143899. /**
  143900. * The scene the component belongs to.
  143901. */
  143902. scene: Scene;
  143903. /**
  143904. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  143905. */
  143906. zOffset: number;
  143907. private _engine;
  143908. private _effect;
  143909. private _cachedDefines;
  143910. private _savedDepthWrite;
  143911. /**
  143912. * Instantiates a new outline renderer. (There could be only one per scene).
  143913. * @param scene Defines the scene it belongs to
  143914. */
  143915. constructor(scene: Scene);
  143916. /**
  143917. * Register the component to one instance of a scene.
  143918. */
  143919. register(): void;
  143920. /**
  143921. * Rebuilds the elements related to this component in case of
  143922. * context lost for instance.
  143923. */
  143924. rebuild(): void;
  143925. /**
  143926. * Disposes the component and the associated ressources.
  143927. */
  143928. dispose(): void;
  143929. /**
  143930. * Renders the outline in the canvas.
  143931. * @param subMesh Defines the sumesh to render
  143932. * @param batch Defines the batch of meshes in case of instances
  143933. * @param useOverlay Defines if the rendering is for the overlay or the outline
  143934. */
  143935. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  143936. /**
  143937. * Returns whether or not the outline renderer is ready for a given submesh.
  143938. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  143939. * @param subMesh Defines the submesh to check readyness for
  143940. * @param useInstances Defines wheter wee are trying to render instances or not
  143941. * @returns true if ready otherwise false
  143942. */
  143943. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  143944. private _beforeRenderingMesh;
  143945. private _afterRenderingMesh;
  143946. }
  143947. }
  143948. declare module BABYLON {
  143949. /**
  143950. * Defines the basic options interface of a Sprite Frame Source Size.
  143951. */
  143952. export interface ISpriteJSONSpriteSourceSize {
  143953. /**
  143954. * number of the original width of the Frame
  143955. */
  143956. w: number;
  143957. /**
  143958. * number of the original height of the Frame
  143959. */
  143960. h: number;
  143961. }
  143962. /**
  143963. * Defines the basic options interface of a Sprite Frame Data.
  143964. */
  143965. export interface ISpriteJSONSpriteFrameData {
  143966. /**
  143967. * number of the x offset of the Frame
  143968. */
  143969. x: number;
  143970. /**
  143971. * number of the y offset of the Frame
  143972. */
  143973. y: number;
  143974. /**
  143975. * number of the width of the Frame
  143976. */
  143977. w: number;
  143978. /**
  143979. * number of the height of the Frame
  143980. */
  143981. h: number;
  143982. }
  143983. /**
  143984. * Defines the basic options interface of a JSON Sprite.
  143985. */
  143986. export interface ISpriteJSONSprite {
  143987. /**
  143988. * string name of the Frame
  143989. */
  143990. filename: string;
  143991. /**
  143992. * ISpriteJSONSpriteFrame basic object of the frame data
  143993. */
  143994. frame: ISpriteJSONSpriteFrameData;
  143995. /**
  143996. * boolean to flag is the frame was rotated.
  143997. */
  143998. rotated: boolean;
  143999. /**
  144000. * boolean to flag is the frame was trimmed.
  144001. */
  144002. trimmed: boolean;
  144003. /**
  144004. * ISpriteJSONSpriteFrame basic object of the source data
  144005. */
  144006. spriteSourceSize: ISpriteJSONSpriteFrameData;
  144007. /**
  144008. * ISpriteJSONSpriteFrame basic object of the source data
  144009. */
  144010. sourceSize: ISpriteJSONSpriteSourceSize;
  144011. }
  144012. /**
  144013. * Defines the basic options interface of a JSON atlas.
  144014. */
  144015. export interface ISpriteJSONAtlas {
  144016. /**
  144017. * Array of objects that contain the frame data.
  144018. */
  144019. frames: Array<ISpriteJSONSprite>;
  144020. /**
  144021. * object basic object containing the sprite meta data.
  144022. */
  144023. meta?: object;
  144024. }
  144025. }
  144026. declare module BABYLON {
  144027. /** @hidden */
  144028. export var spriteMapPixelShader: {
  144029. name: string;
  144030. shader: string;
  144031. };
  144032. }
  144033. declare module BABYLON {
  144034. /** @hidden */
  144035. export var spriteMapVertexShader: {
  144036. name: string;
  144037. shader: string;
  144038. };
  144039. }
  144040. declare module BABYLON {
  144041. /**
  144042. * Defines the basic options interface of a SpriteMap
  144043. */
  144044. export interface ISpriteMapOptions {
  144045. /**
  144046. * Vector2 of the number of cells in the grid.
  144047. */
  144048. stageSize?: Vector2;
  144049. /**
  144050. * Vector2 of the size of the output plane in World Units.
  144051. */
  144052. outputSize?: Vector2;
  144053. /**
  144054. * Vector3 of the position of the output plane in World Units.
  144055. */
  144056. outputPosition?: Vector3;
  144057. /**
  144058. * Vector3 of the rotation of the output plane.
  144059. */
  144060. outputRotation?: Vector3;
  144061. /**
  144062. * number of layers that the system will reserve in resources.
  144063. */
  144064. layerCount?: number;
  144065. /**
  144066. * number of max animation frames a single cell will reserve in resources.
  144067. */
  144068. maxAnimationFrames?: number;
  144069. /**
  144070. * number cell index of the base tile when the system compiles.
  144071. */
  144072. baseTile?: number;
  144073. /**
  144074. * boolean flip the sprite after its been repositioned by the framing data.
  144075. */
  144076. flipU?: boolean;
  144077. /**
  144078. * Vector3 scalar of the global RGB values of the SpriteMap.
  144079. */
  144080. colorMultiply?: Vector3;
  144081. }
  144082. /**
  144083. * Defines the IDisposable interface in order to be cleanable from resources.
  144084. */
  144085. export interface ISpriteMap extends IDisposable {
  144086. /**
  144087. * String name of the SpriteMap.
  144088. */
  144089. name: string;
  144090. /**
  144091. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  144092. */
  144093. atlasJSON: ISpriteJSONAtlas;
  144094. /**
  144095. * Texture of the SpriteMap.
  144096. */
  144097. spriteSheet: Texture;
  144098. /**
  144099. * The parameters to initialize the SpriteMap with.
  144100. */
  144101. options: ISpriteMapOptions;
  144102. }
  144103. /**
  144104. * Class used to manage a grid restricted sprite deployment on an Output plane.
  144105. */
  144106. export class SpriteMap implements ISpriteMap {
  144107. /** The Name of the spriteMap */
  144108. name: string;
  144109. /** The JSON file with the frame and meta data */
  144110. atlasJSON: ISpriteJSONAtlas;
  144111. /** The systems Sprite Sheet Texture */
  144112. spriteSheet: Texture;
  144113. /** Arguments passed with the Constructor */
  144114. options: ISpriteMapOptions;
  144115. /** Public Sprite Storage array, parsed from atlasJSON */
  144116. sprites: Array<ISpriteJSONSprite>;
  144117. /** Returns the Number of Sprites in the System */
  144118. get spriteCount(): number;
  144119. /** Returns the Position of Output Plane*/
  144120. get position(): Vector3;
  144121. /** Returns the Position of Output Plane*/
  144122. set position(v: Vector3);
  144123. /** Returns the Rotation of Output Plane*/
  144124. get rotation(): Vector3;
  144125. /** Returns the Rotation of Output Plane*/
  144126. set rotation(v: Vector3);
  144127. /** Sets the AnimationMap*/
  144128. get animationMap(): RawTexture;
  144129. /** Sets the AnimationMap*/
  144130. set animationMap(v: RawTexture);
  144131. /** Scene that the SpriteMap was created in */
  144132. private _scene;
  144133. /** Texture Buffer of Float32 that holds tile frame data*/
  144134. private _frameMap;
  144135. /** Texture Buffers of Float32 that holds tileMap data*/
  144136. private _tileMaps;
  144137. /** Texture Buffer of Float32 that holds Animation Data*/
  144138. private _animationMap;
  144139. /** Custom ShaderMaterial Central to the System*/
  144140. private _material;
  144141. /** Custom ShaderMaterial Central to the System*/
  144142. private _output;
  144143. /** Systems Time Ticker*/
  144144. private _time;
  144145. /**
  144146. * Creates a new SpriteMap
  144147. * @param name defines the SpriteMaps Name
  144148. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  144149. * @param spriteSheet is the Texture that the Sprites are on.
  144150. * @param options a basic deployment configuration
  144151. * @param scene The Scene that the map is deployed on
  144152. */
  144153. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  144154. /**
  144155. * Returns tileID location
  144156. * @returns Vector2 the cell position ID
  144157. */
  144158. getTileID(): Vector2;
  144159. /**
  144160. * Gets the UV location of the mouse over the SpriteMap.
  144161. * @returns Vector2 the UV position of the mouse interaction
  144162. */
  144163. getMousePosition(): Vector2;
  144164. /**
  144165. * Creates the "frame" texture Buffer
  144166. * -------------------------------------
  144167. * Structure of frames
  144168. * "filename": "Falling-Water-2.png",
  144169. * "frame": {"x":69,"y":103,"w":24,"h":32},
  144170. * "rotated": true,
  144171. * "trimmed": true,
  144172. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  144173. * "sourceSize": {"w":32,"h":32}
  144174. * @returns RawTexture of the frameMap
  144175. */
  144176. private _createFrameBuffer;
  144177. /**
  144178. * Creates the tileMap texture Buffer
  144179. * @param buffer normally and array of numbers, or a false to generate from scratch
  144180. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  144181. * @returns RawTexture of the tileMap
  144182. */
  144183. private _createTileBuffer;
  144184. /**
  144185. * Modifies the data of the tileMaps
  144186. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  144187. * @param pos is the iVector2 Coordinates of the Tile
  144188. * @param tile The SpriteIndex of the new Tile
  144189. */
  144190. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  144191. /**
  144192. * Creates the animationMap texture Buffer
  144193. * @param buffer normally and array of numbers, or a false to generate from scratch
  144194. * @returns RawTexture of the animationMap
  144195. */
  144196. private _createTileAnimationBuffer;
  144197. /**
  144198. * Modifies the data of the animationMap
  144199. * @param cellID is the Index of the Sprite
  144200. * @param _frame is the target Animation frame
  144201. * @param toCell is the Target Index of the next frame of the animation
  144202. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  144203. * @param speed is a global scalar of the time variable on the map.
  144204. */
  144205. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  144206. /**
  144207. * Exports the .tilemaps file
  144208. */
  144209. saveTileMaps(): void;
  144210. /**
  144211. * Imports the .tilemaps file
  144212. * @param url of the .tilemaps file
  144213. */
  144214. loadTileMaps(url: string): void;
  144215. /**
  144216. * Release associated resources
  144217. */
  144218. dispose(): void;
  144219. }
  144220. }
  144221. declare module BABYLON {
  144222. /**
  144223. * Class used to manage multiple sprites of different sizes on the same spritesheet
  144224. * @see http://doc.babylonjs.com/babylon101/sprites
  144225. */
  144226. export class SpritePackedManager extends SpriteManager {
  144227. /** defines the packed manager's name */
  144228. name: string;
  144229. /**
  144230. * Creates a new sprite manager from a packed sprite sheet
  144231. * @param name defines the manager's name
  144232. * @param imgUrl defines the sprite sheet url
  144233. * @param capacity defines the maximum allowed number of sprites
  144234. * @param scene defines the hosting scene
  144235. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  144236. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  144237. * @param samplingMode defines the smapling mode to use with spritesheet
  144238. * @param fromPacked set to true; do not alter
  144239. */
  144240. constructor(
  144241. /** defines the packed manager's name */
  144242. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  144243. }
  144244. }
  144245. declare module BABYLON {
  144246. /**
  144247. * Defines the list of states available for a task inside a AssetsManager
  144248. */
  144249. export enum AssetTaskState {
  144250. /**
  144251. * Initialization
  144252. */
  144253. INIT = 0,
  144254. /**
  144255. * Running
  144256. */
  144257. RUNNING = 1,
  144258. /**
  144259. * Done
  144260. */
  144261. DONE = 2,
  144262. /**
  144263. * Error
  144264. */
  144265. ERROR = 3
  144266. }
  144267. /**
  144268. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  144269. */
  144270. export abstract class AbstractAssetTask {
  144271. /**
  144272. * Task name
  144273. */ name: string;
  144274. /**
  144275. * Callback called when the task is successful
  144276. */
  144277. onSuccess: (task: any) => void;
  144278. /**
  144279. * Callback called when the task is not successful
  144280. */
  144281. onError: (task: any, message?: string, exception?: any) => void;
  144282. /**
  144283. * Creates a new AssetsManager
  144284. * @param name defines the name of the task
  144285. */
  144286. constructor(
  144287. /**
  144288. * Task name
  144289. */ name: string);
  144290. private _isCompleted;
  144291. private _taskState;
  144292. private _errorObject;
  144293. /**
  144294. * Get if the task is completed
  144295. */
  144296. get isCompleted(): boolean;
  144297. /**
  144298. * Gets the current state of the task
  144299. */
  144300. get taskState(): AssetTaskState;
  144301. /**
  144302. * Gets the current error object (if task is in error)
  144303. */
  144304. get errorObject(): {
  144305. message?: string;
  144306. exception?: any;
  144307. };
  144308. /**
  144309. * Internal only
  144310. * @hidden
  144311. */
  144312. _setErrorObject(message?: string, exception?: any): void;
  144313. /**
  144314. * Execute the current task
  144315. * @param scene defines the scene where you want your assets to be loaded
  144316. * @param onSuccess is a callback called when the task is successfully executed
  144317. * @param onError is a callback called if an error occurs
  144318. */
  144319. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  144320. /**
  144321. * Execute the current task
  144322. * @param scene defines the scene where you want your assets to be loaded
  144323. * @param onSuccess is a callback called when the task is successfully executed
  144324. * @param onError is a callback called if an error occurs
  144325. */
  144326. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  144327. /**
  144328. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  144329. * This can be used with failed tasks that have the reason for failure fixed.
  144330. */
  144331. reset(): void;
  144332. private onErrorCallback;
  144333. private onDoneCallback;
  144334. }
  144335. /**
  144336. * Define the interface used by progress events raised during assets loading
  144337. */
  144338. export interface IAssetsProgressEvent {
  144339. /**
  144340. * Defines the number of remaining tasks to process
  144341. */
  144342. remainingCount: number;
  144343. /**
  144344. * Defines the total number of tasks
  144345. */
  144346. totalCount: number;
  144347. /**
  144348. * Defines the task that was just processed
  144349. */
  144350. task: AbstractAssetTask;
  144351. }
  144352. /**
  144353. * Class used to share progress information about assets loading
  144354. */
  144355. export class AssetsProgressEvent implements IAssetsProgressEvent {
  144356. /**
  144357. * Defines the number of remaining tasks to process
  144358. */
  144359. remainingCount: number;
  144360. /**
  144361. * Defines the total number of tasks
  144362. */
  144363. totalCount: number;
  144364. /**
  144365. * Defines the task that was just processed
  144366. */
  144367. task: AbstractAssetTask;
  144368. /**
  144369. * Creates a AssetsProgressEvent
  144370. * @param remainingCount defines the number of remaining tasks to process
  144371. * @param totalCount defines the total number of tasks
  144372. * @param task defines the task that was just processed
  144373. */
  144374. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  144375. }
  144376. /**
  144377. * Define a task used by AssetsManager to load meshes
  144378. */
  144379. export class MeshAssetTask extends AbstractAssetTask {
  144380. /**
  144381. * Defines the name of the task
  144382. */
  144383. name: string;
  144384. /**
  144385. * Defines the list of mesh's names you want to load
  144386. */
  144387. meshesNames: any;
  144388. /**
  144389. * Defines the root url to use as a base to load your meshes and associated resources
  144390. */
  144391. rootUrl: string;
  144392. /**
  144393. * Defines the filename of the scene to load from
  144394. */
  144395. sceneFilename: string;
  144396. /**
  144397. * Gets the list of loaded meshes
  144398. */
  144399. loadedMeshes: Array<AbstractMesh>;
  144400. /**
  144401. * Gets the list of loaded particle systems
  144402. */
  144403. loadedParticleSystems: Array<IParticleSystem>;
  144404. /**
  144405. * Gets the list of loaded skeletons
  144406. */
  144407. loadedSkeletons: Array<Skeleton>;
  144408. /**
  144409. * Gets the list of loaded animation groups
  144410. */
  144411. loadedAnimationGroups: Array<AnimationGroup>;
  144412. /**
  144413. * Callback called when the task is successful
  144414. */
  144415. onSuccess: (task: MeshAssetTask) => void;
  144416. /**
  144417. * Callback called when the task is successful
  144418. */
  144419. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  144420. /**
  144421. * Creates a new MeshAssetTask
  144422. * @param name defines the name of the task
  144423. * @param meshesNames defines the list of mesh's names you want to load
  144424. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  144425. * @param sceneFilename defines the filename of the scene to load from
  144426. */
  144427. constructor(
  144428. /**
  144429. * Defines the name of the task
  144430. */
  144431. name: string,
  144432. /**
  144433. * Defines the list of mesh's names you want to load
  144434. */
  144435. meshesNames: any,
  144436. /**
  144437. * Defines the root url to use as a base to load your meshes and associated resources
  144438. */
  144439. rootUrl: string,
  144440. /**
  144441. * Defines the filename of the scene to load from
  144442. */
  144443. sceneFilename: string);
  144444. /**
  144445. * Execute the current task
  144446. * @param scene defines the scene where you want your assets to be loaded
  144447. * @param onSuccess is a callback called when the task is successfully executed
  144448. * @param onError is a callback called if an error occurs
  144449. */
  144450. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  144451. }
  144452. /**
  144453. * Define a task used by AssetsManager to load text content
  144454. */
  144455. export class TextFileAssetTask extends AbstractAssetTask {
  144456. /**
  144457. * Defines the name of the task
  144458. */
  144459. name: string;
  144460. /**
  144461. * Defines the location of the file to load
  144462. */
  144463. url: string;
  144464. /**
  144465. * Gets the loaded text string
  144466. */
  144467. text: string;
  144468. /**
  144469. * Callback called when the task is successful
  144470. */
  144471. onSuccess: (task: TextFileAssetTask) => void;
  144472. /**
  144473. * Callback called when the task is successful
  144474. */
  144475. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  144476. /**
  144477. * Creates a new TextFileAssetTask object
  144478. * @param name defines the name of the task
  144479. * @param url defines the location of the file to load
  144480. */
  144481. constructor(
  144482. /**
  144483. * Defines the name of the task
  144484. */
  144485. name: string,
  144486. /**
  144487. * Defines the location of the file to load
  144488. */
  144489. url: string);
  144490. /**
  144491. * Execute the current task
  144492. * @param scene defines the scene where you want your assets to be loaded
  144493. * @param onSuccess is a callback called when the task is successfully executed
  144494. * @param onError is a callback called if an error occurs
  144495. */
  144496. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  144497. }
  144498. /**
  144499. * Define a task used by AssetsManager to load binary data
  144500. */
  144501. export class BinaryFileAssetTask extends AbstractAssetTask {
  144502. /**
  144503. * Defines the name of the task
  144504. */
  144505. name: string;
  144506. /**
  144507. * Defines the location of the file to load
  144508. */
  144509. url: string;
  144510. /**
  144511. * Gets the lodaded data (as an array buffer)
  144512. */
  144513. data: ArrayBuffer;
  144514. /**
  144515. * Callback called when the task is successful
  144516. */
  144517. onSuccess: (task: BinaryFileAssetTask) => void;
  144518. /**
  144519. * Callback called when the task is successful
  144520. */
  144521. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  144522. /**
  144523. * Creates a new BinaryFileAssetTask object
  144524. * @param name defines the name of the new task
  144525. * @param url defines the location of the file to load
  144526. */
  144527. constructor(
  144528. /**
  144529. * Defines the name of the task
  144530. */
  144531. name: string,
  144532. /**
  144533. * Defines the location of the file to load
  144534. */
  144535. url: string);
  144536. /**
  144537. * Execute the current task
  144538. * @param scene defines the scene where you want your assets to be loaded
  144539. * @param onSuccess is a callback called when the task is successfully executed
  144540. * @param onError is a callback called if an error occurs
  144541. */
  144542. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  144543. }
  144544. /**
  144545. * Define a task used by AssetsManager to load images
  144546. */
  144547. export class ImageAssetTask extends AbstractAssetTask {
  144548. /**
  144549. * Defines the name of the task
  144550. */
  144551. name: string;
  144552. /**
  144553. * Defines the location of the image to load
  144554. */
  144555. url: string;
  144556. /**
  144557. * Gets the loaded images
  144558. */
  144559. image: HTMLImageElement;
  144560. /**
  144561. * Callback called when the task is successful
  144562. */
  144563. onSuccess: (task: ImageAssetTask) => void;
  144564. /**
  144565. * Callback called when the task is successful
  144566. */
  144567. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  144568. /**
  144569. * Creates a new ImageAssetTask
  144570. * @param name defines the name of the task
  144571. * @param url defines the location of the image to load
  144572. */
  144573. constructor(
  144574. /**
  144575. * Defines the name of the task
  144576. */
  144577. name: string,
  144578. /**
  144579. * Defines the location of the image to load
  144580. */
  144581. url: string);
  144582. /**
  144583. * Execute the current task
  144584. * @param scene defines the scene where you want your assets to be loaded
  144585. * @param onSuccess is a callback called when the task is successfully executed
  144586. * @param onError is a callback called if an error occurs
  144587. */
  144588. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  144589. }
  144590. /**
  144591. * Defines the interface used by texture loading tasks
  144592. */
  144593. export interface ITextureAssetTask<TEX extends BaseTexture> {
  144594. /**
  144595. * Gets the loaded texture
  144596. */
  144597. texture: TEX;
  144598. }
  144599. /**
  144600. * Define a task used by AssetsManager to load 2D textures
  144601. */
  144602. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  144603. /**
  144604. * Defines the name of the task
  144605. */
  144606. name: string;
  144607. /**
  144608. * Defines the location of the file to load
  144609. */
  144610. url: string;
  144611. /**
  144612. * Defines if mipmap should not be generated (default is false)
  144613. */
  144614. noMipmap?: boolean | undefined;
  144615. /**
  144616. * Defines if texture must be inverted on Y axis (default is true)
  144617. */
  144618. invertY: boolean;
  144619. /**
  144620. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  144621. */
  144622. samplingMode: number;
  144623. /**
  144624. * Gets the loaded texture
  144625. */
  144626. texture: Texture;
  144627. /**
  144628. * Callback called when the task is successful
  144629. */
  144630. onSuccess: (task: TextureAssetTask) => void;
  144631. /**
  144632. * Callback called when the task is successful
  144633. */
  144634. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  144635. /**
  144636. * Creates a new TextureAssetTask object
  144637. * @param name defines the name of the task
  144638. * @param url defines the location of the file to load
  144639. * @param noMipmap defines if mipmap should not be generated (default is false)
  144640. * @param invertY defines if texture must be inverted on Y axis (default is true)
  144641. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  144642. */
  144643. constructor(
  144644. /**
  144645. * Defines the name of the task
  144646. */
  144647. name: string,
  144648. /**
  144649. * Defines the location of the file to load
  144650. */
  144651. url: string,
  144652. /**
  144653. * Defines if mipmap should not be generated (default is false)
  144654. */
  144655. noMipmap?: boolean | undefined,
  144656. /**
  144657. * Defines if texture must be inverted on Y axis (default is true)
  144658. */
  144659. invertY?: boolean,
  144660. /**
  144661. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  144662. */
  144663. samplingMode?: number);
  144664. /**
  144665. * Execute the current task
  144666. * @param scene defines the scene where you want your assets to be loaded
  144667. * @param onSuccess is a callback called when the task is successfully executed
  144668. * @param onError is a callback called if an error occurs
  144669. */
  144670. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  144671. }
  144672. /**
  144673. * Define a task used by AssetsManager to load cube textures
  144674. */
  144675. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  144676. /**
  144677. * Defines the name of the task
  144678. */
  144679. name: string;
  144680. /**
  144681. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  144682. */
  144683. url: string;
  144684. /**
  144685. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  144686. */
  144687. extensions?: string[] | undefined;
  144688. /**
  144689. * Defines if mipmaps should not be generated (default is false)
  144690. */
  144691. noMipmap?: boolean | undefined;
  144692. /**
  144693. * Defines the explicit list of files (undefined by default)
  144694. */
  144695. files?: string[] | undefined;
  144696. /**
  144697. * Gets the loaded texture
  144698. */
  144699. texture: CubeTexture;
  144700. /**
  144701. * Callback called when the task is successful
  144702. */
  144703. onSuccess: (task: CubeTextureAssetTask) => void;
  144704. /**
  144705. * Callback called when the task is successful
  144706. */
  144707. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  144708. /**
  144709. * Creates a new CubeTextureAssetTask
  144710. * @param name defines the name of the task
  144711. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  144712. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  144713. * @param noMipmap defines if mipmaps should not be generated (default is false)
  144714. * @param files defines the explicit list of files (undefined by default)
  144715. */
  144716. constructor(
  144717. /**
  144718. * Defines the name of the task
  144719. */
  144720. name: string,
  144721. /**
  144722. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  144723. */
  144724. url: string,
  144725. /**
  144726. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  144727. */
  144728. extensions?: string[] | undefined,
  144729. /**
  144730. * Defines if mipmaps should not be generated (default is false)
  144731. */
  144732. noMipmap?: boolean | undefined,
  144733. /**
  144734. * Defines the explicit list of files (undefined by default)
  144735. */
  144736. files?: string[] | undefined);
  144737. /**
  144738. * Execute the current task
  144739. * @param scene defines the scene where you want your assets to be loaded
  144740. * @param onSuccess is a callback called when the task is successfully executed
  144741. * @param onError is a callback called if an error occurs
  144742. */
  144743. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  144744. }
  144745. /**
  144746. * Define a task used by AssetsManager to load HDR cube textures
  144747. */
  144748. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  144749. /**
  144750. * Defines the name of the task
  144751. */
  144752. name: string;
  144753. /**
  144754. * Defines the location of the file to load
  144755. */
  144756. url: string;
  144757. /**
  144758. * Defines the desired size (the more it increases the longer the generation will be)
  144759. */
  144760. size: number;
  144761. /**
  144762. * Defines if mipmaps should not be generated (default is false)
  144763. */
  144764. noMipmap: boolean;
  144765. /**
  144766. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  144767. */
  144768. generateHarmonics: boolean;
  144769. /**
  144770. * 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)
  144771. */
  144772. gammaSpace: boolean;
  144773. /**
  144774. * Internal Use Only
  144775. */
  144776. reserved: boolean;
  144777. /**
  144778. * Gets the loaded texture
  144779. */
  144780. texture: HDRCubeTexture;
  144781. /**
  144782. * Callback called when the task is successful
  144783. */
  144784. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  144785. /**
  144786. * Callback called when the task is successful
  144787. */
  144788. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  144789. /**
  144790. * Creates a new HDRCubeTextureAssetTask object
  144791. * @param name defines the name of the task
  144792. * @param url defines the location of the file to load
  144793. * @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.
  144794. * @param noMipmap defines if mipmaps should not be generated (default is false)
  144795. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  144796. * @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)
  144797. * @param reserved Internal use only
  144798. */
  144799. constructor(
  144800. /**
  144801. * Defines the name of the task
  144802. */
  144803. name: string,
  144804. /**
  144805. * Defines the location of the file to load
  144806. */
  144807. url: string,
  144808. /**
  144809. * Defines the desired size (the more it increases the longer the generation will be)
  144810. */
  144811. size: number,
  144812. /**
  144813. * Defines if mipmaps should not be generated (default is false)
  144814. */
  144815. noMipmap?: boolean,
  144816. /**
  144817. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  144818. */
  144819. generateHarmonics?: boolean,
  144820. /**
  144821. * 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)
  144822. */
  144823. gammaSpace?: boolean,
  144824. /**
  144825. * Internal Use Only
  144826. */
  144827. reserved?: boolean);
  144828. /**
  144829. * Execute the current task
  144830. * @param scene defines the scene where you want your assets to be loaded
  144831. * @param onSuccess is a callback called when the task is successfully executed
  144832. * @param onError is a callback called if an error occurs
  144833. */
  144834. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  144835. }
  144836. /**
  144837. * Define a task used by AssetsManager to load Equirectangular cube textures
  144838. */
  144839. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  144840. /**
  144841. * Defines the name of the task
  144842. */
  144843. name: string;
  144844. /**
  144845. * Defines the location of the file to load
  144846. */
  144847. url: string;
  144848. /**
  144849. * Defines the desired size (the more it increases the longer the generation will be)
  144850. */
  144851. size: number;
  144852. /**
  144853. * Defines if mipmaps should not be generated (default is false)
  144854. */
  144855. noMipmap: boolean;
  144856. /**
  144857. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  144858. * but the standard material would require them in Gamma space) (default is true)
  144859. */
  144860. gammaSpace: boolean;
  144861. /**
  144862. * Gets the loaded texture
  144863. */
  144864. texture: EquiRectangularCubeTexture;
  144865. /**
  144866. * Callback called when the task is successful
  144867. */
  144868. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  144869. /**
  144870. * Callback called when the task is successful
  144871. */
  144872. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  144873. /**
  144874. * Creates a new EquiRectangularCubeTextureAssetTask object
  144875. * @param name defines the name of the task
  144876. * @param url defines the location of the file to load
  144877. * @param size defines the desired size (the more it increases the longer the generation will be)
  144878. * If the size is omitted this implies you are using a preprocessed cubemap.
  144879. * @param noMipmap defines if mipmaps should not be generated (default is false)
  144880. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  144881. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  144882. * (default is true)
  144883. */
  144884. constructor(
  144885. /**
  144886. * Defines the name of the task
  144887. */
  144888. name: string,
  144889. /**
  144890. * Defines the location of the file to load
  144891. */
  144892. url: string,
  144893. /**
  144894. * Defines the desired size (the more it increases the longer the generation will be)
  144895. */
  144896. size: number,
  144897. /**
  144898. * Defines if mipmaps should not be generated (default is false)
  144899. */
  144900. noMipmap?: boolean,
  144901. /**
  144902. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  144903. * but the standard material would require them in Gamma space) (default is true)
  144904. */
  144905. gammaSpace?: boolean);
  144906. /**
  144907. * Execute the current task
  144908. * @param scene defines the scene where you want your assets to be loaded
  144909. * @param onSuccess is a callback called when the task is successfully executed
  144910. * @param onError is a callback called if an error occurs
  144911. */
  144912. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  144913. }
  144914. /**
  144915. * This class can be used to easily import assets into a scene
  144916. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  144917. */
  144918. export class AssetsManager {
  144919. private _scene;
  144920. private _isLoading;
  144921. protected _tasks: AbstractAssetTask[];
  144922. protected _waitingTasksCount: number;
  144923. protected _totalTasksCount: number;
  144924. /**
  144925. * Callback called when all tasks are processed
  144926. */
  144927. onFinish: (tasks: AbstractAssetTask[]) => void;
  144928. /**
  144929. * Callback called when a task is successful
  144930. */
  144931. onTaskSuccess: (task: AbstractAssetTask) => void;
  144932. /**
  144933. * Callback called when a task had an error
  144934. */
  144935. onTaskError: (task: AbstractAssetTask) => void;
  144936. /**
  144937. * Callback called when a task is done (whatever the result is)
  144938. */
  144939. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  144940. /**
  144941. * Observable called when all tasks are processed
  144942. */
  144943. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  144944. /**
  144945. * Observable called when a task had an error
  144946. */
  144947. onTaskErrorObservable: Observable<AbstractAssetTask>;
  144948. /**
  144949. * Observable called when all tasks were executed
  144950. */
  144951. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  144952. /**
  144953. * Observable called when a task is done (whatever the result is)
  144954. */
  144955. onProgressObservable: Observable<IAssetsProgressEvent>;
  144956. /**
  144957. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  144958. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  144959. */
  144960. useDefaultLoadingScreen: boolean;
  144961. /**
  144962. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  144963. * when all assets have been downloaded.
  144964. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  144965. */
  144966. autoHideLoadingUI: boolean;
  144967. /**
  144968. * Creates a new AssetsManager
  144969. * @param scene defines the scene to work on
  144970. */
  144971. constructor(scene: Scene);
  144972. /**
  144973. * Add a MeshAssetTask to the list of active tasks
  144974. * @param taskName defines the name of the new task
  144975. * @param meshesNames defines the name of meshes to load
  144976. * @param rootUrl defines the root url to use to locate files
  144977. * @param sceneFilename defines the filename of the scene file
  144978. * @returns a new MeshAssetTask object
  144979. */
  144980. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  144981. /**
  144982. * Add a TextFileAssetTask to the list of active tasks
  144983. * @param taskName defines the name of the new task
  144984. * @param url defines the url of the file to load
  144985. * @returns a new TextFileAssetTask object
  144986. */
  144987. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  144988. /**
  144989. * Add a BinaryFileAssetTask to the list of active tasks
  144990. * @param taskName defines the name of the new task
  144991. * @param url defines the url of the file to load
  144992. * @returns a new BinaryFileAssetTask object
  144993. */
  144994. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  144995. /**
  144996. * Add a ImageAssetTask to the list of active tasks
  144997. * @param taskName defines the name of the new task
  144998. * @param url defines the url of the file to load
  144999. * @returns a new ImageAssetTask object
  145000. */
  145001. addImageTask(taskName: string, url: string): ImageAssetTask;
  145002. /**
  145003. * Add a TextureAssetTask to the list of active tasks
  145004. * @param taskName defines the name of the new task
  145005. * @param url defines the url of the file to load
  145006. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  145007. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  145008. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  145009. * @returns a new TextureAssetTask object
  145010. */
  145011. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  145012. /**
  145013. * Add a CubeTextureAssetTask to the list of active tasks
  145014. * @param taskName defines the name of the new task
  145015. * @param url defines the url of the file to load
  145016. * @param extensions defines the extension to use to load the cube map (can be null)
  145017. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  145018. * @param files defines the list of files to load (can be null)
  145019. * @returns a new CubeTextureAssetTask object
  145020. */
  145021. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  145022. /**
  145023. *
  145024. * Add a HDRCubeTextureAssetTask to the list of active tasks
  145025. * @param taskName defines the name of the new task
  145026. * @param url defines the url of the file to load
  145027. * @param size defines the size you want for the cubemap (can be null)
  145028. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  145029. * @param generateHarmonics defines if you want to automatically generate (true by default)
  145030. * @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)
  145031. * @param reserved Internal use only
  145032. * @returns a new HDRCubeTextureAssetTask object
  145033. */
  145034. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  145035. /**
  145036. *
  145037. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  145038. * @param taskName defines the name of the new task
  145039. * @param url defines the url of the file to load
  145040. * @param size defines the size you want for the cubemap (can be null)
  145041. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  145042. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  145043. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  145044. * @returns a new EquiRectangularCubeTextureAssetTask object
  145045. */
  145046. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  145047. /**
  145048. * Remove a task from the assets manager.
  145049. * @param task the task to remove
  145050. */
  145051. removeTask(task: AbstractAssetTask): void;
  145052. private _decreaseWaitingTasksCount;
  145053. private _runTask;
  145054. /**
  145055. * Reset the AssetsManager and remove all tasks
  145056. * @return the current instance of the AssetsManager
  145057. */
  145058. reset(): AssetsManager;
  145059. /**
  145060. * Start the loading process
  145061. * @return the current instance of the AssetsManager
  145062. */
  145063. load(): AssetsManager;
  145064. /**
  145065. * Start the loading process as an async operation
  145066. * @return a promise returning the list of failed tasks
  145067. */
  145068. loadAsync(): Promise<void>;
  145069. }
  145070. }
  145071. declare module BABYLON {
  145072. /**
  145073. * Wrapper class for promise with external resolve and reject.
  145074. */
  145075. export class Deferred<T> {
  145076. /**
  145077. * The promise associated with this deferred object.
  145078. */
  145079. readonly promise: Promise<T>;
  145080. private _resolve;
  145081. private _reject;
  145082. /**
  145083. * The resolve method of the promise associated with this deferred object.
  145084. */
  145085. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  145086. /**
  145087. * The reject method of the promise associated with this deferred object.
  145088. */
  145089. get reject(): (reason?: any) => void;
  145090. /**
  145091. * Constructor for this deferred object.
  145092. */
  145093. constructor();
  145094. }
  145095. }
  145096. declare module BABYLON {
  145097. /**
  145098. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  145099. */
  145100. export class MeshExploder {
  145101. private _centerMesh;
  145102. private _meshes;
  145103. private _meshesOrigins;
  145104. private _toCenterVectors;
  145105. private _scaledDirection;
  145106. private _newPosition;
  145107. private _centerPosition;
  145108. /**
  145109. * Explodes meshes from a center mesh.
  145110. * @param meshes The meshes to explode.
  145111. * @param centerMesh The mesh to be center of explosion.
  145112. */
  145113. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  145114. private _setCenterMesh;
  145115. /**
  145116. * Get class name
  145117. * @returns "MeshExploder"
  145118. */
  145119. getClassName(): string;
  145120. /**
  145121. * "Exploded meshes"
  145122. * @returns Array of meshes with the centerMesh at index 0.
  145123. */
  145124. getMeshes(): Array<Mesh>;
  145125. /**
  145126. * Explodes meshes giving a specific direction
  145127. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  145128. */
  145129. explode(direction?: number): void;
  145130. }
  145131. }
  145132. declare module BABYLON {
  145133. /**
  145134. * Class used to help managing file picking and drag'n'drop
  145135. */
  145136. export class FilesInput {
  145137. /**
  145138. * List of files ready to be loaded
  145139. */
  145140. static get FilesToLoad(): {
  145141. [key: string]: File;
  145142. };
  145143. /**
  145144. * Callback called when a file is processed
  145145. */
  145146. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  145147. private _engine;
  145148. private _currentScene;
  145149. private _sceneLoadedCallback;
  145150. private _progressCallback;
  145151. private _additionalRenderLoopLogicCallback;
  145152. private _textureLoadingCallback;
  145153. private _startingProcessingFilesCallback;
  145154. private _onReloadCallback;
  145155. private _errorCallback;
  145156. private _elementToMonitor;
  145157. private _sceneFileToLoad;
  145158. private _filesToLoad;
  145159. /**
  145160. * Creates a new FilesInput
  145161. * @param engine defines the rendering engine
  145162. * @param scene defines the hosting scene
  145163. * @param sceneLoadedCallback callback called when scene is loaded
  145164. * @param progressCallback callback called to track progress
  145165. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  145166. * @param textureLoadingCallback callback called when a texture is loading
  145167. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  145168. * @param onReloadCallback callback called when a reload is requested
  145169. * @param errorCallback callback call if an error occurs
  145170. */
  145171. 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);
  145172. private _dragEnterHandler;
  145173. private _dragOverHandler;
  145174. private _dropHandler;
  145175. /**
  145176. * Calls this function to listen to drag'n'drop events on a specific DOM element
  145177. * @param elementToMonitor defines the DOM element to track
  145178. */
  145179. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  145180. /**
  145181. * Release all associated resources
  145182. */
  145183. dispose(): void;
  145184. private renderFunction;
  145185. private drag;
  145186. private drop;
  145187. private _traverseFolder;
  145188. private _processFiles;
  145189. /**
  145190. * Load files from a drop event
  145191. * @param event defines the drop event to use as source
  145192. */
  145193. loadFiles(event: any): void;
  145194. private _processReload;
  145195. /**
  145196. * Reload the current scene from the loaded files
  145197. */
  145198. reload(): void;
  145199. }
  145200. }
  145201. declare module BABYLON {
  145202. /**
  145203. * Defines the root class used to create scene optimization to use with SceneOptimizer
  145204. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  145205. */
  145206. export class SceneOptimization {
  145207. /**
  145208. * Defines the priority of this optimization (0 by default which means first in the list)
  145209. */
  145210. priority: number;
  145211. /**
  145212. * Gets a string describing the action executed by the current optimization
  145213. * @returns description string
  145214. */
  145215. getDescription(): string;
  145216. /**
  145217. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  145218. * @param scene defines the current scene where to apply this optimization
  145219. * @param optimizer defines the current optimizer
  145220. * @returns true if everything that can be done was applied
  145221. */
  145222. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  145223. /**
  145224. * Creates the SceneOptimization object
  145225. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  145226. * @param desc defines the description associated with the optimization
  145227. */
  145228. constructor(
  145229. /**
  145230. * Defines the priority of this optimization (0 by default which means first in the list)
  145231. */
  145232. priority?: number);
  145233. }
  145234. /**
  145235. * Defines an optimization used to reduce the size of render target textures
  145236. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  145237. */
  145238. export class TextureOptimization extends SceneOptimization {
  145239. /**
  145240. * Defines the priority of this optimization (0 by default which means first in the list)
  145241. */
  145242. priority: number;
  145243. /**
  145244. * 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
  145245. */
  145246. maximumSize: number;
  145247. /**
  145248. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  145249. */
  145250. step: number;
  145251. /**
  145252. * Gets a string describing the action executed by the current optimization
  145253. * @returns description string
  145254. */
  145255. getDescription(): string;
  145256. /**
  145257. * Creates the TextureOptimization object
  145258. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  145259. * @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
  145260. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  145261. */
  145262. constructor(
  145263. /**
  145264. * Defines the priority of this optimization (0 by default which means first in the list)
  145265. */
  145266. priority?: number,
  145267. /**
  145268. * 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
  145269. */
  145270. maximumSize?: number,
  145271. /**
  145272. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  145273. */
  145274. step?: number);
  145275. /**
  145276. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  145277. * @param scene defines the current scene where to apply this optimization
  145278. * @param optimizer defines the current optimizer
  145279. * @returns true if everything that can be done was applied
  145280. */
  145281. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  145282. }
  145283. /**
  145284. * Defines an optimization used to increase or decrease the rendering resolution
  145285. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  145286. */
  145287. export class HardwareScalingOptimization extends SceneOptimization {
  145288. /**
  145289. * Defines the priority of this optimization (0 by default which means first in the list)
  145290. */
  145291. priority: number;
  145292. /**
  145293. * Defines the maximum scale to use (2 by default)
  145294. */
  145295. maximumScale: number;
  145296. /**
  145297. * Defines the step to use between two passes (0.5 by default)
  145298. */
  145299. step: number;
  145300. private _currentScale;
  145301. private _directionOffset;
  145302. /**
  145303. * Gets a string describing the action executed by the current optimization
  145304. * @return description string
  145305. */
  145306. getDescription(): string;
  145307. /**
  145308. * Creates the HardwareScalingOptimization object
  145309. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  145310. * @param maximumScale defines the maximum scale to use (2 by default)
  145311. * @param step defines the step to use between two passes (0.5 by default)
  145312. */
  145313. constructor(
  145314. /**
  145315. * Defines the priority of this optimization (0 by default which means first in the list)
  145316. */
  145317. priority?: number,
  145318. /**
  145319. * Defines the maximum scale to use (2 by default)
  145320. */
  145321. maximumScale?: number,
  145322. /**
  145323. * Defines the step to use between two passes (0.5 by default)
  145324. */
  145325. step?: number);
  145326. /**
  145327. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  145328. * @param scene defines the current scene where to apply this optimization
  145329. * @param optimizer defines the current optimizer
  145330. * @returns true if everything that can be done was applied
  145331. */
  145332. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  145333. }
  145334. /**
  145335. * Defines an optimization used to remove shadows
  145336. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  145337. */
  145338. export class ShadowsOptimization extends SceneOptimization {
  145339. /**
  145340. * Gets a string describing the action executed by the current optimization
  145341. * @return description string
  145342. */
  145343. getDescription(): string;
  145344. /**
  145345. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  145346. * @param scene defines the current scene where to apply this optimization
  145347. * @param optimizer defines the current optimizer
  145348. * @returns true if everything that can be done was applied
  145349. */
  145350. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  145351. }
  145352. /**
  145353. * Defines an optimization used to turn post-processes off
  145354. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  145355. */
  145356. export class PostProcessesOptimization extends SceneOptimization {
  145357. /**
  145358. * Gets a string describing the action executed by the current optimization
  145359. * @return description string
  145360. */
  145361. getDescription(): string;
  145362. /**
  145363. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  145364. * @param scene defines the current scene where to apply this optimization
  145365. * @param optimizer defines the current optimizer
  145366. * @returns true if everything that can be done was applied
  145367. */
  145368. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  145369. }
  145370. /**
  145371. * Defines an optimization used to turn lens flares off
  145372. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  145373. */
  145374. export class LensFlaresOptimization extends SceneOptimization {
  145375. /**
  145376. * Gets a string describing the action executed by the current optimization
  145377. * @return description string
  145378. */
  145379. getDescription(): string;
  145380. /**
  145381. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  145382. * @param scene defines the current scene where to apply this optimization
  145383. * @param optimizer defines the current optimizer
  145384. * @returns true if everything that can be done was applied
  145385. */
  145386. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  145387. }
  145388. /**
  145389. * Defines an optimization based on user defined callback.
  145390. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  145391. */
  145392. export class CustomOptimization extends SceneOptimization {
  145393. /**
  145394. * Callback called to apply the custom optimization.
  145395. */
  145396. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  145397. /**
  145398. * Callback called to get custom description
  145399. */
  145400. onGetDescription: () => string;
  145401. /**
  145402. * Gets a string describing the action executed by the current optimization
  145403. * @returns description string
  145404. */
  145405. getDescription(): string;
  145406. /**
  145407. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  145408. * @param scene defines the current scene where to apply this optimization
  145409. * @param optimizer defines the current optimizer
  145410. * @returns true if everything that can be done was applied
  145411. */
  145412. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  145413. }
  145414. /**
  145415. * Defines an optimization used to turn particles off
  145416. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  145417. */
  145418. export class ParticlesOptimization extends SceneOptimization {
  145419. /**
  145420. * Gets a string describing the action executed by the current optimization
  145421. * @return description string
  145422. */
  145423. getDescription(): string;
  145424. /**
  145425. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  145426. * @param scene defines the current scene where to apply this optimization
  145427. * @param optimizer defines the current optimizer
  145428. * @returns true if everything that can be done was applied
  145429. */
  145430. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  145431. }
  145432. /**
  145433. * Defines an optimization used to turn render targets off
  145434. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  145435. */
  145436. export class RenderTargetsOptimization extends SceneOptimization {
  145437. /**
  145438. * Gets a string describing the action executed by the current optimization
  145439. * @return description string
  145440. */
  145441. getDescription(): string;
  145442. /**
  145443. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  145444. * @param scene defines the current scene where to apply this optimization
  145445. * @param optimizer defines the current optimizer
  145446. * @returns true if everything that can be done was applied
  145447. */
  145448. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  145449. }
  145450. /**
  145451. * Defines an optimization used to merge meshes with compatible materials
  145452. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  145453. */
  145454. export class MergeMeshesOptimization extends SceneOptimization {
  145455. private static _UpdateSelectionTree;
  145456. /**
  145457. * Gets or sets a boolean which defines if optimization octree has to be updated
  145458. */
  145459. static get UpdateSelectionTree(): boolean;
  145460. /**
  145461. * Gets or sets a boolean which defines if optimization octree has to be updated
  145462. */
  145463. static set UpdateSelectionTree(value: boolean);
  145464. /**
  145465. * Gets a string describing the action executed by the current optimization
  145466. * @return description string
  145467. */
  145468. getDescription(): string;
  145469. private _canBeMerged;
  145470. /**
  145471. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  145472. * @param scene defines the current scene where to apply this optimization
  145473. * @param optimizer defines the current optimizer
  145474. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  145475. * @returns true if everything that can be done was applied
  145476. */
  145477. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  145478. }
  145479. /**
  145480. * Defines a list of options used by SceneOptimizer
  145481. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  145482. */
  145483. export class SceneOptimizerOptions {
  145484. /**
  145485. * Defines the target frame rate to reach (60 by default)
  145486. */
  145487. targetFrameRate: number;
  145488. /**
  145489. * Defines the interval between two checkes (2000ms by default)
  145490. */
  145491. trackerDuration: number;
  145492. /**
  145493. * Gets the list of optimizations to apply
  145494. */
  145495. optimizations: SceneOptimization[];
  145496. /**
  145497. * Creates a new list of options used by SceneOptimizer
  145498. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  145499. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  145500. */
  145501. constructor(
  145502. /**
  145503. * Defines the target frame rate to reach (60 by default)
  145504. */
  145505. targetFrameRate?: number,
  145506. /**
  145507. * Defines the interval between two checkes (2000ms by default)
  145508. */
  145509. trackerDuration?: number);
  145510. /**
  145511. * Add a new optimization
  145512. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  145513. * @returns the current SceneOptimizerOptions
  145514. */
  145515. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  145516. /**
  145517. * Add a new custom optimization
  145518. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  145519. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  145520. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  145521. * @returns the current SceneOptimizerOptions
  145522. */
  145523. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  145524. /**
  145525. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  145526. * @param targetFrameRate defines the target frame rate (60 by default)
  145527. * @returns a SceneOptimizerOptions object
  145528. */
  145529. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  145530. /**
  145531. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  145532. * @param targetFrameRate defines the target frame rate (60 by default)
  145533. * @returns a SceneOptimizerOptions object
  145534. */
  145535. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  145536. /**
  145537. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  145538. * @param targetFrameRate defines the target frame rate (60 by default)
  145539. * @returns a SceneOptimizerOptions object
  145540. */
  145541. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  145542. }
  145543. /**
  145544. * Class used to run optimizations in order to reach a target frame rate
  145545. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  145546. */
  145547. export class SceneOptimizer implements IDisposable {
  145548. private _isRunning;
  145549. private _options;
  145550. private _scene;
  145551. private _currentPriorityLevel;
  145552. private _targetFrameRate;
  145553. private _trackerDuration;
  145554. private _currentFrameRate;
  145555. private _sceneDisposeObserver;
  145556. private _improvementMode;
  145557. /**
  145558. * Defines an observable called when the optimizer reaches the target frame rate
  145559. */
  145560. onSuccessObservable: Observable<SceneOptimizer>;
  145561. /**
  145562. * Defines an observable called when the optimizer enables an optimization
  145563. */
  145564. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  145565. /**
  145566. * Defines an observable called when the optimizer is not able to reach the target frame rate
  145567. */
  145568. onFailureObservable: Observable<SceneOptimizer>;
  145569. /**
  145570. * Gets a boolean indicating if the optimizer is in improvement mode
  145571. */
  145572. get isInImprovementMode(): boolean;
  145573. /**
  145574. * Gets the current priority level (0 at start)
  145575. */
  145576. get currentPriorityLevel(): number;
  145577. /**
  145578. * Gets the current frame rate checked by the SceneOptimizer
  145579. */
  145580. get currentFrameRate(): number;
  145581. /**
  145582. * Gets or sets the current target frame rate (60 by default)
  145583. */
  145584. get targetFrameRate(): number;
  145585. /**
  145586. * Gets or sets the current target frame rate (60 by default)
  145587. */
  145588. set targetFrameRate(value: number);
  145589. /**
  145590. * Gets or sets the current interval between two checks (every 2000ms by default)
  145591. */
  145592. get trackerDuration(): number;
  145593. /**
  145594. * Gets or sets the current interval between two checks (every 2000ms by default)
  145595. */
  145596. set trackerDuration(value: number);
  145597. /**
  145598. * Gets the list of active optimizations
  145599. */
  145600. get optimizations(): SceneOptimization[];
  145601. /**
  145602. * Creates a new SceneOptimizer
  145603. * @param scene defines the scene to work on
  145604. * @param options defines the options to use with the SceneOptimizer
  145605. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  145606. * @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)
  145607. */
  145608. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  145609. /**
  145610. * Stops the current optimizer
  145611. */
  145612. stop(): void;
  145613. /**
  145614. * Reset the optimizer to initial step (current priority level = 0)
  145615. */
  145616. reset(): void;
  145617. /**
  145618. * Start the optimizer. By default it will try to reach a specific framerate
  145619. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  145620. */
  145621. start(): void;
  145622. private _checkCurrentState;
  145623. /**
  145624. * Release all resources
  145625. */
  145626. dispose(): void;
  145627. /**
  145628. * Helper function to create a SceneOptimizer with one single line of code
  145629. * @param scene defines the scene to work on
  145630. * @param options defines the options to use with the SceneOptimizer
  145631. * @param onSuccess defines a callback to call on success
  145632. * @param onFailure defines a callback to call on failure
  145633. * @returns the new SceneOptimizer object
  145634. */
  145635. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  145636. }
  145637. }
  145638. declare module BABYLON {
  145639. /**
  145640. * Class used to serialize a scene into a string
  145641. */
  145642. export class SceneSerializer {
  145643. /**
  145644. * Clear cache used by a previous serialization
  145645. */
  145646. static ClearCache(): void;
  145647. /**
  145648. * Serialize a scene into a JSON compatible object
  145649. * @param scene defines the scene to serialize
  145650. * @returns a JSON compatible object
  145651. */
  145652. static Serialize(scene: Scene): any;
  145653. /**
  145654. * Serialize a mesh into a JSON compatible object
  145655. * @param toSerialize defines the mesh to serialize
  145656. * @param withParents defines if parents must be serialized as well
  145657. * @param withChildren defines if children must be serialized as well
  145658. * @returns a JSON compatible object
  145659. */
  145660. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  145661. }
  145662. }
  145663. declare module BABYLON {
  145664. /**
  145665. * Class used to host texture specific utilities
  145666. */
  145667. export class TextureTools {
  145668. /**
  145669. * Uses the GPU to create a copy texture rescaled at a given size
  145670. * @param texture Texture to copy from
  145671. * @param width defines the desired width
  145672. * @param height defines the desired height
  145673. * @param useBilinearMode defines if bilinear mode has to be used
  145674. * @return the generated texture
  145675. */
  145676. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  145677. }
  145678. }
  145679. declare module BABYLON {
  145680. /**
  145681. * This represents the different options available for the video capture.
  145682. */
  145683. export interface VideoRecorderOptions {
  145684. /** Defines the mime type of the video. */
  145685. mimeType: string;
  145686. /** Defines the FPS the video should be recorded at. */
  145687. fps: number;
  145688. /** Defines the chunk size for the recording data. */
  145689. recordChunckSize: number;
  145690. /** The audio tracks to attach to the recording. */
  145691. audioTracks?: MediaStreamTrack[];
  145692. }
  145693. /**
  145694. * This can help with recording videos from BabylonJS.
  145695. * This is based on the available WebRTC functionalities of the browser.
  145696. *
  145697. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  145698. */
  145699. export class VideoRecorder {
  145700. private static readonly _defaultOptions;
  145701. /**
  145702. * Returns whether or not the VideoRecorder is available in your browser.
  145703. * @param engine Defines the Babylon Engine.
  145704. * @returns true if supported otherwise false.
  145705. */
  145706. static IsSupported(engine: Engine): boolean;
  145707. private readonly _options;
  145708. private _canvas;
  145709. private _mediaRecorder;
  145710. private _recordedChunks;
  145711. private _fileName;
  145712. private _resolve;
  145713. private _reject;
  145714. /**
  145715. * True when a recording is already in progress.
  145716. */
  145717. get isRecording(): boolean;
  145718. /**
  145719. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  145720. * @param engine Defines the BabylonJS Engine you wish to record.
  145721. * @param options Defines options that can be used to customize the capture.
  145722. */
  145723. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  145724. /**
  145725. * Stops the current recording before the default capture timeout passed in the startRecording function.
  145726. */
  145727. stopRecording(): void;
  145728. /**
  145729. * Starts recording the canvas for a max duration specified in parameters.
  145730. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  145731. * If null no automatic download will start and you can rely on the promise to get the data back.
  145732. * @param maxDuration Defines the maximum recording time in seconds.
  145733. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  145734. * @return A promise callback at the end of the recording with the video data in Blob.
  145735. */
  145736. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  145737. /**
  145738. * Releases internal resources used during the recording.
  145739. */
  145740. dispose(): void;
  145741. private _handleDataAvailable;
  145742. private _handleError;
  145743. private _handleStop;
  145744. }
  145745. }
  145746. declare module BABYLON {
  145747. /**
  145748. * Class containing a set of static utilities functions for screenshots
  145749. */
  145750. export class ScreenshotTools {
  145751. /**
  145752. * Captures a screenshot of the current rendering
  145753. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  145754. * @param engine defines the rendering engine
  145755. * @param camera defines the source camera
  145756. * @param size This parameter can be set to a single number or to an object with the
  145757. * following (optional) properties: precision, width, height. If a single number is passed,
  145758. * it will be used for both width and height. If an object is passed, the screenshot size
  145759. * will be derived from the parameters. The precision property is a multiplier allowing
  145760. * rendering at a higher or lower resolution
  145761. * @param successCallback defines the callback receives a single parameter which contains the
  145762. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  145763. * src parameter of an <img> to display it
  145764. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  145765. * Check your browser for supported MIME types
  145766. */
  145767. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  145768. /**
  145769. * Captures a screenshot of the current rendering
  145770. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  145771. * @param engine defines the rendering engine
  145772. * @param camera defines the source camera
  145773. * @param size This parameter can be set to a single number or to an object with the
  145774. * following (optional) properties: precision, width, height. If a single number is passed,
  145775. * it will be used for both width and height. If an object is passed, the screenshot size
  145776. * will be derived from the parameters. The precision property is a multiplier allowing
  145777. * rendering at a higher or lower resolution
  145778. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  145779. * Check your browser for supported MIME types
  145780. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  145781. * to the src parameter of an <img> to display it
  145782. */
  145783. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  145784. /**
  145785. * Generates an image screenshot from the specified camera.
  145786. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  145787. * @param engine The engine to use for rendering
  145788. * @param camera The camera to use for rendering
  145789. * @param size This parameter can be set to a single number or to an object with the
  145790. * following (optional) properties: precision, width, height. If a single number is passed,
  145791. * it will be used for both width and height. If an object is passed, the screenshot size
  145792. * will be derived from the parameters. The precision property is a multiplier allowing
  145793. * rendering at a higher or lower resolution
  145794. * @param successCallback The callback receives a single parameter which contains the
  145795. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  145796. * src parameter of an <img> to display it
  145797. * @param mimeType The MIME type of the screenshot image (default: image/png).
  145798. * Check your browser for supported MIME types
  145799. * @param samples Texture samples (default: 1)
  145800. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  145801. * @param fileName A name for for the downloaded file.
  145802. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  145803. */
  145804. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): void;
  145805. /**
  145806. * Generates an image screenshot from the specified camera.
  145807. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  145808. * @param engine The engine to use for rendering
  145809. * @param camera The camera to use for rendering
  145810. * @param size This parameter can be set to a single number or to an object with the
  145811. * following (optional) properties: precision, width, height. If a single number is passed,
  145812. * it will be used for both width and height. If an object is passed, the screenshot size
  145813. * will be derived from the parameters. The precision property is a multiplier allowing
  145814. * rendering at a higher or lower resolution
  145815. * @param mimeType The MIME type of the screenshot image (default: image/png).
  145816. * Check your browser for supported MIME types
  145817. * @param samples Texture samples (default: 1)
  145818. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  145819. * @param fileName A name for for the downloaded file.
  145820. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  145821. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  145822. * to the src parameter of an <img> to display it
  145823. */
  145824. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): Promise<string>;
  145825. /**
  145826. * Gets height and width for screenshot size
  145827. * @private
  145828. */
  145829. private static _getScreenshotSize;
  145830. }
  145831. }
  145832. declare module BABYLON {
  145833. /**
  145834. * Interface for a data buffer
  145835. */
  145836. export interface IDataBuffer {
  145837. /**
  145838. * Reads bytes from the data buffer.
  145839. * @param byteOffset The byte offset to read
  145840. * @param byteLength The byte length to read
  145841. * @returns A promise that resolves when the bytes are read
  145842. */
  145843. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  145844. /**
  145845. * The byte length of the buffer.
  145846. */
  145847. readonly byteLength: number;
  145848. }
  145849. /**
  145850. * Utility class for reading from a data buffer
  145851. */
  145852. export class DataReader {
  145853. /**
  145854. * The data buffer associated with this data reader.
  145855. */
  145856. readonly buffer: IDataBuffer;
  145857. /**
  145858. * The current byte offset from the beginning of the data buffer.
  145859. */
  145860. byteOffset: number;
  145861. private _dataView;
  145862. private _dataByteOffset;
  145863. /**
  145864. * Constructor
  145865. * @param buffer The buffer to read
  145866. */
  145867. constructor(buffer: IDataBuffer);
  145868. /**
  145869. * Loads the given byte length.
  145870. * @param byteLength The byte length to load
  145871. * @returns A promise that resolves when the load is complete
  145872. */
  145873. loadAsync(byteLength: number): Promise<void>;
  145874. /**
  145875. * Read a unsigned 32-bit integer from the currently loaded data range.
  145876. * @returns The 32-bit integer read
  145877. */
  145878. readUint32(): number;
  145879. /**
  145880. * Read a byte array from the currently loaded data range.
  145881. * @param byteLength The byte length to read
  145882. * @returns The byte array read
  145883. */
  145884. readUint8Array(byteLength: number): Uint8Array;
  145885. /**
  145886. * Read a string from the currently loaded data range.
  145887. * @param byteLength The byte length to read
  145888. * @returns The string read
  145889. */
  145890. readString(byteLength: number): string;
  145891. /**
  145892. * Skips the given byte length the currently loaded data range.
  145893. * @param byteLength The byte length to skip
  145894. */
  145895. skipBytes(byteLength: number): void;
  145896. }
  145897. }
  145898. declare module BABYLON {
  145899. /**
  145900. * Class for storing data to local storage if available or in-memory storage otherwise
  145901. */
  145902. export class DataStorage {
  145903. private static _Storage;
  145904. private static _GetStorage;
  145905. /**
  145906. * Reads a string from the data storage
  145907. * @param key The key to read
  145908. * @param defaultValue The value if the key doesn't exist
  145909. * @returns The string value
  145910. */
  145911. static ReadString(key: string, defaultValue: string): string;
  145912. /**
  145913. * Writes a string to the data storage
  145914. * @param key The key to write
  145915. * @param value The value to write
  145916. */
  145917. static WriteString(key: string, value: string): void;
  145918. /**
  145919. * Reads a boolean from the data storage
  145920. * @param key The key to read
  145921. * @param defaultValue The value if the key doesn't exist
  145922. * @returns The boolean value
  145923. */
  145924. static ReadBoolean(key: string, defaultValue: boolean): boolean;
  145925. /**
  145926. * Writes a boolean to the data storage
  145927. * @param key The key to write
  145928. * @param value The value to write
  145929. */
  145930. static WriteBoolean(key: string, value: boolean): void;
  145931. /**
  145932. * Reads a number from the data storage
  145933. * @param key The key to read
  145934. * @param defaultValue The value if the key doesn't exist
  145935. * @returns The number value
  145936. */
  145937. static ReadNumber(key: string, defaultValue: number): number;
  145938. /**
  145939. * Writes a number to the data storage
  145940. * @param key The key to write
  145941. * @param value The value to write
  145942. */
  145943. static WriteNumber(key: string, value: number): void;
  145944. }
  145945. }
  145946. declare module BABYLON {
  145947. /**
  145948. * Options used for hit testing
  145949. */
  145950. export interface IWebXRLegacyHitTestOptions {
  145951. /**
  145952. * Only test when user interacted with the scene. Default - hit test every frame
  145953. */
  145954. testOnPointerDownOnly?: boolean;
  145955. /**
  145956. * The node to use to transform the local results to world coordinates
  145957. */
  145958. worldParentNode?: TransformNode;
  145959. }
  145960. /**
  145961. * Interface defining the babylon result of raycasting/hit-test
  145962. */
  145963. export interface IWebXRLegacyHitResult {
  145964. /**
  145965. * Transformation matrix that can be applied to a node that will put it in the hit point location
  145966. */
  145967. transformationMatrix: Matrix;
  145968. /**
  145969. * The native hit test result
  145970. */
  145971. xrHitResult: XRHitResult | XRHitTestResult;
  145972. }
  145973. /**
  145974. * The currently-working hit-test module.
  145975. * Hit test (or Ray-casting) is used to interact with the real world.
  145976. * For further information read here - https://github.com/immersive-web/hit-test
  145977. */
  145978. export class WebXRHitTestLegacy extends WebXRAbstractFeature {
  145979. /**
  145980. * options to use when constructing this feature
  145981. */
  145982. readonly options: IWebXRLegacyHitTestOptions;
  145983. private _direction;
  145984. private _mat;
  145985. private _onSelectEnabled;
  145986. private _origin;
  145987. /**
  145988. * The module's name
  145989. */
  145990. static readonly Name: string;
  145991. /**
  145992. * The (Babylon) version of this module.
  145993. * This is an integer representing the implementation version.
  145994. * This number does not correspond to the WebXR specs version
  145995. */
  145996. static readonly Version: number;
  145997. /**
  145998. * Populated with the last native XR Hit Results
  145999. */
  146000. lastNativeXRHitResults: XRHitResult[];
  146001. /**
  146002. * Triggered when new babylon (transformed) hit test results are available
  146003. */
  146004. onHitTestResultObservable: Observable<IWebXRLegacyHitResult[]>;
  146005. /**
  146006. * Creates a new instance of the (legacy version) hit test feature
  146007. * @param _xrSessionManager an instance of WebXRSessionManager
  146008. * @param options options to use when constructing this feature
  146009. */
  146010. constructor(_xrSessionManager: WebXRSessionManager,
  146011. /**
  146012. * options to use when constructing this feature
  146013. */
  146014. options?: IWebXRLegacyHitTestOptions);
  146015. /**
  146016. * execute a hit test with an XR Ray
  146017. *
  146018. * @param xrSession a native xrSession that will execute this hit test
  146019. * @param xrRay the ray (position and direction) to use for ray-casting
  146020. * @param referenceSpace native XR reference space to use for the hit-test
  146021. * @param filter filter function that will filter the results
  146022. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  146023. */
  146024. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  146025. /**
  146026. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  146027. * @param event the (select) event to use to select with
  146028. * @param referenceSpace the reference space to use for this hit test
  146029. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  146030. */
  146031. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  146032. /**
  146033. * attach this feature
  146034. * Will usually be called by the features manager
  146035. *
  146036. * @returns true if successful.
  146037. */
  146038. attach(): boolean;
  146039. /**
  146040. * detach this feature.
  146041. * Will usually be called by the features manager
  146042. *
  146043. * @returns true if successful.
  146044. */
  146045. detach(): boolean;
  146046. /**
  146047. * Dispose this feature and all of the resources attached
  146048. */
  146049. dispose(): void;
  146050. protected _onXRFrame(frame: XRFrame): void;
  146051. private _onHitTestResults;
  146052. private _onSelect;
  146053. }
  146054. }
  146055. declare module BABYLON {
  146056. /**
  146057. * Options used in the plane detector module
  146058. */
  146059. export interface IWebXRPlaneDetectorOptions {
  146060. /**
  146061. * The node to use to transform the local results to world coordinates
  146062. */
  146063. worldParentNode?: TransformNode;
  146064. }
  146065. /**
  146066. * A babylon interface for a WebXR plane.
  146067. * A Plane is actually a polygon, built from N points in space
  146068. *
  146069. * Supported in chrome 79, not supported in canary 81 ATM
  146070. */
  146071. export interface IWebXRPlane {
  146072. /**
  146073. * a babylon-assigned ID for this polygon
  146074. */
  146075. id: number;
  146076. /**
  146077. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  146078. */
  146079. polygonDefinition: Array<Vector3>;
  146080. /**
  146081. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  146082. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  146083. */
  146084. transformationMatrix: Matrix;
  146085. /**
  146086. * the native xr-plane object
  146087. */
  146088. xrPlane: XRPlane;
  146089. }
  146090. /**
  146091. * The plane detector is used to detect planes in the real world when in AR
  146092. * For more information see https://github.com/immersive-web/real-world-geometry/
  146093. */
  146094. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  146095. private _options;
  146096. private _detectedPlanes;
  146097. private _enabled;
  146098. private _lastFrameDetected;
  146099. /**
  146100. * The module's name
  146101. */
  146102. static readonly Name: string;
  146103. /**
  146104. * The (Babylon) version of this module.
  146105. * This is an integer representing the implementation version.
  146106. * This number does not correspond to the WebXR specs version
  146107. */
  146108. static readonly Version: number;
  146109. /**
  146110. * Observers registered here will be executed when a new plane was added to the session
  146111. */
  146112. onPlaneAddedObservable: Observable<IWebXRPlane>;
  146113. /**
  146114. * Observers registered here will be executed when a plane is no longer detected in the session
  146115. */
  146116. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  146117. /**
  146118. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  146119. * This can execute N times every frame
  146120. */
  146121. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  146122. /**
  146123. * construct a new Plane Detector
  146124. * @param _xrSessionManager an instance of xr Session manager
  146125. * @param _options configuration to use when constructing this feature
  146126. */
  146127. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  146128. /**
  146129. * Dispose this feature and all of the resources attached
  146130. */
  146131. dispose(): void;
  146132. protected _onXRFrame(frame: XRFrame): void;
  146133. private _init;
  146134. private _updatePlaneWithXRPlane;
  146135. /**
  146136. * avoiding using Array.find for global support.
  146137. * @param xrPlane the plane to find in the array
  146138. */
  146139. private findIndexInPlaneArray;
  146140. }
  146141. }
  146142. declare module BABYLON {
  146143. /**
  146144. * Configuration options of the anchor system
  146145. */
  146146. export interface IWebXRAnchorSystemOptions {
  146147. /**
  146148. * Should a new anchor be added every time a select event is triggered
  146149. */
  146150. addAnchorOnSelect?: boolean;
  146151. /**
  146152. * should the anchor system use plane detection.
  146153. * If set to true, the plane-detection feature should be set using setPlaneDetector
  146154. */
  146155. usePlaneDetection?: boolean;
  146156. /**
  146157. * a node that will be used to convert local to world coordinates
  146158. */
  146159. worldParentNode?: TransformNode;
  146160. }
  146161. /**
  146162. * A babylon container for an XR Anchor
  146163. */
  146164. export interface IWebXRAnchor {
  146165. /**
  146166. * A babylon-assigned ID for this anchor
  146167. */
  146168. id: number;
  146169. /**
  146170. * Transformation matrix to apply to an object attached to this anchor
  146171. */
  146172. transformationMatrix: Matrix;
  146173. /**
  146174. * The native anchor object
  146175. */
  146176. xrAnchor: XRAnchor;
  146177. }
  146178. /**
  146179. * An implementation of the anchor system of WebXR.
  146180. * Note that the current documented implementation is not available in any browser. Future implementations
  146181. * will use the frame to create an anchor and not the session or a detected plane
  146182. * For further information see https://github.com/immersive-web/anchors/
  146183. */
  146184. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  146185. private _options;
  146186. private _enabled;
  146187. private _hitTestModule;
  146188. private _lastFrameDetected;
  146189. private _onSelect;
  146190. private _planeDetector;
  146191. private _trackedAnchors;
  146192. /**
  146193. * The module's name
  146194. */
  146195. static readonly Name: string;
  146196. /**
  146197. * The (Babylon) version of this module.
  146198. * This is an integer representing the implementation version.
  146199. * This number does not correspond to the WebXR specs version
  146200. */
  146201. static readonly Version: number;
  146202. /**
  146203. * Observers registered here will be executed when a new anchor was added to the session
  146204. */
  146205. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  146206. /**
  146207. * Observers registered here will be executed when an anchor was removed from the session
  146208. */
  146209. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  146210. /**
  146211. * Observers registered here will be executed when an existing anchor updates
  146212. * This can execute N times every frame
  146213. */
  146214. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  146215. /**
  146216. * constructs a new anchor system
  146217. * @param _xrSessionManager an instance of WebXRSessionManager
  146218. * @param _options configuration object for this feature
  146219. */
  146220. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  146221. /**
  146222. * Add anchor at a specific XR point.
  146223. *
  146224. * @param xrRigidTransformation xr-coordinates where a new anchor should be added
  146225. * @param anchorCreator the object o use to create an anchor with. either a session or a plane
  146226. * @returns a promise the fulfills when the anchor was created
  146227. */
  146228. addAnchorAtRigidTransformation(xrRigidTransformation: XRRigidTransform, anchorCreator?: XRAnchorCreator): Promise<XRAnchor>;
  146229. /**
  146230. * attach this feature
  146231. * Will usually be called by the features manager
  146232. *
  146233. * @returns true if successful.
  146234. */
  146235. attach(): boolean;
  146236. /**
  146237. * detach this feature.
  146238. * Will usually be called by the features manager
  146239. *
  146240. * @returns true if successful.
  146241. */
  146242. detach(): boolean;
  146243. /**
  146244. * Dispose this feature and all of the resources attached
  146245. */
  146246. dispose(): void;
  146247. /**
  146248. * If set, it will improve performance by using the current hit-test results instead of executing a new hit-test
  146249. * @param hitTestModule the hit-test module to use.
  146250. */
  146251. setHitTestModule(hitTestModule: WebXRHitTestLegacy): void;
  146252. /**
  146253. * set the plane detector to use in order to create anchors from frames
  146254. * @param planeDetector the plane-detector module to use
  146255. * @param enable enable plane-anchors. default is true
  146256. */
  146257. setPlaneDetector(planeDetector: WebXRPlaneDetector, enable?: boolean): void;
  146258. protected _onXRFrame(frame: XRFrame): void;
  146259. /**
  146260. * avoiding using Array.find for global support.
  146261. * @param xrAnchor the plane to find in the array
  146262. */
  146263. private _findIndexInAnchorArray;
  146264. private _updateAnchorWithXRFrame;
  146265. }
  146266. }
  146267. declare module BABYLON {
  146268. /**
  146269. * Options interface for the background remover plugin
  146270. */
  146271. export interface IWebXRBackgroundRemoverOptions {
  146272. /**
  146273. * Further background meshes to disable when entering AR
  146274. */
  146275. backgroundMeshes?: AbstractMesh[];
  146276. /**
  146277. * flags to configure the removal of the environment helper.
  146278. * If not set, the entire background will be removed. If set, flags should be set as well.
  146279. */
  146280. environmentHelperRemovalFlags?: {
  146281. /**
  146282. * Should the skybox be removed (default false)
  146283. */
  146284. skyBox?: boolean;
  146285. /**
  146286. * Should the ground be removed (default false)
  146287. */
  146288. ground?: boolean;
  146289. };
  146290. /**
  146291. * don't disable the environment helper
  146292. */
  146293. ignoreEnvironmentHelper?: boolean;
  146294. }
  146295. /**
  146296. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  146297. */
  146298. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  146299. /**
  146300. * read-only options to be used in this module
  146301. */
  146302. readonly options: IWebXRBackgroundRemoverOptions;
  146303. /**
  146304. * The module's name
  146305. */
  146306. static readonly Name: string;
  146307. /**
  146308. * The (Babylon) version of this module.
  146309. * This is an integer representing the implementation version.
  146310. * This number does not correspond to the WebXR specs version
  146311. */
  146312. static readonly Version: number;
  146313. /**
  146314. * registered observers will be triggered when the background state changes
  146315. */
  146316. onBackgroundStateChangedObservable: Observable<boolean>;
  146317. /**
  146318. * constructs a new background remover module
  146319. * @param _xrSessionManager the session manager for this module
  146320. * @param options read-only options to be used in this module
  146321. */
  146322. constructor(_xrSessionManager: WebXRSessionManager,
  146323. /**
  146324. * read-only options to be used in this module
  146325. */
  146326. options?: IWebXRBackgroundRemoverOptions);
  146327. /**
  146328. * attach this feature
  146329. * Will usually be called by the features manager
  146330. *
  146331. * @returns true if successful.
  146332. */
  146333. attach(): boolean;
  146334. /**
  146335. * detach this feature.
  146336. * Will usually be called by the features manager
  146337. *
  146338. * @returns true if successful.
  146339. */
  146340. detach(): boolean;
  146341. /**
  146342. * Dispose this feature and all of the resources attached
  146343. */
  146344. dispose(): void;
  146345. protected _onXRFrame(_xrFrame: XRFrame): void;
  146346. private _setBackgroundState;
  146347. }
  146348. }
  146349. declare module BABYLON {
  146350. /**
  146351. * Options for the controller physics feature
  146352. */
  146353. export class IWebXRControllerPhysicsOptions {
  146354. /**
  146355. * Should the headset get its own impostor
  146356. */
  146357. enableHeadsetImpostor?: boolean;
  146358. /**
  146359. * Optional parameters for the headset impostor
  146360. */
  146361. headsetImpostorParams?: {
  146362. /**
  146363. * The type of impostor to create. Default is sphere
  146364. */
  146365. impostorType: number;
  146366. /**
  146367. * the size of the impostor. Defaults to 10cm
  146368. */
  146369. impostorSize?: number | {
  146370. width: number;
  146371. height: number;
  146372. depth: number;
  146373. };
  146374. /**
  146375. * Friction definitions
  146376. */
  146377. friction?: number;
  146378. /**
  146379. * Restitution
  146380. */
  146381. restitution?: number;
  146382. };
  146383. /**
  146384. * The physics properties of the future impostors
  146385. */
  146386. physicsProperties?: {
  146387. /**
  146388. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  146389. * Note that this requires a physics engine that supports mesh impostors!
  146390. */
  146391. useControllerMesh?: boolean;
  146392. /**
  146393. * The type of impostor to create. Default is sphere
  146394. */
  146395. impostorType?: number;
  146396. /**
  146397. * the size of the impostor. Defaults to 10cm
  146398. */
  146399. impostorSize?: number | {
  146400. width: number;
  146401. height: number;
  146402. depth: number;
  146403. };
  146404. /**
  146405. * Friction definitions
  146406. */
  146407. friction?: number;
  146408. /**
  146409. * Restitution
  146410. */
  146411. restitution?: number;
  146412. };
  146413. /**
  146414. * the xr input to use with this pointer selection
  146415. */
  146416. xrInput: WebXRInput;
  146417. }
  146418. /**
  146419. * Add physics impostor to your webxr controllers,
  146420. * including naive calculation of their linear and angular velocity
  146421. */
  146422. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  146423. private readonly _options;
  146424. private _attachController;
  146425. private _controllers;
  146426. private _debugMode;
  146427. private _delta;
  146428. private _headsetImpostor?;
  146429. private _headsetMesh?;
  146430. private _lastTimestamp;
  146431. private _tmpQuaternion;
  146432. private _tmpVector;
  146433. /**
  146434. * The module's name
  146435. */
  146436. static readonly Name: string;
  146437. /**
  146438. * The (Babylon) version of this module.
  146439. * This is an integer representing the implementation version.
  146440. * This number does not correspond to the webxr specs version
  146441. */
  146442. static readonly Version: number;
  146443. /**
  146444. * Construct a new Controller Physics Feature
  146445. * @param _xrSessionManager the corresponding xr session manager
  146446. * @param _options options to create this feature with
  146447. */
  146448. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  146449. /**
  146450. * @hidden
  146451. * enable debugging - will show console outputs and the impostor mesh
  146452. */
  146453. _enablePhysicsDebug(): void;
  146454. /**
  146455. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  146456. * @param xrController the controller to add
  146457. */
  146458. addController(xrController: WebXRInputSource): void;
  146459. /**
  146460. * attach this feature
  146461. * Will usually be called by the features manager
  146462. *
  146463. * @returns true if successful.
  146464. */
  146465. attach(): boolean;
  146466. /**
  146467. * detach this feature.
  146468. * Will usually be called by the features manager
  146469. *
  146470. * @returns true if successful.
  146471. */
  146472. detach(): boolean;
  146473. /**
  146474. * Get the headset impostor, if enabled
  146475. * @returns the impostor
  146476. */
  146477. getHeadsetImpostor(): PhysicsImpostor | undefined;
  146478. /**
  146479. * Get the physics impostor of a specific controller.
  146480. * The impostor is not attached to a mesh because a mesh for each controller is not obligatory
  146481. * @param controller the controller or the controller id of which to get the impostor
  146482. * @returns the impostor or null
  146483. */
  146484. getImpostorForController(controller: WebXRInputSource | string): Nullable<PhysicsImpostor>;
  146485. /**
  146486. * Update the physics properties provided in the constructor
  146487. * @param newProperties the new properties object
  146488. */
  146489. setPhysicsProperties(newProperties: {
  146490. impostorType?: number;
  146491. impostorSize?: number | {
  146492. width: number;
  146493. height: number;
  146494. depth: number;
  146495. };
  146496. friction?: number;
  146497. restitution?: number;
  146498. }): void;
  146499. protected _onXRFrame(_xrFrame: any): void;
  146500. private _detachController;
  146501. }
  146502. }
  146503. declare module BABYLON {
  146504. /**
  146505. * Options used for hit testing (version 2)
  146506. */
  146507. export interface IWebXRHitTestOptions extends IWebXRLegacyHitTestOptions {
  146508. /**
  146509. * Do not create a permanent hit test. Will usually be used when only
  146510. * transient inputs are needed.
  146511. */
  146512. disablePermanentHitTest?: boolean;
  146513. /**
  146514. * Enable transient (for example touch-based) hit test inspections
  146515. */
  146516. enableTransientHitTest?: boolean;
  146517. /**
  146518. * Offset ray for the permanent hit test
  146519. */
  146520. offsetRay?: Vector3;
  146521. /**
  146522. * Offset ray for the transient hit test
  146523. */
  146524. transientOffsetRay?: Vector3;
  146525. /**
  146526. * Instead of using viewer space for hit tests, use the reference space defined in the session manager
  146527. */
  146528. useReferenceSpace?: boolean;
  146529. }
  146530. /**
  146531. * Interface defining the babylon result of hit-test
  146532. */
  146533. export interface IWebXRHitResult extends IWebXRLegacyHitResult {
  146534. /**
  146535. * The input source that generated this hit test (if transient)
  146536. */
  146537. inputSource?: XRInputSource;
  146538. /**
  146539. * Is this a transient hit test
  146540. */
  146541. isTransient?: boolean;
  146542. /**
  146543. * Position of the hit test result
  146544. */
  146545. position: Vector3;
  146546. /**
  146547. * Rotation of the hit test result
  146548. */
  146549. rotationQuaternion: Quaternion;
  146550. }
  146551. /**
  146552. * The currently-working hit-test module.
  146553. * Hit test (or Ray-casting) is used to interact with the real world.
  146554. * For further information read here - https://github.com/immersive-web/hit-test
  146555. *
  146556. * Tested on chrome (mobile) 80.
  146557. */
  146558. export class WebXRHitTest extends WebXRAbstractFeature {
  146559. /**
  146560. * options to use when constructing this feature
  146561. */
  146562. readonly options: IWebXRHitTestOptions;
  146563. private _tmpMat;
  146564. private _tmpPos;
  146565. private _tmpQuat;
  146566. private _transientXrHitTestSource;
  146567. private _xrHitTestSource;
  146568. private initHitTestSource;
  146569. /**
  146570. * The module's name
  146571. */
  146572. static readonly Name: string;
  146573. /**
  146574. * The (Babylon) version of this module.
  146575. * This is an integer representing the implementation version.
  146576. * This number does not correspond to the WebXR specs version
  146577. */
  146578. static readonly Version: number;
  146579. /**
  146580. * When set to true, each hit test will have its own position/rotation objects
  146581. * When set to false, position and rotation objects will be reused for each hit test. It is expected that
  146582. * the developers will clone them or copy them as they see fit.
  146583. */
  146584. autoCloneTransformation: boolean;
  146585. /**
  146586. * Populated with the last native XR Hit Results
  146587. */
  146588. lastNativeXRHitResults: XRHitResult[];
  146589. /**
  146590. * Triggered when new babylon (transformed) hit test results are available
  146591. */
  146592. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  146593. /**
  146594. * Use this to temporarily pause hit test checks.
  146595. */
  146596. paused: boolean;
  146597. /**
  146598. * Creates a new instance of the hit test feature
  146599. * @param _xrSessionManager an instance of WebXRSessionManager
  146600. * @param options options to use when constructing this feature
  146601. */
  146602. constructor(_xrSessionManager: WebXRSessionManager,
  146603. /**
  146604. * options to use when constructing this feature
  146605. */
  146606. options?: IWebXRHitTestOptions);
  146607. /**
  146608. * attach this feature
  146609. * Will usually be called by the features manager
  146610. *
  146611. * @returns true if successful.
  146612. */
  146613. attach(): boolean;
  146614. /**
  146615. * detach this feature.
  146616. * Will usually be called by the features manager
  146617. *
  146618. * @returns true if successful.
  146619. */
  146620. detach(): boolean;
  146621. /**
  146622. * Dispose this feature and all of the resources attached
  146623. */
  146624. dispose(): void;
  146625. protected _onXRFrame(frame: XRFrame): void;
  146626. private _processWebXRHitTestResult;
  146627. }
  146628. }
  146629. declare module BABYLON {
  146630. /**
  146631. * The motion controller class for all microsoft mixed reality controllers
  146632. */
  146633. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  146634. protected readonly _mapping: {
  146635. defaultButton: {
  146636. valueNodeName: string;
  146637. unpressedNodeName: string;
  146638. pressedNodeName: string;
  146639. };
  146640. defaultAxis: {
  146641. valueNodeName: string;
  146642. minNodeName: string;
  146643. maxNodeName: string;
  146644. };
  146645. buttons: {
  146646. "xr-standard-trigger": {
  146647. rootNodeName: string;
  146648. componentProperty: string;
  146649. states: string[];
  146650. };
  146651. "xr-standard-squeeze": {
  146652. rootNodeName: string;
  146653. componentProperty: string;
  146654. states: string[];
  146655. };
  146656. "xr-standard-touchpad": {
  146657. rootNodeName: string;
  146658. labelAnchorNodeName: string;
  146659. touchPointNodeName: string;
  146660. };
  146661. "xr-standard-thumbstick": {
  146662. rootNodeName: string;
  146663. componentProperty: string;
  146664. states: string[];
  146665. };
  146666. };
  146667. axes: {
  146668. "xr-standard-touchpad": {
  146669. "x-axis": {
  146670. rootNodeName: string;
  146671. };
  146672. "y-axis": {
  146673. rootNodeName: string;
  146674. };
  146675. };
  146676. "xr-standard-thumbstick": {
  146677. "x-axis": {
  146678. rootNodeName: string;
  146679. };
  146680. "y-axis": {
  146681. rootNodeName: string;
  146682. };
  146683. };
  146684. };
  146685. };
  146686. /**
  146687. * The base url used to load the left and right controller models
  146688. */
  146689. static MODEL_BASE_URL: string;
  146690. /**
  146691. * The name of the left controller model file
  146692. */
  146693. static MODEL_LEFT_FILENAME: string;
  146694. /**
  146695. * The name of the right controller model file
  146696. */
  146697. static MODEL_RIGHT_FILENAME: string;
  146698. profileId: string;
  146699. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  146700. protected _getFilenameAndPath(): {
  146701. filename: string;
  146702. path: string;
  146703. };
  146704. protected _getModelLoadingConstraints(): boolean;
  146705. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  146706. protected _setRootMesh(meshes: AbstractMesh[]): void;
  146707. protected _updateModel(): void;
  146708. }
  146709. }
  146710. declare module BABYLON {
  146711. /**
  146712. * The motion controller class for oculus touch (quest, rift).
  146713. * This class supports legacy mapping as well the standard xr mapping
  146714. */
  146715. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  146716. private _forceLegacyControllers;
  146717. private _modelRootNode;
  146718. /**
  146719. * The base url used to load the left and right controller models
  146720. */
  146721. static MODEL_BASE_URL: string;
  146722. /**
  146723. * The name of the left controller model file
  146724. */
  146725. static MODEL_LEFT_FILENAME: string;
  146726. /**
  146727. * The name of the right controller model file
  146728. */
  146729. static MODEL_RIGHT_FILENAME: string;
  146730. /**
  146731. * Base Url for the Quest controller model.
  146732. */
  146733. static QUEST_MODEL_BASE_URL: string;
  146734. profileId: string;
  146735. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  146736. protected _getFilenameAndPath(): {
  146737. filename: string;
  146738. path: string;
  146739. };
  146740. protected _getModelLoadingConstraints(): boolean;
  146741. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  146742. protected _setRootMesh(meshes: AbstractMesh[]): void;
  146743. protected _updateModel(): void;
  146744. /**
  146745. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  146746. * between the touch and touch 2.
  146747. */
  146748. private _isQuest;
  146749. }
  146750. }
  146751. declare module BABYLON {
  146752. /**
  146753. * The motion controller class for the standard HTC-Vive controllers
  146754. */
  146755. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  146756. private _modelRootNode;
  146757. /**
  146758. * The base url used to load the left and right controller models
  146759. */
  146760. static MODEL_BASE_URL: string;
  146761. /**
  146762. * File name for the controller model.
  146763. */
  146764. static MODEL_FILENAME: string;
  146765. profileId: string;
  146766. /**
  146767. * Create a new Vive motion controller object
  146768. * @param scene the scene to use to create this controller
  146769. * @param gamepadObject the corresponding gamepad object
  146770. * @param handedness the handedness of the controller
  146771. */
  146772. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  146773. protected _getFilenameAndPath(): {
  146774. filename: string;
  146775. path: string;
  146776. };
  146777. protected _getModelLoadingConstraints(): boolean;
  146778. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  146779. protected _setRootMesh(meshes: AbstractMesh[]): void;
  146780. protected _updateModel(): void;
  146781. }
  146782. }
  146783. declare module BABYLON {
  146784. /**
  146785. * A cursor which tracks a point on a path
  146786. */
  146787. export class PathCursor {
  146788. private path;
  146789. /**
  146790. * Stores path cursor callbacks for when an onchange event is triggered
  146791. */
  146792. private _onchange;
  146793. /**
  146794. * The value of the path cursor
  146795. */
  146796. value: number;
  146797. /**
  146798. * The animation array of the path cursor
  146799. */
  146800. animations: Animation[];
  146801. /**
  146802. * Initializes the path cursor
  146803. * @param path The path to track
  146804. */
  146805. constructor(path: Path2);
  146806. /**
  146807. * Gets the cursor point on the path
  146808. * @returns A point on the path cursor at the cursor location
  146809. */
  146810. getPoint(): Vector3;
  146811. /**
  146812. * Moves the cursor ahead by the step amount
  146813. * @param step The amount to move the cursor forward
  146814. * @returns This path cursor
  146815. */
  146816. moveAhead(step?: number): PathCursor;
  146817. /**
  146818. * Moves the cursor behind by the step amount
  146819. * @param step The amount to move the cursor back
  146820. * @returns This path cursor
  146821. */
  146822. moveBack(step?: number): PathCursor;
  146823. /**
  146824. * Moves the cursor by the step amount
  146825. * If the step amount is greater than one, an exception is thrown
  146826. * @param step The amount to move the cursor
  146827. * @returns This path cursor
  146828. */
  146829. move(step: number): PathCursor;
  146830. /**
  146831. * Ensures that the value is limited between zero and one
  146832. * @returns This path cursor
  146833. */
  146834. private ensureLimits;
  146835. /**
  146836. * Runs onchange callbacks on change (used by the animation engine)
  146837. * @returns This path cursor
  146838. */
  146839. private raiseOnChange;
  146840. /**
  146841. * Executes a function on change
  146842. * @param f A path cursor onchange callback
  146843. * @returns This path cursor
  146844. */
  146845. onchange(f: (cursor: PathCursor) => void): PathCursor;
  146846. }
  146847. }
  146848. declare module BABYLON {
  146849. /** @hidden */
  146850. export var blurPixelShader: {
  146851. name: string;
  146852. shader: string;
  146853. };
  146854. }
  146855. declare module BABYLON {
  146856. /** @hidden */
  146857. export var pointCloudVertexDeclaration: {
  146858. name: string;
  146859. shader: string;
  146860. };
  146861. }
  146862. // Mixins
  146863. interface Window {
  146864. mozIndexedDB: IDBFactory;
  146865. webkitIndexedDB: IDBFactory;
  146866. msIndexedDB: IDBFactory;
  146867. webkitURL: typeof URL;
  146868. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  146869. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  146870. WebGLRenderingContext: WebGLRenderingContext;
  146871. MSGesture: MSGesture;
  146872. CANNON: any;
  146873. AudioContext: AudioContext;
  146874. webkitAudioContext: AudioContext;
  146875. PointerEvent: any;
  146876. Math: Math;
  146877. Uint8Array: Uint8ArrayConstructor;
  146878. Float32Array: Float32ArrayConstructor;
  146879. mozURL: typeof URL;
  146880. msURL: typeof URL;
  146881. VRFrameData: any; // WebVR, from specs 1.1
  146882. DracoDecoderModule: any;
  146883. setImmediate(handler: (...args: any[]) => void): number;
  146884. }
  146885. interface HTMLCanvasElement {
  146886. requestPointerLock(): void;
  146887. msRequestPointerLock?(): void;
  146888. mozRequestPointerLock?(): void;
  146889. webkitRequestPointerLock?(): void;
  146890. /** Track wether a record is in progress */
  146891. isRecording: boolean;
  146892. /** Capture Stream method defined by some browsers */
  146893. captureStream(fps?: number): MediaStream;
  146894. }
  146895. interface CanvasRenderingContext2D {
  146896. msImageSmoothingEnabled: boolean;
  146897. }
  146898. interface MouseEvent {
  146899. mozMovementX: number;
  146900. mozMovementY: number;
  146901. webkitMovementX: number;
  146902. webkitMovementY: number;
  146903. msMovementX: number;
  146904. msMovementY: number;
  146905. }
  146906. interface Navigator {
  146907. mozGetVRDevices: (any: any) => any;
  146908. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  146909. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  146910. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  146911. webkitGetGamepads(): Gamepad[];
  146912. msGetGamepads(): Gamepad[];
  146913. webkitGamepads(): Gamepad[];
  146914. }
  146915. interface HTMLVideoElement {
  146916. mozSrcObject: any;
  146917. }
  146918. interface Math {
  146919. fround(x: number): number;
  146920. imul(a: number, b: number): number;
  146921. }
  146922. interface WebGLRenderingContext {
  146923. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  146924. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  146925. vertexAttribDivisor(index: number, divisor: number): void;
  146926. createVertexArray(): any;
  146927. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  146928. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  146929. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  146930. renderbufferStorageMultisample?(target: number, samples: number, internalformat: number, width: number, height: number): void;
  146931. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  146932. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  146933. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  146934. // Queries
  146935. createQuery(): WebGLQuery;
  146936. deleteQuery(query: WebGLQuery): void;
  146937. beginQuery(target: number, query: WebGLQuery): void;
  146938. endQuery(target: number): void;
  146939. getQueryParameter(query: WebGLQuery, pname: number): any;
  146940. getQuery(target: number, pname: number): any;
  146941. MAX_SAMPLES: number;
  146942. RGBA8: number;
  146943. READ_FRAMEBUFFER: number;
  146944. DRAW_FRAMEBUFFER: number;
  146945. UNIFORM_BUFFER: number;
  146946. HALF_FLOAT_OES: number;
  146947. RGBA16F: number;
  146948. RGBA32F: number;
  146949. R32F: number;
  146950. RG32F: number;
  146951. RGB32F: number;
  146952. R16F: number;
  146953. RG16F: number;
  146954. RGB16F: number;
  146955. RED: number;
  146956. RG: number;
  146957. R8: number;
  146958. RG8: number;
  146959. UNSIGNED_INT_24_8: number;
  146960. DEPTH24_STENCIL8: number;
  146961. MIN: number;
  146962. MAX: number;
  146963. /* Multiple Render Targets */
  146964. drawBuffers(buffers: number[]): void;
  146965. readBuffer(src: number): void;
  146966. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  146967. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  146968. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  146969. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  146970. // Occlusion Query
  146971. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  146972. ANY_SAMPLES_PASSED: number;
  146973. QUERY_RESULT_AVAILABLE: number;
  146974. QUERY_RESULT: number;
  146975. }
  146976. interface WebGLProgram {
  146977. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  146978. }
  146979. interface EXT_disjoint_timer_query {
  146980. QUERY_COUNTER_BITS_EXT: number;
  146981. TIME_ELAPSED_EXT: number;
  146982. TIMESTAMP_EXT: number;
  146983. GPU_DISJOINT_EXT: number;
  146984. QUERY_RESULT_EXT: number;
  146985. QUERY_RESULT_AVAILABLE_EXT: number;
  146986. queryCounterEXT(query: WebGLQuery, target: number): void;
  146987. createQueryEXT(): WebGLQuery;
  146988. beginQueryEXT(target: number, query: WebGLQuery): void;
  146989. endQueryEXT(target: number): void;
  146990. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  146991. deleteQueryEXT(query: WebGLQuery): void;
  146992. }
  146993. interface WebGLUniformLocation {
  146994. _currentState: any;
  146995. }
  146996. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  146997. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  146998. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  146999. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  147000. interface WebGLRenderingContext {
  147001. readonly RASTERIZER_DISCARD: number;
  147002. readonly DEPTH_COMPONENT24: number;
  147003. readonly TEXTURE_3D: number;
  147004. readonly TEXTURE_2D_ARRAY: number;
  147005. readonly TEXTURE_COMPARE_FUNC: number;
  147006. readonly TEXTURE_COMPARE_MODE: number;
  147007. readonly COMPARE_REF_TO_TEXTURE: number;
  147008. readonly TEXTURE_WRAP_R: number;
  147009. readonly HALF_FLOAT: number;
  147010. readonly RGB8: number;
  147011. readonly RED_INTEGER: number;
  147012. readonly RG_INTEGER: number;
  147013. readonly RGB_INTEGER: number;
  147014. readonly RGBA_INTEGER: number;
  147015. readonly R8_SNORM: number;
  147016. readonly RG8_SNORM: number;
  147017. readonly RGB8_SNORM: number;
  147018. readonly RGBA8_SNORM: number;
  147019. readonly R8I: number;
  147020. readonly RG8I: number;
  147021. readonly RGB8I: number;
  147022. readonly RGBA8I: number;
  147023. readonly R8UI: number;
  147024. readonly RG8UI: number;
  147025. readonly RGB8UI: number;
  147026. readonly RGBA8UI: number;
  147027. readonly R16I: number;
  147028. readonly RG16I: number;
  147029. readonly RGB16I: number;
  147030. readonly RGBA16I: number;
  147031. readonly R16UI: number;
  147032. readonly RG16UI: number;
  147033. readonly RGB16UI: number;
  147034. readonly RGBA16UI: number;
  147035. readonly R32I: number;
  147036. readonly RG32I: number;
  147037. readonly RGB32I: number;
  147038. readonly RGBA32I: number;
  147039. readonly R32UI: number;
  147040. readonly RG32UI: number;
  147041. readonly RGB32UI: number;
  147042. readonly RGBA32UI: number;
  147043. readonly RGB10_A2UI: number;
  147044. readonly R11F_G11F_B10F: number;
  147045. readonly RGB9_E5: number;
  147046. readonly RGB10_A2: number;
  147047. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  147048. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  147049. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  147050. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  147051. readonly DEPTH_COMPONENT32F: number;
  147052. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  147053. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  147054. 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;
  147055. framebufferTextureLayer(target: number, attachment: number, texture: WebGLTexture | null, level: number, layer: number): void;
  147056. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  147057. readonly TRANSFORM_FEEDBACK: number;
  147058. readonly INTERLEAVED_ATTRIBS: number;
  147059. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  147060. createTransformFeedback(): WebGLTransformFeedback;
  147061. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  147062. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  147063. beginTransformFeedback(primitiveMode: number): void;
  147064. endTransformFeedback(): void;
  147065. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  147066. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  147067. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  147068. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  147069. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  147070. }
  147071. interface ImageBitmap {
  147072. readonly width: number;
  147073. readonly height: number;
  147074. close(): void;
  147075. }
  147076. interface WebGLQuery extends WebGLObject {
  147077. }
  147078. declare var WebGLQuery: {
  147079. prototype: WebGLQuery;
  147080. new(): WebGLQuery;
  147081. };
  147082. interface WebGLSampler extends WebGLObject {
  147083. }
  147084. declare var WebGLSampler: {
  147085. prototype: WebGLSampler;
  147086. new(): WebGLSampler;
  147087. };
  147088. interface WebGLSync extends WebGLObject {
  147089. }
  147090. declare var WebGLSync: {
  147091. prototype: WebGLSync;
  147092. new(): WebGLSync;
  147093. };
  147094. interface WebGLTransformFeedback extends WebGLObject {
  147095. }
  147096. declare var WebGLTransformFeedback: {
  147097. prototype: WebGLTransformFeedback;
  147098. new(): WebGLTransformFeedback;
  147099. };
  147100. interface WebGLVertexArrayObject extends WebGLObject {
  147101. }
  147102. declare var WebGLVertexArrayObject: {
  147103. prototype: WebGLVertexArrayObject;
  147104. new(): WebGLVertexArrayObject;
  147105. };
  147106. // Type definitions for WebVR API
  147107. // Project: https://w3c.github.io/webvr/
  147108. // Definitions by: six a <https://github.com/lostfictions>
  147109. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  147110. interface VRDisplay extends EventTarget {
  147111. /**
  147112. * Dictionary of capabilities describing the VRDisplay.
  147113. */
  147114. readonly capabilities: VRDisplayCapabilities;
  147115. /**
  147116. * z-depth defining the far plane of the eye view frustum
  147117. * enables mapping of values in the render target depth
  147118. * attachment to scene coordinates. Initially set to 10000.0.
  147119. */
  147120. depthFar: number;
  147121. /**
  147122. * z-depth defining the near plane of the eye view frustum
  147123. * enables mapping of values in the render target depth
  147124. * attachment to scene coordinates. Initially set to 0.01.
  147125. */
  147126. depthNear: number;
  147127. /**
  147128. * An identifier for this distinct VRDisplay. Used as an
  147129. * association point in the Gamepad API.
  147130. */
  147131. readonly displayId: number;
  147132. /**
  147133. * A display name, a user-readable name identifying it.
  147134. */
  147135. readonly displayName: string;
  147136. readonly isConnected: boolean;
  147137. readonly isPresenting: boolean;
  147138. /**
  147139. * If this VRDisplay supports room-scale experiences, the optional
  147140. * stage attribute contains details on the room-scale parameters.
  147141. */
  147142. readonly stageParameters: VRStageParameters | null;
  147143. /**
  147144. * Passing the value returned by `requestAnimationFrame` to
  147145. * `cancelAnimationFrame` will unregister the callback.
  147146. * @param handle Define the hanle of the request to cancel
  147147. */
  147148. cancelAnimationFrame(handle: number): void;
  147149. /**
  147150. * Stops presenting to the VRDisplay.
  147151. * @returns a promise to know when it stopped
  147152. */
  147153. exitPresent(): Promise<void>;
  147154. /**
  147155. * Return the current VREyeParameters for the given eye.
  147156. * @param whichEye Define the eye we want the parameter for
  147157. * @returns the eye parameters
  147158. */
  147159. getEyeParameters(whichEye: string): VREyeParameters;
  147160. /**
  147161. * Populates the passed VRFrameData with the information required to render
  147162. * the current frame.
  147163. * @param frameData Define the data structure to populate
  147164. * @returns true if ok otherwise false
  147165. */
  147166. getFrameData(frameData: VRFrameData): boolean;
  147167. /**
  147168. * Get the layers currently being presented.
  147169. * @returns the list of VR layers
  147170. */
  147171. getLayers(): VRLayer[];
  147172. /**
  147173. * Return a VRPose containing the future predicted pose of the VRDisplay
  147174. * when the current frame will be presented. The value returned will not
  147175. * change until JavaScript has returned control to the browser.
  147176. *
  147177. * The VRPose will contain the position, orientation, velocity,
  147178. * and acceleration of each of these properties.
  147179. * @returns the pose object
  147180. */
  147181. getPose(): VRPose;
  147182. /**
  147183. * Return the current instantaneous pose of the VRDisplay, with no
  147184. * prediction applied.
  147185. * @returns the current instantaneous pose
  147186. */
  147187. getImmediatePose(): VRPose;
  147188. /**
  147189. * The callback passed to `requestAnimationFrame` will be called
  147190. * any time a new frame should be rendered. When the VRDisplay is
  147191. * presenting the callback will be called at the native refresh
  147192. * rate of the HMD. When not presenting this function acts
  147193. * identically to how window.requestAnimationFrame acts. Content should
  147194. * make no assumptions of frame rate or vsync behavior as the HMD runs
  147195. * asynchronously from other displays and at differing refresh rates.
  147196. * @param callback Define the eaction to run next frame
  147197. * @returns the request handle it
  147198. */
  147199. requestAnimationFrame(callback: FrameRequestCallback): number;
  147200. /**
  147201. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  147202. * Repeat calls while already presenting will update the VRLayers being displayed.
  147203. * @param layers Define the list of layer to present
  147204. * @returns a promise to know when the request has been fulfilled
  147205. */
  147206. requestPresent(layers: VRLayer[]): Promise<void>;
  147207. /**
  147208. * Reset the pose for this display, treating its current position and
  147209. * orientation as the "origin/zero" values. VRPose.position,
  147210. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  147211. * updated when calling resetPose(). This should be called in only
  147212. * sitting-space experiences.
  147213. */
  147214. resetPose(): void;
  147215. /**
  147216. * The VRLayer provided to the VRDisplay will be captured and presented
  147217. * in the HMD. Calling this function has the same effect on the source
  147218. * canvas as any other operation that uses its source image, and canvases
  147219. * created without preserveDrawingBuffer set to true will be cleared.
  147220. * @param pose Define the pose to submit
  147221. */
  147222. submitFrame(pose?: VRPose): void;
  147223. }
  147224. declare var VRDisplay: {
  147225. prototype: VRDisplay;
  147226. new(): VRDisplay;
  147227. };
  147228. interface VRLayer {
  147229. leftBounds?: number[] | Float32Array | null;
  147230. rightBounds?: number[] | Float32Array | null;
  147231. source?: HTMLCanvasElement | null;
  147232. }
  147233. interface VRDisplayCapabilities {
  147234. readonly canPresent: boolean;
  147235. readonly hasExternalDisplay: boolean;
  147236. readonly hasOrientation: boolean;
  147237. readonly hasPosition: boolean;
  147238. readonly maxLayers: number;
  147239. }
  147240. interface VREyeParameters {
  147241. /** @deprecated */
  147242. readonly fieldOfView: VRFieldOfView;
  147243. readonly offset: Float32Array;
  147244. readonly renderHeight: number;
  147245. readonly renderWidth: number;
  147246. }
  147247. interface VRFieldOfView {
  147248. readonly downDegrees: number;
  147249. readonly leftDegrees: number;
  147250. readonly rightDegrees: number;
  147251. readonly upDegrees: number;
  147252. }
  147253. interface VRFrameData {
  147254. readonly leftProjectionMatrix: Float32Array;
  147255. readonly leftViewMatrix: Float32Array;
  147256. readonly pose: VRPose;
  147257. readonly rightProjectionMatrix: Float32Array;
  147258. readonly rightViewMatrix: Float32Array;
  147259. readonly timestamp: number;
  147260. }
  147261. interface VRPose {
  147262. readonly angularAcceleration: Float32Array | null;
  147263. readonly angularVelocity: Float32Array | null;
  147264. readonly linearAcceleration: Float32Array | null;
  147265. readonly linearVelocity: Float32Array | null;
  147266. readonly orientation: Float32Array | null;
  147267. readonly position: Float32Array | null;
  147268. readonly timestamp: number;
  147269. }
  147270. interface VRStageParameters {
  147271. sittingToStandingTransform?: Float32Array;
  147272. sizeX?: number;
  147273. sizeY?: number;
  147274. }
  147275. interface Navigator {
  147276. getVRDisplays(): Promise<VRDisplay[]>;
  147277. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  147278. }
  147279. interface Window {
  147280. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  147281. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  147282. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  147283. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  147284. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  147285. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  147286. }
  147287. interface Gamepad {
  147288. readonly displayId: number;
  147289. }
  147290. type XRSessionMode =
  147291. | "inline"
  147292. | "immersive-vr"
  147293. | "immersive-ar";
  147294. type XRReferenceSpaceType =
  147295. | "viewer"
  147296. | "local"
  147297. | "local-floor"
  147298. | "bounded-floor"
  147299. | "unbounded";
  147300. type XREnvironmentBlendMode =
  147301. | "opaque"
  147302. | "additive"
  147303. | "alpha-blend";
  147304. type XRVisibilityState =
  147305. | "visible"
  147306. | "visible-blurred"
  147307. | "hidden";
  147308. type XRHandedness =
  147309. | "none"
  147310. | "left"
  147311. | "right";
  147312. type XRTargetRayMode =
  147313. | "gaze"
  147314. | "tracked-pointer"
  147315. | "screen";
  147316. type XREye =
  147317. | "none"
  147318. | "left"
  147319. | "right";
  147320. type XREventType =
  147321. | "devicechange"
  147322. | "visibilitychange"
  147323. | "end"
  147324. | "inputsourceschange"
  147325. | "select"
  147326. | "selectstart"
  147327. | "selectend"
  147328. | "squeeze"
  147329. | "squeezestart"
  147330. | "squeezeend"
  147331. | "reset";
  147332. interface XRSpace extends EventTarget {
  147333. }
  147334. interface XRRenderState {
  147335. depthNear?: number;
  147336. depthFar?: number;
  147337. inlineVerticalFieldOfView?: number;
  147338. baseLayer?: XRWebGLLayer;
  147339. }
  147340. interface XRInputSource {
  147341. handedness: XRHandedness;
  147342. targetRayMode: XRTargetRayMode;
  147343. targetRaySpace: XRSpace;
  147344. gripSpace: XRSpace | undefined;
  147345. gamepad: Gamepad | undefined;
  147346. profiles: Array<string>;
  147347. }
  147348. interface XRSessionInit {
  147349. optionalFeatures?: XRReferenceSpaceType[];
  147350. requiredFeatures?: XRReferenceSpaceType[];
  147351. }
  147352. interface XRSession extends XRAnchorCreator {
  147353. addEventListener: Function;
  147354. removeEventListener: Function;
  147355. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  147356. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  147357. requestAnimationFrame: Function;
  147358. end(): Promise<void>;
  147359. renderState: XRRenderState;
  147360. inputSources: Array<XRInputSource>;
  147361. // hit test
  147362. requestHitTestSource(options: XRHitTestOptionsInit): Promise<XRHitTestSource>;
  147363. requestHitTestSourceForTransientInput(options: XRTransientInputHitTestOptionsInit): Promise<XRTransientInputHitTestSource>;
  147364. // legacy AR hit test
  147365. requestHitTest(ray: XRRay, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  147366. // legacy plane detection
  147367. updateWorldTrackingState(options: {
  147368. planeDetectionState?: { enabled: boolean; }
  147369. }): void;
  147370. }
  147371. interface XRReferenceSpace extends XRSpace {
  147372. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  147373. onreset: any;
  147374. }
  147375. type XRPlaneSet = Set<XRPlane>;
  147376. type XRAnchorSet = Set<XRAnchor>;
  147377. interface XRFrame {
  147378. session: XRSession;
  147379. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  147380. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  147381. // AR
  147382. getHitTestResults(hitTestSource: XRHitTestSource): Array<XRHitTestResult> ;
  147383. getHitTestResultsForTransientInput(hitTestSource: XRTransientInputHitTestSource): Array<XRTransientInputHitTestResult>;
  147384. // Anchors
  147385. trackedAnchors?: XRAnchorSet;
  147386. // Planes
  147387. worldInformation: {
  147388. detectedPlanes?: XRPlaneSet;
  147389. };
  147390. }
  147391. interface XRViewerPose extends XRPose {
  147392. views: Array<XRView>;
  147393. }
  147394. interface XRPose {
  147395. transform: XRRigidTransform;
  147396. emulatedPosition: boolean;
  147397. }
  147398. interface XRWebGLLayerOptions {
  147399. antialias?: boolean;
  147400. depth?: boolean;
  147401. stencil?: boolean;
  147402. alpha?: boolean;
  147403. multiview?: boolean;
  147404. framebufferScaleFactor?: number;
  147405. }
  147406. declare var XRWebGLLayer: {
  147407. prototype: XRWebGLLayer;
  147408. new(session: XRSession, context: WebGLRenderingContext | undefined, options?: XRWebGLLayerOptions): XRWebGLLayer;
  147409. };
  147410. interface XRWebGLLayer {
  147411. framebuffer: WebGLFramebuffer;
  147412. framebufferWidth: number;
  147413. framebufferHeight: number;
  147414. getViewport: Function;
  147415. }
  147416. declare class XRRigidTransform {
  147417. constructor(matrix: Float32Array | DOMPointInit, direction?: DOMPointInit);
  147418. position: DOMPointReadOnly;
  147419. orientation: DOMPointReadOnly;
  147420. matrix: Float32Array;
  147421. inverse: XRRigidTransform;
  147422. }
  147423. interface XRView {
  147424. eye: XREye;
  147425. projectionMatrix: Float32Array;
  147426. transform: XRRigidTransform;
  147427. }
  147428. interface XRInputSourceChangeEvent {
  147429. session: XRSession;
  147430. removed: Array<XRInputSource>;
  147431. added: Array<XRInputSource>;
  147432. }
  147433. interface XRInputSourceEvent extends Event {
  147434. readonly frame: XRFrame;
  147435. readonly inputSource: XRInputSource;
  147436. }
  147437. // Experimental(er) features
  147438. declare class XRRay {
  147439. constructor(transformOrOrigin: XRRigidTransform | DOMPointInit, direction?: DOMPointInit);
  147440. origin: DOMPointReadOnly;
  147441. direction: DOMPointReadOnly;
  147442. matrix: Float32Array;
  147443. }
  147444. declare enum XRHitTestTrackableType {
  147445. "point",
  147446. "plane"
  147447. }
  147448. interface XRHitResult {
  147449. hitMatrix: Float32Array;
  147450. }
  147451. interface XRTransientInputHitTestResult {
  147452. readonly inputSource: XRInputSource;
  147453. readonly results: Array<XRHitTestResult>;
  147454. }
  147455. interface XRHitTestResult {
  147456. getPose(baseSpace: XRSpace): XRPose | undefined;
  147457. }
  147458. interface XRHitTestSource {
  147459. cancel(): void;
  147460. }
  147461. interface XRTransientInputHitTestSource {
  147462. cancel(): void;
  147463. }
  147464. interface XRHitTestOptionsInit {
  147465. space: XRSpace;
  147466. entityTypes?: Array<XRHitTestTrackableType>;
  147467. offsetRay?: XRRay;
  147468. }
  147469. interface XRTransientInputHitTestOptionsInit {
  147470. profile: string;
  147471. entityTypes?: Array<XRHitTestTrackableType>;
  147472. offsetRay?: XRRay;
  147473. }
  147474. interface XRAnchor {
  147475. // remove?
  147476. id?: string;
  147477. anchorSpace: XRSpace;
  147478. lastChangedTime: number;
  147479. detach(): void;
  147480. }
  147481. interface XRPlane extends XRAnchorCreator {
  147482. orientation: "Horizontal" | "Vertical";
  147483. planeSpace: XRSpace;
  147484. polygon: Array<DOMPointReadOnly>;
  147485. lastChangedTime: number;
  147486. }
  147487. interface XRAnchorCreator {
  147488. // AR Anchors
  147489. createAnchor(pose: XRPose | XRRigidTransform, referenceSpace: XRReferenceSpace): Promise<XRAnchor>;
  147490. }